import { argbFromHex, hexFromArgb, Hct, MaterialDynamicColors, SchemeTonalSpot, } from '@material/material-color-utilities'; /** * Material-3-Rollen, die als Vuetify-Farben bereitgestellt werden. * Schlüssel = Vuetify-Farbname, Wert = Rolle aus MaterialDynamicColors. */ const ROLES = { primary: 'primary', 'on-primary': 'onPrimary', 'primary-container': 'primaryContainer', 'on-primary-container': 'onPrimaryContainer', secondary: 'secondary', 'on-secondary': 'onSecondary', 'secondary-container': 'secondaryContainer', 'on-secondary-container': 'onSecondaryContainer', tertiary: 'tertiary', 'on-tertiary': 'onTertiary', 'tertiary-container': 'tertiaryContainer', 'on-tertiary-container': 'onTertiaryContainer', error: 'error', 'on-error': 'onError', 'error-container': 'errorContainer', 'on-error-container': 'onErrorContainer', background: 'background', 'on-background': 'onBackground', surface: 'surface', 'on-surface': 'onSurface', 'surface-variant': 'surfaceVariant', 'on-surface-variant': 'onSurfaceVariant', 'surface-bright': 'surfaceBright', 'surface-dim': 'surfaceDim', 'surface-container-lowest': 'surfaceContainerLowest', 'surface-container-low': 'surfaceContainerLow', 'surface-container': 'surfaceContainer', 'surface-container-high': 'surfaceContainerHigh', 'surface-container-highest': 'surfaceContainerHighest', 'inverse-surface': 'inverseSurface', 'inverse-on-surface': 'inverseOnSurface', 'inverse-primary': 'inversePrimary', outline: 'outline', 'outline-variant': 'outlineVariant', }; /** * Berechnet aus einer Seed-Farbe das komplette Material-3-Farbschema * (Dynamic Color, Variante „Tonal Spot“). * * @param {string} seedHex z. B. "#2E6B5E" * @param {boolean} isDark * @returns {Record} Vuetify-Farben */ export function materialColors(seedHex, isDark) { const scheme = new SchemeTonalSpot(Hct.fromInt(argbFromHex(seedHex)), isDark, 0); const colors = {}; for (const [name, role] of Object.entries(ROLES)) { colors[name] = hexFromArgb(MaterialDynamicColors[role].getArgb(scheme)); } // Vuetify nutzt „surface-light“ z. B. für Chips und Hover-Flächen. colors['surface-light'] = colors['surface-container-high']; // Statusfarben ohne M3-Entsprechung: auf die Palette abgestimmte Töne. colors.info = isDark ? '#9ECAFF' : '#0061A4'; colors.success = isDark ? '#7DDC7A' : '#1E6C23'; colors.warning = isDark ? '#FFB86E' : '#8B5000'; return colors; } /** * @param {string} seedHex */ export function vuetifyThemes(seedHex) { return { light: { dark: false, colors: materialColors(seedHex, false) }, dark: { dark: true, colors: materialColors(seedHex, true) }, }; }