1 |
- {"version":3,"file":"theme.mjs","names":["computed","inject","provide","ref","watch","watchEffect","createRange","darken","getCurrentInstance","getLuma","IN_BROWSER","lighten","mergeDeep","parseColor","propsFactory","RGBtoHex","APCAcontrast","ThemeSymbol","Symbol","for","makeThemeProps","theme","String","defaultThemeOptions","defaultTheme","variations","colors","themes","light","dark","background","surface","primary","secondary","error","info","success","warning","variables","parseThemeOptions","options","arguments","length","undefined","isDisabled","key","Object","entries","createTheme","parsedOptions","name","computedThemes","acc","original","value","color","variation","fn","amount","keys","test","onColor","colorVal","blackContrast","Math","abs","whiteContrast","min","current","styles","lines","createCssClass","genCssVariables","themeName","bgLines","fgLines","Set","values","flatMap","push","map","str","i","join","getHead","style","children","id","nonce","cspNonce","install","app","head","_context","provides","usehead","entry","patch","addHeadObjs","updateDOM","styleEl","document","getElementById","updateStyles","immediate","el","createElement","type","setAttribute","appendChild","innerHTML","themeClasses","global","provideTheme","props","Error","newTheme","useTheme","selector","content","line","lightOverlay","darkOverlay","rgb","r","g","b","startsWith"],"sources":["../../src/composables/theme.ts"],"sourcesContent":["// Utilities\nimport {\n computed,\n inject,\n provide,\n ref,\n watch,\n watchEffect,\n} from 'vue'\nimport {\n createRange,\n darken,\n getCurrentInstance,\n getLuma,\n IN_BROWSER,\n lighten,\n mergeDeep,\n parseColor,\n propsFactory,\n RGBtoHex,\n} from '@/util'\nimport { APCAcontrast } from '@/util/color/APCA'\n\n// Types\nimport type { HeadClient } from '@vueuse/head'\nimport type { App, DeepReadonly, InjectionKey, Ref } from 'vue'\n\ntype DeepPartial<T> = T extends object ? { [P in keyof T]?: DeepPartial<T[P]> } : T\n\nexport type ThemeOptions = false | {\n cspNonce?: string\n defaultTheme?: string\n variations?: false | VariationsOptions\n themes?: Record<string, ThemeDefinition>\n}\nexport type ThemeDefinition = DeepPartial<InternalThemeDefinition>\n\ninterface InternalThemeOptions {\n cspNonce?: string\n isDisabled: boolean\n defaultTheme: string\n variations: false | VariationsOptions\n themes: Record<string, InternalThemeDefinition>\n}\n\ninterface VariationsOptions {\n colors: string[]\n lighten: number\n darken: number\n}\n\ninterface InternalThemeDefinition {\n dark: boolean\n colors: Colors\n variables: Record<string, string | number>\n}\n\nexport interface Colors extends BaseColors, OnColors {\n [key: string]: string\n}\n\ninterface BaseColors {\n background: string\n surface: string\n primary: string\n secondary: string\n success: string\n warning: string\n error: string\n info: string\n}\n\ninterface OnColors {\n 'on-background': string\n 'on-surface': string\n 'on-primary': string\n 'on-secondary': string\n 'on-success': string\n 'on-warning': string\n 'on-error': string\n 'on-info': string\n}\n\nexport interface ThemeInstance {\n readonly isDisabled: boolean\n readonly themes: Ref<Record<string, InternalThemeDefinition>>\n\n readonly name: Readonly<Ref<string>>\n readonly current: DeepReadonly<Ref<InternalThemeDefinition>>\n readonly computedThemes: DeepReadonly<Ref<Record<string, InternalThemeDefinition>>>\n\n readonly themeClasses: Readonly<Ref<string | undefined>>\n readonly styles: Readonly<Ref<string>>\n\n readonly global: {\n readonly name: Ref<string>\n readonly current: DeepReadonly<Ref<InternalThemeDefinition>>\n }\n}\n\nexport const ThemeSymbol: InjectionKey<ThemeInstance> = Symbol.for('vuetify:theme')\n\nexport const makeThemeProps = propsFactory({\n theme: String,\n}, 'theme')\n\nconst defaultThemeOptions: Exclude<ThemeOptions, false> = {\n defaultTheme: 'light',\n variations: { colors: [], lighten: 0, darken: 0 },\n themes: {\n light: {\n dark: false,\n colors: {\n background: '#FFFFFF',\n surface: '#FFFFFF',\n 'surface-variant': '#424242',\n 'on-surface-variant': '#EEEEEE',\n primary: '#6200EE',\n 'primary-darken-1': '#3700B3',\n secondary: '#03DAC6',\n 'secondary-darken-1': '#018786',\n error: '#B00020',\n info: '#2196F3',\n success: '#4CAF50',\n warning: '#FB8C00',\n },\n variables: {\n 'border-color': '#000000',\n 'border-opacity': 0.12,\n 'high-emphasis-opacity': 0.87,\n 'medium-emphasis-opacity': 0.60,\n 'disabled-opacity': 0.38,\n 'idle-opacity': 0.04,\n 'hover-opacity': 0.04,\n 'focus-opacity': 0.12,\n 'selected-opacity': 0.08,\n 'activated-opacity': 0.12,\n 'pressed-opacity': 0.12,\n 'dragged-opacity': 0.08,\n 'theme-kbd': '#212529',\n 'theme-on-kbd': '#FFFFFF',\n 'theme-code': '#F5F5F5',\n 'theme-on-code': '#000000',\n },\n },\n dark: {\n dark: true,\n colors: {\n background: '#121212',\n surface: '#212121',\n 'surface-variant': '#BDBDBD',\n 'on-surface-variant': '#424242',\n primary: '#BB86FC',\n 'primary-darken-1': '#3700B3',\n secondary: '#03DAC5',\n 'secondary-darken-1': '#03DAC5',\n error: '#CF6679',\n info: '#2196F3',\n success: '#4CAF50',\n warning: '#FB8C00',\n },\n variables: {\n 'border-color': '#FFFFFF',\n 'border-opacity': 0.12,\n 'high-emphasis-opacity': 1,\n 'medium-emphasis-opacity': 0.70,\n 'disabled-opacity': 0.50,\n 'idle-opacity': 0.10,\n 'hover-opacity': 0.04,\n 'focus-opacity': 0.12,\n 'selected-opacity': 0.08,\n 'activated-opacity': 0.12,\n 'pressed-opacity': 0.16,\n 'dragged-opacity': 0.08,\n 'theme-kbd': '#212529',\n 'theme-on-kbd': '#FFFFFF',\n 'theme-code': '#343434',\n 'theme-on-code': '#CCCCCC',\n },\n },\n },\n}\n\nfunction parseThemeOptions (options: ThemeOptions = defaultThemeOptions): InternalThemeOptions {\n if (!options) return { ...defaultThemeOptions, isDisabled: true } as InternalThemeOptions\n\n const themes: Record<string, InternalThemeDefinition> = {}\n for (const [key, theme] of Object.entries(options.themes ?? {})) {\n const defaultTheme = theme.dark || key === 'dark'\n ? defaultThemeOptions.themes?.dark\n : defaultThemeOptions.themes?.light\n themes[key] = mergeDeep(defaultTheme, theme) as InternalThemeDefinition\n }\n\n return mergeDeep(\n defaultThemeOptions,\n { ...options, themes },\n ) as InternalThemeOptions\n}\n\n// Composables\nexport function createTheme (options?: ThemeOptions): ThemeInstance & { install: (app: App) => void } {\n const parsedOptions = parseThemeOptions(options)\n const name = ref(parsedOptions.defaultTheme)\n const themes = ref(parsedOptions.themes)\n\n const computedThemes = computed(() => {\n const acc: Record<string, InternalThemeDefinition> = {}\n for (const [name, original] of Object.entries(themes.value)) {\n const theme: InternalThemeDefinition = acc[name] = {\n ...original,\n colors: {\n ...original.colors,\n },\n }\n\n if (parsedOptions.variations) {\n for (const name of parsedOptions.variations.colors) {\n const color = theme.colors[name]\n\n if (!color) continue\n\n for (const variation of (['lighten', 'darken'] as const)) {\n const fn = variation === 'lighten' ? lighten : darken\n for (const amount of createRange(parsedOptions.variations[variation], 1)) {\n theme.colors[`${name}-${variation}-${amount}`] = RGBtoHex(fn(parseColor(color), amount))\n }\n }\n }\n }\n\n for (const color of Object.keys(theme.colors)) {\n if (/^on-[a-z]/.test(color) || theme.colors[`on-${color}`]) continue\n\n const onColor = `on-${color}` as keyof OnColors\n const colorVal = parseColor(theme.colors[color]!)\n\n const blackContrast = Math.abs(APCAcontrast(parseColor(0), colorVal))\n const whiteContrast = Math.abs(APCAcontrast(parseColor(0xffffff), colorVal))\n\n // TODO: warn about poor color selections\n // const contrastAsText = Math.abs(APCAcontrast(colorVal, colorToInt(theme.colors.background)))\n // const minContrast = Math.max(blackContrast, whiteContrast)\n // if (minContrast < 60) {\n // consoleInfo(`${key} theme color ${color} has poor contrast (${minContrast.toFixed()}%)`)\n // } else if (contrastAsText < 60 && !['background', 'surface'].includes(color)) {\n // consoleInfo(`${key} theme color ${color} has poor contrast as text (${contrastAsText.toFixed()}%)`)\n // }\n\n // Prefer white text if both have an acceptable contrast ratio\n theme.colors[onColor] = whiteContrast > Math.min(blackContrast, 50) ? '#fff' : '#000'\n }\n }\n\n return acc\n })\n const current = computed(() => computedThemes.value[name.value])\n\n const styles = computed(() => {\n const lines: string[] = []\n\n if (current.value.dark) {\n createCssClass(lines, ':root', ['color-scheme: dark'])\n }\n\n createCssClass(lines, ':root', genCssVariables(current.value))\n\n for (const [themeName, theme] of Object.entries(computedThemes.value)) {\n createCssClass(lines, `.v-theme--${themeName}`, [\n `color-scheme: ${theme.dark ? 'dark' : 'normal'}`,\n ...genCssVariables(theme),\n ])\n }\n\n const bgLines: string[] = []\n const fgLines: string[] = []\n\n const colors = new Set(Object.values(computedThemes.value).flatMap(theme => Object.keys(theme.colors)))\n for (const key of colors) {\n if (/^on-[a-z]/.test(key)) {\n createCssClass(fgLines, `.${key}`, [`color: rgb(var(--v-theme-${key})) !important`])\n } else {\n createCssClass(bgLines, `.bg-${key}`, [\n `--v-theme-overlay-multiplier: var(--v-theme-${key}-overlay-multiplier)`,\n `background-color: rgb(var(--v-theme-${key})) !important`,\n `color: rgb(var(--v-theme-on-${key})) !important`,\n ])\n createCssClass(fgLines, `.text-${key}`, [`color: rgb(var(--v-theme-${key})) !important`])\n createCssClass(fgLines, `.border-${key}`, [`--v-border-color: var(--v-theme-${key})`])\n }\n }\n\n lines.push(...bgLines, ...fgLines)\n\n return lines.map((str, i) => i === 0 ? str : ` ${str}`).join('')\n })\n\n function getHead () {\n return {\n style: [{\n children: styles.value,\n id: 'vuetify-theme-stylesheet',\n nonce: parsedOptions.cspNonce || false as never,\n }],\n }\n }\n\n function install (app: App) {\n if (parsedOptions.isDisabled) return\n\n const head = app._context.provides.usehead as HeadClient | undefined\n if (head) {\n if (head.push) {\n const entry = head.push(getHead)\n if (IN_BROWSER) {\n watch(styles, () => { entry.patch(getHead) })\n }\n } else {\n if (IN_BROWSER) {\n head.addHeadObjs(computed(getHead))\n watchEffect(() => head.updateDOM())\n } else {\n head.addHeadObjs(getHead())\n }\n }\n } else {\n let styleEl = IN_BROWSER\n ? document.getElementById('vuetify-theme-stylesheet')\n : null\n\n if (IN_BROWSER) {\n watch(styles, updateStyles, { immediate: true })\n } else {\n updateStyles()\n }\n\n function updateStyles () {\n if (typeof document !== 'undefined' && !styleEl) {\n const el = document.createElement('style')\n el.type = 'text/css'\n el.id = 'vuetify-theme-stylesheet'\n if (parsedOptions.cspNonce) el.setAttribute('nonce', parsedOptions.cspNonce)\n\n styleEl = el\n document.head.appendChild(styleEl)\n }\n\n if (styleEl) styleEl.innerHTML = styles.value\n }\n }\n }\n\n const themeClasses = computed(() => parsedOptions.isDisabled ? undefined : `v-theme--${name.value}`)\n\n return {\n install,\n isDisabled: parsedOptions.isDisabled,\n name,\n themes,\n current,\n computedThemes,\n themeClasses,\n styles,\n global: {\n name,\n current,\n },\n }\n}\n\nexport function provideTheme (props: { theme?: string }) {\n getCurrentInstance('provideTheme')\n\n const theme = inject(ThemeSymbol, null)\n\n if (!theme) throw new Error('Could not find Vuetify theme injection')\n\n const name = computed<string>(() => {\n return props.theme ?? theme?.name.value\n })\n\n const themeClasses = computed(() => theme.isDisabled ? undefined : `v-theme--${name.value}`)\n\n const newTheme: ThemeInstance = {\n ...theme,\n name,\n themeClasses,\n }\n\n provide(ThemeSymbol, newTheme)\n\n return newTheme\n}\n\nexport function useTheme () {\n getCurrentInstance('useTheme')\n\n const theme = inject(ThemeSymbol, null)\n\n if (!theme) throw new Error('Could not find Vuetify theme injection')\n\n return theme\n}\n\nfunction createCssClass (lines: string[], selector: string, content: string[]) {\n lines.push(\n `${selector} {\\n`,\n ...content.map(line => ` ${line};\\n`),\n '}\\n',\n )\n}\n\nfunction genCssVariables (theme: InternalThemeDefinition) {\n const lightOverlay = theme.dark ? 2 : 1\n const darkOverlay = theme.dark ? 1 : 2\n\n const variables: string[] = []\n for (const [key, value] of Object.entries(theme.colors)) {\n const rgb = parseColor(value)\n variables.push(`--v-theme-${key}: ${rgb.r},${rgb.g},${rgb.b}`)\n if (!key.startsWith('on-')) {\n variables.push(`--v-theme-${key}-overlay-multiplier: ${getLuma(value) > 0.18 ? lightOverlay : darkOverlay}`)\n }\n }\n\n for (const [key, value] of Object.entries(theme.variables)) {\n const color = typeof value === 'string' && value.startsWith('#') ? parseColor(value) : undefined\n const rgb = color ? `${color.r}, ${color.g}, ${color.b}` : undefined\n variables.push(`--v-${key}: ${rgb ?? value}`)\n }\n\n return variables\n}\n"],"mappings":"AAAA;AACA,SACEA,QAAQ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