@digdir/designsystemet 0.1.0-alpha.11 → 0.1.0-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/designsystemet.js +3445 -0
- package/dist/bin/designsystemet.js.map +1 -0
- package/dist/src/colors/colorUtils.js +364 -0
- package/dist/src/colors/colorUtils.js.map +1 -0
- package/dist/src/colors/index.js +607 -0
- package/dist/src/colors/index.js.map +1 -0
- package/dist/src/colors/themeUtils.js +365 -0
- package/dist/src/colors/themeUtils.js.map +1 -0
- package/dist/src/colors/types.js +1 -0
- package/dist/src/colors/types.js.map +1 -0
- package/dist/src/migrations/beta-to-v1.js +407 -0
- package/dist/src/migrations/beta-to-v1.js.map +1 -0
- package/dist/src/migrations/codemods/css/plugins.js +49 -0
- package/dist/src/migrations/codemods/css/plugins.js.map +1 -0
- package/dist/src/migrations/codemods/css/run.js +21 -0
- package/dist/src/migrations/codemods/css/run.js.map +1 -0
- package/dist/src/migrations/codemods/jsx/classname-prefix.js +65 -0
- package/dist/src/migrations/codemods/jsx/classname-prefix.js.map +1 -0
- package/dist/src/migrations/codemods/jsx/run.js +24 -0
- package/dist/src/migrations/codemods/jsx/run.js.map +1 -0
- package/dist/src/migrations/index.js +437 -0
- package/dist/src/migrations/index.js.map +1 -0
- package/dist/src/migrations/react-beta-to-v1.js +27 -0
- package/dist/src/migrations/react-beta-to-v1.js.map +1 -0
- package/dist/src/tokens/actions.js +2180 -0
- package/dist/src/tokens/actions.js.map +1 -0
- package/dist/src/tokens/build.js +2980 -0
- package/dist/src/tokens/build.js.map +1 -0
- package/dist/src/tokens/configs.js +2898 -0
- package/dist/src/tokens/configs.js.map +1 -0
- package/dist/src/tokens/formats/css.js +2656 -0
- package/dist/src/tokens/formats/css.js.map +1 -0
- package/dist/src/tokens/formats/js-tokens.js +44 -0
- package/dist/src/tokens/formats/js-tokens.js.map +1 -0
- package/dist/src/tokens/transformers.js +87 -0
- package/dist/src/tokens/transformers.js.map +1 -0
- package/dist/src/tokens/utils/noCase.js +30 -0
- package/dist/src/tokens/utils/noCase.js.map +1 -0
- package/dist/src/tokens/utils/permutateThemes.js +229 -0
- package/dist/src/tokens/utils/permutateThemes.js.map +1 -0
- package/dist/src/tokens/utils/utils.js +16 -0
- package/dist/src/tokens/utils/utils.js.map +1 -0
- package/package.json +23 -9
- package/dist/build/bin/designsystemet.js +0 -50
- package/dist/build/src/colors/colorUtils.js +0 -314
- package/dist/build/src/colors/index.js +0 -3
- package/dist/build/src/colors/themeUtils.js +0 -293
- package/dist/build/src/colors/types.js +0 -1
- package/dist/build/src/migrations/beta-to-v1.js +0 -341
- package/dist/build/src/migrations/codemods/css/plugins.js +0 -45
- package/dist/build/src/migrations/codemods/css/run.js +0 -17
- package/dist/build/src/migrations/codemods/jsx/classname-prefix.js +0 -80
- package/dist/build/src/migrations/codemods/jsx/run.js +0 -19
- package/dist/build/src/migrations/index.js +0 -6
- package/dist/build/src/migrations/react-beta-to-v1.js +0 -2
- package/dist/build/src/test/jsx-test.js +0 -10
- package/dist/build/src/tokens/actions.js +0 -20
- package/dist/build/src/tokens/build.js +0 -63
- package/dist/build/src/tokens/configs.js +0 -206
- package/dist/build/src/tokens/formats/css-classes.js +0 -78
- package/dist/build/src/tokens/formats/css-variables.js +0 -39
- package/dist/build/src/tokens/formats/js-tokens.js +0 -29
- package/dist/build/src/tokens/transformers.js +0 -42
- package/dist/build/src/tokens/utils/noCase.js +0 -30
- package/dist/build/src/tokens/utils/permutateThemes.js +0 -56
- package/dist/build/src/tokens/utils/utils.js +0 -21
- package/dist/build/tsconfig.tsbuildinfo +0 -1
- package/dist/types/bin/designsystemet.d.ts +0 -3
- package/dist/types/bin/designsystemet.d.ts.map +0 -1
- package/dist/types/src/colors/colorUtils.d.ts +0 -118
- package/dist/types/src/colors/colorUtils.d.ts.map +0 -1
- package/dist/types/src/colors/index.d.ts +0 -4
- package/dist/types/src/colors/index.d.ts.map +0 -1
- package/dist/types/src/colors/themeUtils.d.ts +0 -102
- package/dist/types/src/colors/themeUtils.d.ts.map +0 -1
- package/dist/types/src/colors/types.d.ts +0 -16
- package/dist/types/src/colors/types.d.ts.map +0 -1
- package/dist/types/src/migrations/beta-to-v1.d.ts +0 -3
- package/dist/types/src/migrations/beta-to-v1.d.ts.map +0 -1
- package/dist/types/src/migrations/codemods/css/plugins.d.ts +0 -6
- package/dist/types/src/migrations/codemods/css/plugins.d.ts.map +0 -1
- package/dist/types/src/migrations/codemods/css/run.d.ts +0 -8
- package/dist/types/src/migrations/codemods/css/run.d.ts.map +0 -1
- package/dist/types/src/migrations/codemods/jsx/classname-prefix.d.ts +0 -10
- package/dist/types/src/migrations/codemods/jsx/classname-prefix.d.ts.map +0 -1
- package/dist/types/src/migrations/codemods/jsx/run.d.ts +0 -7
- package/dist/types/src/migrations/codemods/jsx/run.d.ts.map +0 -1
- package/dist/types/src/migrations/index.d.ts +0 -6
- package/dist/types/src/migrations/index.d.ts.map +0 -1
- package/dist/types/src/migrations/react-beta-to-v1.d.ts +0 -3
- package/dist/types/src/migrations/react-beta-to-v1.d.ts.map +0 -1
- package/dist/types/src/test/jsx-test.d.ts +0 -4
- package/dist/types/src/test/jsx-test.d.ts.map +0 -1
- package/dist/types/src/tokens/actions.d.ts +0 -3
- package/dist/types/src/tokens/actions.d.ts.map +0 -1
- package/dist/types/src/tokens/build.d.ts +0 -11
- package/dist/types/src/tokens/build.d.ts.map +0 -1
- package/dist/types/src/tokens/configs.d.ts +0 -26
- package/dist/types/src/tokens/configs.d.ts.map +0 -1
- package/dist/types/src/tokens/formats/css-classes.d.ts +0 -6
- package/dist/types/src/tokens/formats/css-classes.d.ts.map +0 -1
- package/dist/types/src/tokens/formats/css-variables.d.ts +0 -3
- package/dist/types/src/tokens/formats/css-variables.d.ts.map +0 -1
- package/dist/types/src/tokens/formats/js-tokens.d.ts +0 -6
- package/dist/types/src/tokens/formats/js-tokens.d.ts.map +0 -1
- package/dist/types/src/tokens/transformers.d.ts +0 -5
- package/dist/types/src/tokens/transformers.d.ts.map +0 -1
- package/dist/types/src/tokens/utils/noCase.d.ts +0 -11
- package/dist/types/src/tokens/utils/noCase.d.ts.map +0 -1
- package/dist/types/src/tokens/utils/permutateThemes.d.ts +0 -7
- package/dist/types/src/tokens/utils/permutateThemes.d.ts.map +0 -1
- package/dist/types/src/tokens/utils/utils.d.ts +0 -17
- package/dist/types/src/tokens/utils/utils.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/colors/colorUtils.ts","../../../../../node_modules/apca-w3/src/apca-w3.js","../../../src/colors/themeUtils.ts"],"sourcesContent":["import type { CssColor } from '@adobe/leonardo-contrast-colors';\nimport { Hsluv } from 'hsluv';\nimport chroma from 'chroma-js';\nimport { APCAcontrast, sRGBtoY } from 'apca-w3';\n\n/**\n * Converts a HEX color '#xxxxxx' into a CSS HSL string 'hsl(x,x,x)'\n *\n * @param hex A hex color string\n * @param valuesOnly If true, only the values are returned\n * @returns A CSS HSL string\n */\nexport const hexToCssHsl = (hex: string, valuesOnly = false) => {\n const result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\n let r = 0;\n let g = 0;\n let b = 0;\n let cssString = '';\n if (result) {\n r = parseInt(result[1], 16);\n g = parseInt(result[2], 16);\n b = parseInt(result[3], 16);\n }\n (r /= 255), (g /= 255), (b /= 255);\n const max = Math.max(r, g, b),\n min = Math.min(r, g, b);\n let h,\n s,\n l = (max + min) / 2;\n if (max == min) {\n h = s = 0; // achromatic\n } else {\n const d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n switch (max) {\n case r:\n h = (g - b) / d + (g < b ? 6 : 0);\n break;\n case g:\n h = (b - r) / d + 2;\n break;\n case b:\n h = (r - g) / d + 4;\n break;\n }\n }\n\n h = Math.round(h ? h * 360 : 0);\n s = Math.round(s * 100);\n l = Math.round(l * 100);\n\n cssString = h + ',' + s + '%,' + l + '%';\n cssString = !valuesOnly ? 'hsl(' + cssString + ')' : cssString;\n\n return cssString;\n};\n\n/**\n * Converts a HEX string '#xxxxxx' into an array of HSL values '[h,s,l]'\n *\n * @param H A Hex color string\n * @returns HSL values in an array\n */\nexport const hexToHSL = (H: string) => {\n // Convert hex to RGB first\n let r = 0,\n g = 0,\n b = 0;\n if (H.length == 4) {\n r = parseInt('0x' + H[1] + H[1]);\n g = parseInt('0x' + H[2] + H[2]);\n b = parseInt('0x' + H[3] + H[3]);\n } else if (H.length == 7) {\n r = parseInt('0x' + H[1] + H[2]);\n g = parseInt('0x' + H[3] + H[4]);\n b = parseInt('0x' + H[5] + H[6]);\n }\n // Then to HSL\n r /= 255;\n g /= 255;\n b /= 255;\n let h = 0,\n s = 0,\n l = 0;\n const cmin = Math.min(r, g, b),\n cmax = Math.max(r, g, b),\n delta = cmax - cmin;\n\n if (delta == 0) h = 0;\n else if (cmax == r) h = ((g - b) / delta) % 6;\n else if (cmax == g) h = (b - r) / delta + 2;\n else h = (r - g) / delta + 4;\n\n h = Math.round(h * 60);\n\n if (h < 0) h += 360;\n\n l = (cmax + cmin) / 2;\n s = delta == 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));\n s = +(s * 100).toFixed(1);\n l = +(l * 100).toFixed(1);\n\n return [h, s, l];\n};\n\n/**\n * Converts a HEX color '#xxxxxx' into an array of HSLuv values '[h,s,l]'\n *\n * @param hex A hex color string\n * @returns\n */\nexport const hexToHsluv = (hex: string) => {\n const conv = new Hsluv();\n conv.hex = hex;\n conv.hexToHsluv();\n return [conv.hsluv_h, conv.hsluv_s, conv.hsluv_l];\n};\n\n/**\n * Converts a HSL number array '[h,s,l]' into HSL CSS string 'hsl(x,x,x)'\n *\n * @param HSL A HSL number array '[h,s,l]'\n * @returns A hex color string\n */\nexport const hslArrToCss = (HSL: number[]) => {\n return 'hsl(' + HSL[0] + ',' + HSL[1] + '%,' + HSL[2] + '%)';\n};\n\n/**\n * Converts a HSL CSS string 'hsl(x,x,x)' into an array of HSL values '[h,s,l]'\n *\n * @param h The HSL hue\n * @param s The HSL saturation\n * @param l The HSL lightness\n * @returns HEX color string\n */\nexport const HSLToHex = (h: number, s: number, l: number) => {\n s /= 100;\n l /= 100;\n\n let r = 0,\n g = 0,\n b = 0;\n const c = (1 - Math.abs(2 * l - 1)) * s,\n x = c * (1 - Math.abs(((h / 60) % 2) - 1)),\n m = l - c / 2;\n\n if (0 <= h && h < 60) {\n r = c;\n g = x;\n b = 0;\n } else if (60 <= h && h < 120) {\n r = x;\n g = c;\n b = 0;\n } else if (120 <= h && h < 180) {\n r = 0;\n g = c;\n b = x;\n } else if (180 <= h && h < 240) {\n r = 0;\n g = x;\n b = c;\n } else if (240 <= h && h < 300) {\n r = x;\n g = 0;\n b = c;\n } else if (300 <= h && h < 360) {\n r = c;\n g = 0;\n b = x;\n }\n // Having obtained RGB, convert channels to hex\n r = parseInt(Math.round((r + m) * 255).toString(16), 16);\n g = parseInt(Math.round((g + m) * 255).toString(16), 16);\n b = parseInt(Math.round((b + m) * 255).toString(16), 16);\n\n // Prepend 0s, if necessary\n if (r.toString().length == 1) r = parseInt('0' + r.toString(), 10);\n if (g.toString().length == 1) g = parseInt('0' + g.toString(), 10);\n if (b.toString().length == 1) b = parseInt('0' + b.toString(), 10);\n\n return '#' + r + g + b;\n};\n\n/**\n * Converts a HEX color '#xxxxxx' into an array of RGB values '[R, G, B]'\n *\n * @param hex A hex color string\n * @returns RGB values in an array\n */\nexport const hexToRgb = (hex: string) => {\n const shorthandRegex = /^#?([a-f\\d])([a-f\\d])([a-f\\d])$/i;\n hex = hex.replace(shorthandRegex, function (m, r: string, g: string, b: string) {\n return r + r + g + g + b + b;\n });\n\n const result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\n return result\n ? {\n r: parseInt(result[1], 16),\n g: parseInt(result[2], 16),\n b: parseInt(result[3], 16),\n }\n : null;\n};\n\n/**\n * Get the luminance of an RGB color\n *\n * @param r RGB red value\n * @param G RGB green value\n * @param b RGB blue value\n * @returns\n */\nexport const luminanceFromRgb = (r: string, g: string, b: string) => {\n const a = [Number(r), Number(g), Number(b)].map(function (v) {\n v /= 255;\n return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);\n });\n return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;\n};\n\n/**\n * Get the luminance of a HEX color\n *\n * @param hex A hex color string\n * @returns\n */\nexport const luminanceFromHex = (hex: CssColor) => {\n const rgb = hexToRgb(hex);\n if (rgb) {\n const r = rgb.r.toString();\n const g = rgb.g.toString();\n const b = rgb.b.toString();\n return luminanceFromRgb(r, g, b);\n }\n return 2;\n};\n\n/**\n * Get the contrast ratio between two luminance values\n *\n * @param lum1 The first luminance value\n * @param lum2 The second luminance value\n * @returns\n */\nexport const getRatioFromLum = (lum1: number, lum2: number) => {\n if (lum1 !== null && lum2 !== null) {\n return (Math.max(lum1, lum2) + 0.05) / (Math.min(lum1, lum2) + 0.05);\n } else {\n return -1;\n }\n};\n\n/**\n * Get the HSL lightness from a HEX color\n *\n * @param hex A hex color string\n * @returns\n */\nexport const getHslLightessFromHex = (hex: CssColor) => {\n return chroma(hex).hsl()[2];\n};\n\nexport const getHslSaturationFromHex = (hex: CssColor) => {\n return chroma(hex).hsl()[1];\n};\n\n/**\n * Get the HSLuv lightness from a HEX color\n *\n * @param hex A hex color string\n * @returns\n */\nexport const getLightnessFromHex = (hex: string) => {\n const conv = new Hsluv();\n conv.hex = hex;\n conv.hexToHsluv();\n return Number(conv.hsluv_l.toFixed(0));\n};\n\n/**\n * Get the contrast ratio between two HEX colors\n *\n * @param {CssColor} color1 The first color\n * @param {CssColor} color2 The second color\n * @returns\n */\nexport const getContrastFromHex = (color1: CssColor, color2: CssColor) => {\n const lum1 = luminanceFromHex(color1);\n const lum2 = luminanceFromHex(color2);\n if (lum1 !== null && lum2 !== null) {\n return getRatioFromLum(lum1, lum2);\n }\n return -1;\n};\n\n/**\n * Get the contrast ratio between two colors at a specific lightness\n *\n * @param lightness The lightness value\n * @param mainColor The main color\n * @param backgroundColor The background color\n * @returns The contrast ratio\n */\nexport const getContrastFromLightness = (lightness: number, mainColor: CssColor, backgroundColor: CssColor) => {\n const conv = new Hsluv();\n conv.hex = mainColor;\n conv.hexToHsluv();\n conv.hsluv_l = lightness;\n conv.hsluvToHex();\n const lightMainColor = conv.hex;\n const lum1 = luminanceFromHex(lightMainColor as CssColor);\n const lum2 = luminanceFromHex(backgroundColor);\n const ratio = getRatioFromLum(lum1 ?? 0, lum2 ?? 0);\n\n return ratio;\n};\n\n/**\n * Maps the numbers from [start1 - end1] to the range [start2 - end2], maintaining the proportionality between the numbers in the ranges using lineaer interpolation.\n */\n// const mapRange = (value: number, start1: number, end1: number, start2: number, end2: number) => {\n// return start2 + ((value - start1) * (end2 - start2)) / (end1 - start1);\n// };\n\n/**\n * Check if two colors have enough contrast to be used together\n *\n * @param {CssColor} color1 The first color\n * @param {CssColor} color2 The second color\n * @returns {boolean} If the colors have enough contrast\n */\nexport const areColorsContrasting = (color1: CssColor, color2: CssColor, type: 'decorative' | 'aa' | 'aaa' = 'aa') => {\n const contrast = getContrastFromHex(color1, color2);\n if (contrast !== null) {\n if (type === 'aaa') {\n return contrast >= 7;\n } else if (type === 'aa') {\n return contrast >= 4.5;\n } else {\n return contrast >= 3;\n }\n }\n return false;\n};\n\nexport const getApcaContrastLc = (textColor: CssColor, backgroundColor: CssColor) => {\n const textColorRgb = hexToRgb(textColor);\n const backgroundColorRgb = hexToRgb(backgroundColor);\n\n if (textColorRgb && backgroundColorRgb) {\n return APCAcontrast(\n sRGBtoY([textColorRgb.r, textColorRgb.g, textColorRgb.b]),\n sRGBtoY([backgroundColorRgb.r, backgroundColorRgb.g, backgroundColorRgb.b]),\n );\n }\n return 0;\n};\n\n/**\n * Check if aa string value is a HEX color\n *\n * @param {string} hex The string to check\n * @returns {boolean} If the string is a HEX color\n */\nexport const isHexColor = (hex: string) => {\n return typeof hex === 'string' && hex.length === 6 && !isNaN(Number('0x' + hex));\n};\n","///////////////////////////////////////////////////////////////////////////////\n/** @preserve\n///// SAPC APCA - Advanced Perceptual Contrast Algorithm\n///// Beta 0.1.9 W3 • contrast function only\n///// DIST: W3 • Revision date: July 3, 2022\n///// Function to parse color values and determine Lc contrast\n///// Copyright © 2019-2022 by Andrew Somers. All Rights Reserved.\n///// LICENSE: W3 LICENSE\n///// CONTACT: Please use the ISSUES or DISCUSSIONS tab at:\n///// https://github.com/Myndex/SAPC-APCA/\n/////\n///////////////////////////////////////////////////////////////////////////////\n/////\n///// MINIMAL IMPORTS:\n///// import { APCAcontrast, sRGBtoY, displayP3toY,\n///// calcAPCA, fontLookupAPCA } from 'apca-w3';\n///// import { colorParsley } from 'colorparsley';\n/////\n///// FORWARD CONTRAST USAGE:\n///// Lc = APCAcontrast( sRGBtoY( TEXTcolor ) , sRGBtoY( BACKGNDcolor ) );\n///// Where the colors are sent as an rgba array [255,255,255,1]\n/////\n///// Retrieving an array of font sizes for the contrast:\n///// fontArray = fontLookupAPCA(Lc);\n/////\n///// Live Demonstrator at https://www.myndex.com/APCA/\n// */\n///////////////////////////////////////////////////////////////////////////////\n\n////////////////////////////////////////////////////////////////////////////////\n/////\n///// SAPC Method and APCA Algorithm\n///// W3 Licensed Version: https://github.com/Myndex/apca-w3\n///// GITHUB MAIN REPO: https://github.com/Myndex/SAPC-APCA\n///// DEVELOPER SITE: https://git.myndex.com/\n/////\n///// Acknowledgments and Thanks To:\n///// • This project references the research & work of M.Fairchild, R.W.Hunt,\n///// Drs. Bailey/Lovie-Kitchin, G.Legge, A.Arditi, M.Stone, C.Poynton, \n///// L.Arend, M.Luo, E.Burns, R.Blackwell, P.Barton, M.Brettel, and many \n///// others — see refs at https://www.myndex.com/WEB/WCAG_CE17polarity\n///// • Bruce Bailey of USAccessBoard for his encouragement, ideas, & feedback\n///// • Chris Lilly of W3C for continued review, examination, & oversight\n///// • Chris Loiselle of Oracle for getting us back on track in a pandemic\n///// • The many volunteer test subjects for participating in the studies.\n///// • The many early adopters, beta testers, and code/issue contributors\n///// • Principal research conducted at Myndex by A.Somers.\n/////\n////////////////////////////////////////////////////////////////////////////////\n\n////////////////////////////////////////////////////////////////////////////////\n/////\n///// ***** SAPC BLOCK *****\n/////\n///// For Evaluations, refer to this as: SAPC-8, 0.0.98G-series constant 4g\n///// SAPC • S-LUV Advanced Predictive Color\n/////\n///// SIMPLE VERSION — Only the basic APCA contrast predictor.\n/////\n///// Included Extensions & Model Features in this file:\n///// • SAPC-8 Core Contrast (Base APCA, non-clinical use only) \n///// • G series constants, group \"G-4g\" using a 2.4 monitor exponent\n///// • sRGB to Y, parses numeric sRGB color to luminance\n///// • SoftToe black level soft clamp and flare compensation.\n/////\n/////\n////////////////////////////////////////////////////////////////////////////////\n/////\n///// DISCLAIMER AND LIMITATIONS OF USE\n///// APCA is an embodiment of certain suprathreshold contrast\n///// prediction technologies and it is licensed to the W3 on a\n///// limited basis for use in certain specific accessibility\n///// guidelines for web content only. APCA may be used for \n///// predicting colors for web content use without royalty.\n/////\n///// However, Any such license excludes other use cases\n///// not related to web content. Prohibited uses include\n///// medical, clinical evaluation, human safety related,\n///// aerospace, transportation, military applications, \n///// and uses which are not specific to web based content\n///// presented on self-illuminated displays or devices.\n/////\n////////////////////////////////////////////////////////////////////////////////\n\n////////// APCA 0.1.9 G 4g USAGE ///////////////////////////////////////////\n///\n/// The API for \"APCA 0.1.9\" is trivially simple.\n/// Send text and background sRGB numeric values to the sRGBtoY() function,\n/// and send the resulting text-Y and background-Y to the APCAcontrast function\n/// it returns a signed float with the numeric Lc contrast result.\n/// \n/// The two inputs are TEXT color and BACKGROUND color in that order.\n/// Each must be a numeric NOT a string, as this simple version has\n/// no string parsing utilities. EXAMPLE:\n/// ________________________________________________________________________\n///\n/// txtColor = colorParsley(0x123456); // color of the text\n/// bgColor = colorParsley(0xabcdef); // color for the background\n///\n/// contrastLc = APCAcontrast( sRGBtoY(txtColor) , sRGBtoY(bgColor) );\n/// ________________________________________________________________________\n///\n/// ********** QUICK START **********\n///\n/// Each color must be a 24bit color (8 bit per channel) as a single integer\n/// (or 0x) sRGB encoded color, i.e. White is either the integer 16777216 or\n/// the hex 0xffffff. A float is returned with a positive or negative value.\n/// Negative values mean light text and a dark background, positive values\n/// mean dark text and a light background. 60.0, or -60.0 is a contrast\n/// \"sort of like\" the old WCAG 2's 4.5:1. NOTE: the total range is now less\n/// than ± 110, so output can be rounded to a signed INT but DO NOT output\n/// an absolute value - light text on dark BG should return a negative number.\n///\n/// ***** IMPORTANT: Do Not Mix Up Text and Background inputs. *****\n/// **************** APCA is polarity sensitive! *****************\n/// \n////////////////////////////////////////////////////////////////////////////////\n\n\n////////////////////////////////////////////////////////////////////////////////\n///////////////////////////////////////////////////////////////////////////////\n///// BEGIN APCA 0.1.9 BLOCK \\/////////////////////////////////////\n//// \\///////////////////////////////////\n/// \\/////////////////////////////////\n// \\///////////////////////////////\n\n\n///// DEPENDENCIES /////\n\n// The following imports are not needed for the main APCA function,\n// but are needed for the shortcut/alias calcAPCA(), and for the\n// future invertAPCA function, which examines hue.\n\n //// (add slash to line start for local test mode, remove before push)\n/* //// LOCAL TESTING SWITCH for using test.html\n import{colorParsley}from'../node_modules/colorparsley/src/colorparsley.js';\n/*/ //// TOGGLE\n import { colorParsley } from 'colorparsley';\n// */ //// END LOCAL TESTING SWITCH\n\n\n///// Module Scope Object Containing Constants /////\n///// APCA 0.0.98G - 4g - W3 Compatible Constants\n\n///// 𝒦 SA98G ///////////////////////////////////\n const SA98G = {\n\n mainTRC: 2.4, // 2.4 exponent for emulating actual monitor perception\n\n // For reverseAPCA\n get mainTRCencode() { return 1 / this.mainTRC },\n\n // sRGB coefficients\n sRco: 0.2126729, \n sGco: 0.7151522, \n sBco: 0.0721750, \n\n // G-4g constants for use with 2.4 exponent\n normBG: 0.56, \n normTXT: 0.57,\n revTXT: 0.62,\n revBG: 0.65,\n\n // G-4g Clamps and Scalers\n blkThrs: 0.022,\n blkClmp: 1.414, \n scaleBoW: 1.14,\n scaleWoB: 1.14,\n loBoWoffset: 0.027,\n loWoBoffset: 0.027,\n deltaYmin: 0.0005,\n loClip: 0.1,\n\n ///// MAGIC NUMBERS for UNCLAMP, for use with 0.022 & 1.414 /////\n // Magic Numbers for reverseAPCA\n mFactor: 1.94685544331710,\n get mFactInv() { return 1 / this.mFactor},\n mOffsetIn: 0.03873938165714010,\n mExpAdj: 0.2833433964208690,\n get mExp() { return this.mExpAdj / this.blkClmp},\n mOffsetOut: 0.3128657958707580,\n }\n\n\n\n\n//////////////////////////////////////////////////////////////////////////////\n////////// APCA CALCULATION FUNCTIONS \\/////////////////////////////////////\n\n////////// ƒ APCAcontrast() ////////////////////////////////////////////\nexport function APCAcontrast (txtY,bgY,places = -1) {\n // send linear Y (luminance) for text and background.\n // txtY and bgY must be between 0.0-1.0\n // IMPORTANT: Do not swap, polarity is important.\n\n const icp = [0.0,1.1]; // input range clamp / input error check\n\n if(isNaN(txtY)||isNaN(bgY)||Math.min(txtY,bgY)<icp[0]||\n Math.max(txtY,bgY)>icp[1]){\n return 0.0; // return zero on error\n // return 'error'; // optional string return for error\n };\n\n////////// SAPC LOCAL VARS /////////////////////////////////////////\n\n let SAPC = 0.0; // For raw SAPC values\n let outputContrast = 0.0; // For weighted final values\n let polCat = 'BoW'; // Alternate Polarity Indicator. N normal R reverse\n\n // TUTORIAL\n\n // Use Y for text and BG, and soft clamp black,\n // return 0 for very close luminances, determine\n // polarity, and calculate SAPC raw contrast\n // Then scale for easy to remember levels.\n\n // Note that reverse contrast (white text on black)\n // intentionally returns a negative number\n // Proper polarity is important!\n\n////////// BLACK SOFT CLAMP ////////////////////////////////////////\n\n // Soft clamps Y for either color if it is near black.\n txtY = (txtY > SA98G.blkThrs) ? txtY :\n txtY + Math.pow(SA98G.blkThrs - txtY, SA98G.blkClmp);\n bgY = (bgY > SA98G.blkThrs) ? bgY :\n bgY + Math.pow(SA98G.blkThrs - bgY, SA98G.blkClmp);\n\n ///// Return 0 Early for extremely low ∆Y\n if ( Math.abs(bgY - txtY) < SA98G.deltaYmin ) { return 0.0; }\n\n\n////////// APCA/SAPC CONTRAST - LOW CLIP (W3 LICENSE) ///////////////\n\n if ( bgY > txtY ) { // For normal polarity, black text on white (BoW)\n\n // Calculate the SAPC contrast value and scale\n SAPC = ( Math.pow(bgY, SA98G.normBG) - \n Math.pow(txtY, SA98G.normTXT) ) * SA98G.scaleBoW;\n\n // Low Contrast smooth rollout to prevent polarity reversal\n // and also a low-clip for very low contrasts\n outputContrast = (SAPC < SA98G.loClip) ? 0.0 : SAPC - SA98G.loBoWoffset;\n\n } else { // For reverse polarity, light text on dark (WoB)\n // WoB should always return negative value.\n polCat = 'WoB';\n\n SAPC = ( Math.pow(bgY, SA98G.revBG) - \n Math.pow(txtY, SA98G.revTXT) ) * SA98G.scaleWoB;\n\n outputContrast = (SAPC > -SA98G.loClip) ? 0.0 : SAPC + SA98G.loWoBoffset;\n }\n\n // return Lc (lightness contrast) as a signed numeric value \n // Round to the nearest whole number as string is optional.\n // Rounded can be a signed INT as output will be within ± 127 \n // places = -1 returns signed float, 1 or more set that many places\n // 0 returns rounded string, uses BoW or WoB instead of minus sign\n\n if(places < 0 ){ // Default (-1) number out, all others are strings\n return outputContrast * 100.0;\n } else if(places == 0 ){\n return Math.round(Math.abs(outputContrast)*100.0)+'<sub>'+polCat+'</sub>';\n } else if(Number.isInteger(places)){\n return (outputContrast * 100.0).toFixed(places);\n } else { return 0.0 }\n\n} // End APCAcontrast()\n\n\n\n\n/* SWITCH -- WORK IN PROGRESS DO NOT USE\n////////// ƒ invertAPCA() //////////////////////////////////////////////////\nexport function invertAPCA (\n {knownColor: [128,128,128], knownType: 'bg', targetCnst: 75,\n returnAs: 'object', unknownType: 'txt', hueInvert: false,\n hueRange: 5, preserveSat: false }) {\n\n //if (Math.abs(targetCnst) < 15) { return false }; // abs contrast must be > 15\n\n let knownY = sRGBtoY (knownColor);\n let unknownY = knownY, knownExp, unknownExp;\n let min,max,knownLs,isBG = true;\n\n\n if (knownType == 'bg' || knownType == 'background') {\n knownLs = Math.pow(knownY, );\n black = APCAcontrast(0,knownY);\n white = APCAcontrast(1,knownY);\n } else if (knownType == 'txt' || knownType == 'text') {\n isBG = false;\n black = APCAcontrast(knownY,0);\n white = APCAcontrast(knownY,1);\n } else { return false } // return false on error\n\n\n///// APCA 0.0.98G - 4g - W3 Compatible Constants ////////////////////\n\n const scale = contrast > 0 ? SA98G.scaleBoW : SA98G.scaleWoB;\n const offset = contrast > 0 ? SA98G.loBoWoffset : -SA98G.loWoBoffset;\n\n\n targetCnst = ( parseFloat(targetCnst) * 0.01 + offset ) / scale;\n\n // Soft clamps Y if it is near black.\n knownY = (knownY > SA98G.blkThrs) ? knownY :\n knownY + Math.pow(SA98G.blkThrs - knownY, SA98G.blkClmp);\n \n // set the known and unknown exponents\n if (isBG) {\n knownExp = targetCnst > 0 ? SA98G.normBG : SA98G.revBG;\n unknownExp = targetCnst > 0 ? SA98G.normTXT : SA98G.revTXT;\n unknownY = Math.pow( Math.pow(knownY,knownExp) - targetCnst, 1/unknownExp );\n if (isNaN(unknownY)) return false;\n } else if (!isBG) {\n knownExp = targetCnst > 0 ? SA98G.normTXT : SA98G.revTXT;\n unknownExp = targetCnst > 0 ? SA98G.normBG : SA98G.revBG;\n unknownY = Math.pow(targetCnst + Math.pow(knownY,knownExp), 1/unknownExp );\n if (isNaN(unknownY)) return false;\n }\n\n //return contrast +'----'+unknownY;\n\n if (unknownY > 1.06 || unknownY < 0) { return false } // return false on overflow\n // if (unknownY < 0) { return false } // return false on underflow\n //unknownY = Math.max(unknownY,0.0);\n \n // unclamp\n unknownY = (unknownY > SA98G.blkThrs) ? unknownY : \n (Math.pow(((unknownY + SA98G.mOffsetIn)m* SA98G.mFactor),\n SA98G.mExp) * SA98G.mFactInv) - SA98G.mOffsetOut;\n \n// unknownY - 0.22 * Math.pow(unknownY*0.5, 1/blkClmp);\n\n unknownY = Math.max(Math.min(unknownY,1.0),0.0);\n\n let testedCnst = (isBG) ? APCAcontrast(unknownY,knownY) : \n APCAcontrast(knownY,unknownY);\n\n if (returnAs === 'object') {\n let hexB = ( Math.round(Math.pow(unknownY,SA98G.mainTRCencode) * 255)\n ).toString(16).padStart(2,'0');\n hexB = '#' + hexB + hexB + hexB;\n return {color: hexB, Lc: testedCnst, whiteLc: white, blackLc: black};\n } else if (returnAs === 'hex') {\n let hexB = ( Math.round(Math.pow(unknownY,SA98G.mainTRCencode) * 255)\n ).toString(16).padStart(2,'0');\n return '#' + hexB + hexB + hexB;\n } else if (returnAs === 'array') {\n let colorB = Math.round(Math.pow(unknownY,SA98G.mainTRCencode) * 255);\n let retUse = (knownType == 'bg') ? 'txtColor' : 'bgColor'\n return [colorB,colorB,colorB,1,retUse];\n } else if (returnAs === 'Y' || returnAs === 'y') {\n return Math.max(0.0,unknownY);\n } else { return false } // return knownY on error\n}\n// */ // END SWITCH\n\n\n\n\n////////// ƒ reverseAPCA() DEPRECATED SOON ///////////////////////////////\nexport function reverseAPCA (contrast = 0,knownY = 1.0,\n knownType = 'bg',returnAs = 'hex') {\n \n if (Math.abs(contrast) < 9) { return false }; // abs contrast must be > 9\n \n let unknownY = knownY, knownExp, unknownExp;\n \n///// APCA 0.0.98G - 4g - W3 Compatible Constants ////////////////////\n\n const scale = contrast > 0 ? SA98G.scaleBoW : SA98G.scaleWoB;\n const offset = contrast > 0 ? SA98G.loBoWoffset : -SA98G.loWoBoffset;\n\n\n contrast = ( parseFloat(contrast) * 0.01 + offset ) / scale;\n\n // Soft clamps Y if it is near black.\n knownY = (knownY > SA98G.blkThrs) ? knownY :\n knownY + Math.pow(SA98G.blkThrs - knownY, SA98G.blkClmp);\n \n // set the known and unknown exponents\n if (knownType == 'bg' || knownType == 'background') {\n knownExp = contrast > 0 ? SA98G.normBG : SA98G.revBG;\n unknownExp = contrast > 0 ? SA98G.normTXT : SA98G.revTXT;\n unknownY = Math.pow( Math.pow(knownY,knownExp) - contrast, 1/unknownExp );\n if (isNaN(unknownY)) return false;\n } else if (knownType == 'txt' || knownType == 'text') {\n knownExp = contrast > 0 ? SA98G.normTXT : SA98G.revTXT;\n unknownExp = contrast > 0 ? SA98G.normBG : SA98G.revBG;\n unknownY = Math.pow(contrast + Math.pow(knownY,knownExp), 1/unknownExp );\n if (isNaN(unknownY)) return false;\n } else { return false } // return false on error\n\n //return contrast +'----'+unknownY;\n\n if (unknownY > 1.06 || unknownY < 0) { return false } // return false on overflow\n // if (unknownY < 0) { return false } // return false on underflow\n //unknownY = Math.max(unknownY,0.0);\n \n // unclamp\n unknownY = (unknownY > SA98G.blkThrs) ? unknownY : \n (Math.pow(((unknownY + SA98G.mOffsetIn) * SA98G.mFactor),\n SA98G.mExp) * SA98G.mFactInv) - SA98G.mOffsetOut;\n \n// unknownY - 0.22 * Math.pow(unknownY*0.5, 1/blkClmp);\n\n unknownY = Math.max(Math.min(unknownY,1.0),0.0);\n\n if (returnAs === 'hex') {\n let hexB = ( Math.round(Math.pow(unknownY,SA98G.mainTRCencode) * 255)\n ).toString(16).padStart(2,'0');\n\n return '#' + hexB + hexB + hexB;\n } else if (returnAs === 'color') {\n let colorB = Math.round(Math.pow(unknownY,SA98G.mainTRCencode) * 255);\n let retUse = (knownType == 'bg') ? 'txtColor' : 'bgColor'\n return [colorB,colorB,colorB,1,retUse];\n } else if (returnAs === 'Y' || returnAs === 'y') {\n return Math.max(0.0,unknownY);\n } else { return false } // return knownY on error\n}\n\n\n\n\n////////// ƒ calcAPCA() /////////////////////////////////////////////\nexport function calcAPCA (textColor, bgColor, places = -1, round = true) {\n\n // Note that this function requires colorParsley !!\n\tlet bgClr = colorParsley(bgColor);\n\tlet txClr = colorParsley(textColor);\n\tlet hasAlpha = (txClr[3] == '' || txClr[3] == 1) ? false : true ;\n\n\tif (hasAlpha) { txClr = alphaBlend( txClr, bgClr, round); };\n\n\treturn APCAcontrast( sRGBtoY(txClr), sRGBtoY(bgClr), places)\n} // End calcAPCA()\n\n\n\n\n//////////////////////////////////////////////////////////////////////////////\n////////// ƒ fontLookupAPCA() 0.1.7 (G) \\////////////////////////////////\n///////// \\//////////////////////////////\n\nexport function fontLookupAPCA (contrast,places=2) {\n\n////////////////////////////////////////////////////////////////////////////\n///// CONTRAST * FONT WEIGHT & SIZE /////////////////////////////////////\n\n// Font size interpolations. Here the chart was re-ordered to put\n// the main contrast levels each on one line, instead of font size per line.\n// First column is LC value, then each following column is font size by weight\n\n// G G G G G G Public Beta 0.1.7 (G) • MAY 28 2022\n\n// Lc values under 70 should have Lc 15 ADDED if used for body text\n// All font sizes are in px and reference font is Barlow\n\n// 999: prohibited - too low contrast\n// 777: NON TEXT at this minimum weight stroke\n// 666 - this is for spot text, not fluent-Things like copyright or placeholder.\n// 5xx - minimum font at this weight for content, 5xx % 500 for font-size\n// 4xx - minimum font at this weight for any purpose], 4xx % 400 for font-size\n\n// MAIN FONT SIZE LOOKUP\n\n//// ASCENDING SORTED Public Beta 0.1.7 (G) • MAY 28 2022 ////\n\n//// Lc 45 * 0.2 = 9 which is the index for the row for Lc 45\n\n// MAIN FONT LOOKUP May 28 2022 EXPANDED\n// Sorted by Lc Value\n// First row is standard weights 100-900\n// First column is font size in px\n// All other values are the Lc contrast \n// 999 = too low. 777 = non-text and spot text only\n\n\nconst fontMatrixAscend = [\n ['Lc',100,200,300,400,500,600,700,800,900],\n [0,999,999,999,999,999,999,999,999,999],\n [10,999,999,999,999,999,999,999,999,999],\n [15,777,777,777,777,777,777,777,777,777],\n [20,777,777,777,777,777,777,777,777,777],\n [25,777,777,777,120,120,108,96,96,96],\n [30,777,777,120,108,108,96,72,72,72],\n [35,777,120,108,96,72,60,48,48,48],\n [40,120,108,96,60,48,42,32,32,32],\n [45,108,96,72,42,32,28,24,24,24],\n [50,96,72,60,32,28,24,21,21,21],\n [55,80,60,48,28,24,21,18,18,18],\n [60,72,48,42,24,21,18,16,16,18],\n [65,68,46,32,21.75,19,17,15,16,18],\n [70,64,44,28,19.5,18,16,14.5,16,18],\n [75,60,42,24,18,16,15,14,16,18],\n [80,56,38.25,23,17.25,15.81,14.81,14,16,18],\n [85,52,34.5,22,16.5,15.625,14.625,14,16,18],\n [90,48,32,21,16,15.5,14.5,14,16,18],\n [95,45,28,19.5,15.5,15,14,13.5,16,18],\n [100,42,26.5,18.5,15,14.5,13.5,13,16,18],\n [105,39,25,18,14.5,14,13,12,16,18],\n [110,36,24,18,14,13,12,11,16,18],\n [115,34.5,22.5,17.25,12.5,11.875,11.25,10.625,14.5,16.5],\n [120,33,21,16.5,11,10.75,10.5,10.25,13,15],\n [125,32,20,16,10,10,10,10,12,14],\n ];\n\n\n// ASCENDING SORTED Public Beta 0.1.7 (G) • MAY 28 2022 ////\n\n// DELTA - MAIN FONT LOOKUP May 28 2022 EXPANDED\n// EXPANDED Sorted by Lc Value •• DELTA\n// The pre-calculated deltas of the above array\n\nconst fontDeltaAscend = [\n ['∆Lc',100,200,300,400,500,600,700,800,900],\n [0,0,0,0,0,0,0,0,0,0],\n [10,0,0,0,0,0,0,0,0,0],\n [15,0,0,0,0,0,0,0,0,0],\n [20,0,0,0,0,0,0,0,0,0],\n [25,0,0,0,12,12,12,24,24,24],\n [30,0,0,12,12,36,36,24,24,24],\n [35,0,12,12,36,24,18,16,16,16],\n [40,12,12,24,18,16,14,8,8,8],\n [45,12,24,12,10,4,4,3,3,3],\n [50,16,12,12,4,4,3,3,3,3],\n [55,8,12,6,4,3,3,2,2,0],\n [60,4,2,10,2.25,2,1,1,0,0],\n [65,4,2,4,2.25,1,1,0.5,0,0],\n [70,4,2,4,1.5,2,1,0.5,0,0],\n [75,4,3.75,1,0.75,0.188,0.188,0,0,0],\n [80,4,3.75,1,0.75,0.188,0.188,0,0,0],\n [85,4,2.5,1,0.5,0.125,0.125,0,0,0],\n [90,3,4,1.5,0.5,0.5,0.5,0.5,0,0],\n [95,3,1.5,1,0.5,0.5,0.5,0.5,0,0],\n [100,3,1.5,0.5,0.5,0.5,0.5,1,0,0],\n [105,3,1,0,0.5,1,1,1,0,0],\n [110,1.5,1.5,0.75,1.5,1.125,0.75,0.375,1.5,1.5],\n [115,1.5,1.5,0.75,1.5,1.125,0.75,0.375,1.5,1.5],\n [120,1,1,0.5,1,0.75,0.5,0.25,1,1],\n [125,0,0,0,0,0,0,0,0,0],\n ];\n\n // APCA CONTRAST FONT LOOKUP TABLES\n // Copyright © 2022 by Myndex Research and Andrew Somers. All Rights Reserved\n // Public Beta 0.1.7 (G) • MAY 28 2022\n // For the following arrays, the Y axis is contrastArrayLen\n // The two x axis are weightArrayLen and scoreArrayLen\n\n // MAY 28 2022\n\n const weightArray = [0,100,200,300,400,500,600,700,800,900];\n const weightArrayLen = weightArray.length; // X axis\n\n let returnArray = [contrast.toFixed(places),0,0,0,0,0,0,0,0,0,];\n const returnArrayLen = returnArray.length; // X axis\n\n\n const contrastArrayAscend = ['lc',0,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,];\n const contrastArrayLenAsc = contrastArrayAscend.length; // Y azis\n\n//// Lc 45 * 0.2 = 9, and 9 is the index for the row for Lc 45\n\n let tempFont = 777;\n contrast = Math.abs(contrast); // Polarity unneeded for LUT\n const factor = 0.2; // 1/5 as LUT is in increments of 5\n const index = (contrast == 0) ?\n 1 : (contrast * factor) | 0 ; // LUT row... n|0 is bw floor\n let w = 0; \n // scoreAdj interpolates the needed font side per the Lc\n let scoreAdj = (contrast - fontMatrixAscend[index][w]) * factor;\n\n w++; // determines column in font matrix LUT\n\n\n///////// Font and Score Interpolation \\/////////////////////////////////\n\n// populate returnArray with interpolated values\n\n for (; w < weightArrayLen; w++) {\n\n tempFont = fontMatrixAscend[index][w]; \n\n if (tempFont > 400) { // declares a specific minimum for the weight.\n returnArray[w] = tempFont;\n } else if (contrast < 14.5 ) {\n returnArray[w] = 999; // 999 = do not use for anything\n } else if (contrast < 29.5 ) {\n returnArray[w] = 777; // 777 = non-text only\n } else {\n // INTERPOLATION OF FONT SIZE\n // sets level for 0.5px size increments of smaller fonts\n // Note bitwise (n|0) instead of floor\n (tempFont > 24) ?\n returnArray[w] =\n Math.round(tempFont - (fontDeltaAscend[index][w] * scoreAdj)) :\n returnArray[w] =\n tempFont - ((2.0 * fontDeltaAscend[index][w] * scoreAdj) | 0) * 0.5;\n // (n|0) is bitwise floor\n }\n }\n///////// End Interpolation ////////////////////////////////////////////\n\n return returnArray\n} // end fontLookupAPCA\n\n/////////\\ ///////////////////////////\\\n//////////\\ END fontLookupAPCA() 0.1.7 (G) /////////////////////////////\\\n/////////////////////////////////////////////////////////////////////////////\\\n\n\n\n\n//////////////////////////////////////////////////////////////////////////////\n////////// LUMINANCE CONVERTERS |//////////////////////////////////////////\n\n\n////////// ƒ sRGBtoY() //////////////////////////////////////////////////\nexport function sRGBtoY (rgb = [0,0,0]) { // send sRGB 8bpc (0xFFFFFF) or string\n\n// NOTE: Currently expects 0-255\n\n///// APCA 0.0.98G - 4g - W3 Compatible Constants ////////////////////\n/*\nconst mainTRC = 2.4; // 2.4 exponent emulates actual monitor perception\n \nconst sRco = 0.2126729, \n sGco = 0.7151522, \n sBco = 0.0721750; // sRGB coefficients\n */\n// Future:\n// 0.2126478133913640\t0.7151791475336150\t0.0721730390750208\n// Derived from:\n// xW\tyW\tK\txR\tyR\txG\tyG\txB\tyB\n// 0.312720\t0.329030\t6504\t0.640\t0.330\t0.300\t0.600\t0.150\t0.060\n\n // linearize r, g, or b then apply coefficients\n // and sum then return the resulting luminance\n\n function simpleExp (chan) { return Math.pow(chan/255.0, SA98G.mainTRC); };\n\n return SA98G.sRco * simpleExp(rgb[0]) +\n SA98G.sGco * simpleExp(rgb[1]) +\n SA98G.sBco * simpleExp(rgb[2]);\n \n} // End sRGBtoY()\n\n\n\n\n////////// ƒ displayP3toY() /////////////////////////////////////////////\nexport function displayP3toY (rgb = [0,0,0]) { // send rgba array\n\n// NOTE: Currently Apple has the tuple as 0.0 to 1.0, NOT 255\n\n///// APCA 0.0.98G - 4g - W3 Compatible Constants ////////////////////\n\nconst mainTRC = 2.4; // 2.4 exponent emulates actual monitor perception\n // Pending evaluation, because, Apple...\n \nconst sRco = 0.2289829594805780, \n sGco = 0.6917492625852380, \n sBco = 0.0792677779341829; // displayP3 coefficients\n\n// Derived from:\n// xW\tyW\tK\txR\tyR\txG\tyG\txB\tyB\n// 0.312720\t0.329030\t6504\t0.680\t0.320\t0.265\t0.690\t0.150\t0.060\n\n // linearize r, g, or b then apply coefficients\n // and sum then return the resulting luminance\n\n function simpleExp (chan) { return Math.pow(chan, mainTRC); };\n\n return sRco * simpleExp(rgb[0]) +\n sGco * simpleExp(rgb[1]) +\n sBco * simpleExp(rgb[2]);\n\n} // End displayP3toY()\n\n\n\n\n////////// ƒ adobeRGBtoY() /////////////////////////////////////////////\nexport function adobeRGBtoY (rgb = [0,0,0]) { // send rgba array\n\n// NOTE: Currently expects 0-255\n\n///// APCA 0.0.98G - 4g - W3 Compatible Constants ////////////////////\n\nconst mainTRC = 2.35; // 2.35 exponent emulates actual monitor perception\n // Pending evaluation...\n \nconst sRco = 0.2973550227113810, \n sGco = 0.6273727497145280, \n sBco = 0.0752722275740913; // adobeRGB coefficients\n\n// Derived from:\n// xW\tyW\tK\txR\tyR\txG\tyG\txB\tyB\n// 0.312720\t0.329030\t6504\t0.640\t0.330\t0.210\t0.710\t0.150\t0.060\n\n // linearize r, g, or b then apply coefficients\n // and sum then return the resulting luminance\n\n function simpleExp (chan) { return Math.pow(chan/255.0, mainTRC); };\n\n return sRco * simpleExp(rgb[0]) +\n sGco * simpleExp(rgb[1]) +\n sBco * simpleExp(rgb[2]);\n\n} // End displayP3toY()\n\n\n\n\n////////////////////////////////////////////////////////////////////////////\n////////// UTILITIES \\///////////////////////////////////////////////////\n\n\n////////// ƒ alphaBlend() /////////////////////////////////////////////\n\n // send rgba array for text/icon, rgb for background.\n // Only foreground allows alpha of 0.0 to 1.0 \n // This blends using gamma encoded space (standard)\n // rounded 0-255 or set round=false for number 0.0-255.0\nexport function alphaBlend (rgbaFG=[0,0,0,1.0], rgbBG=[0,0,0], round = true ) {\n\t\n\trgbaFG[3] = Math.max(Math.min(rgbaFG[3], 1.0), 0.0); // clamp alpha 0-1\n\tlet compBlend = 1.0 - rgbaFG[3];\n\tlet rgbOut = [0,0,0,1,true]; // or just use rgbBG to retain other elements?\n\t\n\tfor (let i=0;i<3;i++) {\n\t\trgbOut[i] = rgbBG[i] * compBlend + rgbaFG[i] * rgbaFG[3];\n\t\tif (round) rgbOut[i] = Math.min(Math.round(rgbOut[i]),255);\n\t};\n return rgbOut;\n} // End alphaBlend()\n\n\n\n\n//\\ ////////////////////////////////////////\n///\\ ////////////////////////////////////////\n////\\ ////////////////////////////////////////\n/////\\ END APCA 0.1.9 G-4g BLOCK ////////////////////////////////////////\n////////////////////////////////////////////////////////////////////////////\n///////////////////////////////////////////////////////////////////////////\n","import type { CssColor } from '@adobe/leonardo-contrast-colors';\nimport { BackgroundColor, Color, Theme } from '@adobe/leonardo-contrast-colors';\nimport { Hsluv } from 'hsluv';\n\nimport type { ContrastMode, Mode, ColorInfo, ColorNumber, ThemeInfo, ColorType } from './types';\nimport { getContrastFromHex, getContrastFromLightness, getLightnessFromHex } from './colorUtils';\n\nconst blueBaseColor = '#0A71C0';\nconst greenBaseColor = '#078D19';\nconst orangeBaseColor = '#CA5C21';\nconst purpleBaseColor = '#663299';\nconst redBaseColor = '#C01B1B';\nconst yellowBaseColor = '#EABF28';\n\nexport type ColorError = 'none' | 'decorative' | 'interaction';\n\ntype GlobalGenType = {\n themeMode?: Mode | 'all';\n contrastMode?: ContrastMode;\n};\n\ntype ThemeGenType = {\n colors: {\n accent: CssColor;\n neutral: CssColor;\n brand1: CssColor;\n brand2: CssColor;\n brand3: CssColor;\n };\n contrastMode?: ContrastMode;\n};\n\n/**\n * Generates a Leonardo theme color that is used to create a Leonardo Theme\n *\n * @param color CssColor\n * @param mode Light, Dark or Contrastmode\n * @param contrastMode Contrast mode\n * @returns\n */\nconst generateThemeColor = (color: CssColor, mode: Mode, contrastMode: 'aa' | 'aaa' = 'aa') => {\n const leoBackgroundColor = new BackgroundColor({\n name: 'backgroundColor',\n colorKeys: ['#ffffff'],\n ratios: [1],\n });\n let colorLightness = getLightnessFromHex(color);\n if (mode === 'dark' || mode === 'contrast') {\n color = getBaseColor(color);\n colorLightness = colorLightness <= 30 ? 70 : 100 - colorLightness;\n }\n\n const multiplier = colorLightness <= 30 ? -8 : 8;\n const baseDefaultContrast = getContrastFromLightness(colorLightness, color, leoBackgroundColor.colorKeys[0]);\n const baseHoverContrast = getContrastFromLightness(\n colorLightness - multiplier,\n color,\n leoBackgroundColor.colorKeys[0],\n );\n const baseActiveContrast = getContrastFromLightness(\n colorLightness - multiplier * 2,\n color,\n leoBackgroundColor.colorKeys[0],\n );\n\n const textSubLightLightness = contrastMode === 'aa' ? 42 : 30;\n const textDefLightLightness = contrastMode === 'aa' ? 18 : 12;\n\n const textSubDarkLightness = contrastMode === 'aa' ? 67 : 80;\n const textDefDarkLightness = contrastMode === 'aa' ? 90 : 94;\n\n let lightnessScale: number[] = [];\n\n if (mode === 'light') {\n lightnessScale = [100, 96, 90, 84, 78, 76, 54, 33, textSubLightLightness, textDefLightLightness];\n } else if (mode === 'dark') {\n lightnessScale = [10, 14, 20, 26, 32, 35, 47, 77, textSubDarkLightness, textDefDarkLightness];\n } else {\n lightnessScale = [1, 6, 14, 20, 26, 58, 70, 82, 80, 95];\n }\n\n const getColorContrasts = (color: CssColor, lightnessScale: number[], backgroundColor: CssColor) => {\n return lightnessScale.map((lightness) => getContrastFromLightness(lightness, color, backgroundColor));\n };\n\n return new Color({\n name: 'color',\n colorKeys: [color],\n ratios: [\n ...getColorContrasts(color, lightnessScale.slice(0, 8), leoBackgroundColor.colorKeys[0]),\n baseDefaultContrast,\n baseHoverContrast,\n baseActiveContrast,\n ...getColorContrasts(color, lightnessScale.slice(8), leoBackgroundColor.colorKeys[0]),\n ],\n });\n};\n\n/**\n *\n * Generates a color scale based on a base color and a mode.\n *\n * @param color The base color that is used to generate the color scale\n * @param mode The mode of the theme\n */\nexport const generateScaleForColor = (color: CssColor, mode: Mode, contrastMode: 'aa' | 'aaa' = 'aa'): ColorInfo[] => {\n const themeColor = generateThemeColor(color, mode, contrastMode);\n\n const leoBackgroundColor = new BackgroundColor({\n name: 'backgroundColor',\n colorKeys: ['#ffffff'],\n ratios: [1],\n });\n\n const theme = new Theme({\n colors: [themeColor],\n backgroundColor: leoBackgroundColor,\n lightness: 100,\n });\n\n const outputArray: ColorInfo[] = [];\n for (let i = 0; i < theme.contrastColorValues.length; i++) {\n outputArray.push({\n hex: theme.contrastColorValues[i],\n number: (i + 1) as ColorNumber,\n name: getColorNameFromNumber((i + 1) as ColorNumber),\n });\n }\n outputArray.push({\n hex: calculateContrastOneColor(theme.contrastColorValues[8]),\n number: 14,\n name: getColorNameFromNumber(14),\n });\n outputArray.push({\n hex: calculateContrastTwoColor(theme.contrastColorValues[8]),\n number: 15,\n name: getColorNameFromNumber(15),\n });\n\n if (mode === 'light') {\n outputArray[8].hex = color;\n }\n\n return outputArray;\n};\n\n/**\n *\n * Generates a color theme based on a base color. Light, Dark and Contrast scales are includes.\n *\n * @param color The base color that is used to generate the color theme\n */\nexport const generateThemeForColor = (color: CssColor, contrastMode: 'aa' | 'aaa' = 'aa') => {\n const lightScale = generateScaleForColor(color, 'light', contrastMode);\n const darkScale = generateScaleForColor(color, 'dark', contrastMode);\n const contrastScale = generateScaleForColor(color, 'contrast', contrastMode);\n\n return {\n light: lightScale,\n dark: darkScale,\n contrast: contrastScale,\n } as ThemeInfo;\n};\n\nexport const generateGlobalColors = ({ contrastMode = 'aa' }: GlobalGenType) => {\n const blueTheme = generateThemeForColor(blueBaseColor, contrastMode);\n const greenTheme = generateThemeForColor(greenBaseColor, contrastMode);\n const orangeTheme = generateThemeForColor(orangeBaseColor, contrastMode);\n const purpleTheme = generateThemeForColor(purpleBaseColor, contrastMode);\n const redTheme = generateThemeForColor(redBaseColor, contrastMode);\n const yellowTheme = generateThemeForColor(yellowBaseColor, contrastMode);\n\n return {\n blue: blueTheme,\n green: greenTheme,\n orange: orangeTheme,\n purple: purpleTheme,\n red: redTheme,\n yellow: yellowTheme,\n };\n};\n\n/**\n * This function generates a complete theme for a set of colors.\n *\n * @param colors Which colors to generate the theme for\n * @param contrastMode The contrast mode to use\n * @returns\n */\nexport const generateColorTheme = ({ colors, contrastMode = 'aa' }: ThemeGenType) => {\n const accentTheme = generateThemeForColor(colors.accent, contrastMode);\n const neutralTheme = generateThemeForColor(colors.neutral, contrastMode);\n const brand1Theme = generateThemeForColor(colors.brand1, contrastMode);\n const brand2Theme = generateThemeForColor(colors.brand2, contrastMode);\n const brand3Theme = generateThemeForColor(colors.brand3, contrastMode);\n\n return {\n accent: accentTheme,\n neutral: neutralTheme,\n brand1: brand1Theme,\n brand2: brand2Theme,\n brand3: brand3Theme,\n };\n};\n\n/**\n *\n * This function calculates a color that can be used as a strong contrast color to a base color.\n *\n * @param baseColor The base color\n */\nexport const calculateContrastOneColor = (baseColor: CssColor) => {\n const contrastWhite = getContrastFromHex(baseColor, '#ffffff');\n const contrastBlack = getContrastFromHex(baseColor, '#000000');\n const lightness = contrastWhite >= contrastBlack ? 100 : 0;\n // const color = createColorWithLightness(baseColor, lightness);\n\n return lightness === 0 ? '#000000' : '#ffffff';\n};\n\n/**\n *\n * This function calculates a color that can be used as a subtle contrast color to a base color.\n *\n * @param color The base color\n */\nexport const calculateContrastTwoColor = (color: CssColor) => {\n const contrastWhite = getContrastFromHex(color, '#ffffff');\n const contrastBlack = getContrastFromHex(color, '#000000');\n const lightness = getLightnessFromHex(color);\n const doubleALightnessModifier = lightness <= 40 ? 60 : lightness >= 60 ? 60 : 50;\n\n let targetLightness = 0;\n const contrastDirection = contrastWhite >= contrastBlack ? 'lighten' : 'darken';\n\n targetLightness =\n contrastDirection === 'lighten' ? lightness + doubleALightnessModifier : lightness - doubleALightnessModifier;\n\n return createColorWithLightness(color, targetLightness);\n};\n\n/**\n *\n * This function checks if white or black text can be used on 2 different colors at 4.5:1 contrast.\n *\n * @param baseDefaultColor Base default color\n * @param baseActiveColor Base active color\n */\nexport const canTextBeUsedOnColors = (baseDefaultColor: CssColor, baseActiveColor: CssColor) => {\n const defaultAgainstWhite = getContrastFromHex(baseDefaultColor, '#ffffff');\n const defaultAgainstBlack = getContrastFromHex(baseDefaultColor, '#000000');\n\n const activeAgainstWhite = getContrastFromHex(baseActiveColor, '#ffffff');\n const activeAgainstBlack = getContrastFromHex(baseActiveColor, '#000000');\n\n if (defaultAgainstWhite >= 4.5 && activeAgainstWhite >= 4.5) {\n return true;\n } else if (defaultAgainstBlack >= 4.5 && activeAgainstBlack >= 4.5) {\n return true;\n }\n\n return false;\n};\n\n/**\n *\n * This function creates a color with a specific lightness value.\n *\n * @param color The base color\n * @param lightness The lightness value from 0 to 100\n */\nexport const createColorWithLightness = (color: CssColor, lightness: number) => {\n const leoBackgroundColor = new BackgroundColor({\n name: 'backgroundColor',\n colorKeys: ['#ffffff'],\n ratios: [1],\n });\n const colors = new Color({\n name: 'color',\n colorKeys: [color],\n ratios: [getContrastFromLightness(lightness, color, '#ffffff')],\n });\n\n const theme = new Theme({\n colors: [colors],\n backgroundColor: leoBackgroundColor,\n lightness: 100,\n });\n return theme.contrastColorValues[0];\n};\n\n/**\n *\n * This function returns the color number based on the color name.\n *\n * @param name The name of the color\n */\nexport const getColorNumberFromName = (name: string): ColorNumber => {\n const colorMap: { [key: string]: ColorNumber } = {\n 'Background Default': 1,\n 'Background Subtle': 2,\n 'Surface Default': 3,\n 'Surface Hover': 4,\n 'Surface Active': 5,\n 'Border Subtle': 6,\n 'Border Default': 7,\n 'Border Strong': 8,\n 'Base Default': 9,\n 'Base Hover': 10,\n 'Base Active': 11,\n 'Text Subtle': 12,\n 'Text Default': 13,\n 'Contrast Default': 14,\n 'Contrast Subtle': 15,\n };\n return colorMap[name];\n};\n\n/**\n *\n * This function returns the color name based on the color number.\n *\n * @param number The number of the color\n */\nexport const getColorNameFromNumber = (number: ColorNumber): string => {\n const colorMap: { [key in ColorNumber]: string } = {\n 1: 'Background Default',\n 2: 'Background Subtle',\n 3: 'Surface Default',\n 4: 'Surface Hover',\n 5: 'Surface Active',\n 6: 'Border Subtle',\n 7: 'Border Default',\n 8: 'Border Strong',\n 9: 'Base Default',\n 10: 'Base Hover',\n 11: 'Base Active',\n 12: 'Text Subtle',\n 13: 'Text Default',\n 14: 'Contrast Default',\n 15: 'Contrast Subtle',\n };\n return colorMap[number];\n};\n\nexport const getBaseColor = (color: CssColor) => {\n const conv = new Hsluv();\n conv.hex = color;\n conv.hexToHsluv();\n // conv.hsluv_l = 100 - conv.hsluv_l;\n // conv.hsluv_s = getSaturationForDarkMode(color, conv.hsluv_s);\n conv.hsluvToHex();\n\n return conv.hex as CssColor;\n};\n\nexport const getCssVariable = (colorType: ColorType, colorNumber: ColorNumber) => {\n return `--ds-${colorType}-${getColorNameFromNumber(colorNumber).toLowerCase().replace(/\\s/g, '-')}`;\n};\n"],"mappings":";AACA,SAAS,aAAa;AACtB,OAAO,YAAY;;;AC+If,IAAM,QAAQ;AAAA,EAEV,SAAS;AAAA;AAAA;AAAA,EAGT,IAAI,gBAAgB;AAAE,WAAO,IAAI,KAAK;AAAA,EAAQ;AAAA;AAAA,EAG9C,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA;AAAA,EAGN,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,OAAO;AAAA;AAAA,EAGP,SAAS;AAAA,EACT,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA,EACV,aAAa;AAAA,EACb,aAAa;AAAA,EACb,WAAW;AAAA,EACX,QAAQ;AAAA;AAAA;AAAA,EAIR,SAAS;AAAA,EACT,IAAI,WAAW;AAAE,WAAO,IAAI,KAAK;AAAA,EAAO;AAAA,EACxC,WAAW;AAAA,EACX,SAAS;AAAA,EACT,IAAI,OAAO;AAAE,WAAO,KAAK,UAAU,KAAK;AAAA,EAA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cAAc;AAAA,IACd,eAAe;AAAA,IACf,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,oBAAoB;AAAA,IACpB,mBAAmB;AAAA,EACrB;AACA,SAAO,SAAS,IAAI;AACtB;AAQO,IAAM,yBAAyB,CAAC,WAAgC;AACrE,QAAM,WAA6C;AAAA,IACjD,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,IACH,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,EACN;AACA,SAAO,SAAS,MAAM;AACxB;AAEO,IAAM,eAAe,CAAC,UAAoB;AAC/C,QAAM,OAAO,IAAIE,OAAM;AACvB,OAAK,MAAM;AACX,OAAK,WAAW;AAGhB,OAAK,WAAW;AAEhB,SAAO,KAAK;AACd;AAEO,IAAM,iBAAiB,CAAC,WAAsB,gBAA6B;AAChF,SAAO,QAAQ,SAAS,IAAI,uBAAuB,WAAW,EAAE,YAAY,EAAE,QAAQ,OAAO,GAAG,CAAC;AACnG;","names":["Hsluv","color","lightnessScale","Hsluv"]}
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
// src/colors/themeUtils.ts
|
|
2
|
+
import { BackgroundColor, Color, Theme } from "@adobe/leonardo-contrast-colors";
|
|
3
|
+
import { Hsluv as Hsluv2 } from "hsluv";
|
|
4
|
+
|
|
5
|
+
// src/colors/colorUtils.ts
|
|
6
|
+
import { Hsluv } from "hsluv";
|
|
7
|
+
import chroma from "chroma-js";
|
|
8
|
+
var hexToRgb = (hex) => {
|
|
9
|
+
const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
|
10
|
+
hex = hex.replace(shorthandRegex, function(m, r, g, b) {
|
|
11
|
+
return r + r + g + g + b + b;
|
|
12
|
+
});
|
|
13
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
14
|
+
return result ? {
|
|
15
|
+
r: parseInt(result[1], 16),
|
|
16
|
+
g: parseInt(result[2], 16),
|
|
17
|
+
b: parseInt(result[3], 16)
|
|
18
|
+
} : null;
|
|
19
|
+
};
|
|
20
|
+
var luminanceFromRgb = (r, g, b) => {
|
|
21
|
+
const a = [Number(r), Number(g), Number(b)].map(function(v) {
|
|
22
|
+
v /= 255;
|
|
23
|
+
return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
|
|
24
|
+
});
|
|
25
|
+
return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;
|
|
26
|
+
};
|
|
27
|
+
var luminanceFromHex = (hex) => {
|
|
28
|
+
const rgb = hexToRgb(hex);
|
|
29
|
+
if (rgb) {
|
|
30
|
+
const r = rgb.r.toString();
|
|
31
|
+
const g = rgb.g.toString();
|
|
32
|
+
const b = rgb.b.toString();
|
|
33
|
+
return luminanceFromRgb(r, g, b);
|
|
34
|
+
}
|
|
35
|
+
return 2;
|
|
36
|
+
};
|
|
37
|
+
var getRatioFromLum = (lum1, lum2) => {
|
|
38
|
+
if (lum1 !== null && lum2 !== null) {
|
|
39
|
+
return (Math.max(lum1, lum2) + 0.05) / (Math.min(lum1, lum2) + 0.05);
|
|
40
|
+
} else {
|
|
41
|
+
return -1;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var getLightnessFromHex = (hex) => {
|
|
45
|
+
const conv = new Hsluv();
|
|
46
|
+
conv.hex = hex;
|
|
47
|
+
conv.hexToHsluv();
|
|
48
|
+
return Number(conv.hsluv_l.toFixed(0));
|
|
49
|
+
};
|
|
50
|
+
var getContrastFromHex = (color1, color2) => {
|
|
51
|
+
const lum1 = luminanceFromHex(color1);
|
|
52
|
+
const lum2 = luminanceFromHex(color2);
|
|
53
|
+
if (lum1 !== null && lum2 !== null) {
|
|
54
|
+
return getRatioFromLum(lum1, lum2);
|
|
55
|
+
}
|
|
56
|
+
return -1;
|
|
57
|
+
};
|
|
58
|
+
var getContrastFromLightness = (lightness, mainColor, backgroundColor) => {
|
|
59
|
+
const conv = new Hsluv();
|
|
60
|
+
conv.hex = mainColor;
|
|
61
|
+
conv.hexToHsluv();
|
|
62
|
+
conv.hsluv_l = lightness;
|
|
63
|
+
conv.hsluvToHex();
|
|
64
|
+
const lightMainColor = conv.hex;
|
|
65
|
+
const lum1 = luminanceFromHex(lightMainColor);
|
|
66
|
+
const lum2 = luminanceFromHex(backgroundColor);
|
|
67
|
+
const ratio = getRatioFromLum(lum1 ?? 0, lum2 ?? 0);
|
|
68
|
+
return ratio;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// src/colors/themeUtils.ts
|
|
72
|
+
var blueBaseColor = "#0A71C0";
|
|
73
|
+
var greenBaseColor = "#078D19";
|
|
74
|
+
var orangeBaseColor = "#CA5C21";
|
|
75
|
+
var purpleBaseColor = "#663299";
|
|
76
|
+
var redBaseColor = "#C01B1B";
|
|
77
|
+
var yellowBaseColor = "#EABF28";
|
|
78
|
+
var generateThemeColor = (color, mode, contrastMode = "aa") => {
|
|
79
|
+
const leoBackgroundColor = new BackgroundColor({
|
|
80
|
+
name: "backgroundColor",
|
|
81
|
+
colorKeys: ["#ffffff"],
|
|
82
|
+
ratios: [1]
|
|
83
|
+
});
|
|
84
|
+
let colorLightness = getLightnessFromHex(color);
|
|
85
|
+
if (mode === "dark" || mode === "contrast") {
|
|
86
|
+
color = getBaseColor(color);
|
|
87
|
+
colorLightness = colorLightness <= 30 ? 70 : 100 - colorLightness;
|
|
88
|
+
}
|
|
89
|
+
const multiplier = colorLightness <= 30 ? -8 : 8;
|
|
90
|
+
const baseDefaultContrast = getContrastFromLightness(colorLightness, color, leoBackgroundColor.colorKeys[0]);
|
|
91
|
+
const baseHoverContrast = getContrastFromLightness(
|
|
92
|
+
colorLightness - multiplier,
|
|
93
|
+
color,
|
|
94
|
+
leoBackgroundColor.colorKeys[0]
|
|
95
|
+
);
|
|
96
|
+
const baseActiveContrast = getContrastFromLightness(
|
|
97
|
+
colorLightness - multiplier * 2,
|
|
98
|
+
color,
|
|
99
|
+
leoBackgroundColor.colorKeys[0]
|
|
100
|
+
);
|
|
101
|
+
const textSubLightLightness = contrastMode === "aa" ? 42 : 30;
|
|
102
|
+
const textDefLightLightness = contrastMode === "aa" ? 18 : 12;
|
|
103
|
+
const textSubDarkLightness = contrastMode === "aa" ? 67 : 80;
|
|
104
|
+
const textDefDarkLightness = contrastMode === "aa" ? 90 : 94;
|
|
105
|
+
let lightnessScale = [];
|
|
106
|
+
if (mode === "light") {
|
|
107
|
+
lightnessScale = [100, 96, 90, 84, 78, 76, 54, 33, textSubLightLightness, textDefLightLightness];
|
|
108
|
+
} else if (mode === "dark") {
|
|
109
|
+
lightnessScale = [10, 14, 20, 26, 32, 35, 47, 77, textSubDarkLightness, textDefDarkLightness];
|
|
110
|
+
} else {
|
|
111
|
+
lightnessScale = [1, 6, 14, 20, 26, 58, 70, 82, 80, 95];
|
|
112
|
+
}
|
|
113
|
+
const getColorContrasts = (color2, lightnessScale2, backgroundColor) => {
|
|
114
|
+
return lightnessScale2.map((lightness) => getContrastFromLightness(lightness, color2, backgroundColor));
|
|
115
|
+
};
|
|
116
|
+
return new Color({
|
|
117
|
+
name: "color",
|
|
118
|
+
colorKeys: [color],
|
|
119
|
+
ratios: [
|
|
120
|
+
...getColorContrasts(color, lightnessScale.slice(0, 8), leoBackgroundColor.colorKeys[0]),
|
|
121
|
+
baseDefaultContrast,
|
|
122
|
+
baseHoverContrast,
|
|
123
|
+
baseActiveContrast,
|
|
124
|
+
...getColorContrasts(color, lightnessScale.slice(8), leoBackgroundColor.colorKeys[0])
|
|
125
|
+
]
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
var generateScaleForColor = (color, mode, contrastMode = "aa") => {
|
|
129
|
+
const themeColor = generateThemeColor(color, mode, contrastMode);
|
|
130
|
+
const leoBackgroundColor = new BackgroundColor({
|
|
131
|
+
name: "backgroundColor",
|
|
132
|
+
colorKeys: ["#ffffff"],
|
|
133
|
+
ratios: [1]
|
|
134
|
+
});
|
|
135
|
+
const theme = new Theme({
|
|
136
|
+
colors: [themeColor],
|
|
137
|
+
backgroundColor: leoBackgroundColor,
|
|
138
|
+
lightness: 100
|
|
139
|
+
});
|
|
140
|
+
const outputArray = [];
|
|
141
|
+
for (let i = 0; i < theme.contrastColorValues.length; i++) {
|
|
142
|
+
outputArray.push({
|
|
143
|
+
hex: theme.contrastColorValues[i],
|
|
144
|
+
number: i + 1,
|
|
145
|
+
name: getColorNameFromNumber(i + 1)
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
outputArray.push({
|
|
149
|
+
hex: calculateContrastOneColor(theme.contrastColorValues[8]),
|
|
150
|
+
number: 14,
|
|
151
|
+
name: getColorNameFromNumber(14)
|
|
152
|
+
});
|
|
153
|
+
outputArray.push({
|
|
154
|
+
hex: calculateContrastTwoColor(theme.contrastColorValues[8]),
|
|
155
|
+
number: 15,
|
|
156
|
+
name: getColorNameFromNumber(15)
|
|
157
|
+
});
|
|
158
|
+
if (mode === "light") {
|
|
159
|
+
outputArray[8].hex = color;
|
|
160
|
+
}
|
|
161
|
+
return outputArray;
|
|
162
|
+
};
|
|
163
|
+
var generateThemeForColor = (color, contrastMode = "aa") => {
|
|
164
|
+
const lightScale = generateScaleForColor(color, "light", contrastMode);
|
|
165
|
+
const darkScale = generateScaleForColor(color, "dark", contrastMode);
|
|
166
|
+
const contrastScale = generateScaleForColor(color, "contrast", contrastMode);
|
|
167
|
+
return {
|
|
168
|
+
light: lightScale,
|
|
169
|
+
dark: darkScale,
|
|
170
|
+
contrast: contrastScale
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
var generateGlobalColors = ({ contrastMode = "aa" }) => {
|
|
174
|
+
const blueTheme = generateThemeForColor(blueBaseColor, contrastMode);
|
|
175
|
+
const greenTheme = generateThemeForColor(greenBaseColor, contrastMode);
|
|
176
|
+
const orangeTheme = generateThemeForColor(orangeBaseColor, contrastMode);
|
|
177
|
+
const purpleTheme = generateThemeForColor(purpleBaseColor, contrastMode);
|
|
178
|
+
const redTheme = generateThemeForColor(redBaseColor, contrastMode);
|
|
179
|
+
const yellowTheme = generateThemeForColor(yellowBaseColor, contrastMode);
|
|
180
|
+
return {
|
|
181
|
+
blue: blueTheme,
|
|
182
|
+
green: greenTheme,
|
|
183
|
+
orange: orangeTheme,
|
|
184
|
+
purple: purpleTheme,
|
|
185
|
+
red: redTheme,
|
|
186
|
+
yellow: yellowTheme
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
var generateColorTheme = ({ colors, contrastMode = "aa" }) => {
|
|
190
|
+
const accentTheme = generateThemeForColor(colors.accent, contrastMode);
|
|
191
|
+
const neutralTheme = generateThemeForColor(colors.neutral, contrastMode);
|
|
192
|
+
const brand1Theme = generateThemeForColor(colors.brand1, contrastMode);
|
|
193
|
+
const brand2Theme = generateThemeForColor(colors.brand2, contrastMode);
|
|
194
|
+
const brand3Theme = generateThemeForColor(colors.brand3, contrastMode);
|
|
195
|
+
return {
|
|
196
|
+
accent: accentTheme,
|
|
197
|
+
neutral: neutralTheme,
|
|
198
|
+
brand1: brand1Theme,
|
|
199
|
+
brand2: brand2Theme,
|
|
200
|
+
brand3: brand3Theme
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
var calculateContrastOneColor = (baseColor) => {
|
|
204
|
+
const contrastWhite = getContrastFromHex(baseColor, "#ffffff");
|
|
205
|
+
const contrastBlack = getContrastFromHex(baseColor, "#000000");
|
|
206
|
+
const lightness = contrastWhite >= contrastBlack ? 100 : 0;
|
|
207
|
+
return lightness === 0 ? "#000000" : "#ffffff";
|
|
208
|
+
};
|
|
209
|
+
var calculateContrastTwoColor = (color) => {
|
|
210
|
+
const contrastWhite = getContrastFromHex(color, "#ffffff");
|
|
211
|
+
const contrastBlack = getContrastFromHex(color, "#000000");
|
|
212
|
+
const lightness = getLightnessFromHex(color);
|
|
213
|
+
const doubleALightnessModifier = lightness <= 40 ? 60 : lightness >= 60 ? 60 : 50;
|
|
214
|
+
let targetLightness = 0;
|
|
215
|
+
const contrastDirection = contrastWhite >= contrastBlack ? "lighten" : "darken";
|
|
216
|
+
targetLightness = contrastDirection === "lighten" ? lightness + doubleALightnessModifier : lightness - doubleALightnessModifier;
|
|
217
|
+
return createColorWithLightness(color, targetLightness);
|
|
218
|
+
};
|
|
219
|
+
var canTextBeUsedOnColors = (baseDefaultColor, baseActiveColor) => {
|
|
220
|
+
const defaultAgainstWhite = getContrastFromHex(baseDefaultColor, "#ffffff");
|
|
221
|
+
const defaultAgainstBlack = getContrastFromHex(baseDefaultColor, "#000000");
|
|
222
|
+
const activeAgainstWhite = getContrastFromHex(baseActiveColor, "#ffffff");
|
|
223
|
+
const activeAgainstBlack = getContrastFromHex(baseActiveColor, "#000000");
|
|
224
|
+
if (defaultAgainstWhite >= 4.5 && activeAgainstWhite >= 4.5) {
|
|
225
|
+
return true;
|
|
226
|
+
} else if (defaultAgainstBlack >= 4.5 && activeAgainstBlack >= 4.5) {
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
return false;
|
|
230
|
+
};
|
|
231
|
+
var createColorWithLightness = (color, lightness) => {
|
|
232
|
+
const leoBackgroundColor = new BackgroundColor({
|
|
233
|
+
name: "backgroundColor",
|
|
234
|
+
colorKeys: ["#ffffff"],
|
|
235
|
+
ratios: [1]
|
|
236
|
+
});
|
|
237
|
+
const colors = new Color({
|
|
238
|
+
name: "color",
|
|
239
|
+
colorKeys: [color],
|
|
240
|
+
ratios: [getContrastFromLightness(lightness, color, "#ffffff")]
|
|
241
|
+
});
|
|
242
|
+
const theme = new Theme({
|
|
243
|
+
colors: [colors],
|
|
244
|
+
backgroundColor: leoBackgroundColor,
|
|
245
|
+
lightness: 100
|
|
246
|
+
});
|
|
247
|
+
return theme.contrastColorValues[0];
|
|
248
|
+
};
|
|
249
|
+
var getColorNumberFromName = (name) => {
|
|
250
|
+
const colorMap = {
|
|
251
|
+
"Background Default": 1,
|
|
252
|
+
"Background Subtle": 2,
|
|
253
|
+
"Surface Default": 3,
|
|
254
|
+
"Surface Hover": 4,
|
|
255
|
+
"Surface Active": 5,
|
|
256
|
+
"Border Subtle": 6,
|
|
257
|
+
"Border Default": 7,
|
|
258
|
+
"Border Strong": 8,
|
|
259
|
+
"Base Default": 9,
|
|
260
|
+
"Base Hover": 10,
|
|
261
|
+
"Base Active": 11,
|
|
262
|
+
"Text Subtle": 12,
|
|
263
|
+
"Text Default": 13,
|
|
264
|
+
"Contrast Default": 14,
|
|
265
|
+
"Contrast Subtle": 15
|
|
266
|
+
};
|
|
267
|
+
return colorMap[name];
|
|
268
|
+
};
|
|
269
|
+
var getColorNameFromNumber = (number) => {
|
|
270
|
+
const colorMap = {
|
|
271
|
+
1: "Background Default",
|
|
272
|
+
2: "Background Subtle",
|
|
273
|
+
3: "Surface Default",
|
|
274
|
+
4: "Surface Hover",
|
|
275
|
+
5: "Surface Active",
|
|
276
|
+
6: "Border Subtle",
|
|
277
|
+
7: "Border Default",
|
|
278
|
+
8: "Border Strong",
|
|
279
|
+
9: "Base Default",
|
|
280
|
+
10: "Base Hover",
|
|
281
|
+
11: "Base Active",
|
|
282
|
+
12: "Text Subtle",
|
|
283
|
+
13: "Text Default",
|
|
284
|
+
14: "Contrast Default",
|
|
285
|
+
15: "Contrast Subtle"
|
|
286
|
+
};
|
|
287
|
+
return colorMap[number];
|
|
288
|
+
};
|
|
289
|
+
var getBaseColor = (color) => {
|
|
290
|
+
const conv = new Hsluv2();
|
|
291
|
+
conv.hex = color;
|
|
292
|
+
conv.hexToHsluv();
|
|
293
|
+
conv.hsluvToHex();
|
|
294
|
+
return conv.hex;
|
|
295
|
+
};
|
|
296
|
+
var getCssVariable = (colorType, colorNumber) => {
|
|
297
|
+
return `--ds-${colorType}-${getColorNameFromNumber(colorNumber).toLowerCase().replace(/\s/g, "-")}`;
|
|
298
|
+
};
|
|
299
|
+
export {
|
|
300
|
+
calculateContrastOneColor,
|
|
301
|
+
calculateContrastTwoColor,
|
|
302
|
+
canTextBeUsedOnColors,
|
|
303
|
+
createColorWithLightness,
|
|
304
|
+
generateColorTheme,
|
|
305
|
+
generateGlobalColors,
|
|
306
|
+
generateScaleForColor,
|
|
307
|
+
generateThemeForColor,
|
|
308
|
+
getBaseColor,
|
|
309
|
+
getColorNameFromNumber,
|
|
310
|
+
getColorNumberFromName,
|
|
311
|
+
getCssVariable
|
|
312
|
+
};
|
|
313
|
+
/*! Bundled license information:
|
|
314
|
+
|
|
315
|
+
colorparsley/src/colorparsley.js:
|
|
316
|
+
(** @preserve
|
|
317
|
+
///// CoLoR PaRsLeY a simple set of color parsing thingies!
|
|
318
|
+
///// Beta 0.1.8 Revision date: June 04, 2022
|
|
319
|
+
/////
|
|
320
|
+
///// Functions to parse color values and return array
|
|
321
|
+
///// Copyright (c) 2019-2022 by Andrew Somers. All Rights Reserved.
|
|
322
|
+
///// LICENSE: AGPL 3
|
|
323
|
+
///// CONTACT: Please use the ISSUES or DISCUSSIONS tab at:
|
|
324
|
+
///// https://github.com/Myndex/colorparsley/
|
|
325
|
+
/////
|
|
326
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
327
|
+
/////
|
|
328
|
+
///// IMPORT:
|
|
329
|
+
///// import { colorParsley } from 'colorparsley';
|
|
330
|
+
/////
|
|
331
|
+
///// let rgbaArray = colorParsley('#abcdef');
|
|
332
|
+
/////
|
|
333
|
+
///// Output as array: [r,g,b,a,isValid,colorspace]
|
|
334
|
+
///// Example: [123,123,123,1.0,true,'sRGB']
|
|
335
|
+
// *)
|
|
336
|
+
|
|
337
|
+
apca-w3/src/apca-w3.js:
|
|
338
|
+
(** @preserve
|
|
339
|
+
///// SAPC APCA - Advanced Perceptual Contrast Algorithm
|
|
340
|
+
///// Beta 0.1.9 W3 • contrast function only
|
|
341
|
+
///// DIST: W3 • Revision date: July 3, 2022
|
|
342
|
+
///// Function to parse color values and determine Lc contrast
|
|
343
|
+
///// Copyright © 2019-2022 by Andrew Somers. All Rights Reserved.
|
|
344
|
+
///// LICENSE: W3 LICENSE
|
|
345
|
+
///// CONTACT: Please use the ISSUES or DISCUSSIONS tab at:
|
|
346
|
+
///// https://github.com/Myndex/SAPC-APCA/
|
|
347
|
+
/////
|
|
348
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
349
|
+
/////
|
|
350
|
+
///// MINIMAL IMPORTS:
|
|
351
|
+
///// import { APCAcontrast, sRGBtoY, displayP3toY,
|
|
352
|
+
///// calcAPCA, fontLookupAPCA } from 'apca-w3';
|
|
353
|
+
///// import { colorParsley } from 'colorparsley';
|
|
354
|
+
/////
|
|
355
|
+
///// FORWARD CONTRAST USAGE:
|
|
356
|
+
///// Lc = APCAcontrast( sRGBtoY( TEXTcolor ) , sRGBtoY( BACKGNDcolor ) );
|
|
357
|
+
///// Where the colors are sent as an rgba array [255,255,255,1]
|
|
358
|
+
/////
|
|
359
|
+
///// Retrieving an array of font sizes for the contrast:
|
|
360
|
+
///// fontArray = fontLookupAPCA(Lc);
|
|
361
|
+
/////
|
|
362
|
+
///// Live Demonstrator at https://www.myndex.com/APCA/
|
|
363
|
+
// *)
|
|
364
|
+
*/
|
|
365
|
+
//# sourceMappingURL=themeUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/colors/themeUtils.ts","../../../src/colors/colorUtils.ts"],"sourcesContent":["import type { CssColor } from '@adobe/leonardo-contrast-colors';\nimport { BackgroundColor, Color, Theme } from '@adobe/leonardo-contrast-colors';\nimport { Hsluv } from 'hsluv';\n\nimport type { ContrastMode, Mode, ColorInfo, ColorNumber, ThemeInfo, ColorType } from './types';\nimport { getContrastFromHex, getContrastFromLightness, getLightnessFromHex } from './colorUtils';\n\nconst blueBaseColor = '#0A71C0';\nconst greenBaseColor = '#078D19';\nconst orangeBaseColor = '#CA5C21';\nconst purpleBaseColor = '#663299';\nconst redBaseColor = '#C01B1B';\nconst yellowBaseColor = '#EABF28';\n\nexport type ColorError = 'none' | 'decorative' | 'interaction';\n\ntype GlobalGenType = {\n themeMode?: Mode | 'all';\n contrastMode?: ContrastMode;\n};\n\ntype ThemeGenType = {\n colors: {\n accent: CssColor;\n neutral: CssColor;\n brand1: CssColor;\n brand2: CssColor;\n brand3: CssColor;\n };\n contrastMode?: ContrastMode;\n};\n\n/**\n * Generates a Leonardo theme color that is used to create a Leonardo Theme\n *\n * @param color CssColor\n * @param mode Light, Dark or Contrastmode\n * @param contrastMode Contrast mode\n * @returns\n */\nconst generateThemeColor = (color: CssColor, mode: Mode, contrastMode: 'aa' | 'aaa' = 'aa') => {\n const leoBackgroundColor = new BackgroundColor({\n name: 'backgroundColor',\n colorKeys: ['#ffffff'],\n ratios: [1],\n });\n let colorLightness = getLightnessFromHex(color);\n if (mode === 'dark' || mode === 'contrast') {\n color = getBaseColor(color);\n colorLightness = colorLightness <= 30 ? 70 : 100 - colorLightness;\n }\n\n const multiplier = colorLightness <= 30 ? -8 : 8;\n const baseDefaultContrast = getContrastFromLightness(colorLightness, color, leoBackgroundColor.colorKeys[0]);\n const baseHoverContrast = getContrastFromLightness(\n colorLightness - multiplier,\n color,\n leoBackgroundColor.colorKeys[0],\n );\n const baseActiveContrast = getContrastFromLightness(\n colorLightness - multiplier * 2,\n color,\n leoBackgroundColor.colorKeys[0],\n );\n\n const textSubLightLightness = contrastMode === 'aa' ? 42 : 30;\n const textDefLightLightness = contrastMode === 'aa' ? 18 : 12;\n\n const textSubDarkLightness = contrastMode === 'aa' ? 67 : 80;\n const textDefDarkLightness = contrastMode === 'aa' ? 90 : 94;\n\n let lightnessScale: number[] = [];\n\n if (mode === 'light') {\n lightnessScale = [100, 96, 90, 84, 78, 76, 54, 33, textSubLightLightness, textDefLightLightness];\n } else if (mode === 'dark') {\n lightnessScale = [10, 14, 20, 26, 32, 35, 47, 77, textSubDarkLightness, textDefDarkLightness];\n } else {\n lightnessScale = [1, 6, 14, 20, 26, 58, 70, 82, 80, 95];\n }\n\n const getColorContrasts = (color: CssColor, lightnessScale: number[], backgroundColor: CssColor) => {\n return lightnessScale.map((lightness) => getContrastFromLightness(lightness, color, backgroundColor));\n };\n\n return new Color({\n name: 'color',\n colorKeys: [color],\n ratios: [\n ...getColorContrasts(color, lightnessScale.slice(0, 8), leoBackgroundColor.colorKeys[0]),\n baseDefaultContrast,\n baseHoverContrast,\n baseActiveContrast,\n ...getColorContrasts(color, lightnessScale.slice(8), leoBackgroundColor.colorKeys[0]),\n ],\n });\n};\n\n/**\n *\n * Generates a color scale based on a base color and a mode.\n *\n * @param color The base color that is used to generate the color scale\n * @param mode The mode of the theme\n */\nexport const generateScaleForColor = (color: CssColor, mode: Mode, contrastMode: 'aa' | 'aaa' = 'aa'): ColorInfo[] => {\n const themeColor = generateThemeColor(color, mode, contrastMode);\n\n const leoBackgroundColor = new BackgroundColor({\n name: 'backgroundColor',\n colorKeys: ['#ffffff'],\n ratios: [1],\n });\n\n const theme = new Theme({\n colors: [themeColor],\n backgroundColor: leoBackgroundColor,\n lightness: 100,\n });\n\n const outputArray: ColorInfo[] = [];\n for (let i = 0; i < theme.contrastColorValues.length; i++) {\n outputArray.push({\n hex: theme.contrastColorValues[i],\n number: (i + 1) as ColorNumber,\n name: getColorNameFromNumber((i + 1) as ColorNumber),\n });\n }\n outputArray.push({\n hex: calculateContrastOneColor(theme.contrastColorValues[8]),\n number: 14,\n name: getColorNameFromNumber(14),\n });\n outputArray.push({\n hex: calculateContrastTwoColor(theme.contrastColorValues[8]),\n number: 15,\n name: getColorNameFromNumber(15),\n });\n\n if (mode === 'light') {\n outputArray[8].hex = color;\n }\n\n return outputArray;\n};\n\n/**\n *\n * Generates a color theme based on a base color. Light, Dark and Contrast scales are includes.\n *\n * @param color The base color that is used to generate the color theme\n */\nexport const generateThemeForColor = (color: CssColor, contrastMode: 'aa' | 'aaa' = 'aa') => {\n const lightScale = generateScaleForColor(color, 'light', contrastMode);\n const darkScale = generateScaleForColor(color, 'dark', contrastMode);\n const contrastScale = generateScaleForColor(color, 'contrast', contrastMode);\n\n return {\n light: lightScale,\n dark: darkScale,\n contrast: contrastScale,\n } as ThemeInfo;\n};\n\nexport const generateGlobalColors = ({ contrastMode = 'aa' }: GlobalGenType) => {\n const blueTheme = generateThemeForColor(blueBaseColor, contrastMode);\n const greenTheme = generateThemeForColor(greenBaseColor, contrastMode);\n const orangeTheme = generateThemeForColor(orangeBaseColor, contrastMode);\n const purpleTheme = generateThemeForColor(purpleBaseColor, contrastMode);\n const redTheme = generateThemeForColor(redBaseColor, contrastMode);\n const yellowTheme = generateThemeForColor(yellowBaseColor, contrastMode);\n\n return {\n blue: blueTheme,\n green: greenTheme,\n orange: orangeTheme,\n purple: purpleTheme,\n red: redTheme,\n yellow: yellowTheme,\n };\n};\n\n/**\n * This function generates a complete theme for a set of colors.\n *\n * @param colors Which colors to generate the theme for\n * @param contrastMode The contrast mode to use\n * @returns\n */\nexport const generateColorTheme = ({ colors, contrastMode = 'aa' }: ThemeGenType) => {\n const accentTheme = generateThemeForColor(colors.accent, contrastMode);\n const neutralTheme = generateThemeForColor(colors.neutral, contrastMode);\n const brand1Theme = generateThemeForColor(colors.brand1, contrastMode);\n const brand2Theme = generateThemeForColor(colors.brand2, contrastMode);\n const brand3Theme = generateThemeForColor(colors.brand3, contrastMode);\n\n return {\n accent: accentTheme,\n neutral: neutralTheme,\n brand1: brand1Theme,\n brand2: brand2Theme,\n brand3: brand3Theme,\n };\n};\n\n/**\n *\n * This function calculates a color that can be used as a strong contrast color to a base color.\n *\n * @param baseColor The base color\n */\nexport const calculateContrastOneColor = (baseColor: CssColor) => {\n const contrastWhite = getContrastFromHex(baseColor, '#ffffff');\n const contrastBlack = getContrastFromHex(baseColor, '#000000');\n const lightness = contrastWhite >= contrastBlack ? 100 : 0;\n // const color = createColorWithLightness(baseColor, lightness);\n\n return lightness === 0 ? '#000000' : '#ffffff';\n};\n\n/**\n *\n * This function calculates a color that can be used as a subtle contrast color to a base color.\n *\n * @param color The base color\n */\nexport const calculateContrastTwoColor = (color: CssColor) => {\n const contrastWhite = getContrastFromHex(color, '#ffffff');\n const contrastBlack = getContrastFromHex(color, '#000000');\n const lightness = getLightnessFromHex(color);\n const doubleALightnessModifier = lightness <= 40 ? 60 : lightness >= 60 ? 60 : 50;\n\n let targetLightness = 0;\n const contrastDirection = contrastWhite >= contrastBlack ? 'lighten' : 'darken';\n\n targetLightness =\n contrastDirection === 'lighten' ? lightness + doubleALightnessModifier : lightness - doubleALightnessModifier;\n\n return createColorWithLightness(color, targetLightness);\n};\n\n/**\n *\n * This function checks if white or black text can be used on 2 different colors at 4.5:1 contrast.\n *\n * @param baseDefaultColor Base default color\n * @param baseActiveColor Base active color\n */\nexport const canTextBeUsedOnColors = (baseDefaultColor: CssColor, baseActiveColor: CssColor) => {\n const defaultAgainstWhite = getContrastFromHex(baseDefaultColor, '#ffffff');\n const defaultAgainstBlack = getContrastFromHex(baseDefaultColor, '#000000');\n\n const activeAgainstWhite = getContrastFromHex(baseActiveColor, '#ffffff');\n const activeAgainstBlack = getContrastFromHex(baseActiveColor, '#000000');\n\n if (defaultAgainstWhite >= 4.5 && activeAgainstWhite >= 4.5) {\n return true;\n } else if (defaultAgainstBlack >= 4.5 && activeAgainstBlack >= 4.5) {\n return true;\n }\n\n return false;\n};\n\n/**\n *\n * This function creates a color with a specific lightness value.\n *\n * @param color The base color\n * @param lightness The lightness value from 0 to 100\n */\nexport const createColorWithLightness = (color: CssColor, lightness: number) => {\n const leoBackgroundColor = new BackgroundColor({\n name: 'backgroundColor',\n colorKeys: ['#ffffff'],\n ratios: [1],\n });\n const colors = new Color({\n name: 'color',\n colorKeys: [color],\n ratios: [getContrastFromLightness(lightness, color, '#ffffff')],\n });\n\n const theme = new Theme({\n colors: [colors],\n backgroundColor: leoBackgroundColor,\n lightness: 100,\n });\n return theme.contrastColorValues[0];\n};\n\n/**\n *\n * This function returns the color number based on the color name.\n *\n * @param name The name of the color\n */\nexport const getColorNumberFromName = (name: string): ColorNumber => {\n const colorMap: { [key: string]: ColorNumber } = {\n 'Background Default': 1,\n 'Background Subtle': 2,\n 'Surface Default': 3,\n 'Surface Hover': 4,\n 'Surface Active': 5,\n 'Border Subtle': 6,\n 'Border Default': 7,\n 'Border Strong': 8,\n 'Base Default': 9,\n 'Base Hover': 10,\n 'Base Active': 11,\n 'Text Subtle': 12,\n 'Text Default': 13,\n 'Contrast Default': 14,\n 'Contrast Subtle': 15,\n };\n return colorMap[name];\n};\n\n/**\n *\n * This function returns the color name based on the color number.\n *\n * @param number The number of the color\n */\nexport const getColorNameFromNumber = (number: ColorNumber): string => {\n const colorMap: { [key in ColorNumber]: string } = {\n 1: 'Background Default',\n 2: 'Background Subtle',\n 3: 'Surface Default',\n 4: 'Surface Hover',\n 5: 'Surface Active',\n 6: 'Border Subtle',\n 7: 'Border Default',\n 8: 'Border Strong',\n 9: 'Base Default',\n 10: 'Base Hover',\n 11: 'Base Active',\n 12: 'Text Subtle',\n 13: 'Text Default',\n 14: 'Contrast Default',\n 15: 'Contrast Subtle',\n };\n return colorMap[number];\n};\n\nexport const getBaseColor = (color: CssColor) => {\n const conv = new Hsluv();\n conv.hex = color;\n conv.hexToHsluv();\n // conv.hsluv_l = 100 - conv.hsluv_l;\n // conv.hsluv_s = getSaturationForDarkMode(color, conv.hsluv_s);\n conv.hsluvToHex();\n\n return conv.hex as CssColor;\n};\n\nexport const getCssVariable = (colorType: ColorType, colorNumber: ColorNumber) => {\n return `--ds-${colorType}-${getColorNameFromNumber(colorNumber).toLowerCase().replace(/\\s/g, '-')}`;\n};\n","import type { CssColor } from '@adobe/leonardo-contrast-colors';\nimport { Hsluv } from 'hsluv';\nimport chroma from 'chroma-js';\nimport { APCAcontrast, sRGBtoY } from 'apca-w3';\n\n/**\n * Converts a HEX color '#xxxxxx' into a CSS HSL string 'hsl(x,x,x)'\n *\n * @param hex A hex color string\n * @param valuesOnly If true, only the values are returned\n * @returns A CSS HSL string\n */\nexport const hexToCssHsl = (hex: string, valuesOnly = false) => {\n const result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\n let r = 0;\n let g = 0;\n let b = 0;\n let cssString = '';\n if (result) {\n r = parseInt(result[1], 16);\n g = parseInt(result[2], 16);\n b = parseInt(result[3], 16);\n }\n (r /= 255), (g /= 255), (b /= 255);\n const max = Math.max(r, g, b),\n min = Math.min(r, g, b);\n let h,\n s,\n l = (max + min) / 2;\n if (max == min) {\n h = s = 0; // achromatic\n } else {\n const d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n switch (max) {\n case r:\n h = (g - b) / d + (g < b ? 6 : 0);\n break;\n case g:\n h = (b - r) / d + 2;\n break;\n case b:\n h = (r - g) / d + 4;\n break;\n }\n }\n\n h = Math.round(h ? h * 360 : 0);\n s = Math.round(s * 100);\n l = Math.round(l * 100);\n\n cssString = h + ',' + s + '%,' + l + '%';\n cssString = !valuesOnly ? 'hsl(' + cssString + ')' : cssString;\n\n return cssString;\n};\n\n/**\n * Converts a HEX string '#xxxxxx' into an array of HSL values '[h,s,l]'\n *\n * @param H A Hex color string\n * @returns HSL values in an array\n */\nexport const hexToHSL = (H: string) => {\n // Convert hex to RGB first\n let r = 0,\n g = 0,\n b = 0;\n if (H.length == 4) {\n r = parseInt('0x' + H[1] + H[1]);\n g = parseInt('0x' + H[2] + H[2]);\n b = parseInt('0x' + H[3] + H[3]);\n } else if (H.length == 7) {\n r = parseInt('0x' + H[1] + H[2]);\n g = parseInt('0x' + H[3] + H[4]);\n b = parseInt('0x' + H[5] + H[6]);\n }\n // Then to HSL\n r /= 255;\n g /= 255;\n b /= 255;\n let h = 0,\n s = 0,\n l = 0;\n const cmin = Math.min(r, g, b),\n cmax = Math.max(r, g, b),\n delta = cmax - cmin;\n\n if (delta == 0) h = 0;\n else if (cmax == r) h = ((g - b) / delta) % 6;\n else if (cmax == g) h = (b - r) / delta + 2;\n else h = (r - g) / delta + 4;\n\n h = Math.round(h * 60);\n\n if (h < 0) h += 360;\n\n l = (cmax + cmin) / 2;\n s = delta == 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));\n s = +(s * 100).toFixed(1);\n l = +(l * 100).toFixed(1);\n\n return [h, s, l];\n};\n\n/**\n * Converts a HEX color '#xxxxxx' into an array of HSLuv values '[h,s,l]'\n *\n * @param hex A hex color string\n * @returns\n */\nexport const hexToHsluv = (hex: string) => {\n const conv = new Hsluv();\n conv.hex = hex;\n conv.hexToHsluv();\n return [conv.hsluv_h, conv.hsluv_s, conv.hsluv_l];\n};\n\n/**\n * Converts a HSL number array '[h,s,l]' into HSL CSS string 'hsl(x,x,x)'\n *\n * @param HSL A HSL number array '[h,s,l]'\n * @returns A hex color string\n */\nexport const hslArrToCss = (HSL: number[]) => {\n return 'hsl(' + HSL[0] + ',' + HSL[1] + '%,' + HSL[2] + '%)';\n};\n\n/**\n * Converts a HSL CSS string 'hsl(x,x,x)' into an array of HSL values '[h,s,l]'\n *\n * @param h The HSL hue\n * @param s The HSL saturation\n * @param l The HSL lightness\n * @returns HEX color string\n */\nexport const HSLToHex = (h: number, s: number, l: number) => {\n s /= 100;\n l /= 100;\n\n let r = 0,\n g = 0,\n b = 0;\n const c = (1 - Math.abs(2 * l - 1)) * s,\n x = c * (1 - Math.abs(((h / 60) % 2) - 1)),\n m = l - c / 2;\n\n if (0 <= h && h < 60) {\n r = c;\n g = x;\n b = 0;\n } else if (60 <= h && h < 120) {\n r = x;\n g = c;\n b = 0;\n } else if (120 <= h && h < 180) {\n r = 0;\n g = c;\n b = x;\n } else if (180 <= h && h < 240) {\n r = 0;\n g = x;\n b = c;\n } else if (240 <= h && h < 300) {\n r = x;\n g = 0;\n b = c;\n } else if (300 <= h && h < 360) {\n r = c;\n g = 0;\n b = x;\n }\n // Having obtained RGB, convert channels to hex\n r = parseInt(Math.round((r + m) * 255).toString(16), 16);\n g = parseInt(Math.round((g + m) * 255).toString(16), 16);\n b = parseInt(Math.round((b + m) * 255).toString(16), 16);\n\n // Prepend 0s, if necessary\n if (r.toString().length == 1) r = parseInt('0' + r.toString(), 10);\n if (g.toString().length == 1) g = parseInt('0' + g.toString(), 10);\n if (b.toString().length == 1) b = parseInt('0' + b.toString(), 10);\n\n return '#' + r + g + b;\n};\n\n/**\n * Converts a HEX color '#xxxxxx' into an array of RGB values '[R, G, B]'\n *\n * @param hex A hex color string\n * @returns RGB values in an array\n */\nexport const hexToRgb = (hex: string) => {\n const shorthandRegex = /^#?([a-f\\d])([a-f\\d])([a-f\\d])$/i;\n hex = hex.replace(shorthandRegex, function (m, r: string, g: string, b: string) {\n return r + r + g + g + b + b;\n });\n\n const result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\n return result\n ? {\n r: parseInt(result[1], 16),\n g: parseInt(result[2], 16),\n b: parseInt(result[3], 16),\n }\n : null;\n};\n\n/**\n * Get the luminance of an RGB color\n *\n * @param r RGB red value\n * @param G RGB green value\n * @param b RGB blue value\n * @returns\n */\nexport const luminanceFromRgb = (r: string, g: string, b: string) => {\n const a = [Number(r), Number(g), Number(b)].map(function (v) {\n v /= 255;\n return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);\n });\n return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;\n};\n\n/**\n * Get the luminance of a HEX color\n *\n * @param hex A hex color string\n * @returns\n */\nexport const luminanceFromHex = (hex: CssColor) => {\n const rgb = hexToRgb(hex);\n if (rgb) {\n const r = rgb.r.toString();\n const g = rgb.g.toString();\n const b = rgb.b.toString();\n return luminanceFromRgb(r, g, b);\n }\n return 2;\n};\n\n/**\n * Get the contrast ratio between two luminance values\n *\n * @param lum1 The first luminance value\n * @param lum2 The second luminance value\n * @returns\n */\nexport const getRatioFromLum = (lum1: number, lum2: number) => {\n if (lum1 !== null && lum2 !== null) {\n return (Math.max(lum1, lum2) + 0.05) / (Math.min(lum1, lum2) + 0.05);\n } else {\n return -1;\n }\n};\n\n/**\n * Get the HSL lightness from a HEX color\n *\n * @param hex A hex color string\n * @returns\n */\nexport const getHslLightessFromHex = (hex: CssColor) => {\n return chroma(hex).hsl()[2];\n};\n\nexport const getHslSaturationFromHex = (hex: CssColor) => {\n return chroma(hex).hsl()[1];\n};\n\n/**\n * Get the HSLuv lightness from a HEX color\n *\n * @param hex A hex color string\n * @returns\n */\nexport const getLightnessFromHex = (hex: string) => {\n const conv = new Hsluv();\n conv.hex = hex;\n conv.hexToHsluv();\n return Number(conv.hsluv_l.toFixed(0));\n};\n\n/**\n * Get the contrast ratio between two HEX colors\n *\n * @param {CssColor} color1 The first color\n * @param {CssColor} color2 The second color\n * @returns\n */\nexport const getContrastFromHex = (color1: CssColor, color2: CssColor) => {\n const lum1 = luminanceFromHex(color1);\n const lum2 = luminanceFromHex(color2);\n if (lum1 !== null && lum2 !== null) {\n return getRatioFromLum(lum1, lum2);\n }\n return -1;\n};\n\n/**\n * Get the contrast ratio between two colors at a specific lightness\n *\n * @param lightness The lightness value\n * @param mainColor The main color\n * @param backgroundColor The background color\n * @returns The contrast ratio\n */\nexport const getContrastFromLightness = (lightness: number, mainColor: CssColor, backgroundColor: CssColor) => {\n const conv = new Hsluv();\n conv.hex = mainColor;\n conv.hexToHsluv();\n conv.hsluv_l = lightness;\n conv.hsluvToHex();\n const lightMainColor = conv.hex;\n const lum1 = luminanceFromHex(lightMainColor as CssColor);\n const lum2 = luminanceFromHex(backgroundColor);\n const ratio = getRatioFromLum(lum1 ?? 0, lum2 ?? 0);\n\n return ratio;\n};\n\n/**\n * Maps the numbers from [start1 - end1] to the range [start2 - end2], maintaining the proportionality between the numbers in the ranges using lineaer interpolation.\n */\n// const mapRange = (value: number, start1: number, end1: number, start2: number, end2: number) => {\n// return start2 + ((value - start1) * (end2 - start2)) / (end1 - start1);\n// };\n\n/**\n * Check if two colors have enough contrast to be used together\n *\n * @param {CssColor} color1 The first color\n * @param {CssColor} color2 The second color\n * @returns {boolean} If the colors have enough contrast\n */\nexport const areColorsContrasting = (color1: CssColor, color2: CssColor, type: 'decorative' | 'aa' | 'aaa' = 'aa') => {\n const contrast = getContrastFromHex(color1, color2);\n if (contrast !== null) {\n if (type === 'aaa') {\n return contrast >= 7;\n } else if (type === 'aa') {\n return contrast >= 4.5;\n } else {\n return contrast >= 3;\n }\n }\n return false;\n};\n\nexport const getApcaContrastLc = (textColor: CssColor, backgroundColor: CssColor) => {\n const textColorRgb = hexToRgb(textColor);\n const backgroundColorRgb = hexToRgb(backgroundColor);\n\n if (textColorRgb && backgroundColorRgb) {\n return APCAcontrast(\n sRGBtoY([textColorRgb.r, textColorRgb.g, textColorRgb.b]),\n sRGBtoY([backgroundColorRgb.r, backgroundColorRgb.g, backgroundColorRgb.b]),\n );\n }\n return 0;\n};\n\n/**\n * Check if aa string value is a HEX color\n *\n * @param {string} hex The string to check\n * @returns {boolean} If the string is a HEX color\n */\nexport const isHexColor = (hex: string) => {\n return typeof hex === 'string' && hex.length === 6 && !isNaN(Number('0x' + hex));\n};\n"],"mappings":";AACA,SAAS,iBAAiB,OAAO,aAAa;AAC9C,SAAS,SAAAA,cAAa;;;ACDtB,SAAS,aAAa;AACtB,OAAO,YAAY;AA6LZ,IAAM,WAAW,CAAC,QAAgB;AACvC,QAAM,iBAAiB;AACvB,QAAM,IAAI,QAAQ,gBAAgB,SAAU,GAAG,GAAW,GAAW,GAAW;AAC9E,WAAO,IAAI,IAAI,IAAI,IAAI,IAAI;AAAA,EAC7B,CAAC;AAED,QAAM,SAAS,4CAA4C,KAAK,GAAG;AACnE,SAAO,SACH;AAAA,IACE,GAAG,SAAS,OAAO,CAAC,GAAG,EAAE;AAAA,IACzB,GAAG,SAAS,OAAO,CAAC,GAAG,EAAE;AAAA,IACzB,GAAG,SAAS,OAAO,CAAC,GAAG,EAAE;AAAA,EAC3B,IACA;AACN;AAUO,IAAM,mBAAmB,CAAC,GAAW,GAAW,MAAc;AACnE,QAAM,IA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,IAAIE,OAAM;AACvB,OAAK,MAAM;AACX,OAAK,WAAW;AAGhB,OAAK,WAAW;AAEhB,SAAO,KAAK;AACd;AAEO,IAAM,iBAAiB,CAAC,WAAsB,gBAA6B;AAChF,SAAO,QAAQ,SAAS,IAAI,uBAAuB,WAAW,EAAE,YAAY,EAAE,QAAQ,OAAO,GAAG,CAAC;AACnG;","names":["Hsluv","color","lightnessScale","Hsluv"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|