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Content":["import { colorToInt, intToHex, colorToHex, ColorInt } from '../../util/colorUtils'\nimport * as sRGB from '../../util/color/transformSRGB'\nimport * as LAB from '../../util/color/transformCIELAB'\nimport {\n VuetifyParsedTheme,\n VuetifyThemeItem,\n} from 'vuetify/types/services/theme'\n\nexport function parse (\n theme: Record<string, VuetifyThemeItem>,\n isItem = false\n): VuetifyParsedTheme {\n const { anchor, ...variant } = theme\n const colors = Object.keys(variant)\n const parsedTheme: any = {}\n\n for (let i = 0; i < colors.length; ++i) {\n const name = colors[i]\n const value = theme[name]\n\n if (value == null) continue\n\n if (isItem) {\n /* istanbul ignore else */\n if (name === 'base' || name.startsWith('lighten') || name.startsWith('darken')) {\n parsedTheme[name] = colorToHex(value)\n }\n } else if (typeof value === 'object') {\n parsedTheme[name] = parse(value, true)\n } else {\n parsedTheme[name] = genVariations(name, colorToInt(value))\n }\n }\n\n if (!isItem) {\n parsedTheme.anchor = anchor || parsedTheme.base || parsedTheme.primary.base\n }\n\n return parsedTheme\n}\n\n/**\n * Generate the CSS for a base color (.primary)\n */\nconst genBaseColor = (name: string, value: string): string => {\n return `\n.v-application .${name} {\n background-color: ${value} !important;\n border-color: ${value} !important;\n}\n.v-application .${name}--text {\n color: ${value} !important;\n caret-color: ${value} !important;\n}`\n}\n\n/**\n * Generate the CSS for a variant color (.primary.darken-2)\n */\nconst genVariantColor = (name: string, variant: string, value: string): string => {\n const [type, n] = variant.split(/(\\d)/, 2)\n return `\n.v-application .${name}.${type}-${n} {\n background-color: ${value} !important;\n border-color: ${value} !important;\n}\n.v-application .${name}--text.text--${type}-${n} {\n color: ${value} !important;\n caret-color: ${value} !important;\n}`\n}\n\nconst genColorVariableName = (name: string, variant = 'base'): string => `--v-${name}-${variant}`\n\nconst genColorVariable = (name: string, variant = 'base'): string => `var(${genColorVariableName(name, variant)})`\n\nexport function genStyles (theme: VuetifyParsedTheme, cssVar = false): string {\n const { anchor, ...variant } = theme\n const colors = Object.keys(variant)\n\n if (!colors.length) return ''\n\n let variablesCss = ''\n let css = ''\n\n const aColor = cssVar ? genColorVariable('anchor') : anchor\n css += `.v-application a { color: ${aColor}; }`\n cssVar && (variablesCss += ` ${genColorVariableName('anchor')}: ${anchor};\\n`)\n\n for (let i = 0; i < colors.length; ++i) {\n const name = colors[i]\n const value = theme[name]\n\n css += genBaseColor(name, cssVar ? genColorVariable(name) : value.base)\n cssVar && (variablesCss += ` ${genColorVariableName(name)}: ${value.base};\\n`)\n\n const variants = Object.keys(value)\n for (let i = 0; i < variants.length; ++i) {\n const variant = variants[i]\n const variantValue = value[variant]\n if (variant === 'base') continue\n\n css += genVariantColor(name, variant, cssVar ? genColorVariable(name, variant) : variantValue)\n cssVar && (variablesCss += ` ${genColorVariableName(name, variant)}: ${variantValue};\\n`)\n }\n }\n\n if (cssVar) {\n variablesCss = `:root {\\n${variablesCss}}\\n\\n`\n }\n\n return variablesCss + css\n}\n\nexport function genVariations (name: string, value: ColorInt): Record<string, string> {\n const values: Record<string, string> = {\n base: intToHex(value),\n }\n\n for (let i = 5; i > 0; --i) {\n values[`lighten${i}`] = intToHex(lighten(value, i))\n }\n\n for (let i = 1; i <= 4; ++i) {\n values[`darken${i}`] = intToHex(darken(value, i))\n }\n\n return values\n}\n\nfunction lighten (value: ColorInt, amount: number): ColorInt {\n const lab = LAB.fromXYZ(sRGB.toXYZ(value))\n lab[0] = lab[0] + amount * 10\n return sRGB.fromXYZ(LAB.toXYZ(lab))\n}\n\nfunction darken (value: ColorInt, amount: number): ColorInt {\n const lab = LAB.fromXYZ(sRGB.toXYZ(value))\n lab[0] = lab[0] - amount * 10\n return sRGB.fromXYZ(LAB.toXYZ(lab))\n}\n"],"sourceRoot":"","file":"utils.js"} |