@razorpay/blade 12.31.0 → 12.31.2
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/build/lib/native/tokens/theme/createTheme.js +1 -1
- package/build/lib/native/tokens/theme/createTheme.js.map +1 -1
- package/build/lib/web/development/components/ListView/ListViewFilters.web.js +13 -4
- package/build/lib/web/development/components/ListView/ListViewFilters.web.js.map +1 -1
- package/build/lib/web/development/tokens/theme/createTheme.js +12 -0
- package/build/lib/web/development/tokens/theme/createTheme.js.map +1 -1
- package/build/lib/web/production/components/ListView/ListViewFilters.web.js +13 -4
- package/build/lib/web/production/components/ListView/ListViewFilters.web.js.map +1 -1
- package/build/lib/web/production/tokens/theme/createTheme.js +12 -0
- package/build/lib/web/production/tokens/theme/createTheme.js.map +1 -1
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ import '../global/typography.js';
|
|
|
7
7
|
import '../global/motion.js';
|
|
8
8
|
import { throwBladeError } from '../../utils/logger/logger.js';
|
|
9
9
|
|
|
10
|
-
var WCAG2ContrastOptions={level:'AAA',size:'large'};var getColorWithOpacity=function getColorWithOpacity(color,opacity){return tinycolor(color).setAlpha(opacity).toHslString();};var generateChromaticBrandColors=function generateChromaticBrandColors(baseColorInput){var baseColor=tinycolor(baseColorInput);var baseColorHslString=baseColor.toHslString();if(__DEV__){if(!baseColor.isValid()){throwBladeError({message:'Invalid brandColor passed',moduleName:'createTheme'});}}var palette=[baseColorHslString];var brightness=tinycolor(baseColor).getBrightness();var lightnessFactor=brightness>150?3:6;var darknessFactor=brightness<50?3:5;var currentColor=baseColor;for(var lightShadeIndex=0;lightShadeIndex<6;lightShadeIndex++){currentColor=currentColor.brighten(lightnessFactor);palette.push(currentColor.toHslString());}currentColor=tinycolor(baseColorHslString);for(var darkShadeIndex=0;darkShadeIndex<4;darkShadeIndex++){currentColor=currentColor.darken(darknessFactor);palette.unshift(currentColor.toHslString());}var colorPalette=palette.reverse();var brandPrimaryColor=colorPalette[6];var brandColors={'50':colorPalette[0],'100':colorPalette[1],'200':colorPalette[2],'300':colorPalette[3],'400':colorPalette[4],'500':colorPalette[5],'600':brandPrimaryColor,'700':colorPalette[7],'800':colorPalette[8],'900':colorPalette[9],'1000':colorPalette[10],a50:getColorWithOpacity(brandPrimaryColor,opacity[100]),a150:getColorWithOpacity(brandPrimaryColor,opacity[100]),a100:getColorWithOpacity(brandPrimaryColor,opacity[200]),a200:getColorWithOpacity(brandPrimaryColor,opacity[300]),a400:getColorWithOpacity(brandPrimaryColor,opacity[400])};return brandColors;};var getOnLightOverrides=function getOnLightOverrides(brandColors){var foregroundOnSurface=tinycolor.isReadable(colors.neutral.blueGrayLight[50],brandColors[600],WCAG2ContrastOptions)?brandColors[600]:colors.neutral.blueGrayLight[1100];var foregroundOnBrand=tinycolor.mostReadable(brandColors[900],[colors.neutral.white[500],colors.neutral.black[500]],WCAG2ContrastOptions).toHslString();var lightThemeOverrides={interactive:{background:{primary:{default:brandColors[600],highlighted:brandColors[700],disabled:brandColors.a100,faded:brandColors.a100,fadedHighlighted:brandColors.a150}},border:{primary:{default:brandColors[600],highlighted:brandColors[700],disabled:brandColors.a100,faded:brandColors.a100}},text:{primary:{normal:foregroundOnSurface,disabled:brandColors.a200,muted:foregroundOnSurface,subtle:foregroundOnSurface},onPrimary:{normal:foregroundOnBrand,disabled:foregroundOnBrand,muted:foregroundOnBrand,subtle:foregroundOnBrand}},icon:{primary:{normal:foregroundOnSurface,disabled:brandColors.a200,muted:foregroundOnSurface,subtle:foregroundOnSurface},onPrimary:{normal:foregroundOnBrand,disabled:foregroundOnBrand,muted:foregroundOnBrand,subtle:foregroundOnBrand}}},surface:{background:{primary:{intense:brandColors[600],subtle:brandColors[200]}},icon:{primary:{normal:brandColors[600]}},text:{primary:{normal:brandColors[600]}}}};return lightThemeOverrides;};var getOnDarkOverrides=function getOnDarkOverrides(brandColors){var foregroundOnSurface=tinycolor.isReadable(colors.neutral.blueGrayDark[1100],brandColors[400],WCAG2ContrastOptions)?brandColors[400]:colors.neutral.blueGrayDark[0];var foregroundOnBrand=tinycolor.mostReadable(brandColors[900],[colors.neutral.white[500],colors.neutral.black[500]],WCAG2ContrastOptions).toHslString();var darkThemeOverrides={interactive:{background:{primary:{default:brandColors[600],highlighted:brandColors[700],disabled:brandColors.a100,faded:brandColors.a100,fadedHighlighted:brandColors.a150}},border:{primary:{default:brandColors[600],highlighted:brandColors[700],disabled:brandColors.a100,faded:brandColors.a100}},text:{primary:{normal:foregroundOnSurface,disabled:brandColors.a400,muted:foregroundOnSurface,subtle:foregroundOnSurface},onPrimary:{normal:foregroundOnBrand,disabled:foregroundOnBrand,muted:foregroundOnBrand,subtle:foregroundOnBrand}},icon:{primary:{normal:foregroundOnSurface,disabled:brandColors.a400,muted:foregroundOnSurface,subtle:foregroundOnSurface},onPrimary:{normal:foregroundOnBrand,disabled:foregroundOnBrand,muted:foregroundOnBrand,subtle:foregroundOnBrand}}},surface:{background:{primary:{intense:brandColors[600],subtle:brandColors[200]}},icon:{primary:{normal:brandColors[600]}}}};return darkThemeOverrides;};var createTheme=function createTheme(_ref){var brandColor=_ref.brandColor;var chromaticBrandColors=generateChromaticBrandColors(brandColor);var brandedLightTheme=getOnLightOverrides(chromaticBrandColors);var brandedDarkTheme=getOnDarkOverrides(chromaticBrandColors);var brandedThemeTokens=overrideTheme({baseThemeTokens:bladeTheme,overrides:{name:`custom-${tinycolor(brandColor).toHex()}`,colors:{onLight:Object.assign({},brandedLightTheme),onDark:Object.assign({},brandedDarkTheme)}}});return {theme:brandedThemeTokens,brandColors:chromaticBrandColors};};
|
|
10
|
+
var WCAG2ContrastOptions={level:'AAA',size:'large'};var getColorWithOpacity=function getColorWithOpacity(color,opacity){return tinycolor(color).setAlpha(opacity).toHslString();};var generateChromaticBrandColors=function generateChromaticBrandColors(baseColorInput){var baseColor=tinycolor(baseColorInput);var baseColorHslString=baseColor.toHslString();if(__DEV__){if(!baseColor.isValid()){throwBladeError({message:'Invalid brandColor passed',moduleName:'createTheme'});}}var palette=[baseColorHslString];var brightness=tinycolor(baseColor).getBrightness();var lightnessFactor=brightness>150?3:6;var darknessFactor=brightness<50?3:5;var currentColor=baseColor;for(var lightShadeIndex=0;lightShadeIndex<6;lightShadeIndex++){currentColor=currentColor.brighten(lightnessFactor);palette.push(currentColor.toHslString());}currentColor=tinycolor(baseColorHslString);for(var darkShadeIndex=0;darkShadeIndex<4;darkShadeIndex++){currentColor=currentColor.darken(darknessFactor);palette.unshift(currentColor.toHslString());}var colorPalette=palette.reverse();var brandPrimaryColor=colorPalette[6];var brandColors={'50':colorPalette[0],'100':colorPalette[1],'200':colorPalette[2],'300':colorPalette[3],'400':colorPalette[4],'500':colorPalette[5],'600':brandPrimaryColor,'700':colorPalette[7],'800':colorPalette[8],'900':colorPalette[9],'1000':colorPalette[10],a50:getColorWithOpacity(brandPrimaryColor,opacity[100]),a150:getColorWithOpacity(brandPrimaryColor,opacity[100]),a100:getColorWithOpacity(brandPrimaryColor,opacity[200]),a200:getColorWithOpacity(brandPrimaryColor,opacity[300]),a400:getColorWithOpacity(brandPrimaryColor,opacity[400])};return brandColors;};var getOnLightOverrides=function getOnLightOverrides(brandColors){var foregroundOnSurface=tinycolor.isReadable(colors.neutral.blueGrayLight[50],brandColors[600],WCAG2ContrastOptions)?brandColors[600]:colors.neutral.blueGrayLight[1100];var foregroundOnBrand=tinycolor.mostReadable(brandColors[900],[colors.neutral.white[500],colors.neutral.black[500]],WCAG2ContrastOptions).toHslString();var lightThemeOverrides={interactive:{background:{primary:{default:brandColors[600],highlighted:brandColors[700],disabled:brandColors.a100,faded:brandColors.a100,fadedHighlighted:brandColors.a150}},border:{primary:{default:brandColors[600],highlighted:brandColors[700],disabled:brandColors.a100,faded:brandColors.a100}},text:{primary:{normal:foregroundOnSurface,disabled:brandColors.a200,muted:foregroundOnSurface,subtle:foregroundOnSurface},onPrimary:{normal:foregroundOnBrand,disabled:foregroundOnBrand,muted:foregroundOnBrand,subtle:foregroundOnBrand}},icon:{primary:{normal:foregroundOnSurface,disabled:brandColors.a200,muted:foregroundOnSurface,subtle:foregroundOnSurface},onPrimary:{normal:foregroundOnBrand,disabled:foregroundOnBrand,muted:foregroundOnBrand,subtle:foregroundOnBrand}}},surface:{background:{primary:{intense:brandColors[600],subtle:brandColors[200]}},border:{primary:{normal:brandColors[600],muted:brandColors.a200}},icon:{primary:{normal:brandColors[600]}},text:{primary:{normal:brandColors[600]}}}};return lightThemeOverrides;};var getOnDarkOverrides=function getOnDarkOverrides(brandColors){var foregroundOnSurface=tinycolor.isReadable(colors.neutral.blueGrayDark[1100],brandColors[400],WCAG2ContrastOptions)?brandColors[400]:colors.neutral.blueGrayDark[0];var foregroundOnBrand=tinycolor.mostReadable(brandColors[900],[colors.neutral.white[500],colors.neutral.black[500]],WCAG2ContrastOptions).toHslString();var darkThemeOverrides={interactive:{background:{primary:{default:brandColors[600],highlighted:brandColors[700],disabled:brandColors.a100,faded:brandColors.a100,fadedHighlighted:brandColors.a150}},border:{primary:{default:brandColors[600],highlighted:brandColors[700],disabled:brandColors.a100,faded:brandColors.a100}},text:{primary:{normal:foregroundOnSurface,disabled:brandColors.a400,muted:foregroundOnSurface,subtle:foregroundOnSurface},onPrimary:{normal:foregroundOnBrand,disabled:foregroundOnBrand,muted:foregroundOnBrand,subtle:foregroundOnBrand}},icon:{primary:{normal:foregroundOnSurface,disabled:brandColors.a400,muted:foregroundOnSurface,subtle:foregroundOnSurface},onPrimary:{normal:foregroundOnBrand,disabled:foregroundOnBrand,muted:foregroundOnBrand,subtle:foregroundOnBrand}}},surface:{background:{primary:{intense:brandColors[600],subtle:brandColors[200]}},border:{primary:{normal:brandColors[600],muted:brandColors.a200}},icon:{primary:{normal:brandColors[600]}}}};return darkThemeOverrides;};var createTheme=function createTheme(_ref){var brandColor=_ref.brandColor;var chromaticBrandColors=generateChromaticBrandColors(brandColor);var brandedLightTheme=getOnLightOverrides(chromaticBrandColors);var brandedDarkTheme=getOnDarkOverrides(chromaticBrandColors);var brandedThemeTokens=overrideTheme({baseThemeTokens:bladeTheme,overrides:{name:`custom-${tinycolor(brandColor).toHex()}`,colors:{onLight:Object.assign({},brandedLightTheme),onDark:Object.assign({},brandedDarkTheme)}}});return {theme:brandedThemeTokens,brandColors:chromaticBrandColors};};
|
|
11
11
|
|
|
12
12
|
export { createTheme };
|
|
13
13
|
//# sourceMappingURL=createTheme.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTheme.js","sources":["../../../../../src/tokens/theme/createTheme.ts"],"sourcesContent":["import tinycolor from 'tinycolor2';\nimport type { WCAG2Options, ColorInput } from 'tinycolor2';\nimport type { ThemeTokens } from './theme';\nimport overrideTheme from './overrideTheme';\nimport bladeTheme from './bladeTheme';\nimport { colors as globalColors, opacity } from '~tokens/global';\nimport type { ColorChromaticScale } from '~tokens/global/colors';\nimport { throwBladeError } from '~utils/logger';\nimport type { DeepPartial } from '~utils/isPartialMatchObjectKeys';\n\n// WCAG2ContrastOptions are the options used to determine if a color is readable\nconst WCAG2ContrastOptions: WCAG2Options = {\n level: 'AAA',\n size: 'large',\n};\n\n/**\n * getColorWithOpacity\n * @param color - The color to add opacity to\n * @param opacity - The opacity to add to the color\n * @returns The color with the opacity added\n * @example\n * getColorWithOpacity('#fff', 0.5) // returns 'hsla(0, 0%, 100%, 0.5)'\n *\n **/\nconst getColorWithOpacity = (color: ColorInput, opacity: number): string => {\n return tinycolor(color).setAlpha(opacity).toHslString();\n};\n\n/**\n *\n * @description\n * Generates a chromatic color palette based on the base color passed in.\n * The base color is used to generate a palette of 11 colors, 5 shades lighter and 5 shades darker than the base color.\n * @param baseColorInput - The base color to generate the chromatic color palette from in hex, rgb, or hsl format\n * @returns Array of chromatic color palette\n */\nconst generateChromaticBrandColors = (baseColorInput: ColorInput): ColorChromaticScale => {\n const baseColor = tinycolor(baseColorInput);\n const baseColorHslString = baseColor.toHslString();\n if (__DEV__) {\n if (!baseColor.isValid()) {\n throwBladeError({\n message: 'Invalid brandColor passed',\n moduleName: 'createTheme',\n });\n }\n }\n\n const palette = [baseColorHslString]; // Include the original color\n const brightness = tinycolor(baseColor).getBrightness();\n // Determine how much to lighten or darken the colors depending on the brightness of the base color\n const lightnessFactor = brightness > 150 ? 3 : 6;\n const darknessFactor = brightness < 50 ? 3 : 5;\n\n let currentColor = baseColor;\n\n // Generate shades lighter\n for (let lightShadeIndex = 0; lightShadeIndex < 6; lightShadeIndex++) {\n currentColor = currentColor.brighten(lightnessFactor);\n palette.push(currentColor.toHslString());\n }\n\n currentColor = tinycolor(baseColorHslString); // Reset to the base color\n\n // Generate shades darker\n for (let darkShadeIndex = 0; darkShadeIndex < 4; darkShadeIndex++) {\n currentColor = currentColor.darken(darknessFactor);\n palette.unshift(currentColor.toHslString()); // Add shades at the beginning of the palette\n }\n\n const colorPalette = palette.reverse();\n const brandPrimaryColor = colorPalette[6];\n\n const brandColors: ColorChromaticScale = {\n '50': colorPalette[0],\n '100': colorPalette[1],\n '200': colorPalette[2],\n '300': colorPalette[3],\n '400': colorPalette[4],\n '500': colorPalette[5],\n '600': brandPrimaryColor,\n '700': colorPalette[7],\n '800': colorPalette[8],\n '900': colorPalette[9],\n '1000': colorPalette[10],\n a50: getColorWithOpacity(brandPrimaryColor, opacity[100]),\n a150: getColorWithOpacity(brandPrimaryColor, opacity[100]),\n a100: getColorWithOpacity(brandPrimaryColor, opacity[200]),\n a200: getColorWithOpacity(brandPrimaryColor, opacity[300]),\n a400: getColorWithOpacity(brandPrimaryColor, opacity[400]),\n };\n\n return brandColors;\n};\n\n/**\n *\n * @param brandColors - The brand colors to use to override the light theme\n * @description Returns overrides for the light theme with the brand colors passed in\n * @returns Overrides for the light theme with the custom brand colors\n */\nconst getOnLightOverrides = (\n brandColors: ColorChromaticScale,\n): DeepPartial<ThemeTokens['colors']['onLight']> => {\n // Select the most readable color to use as the foreground color on top of surface color\n // For example: On Secondary Button where the background color is surface color, the text color should be either the brand color or dark color depending on which is more readable on top of that surface color\n const foregroundOnSurface = tinycolor.isReadable(\n globalColors.neutral.blueGrayLight[50],\n brandColors[600],\n WCAG2ContrastOptions,\n )\n ? brandColors[600]\n : globalColors.neutral.blueGrayLight[1100];\n\n const foregroundOnBrand = tinycolor\n .mostReadable(\n brandColors[900],\n [globalColors.neutral.white[500], globalColors.neutral.black[500]],\n WCAG2ContrastOptions,\n )\n .toHslString();\n\n // Overrides for the light theme with the brand colors passed in\n const lightThemeOverrides: DeepPartial<ThemeTokens['colors']['onLight']> = {\n interactive: {\n background: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n fadedHighlighted: brandColors.a150,\n },\n },\n border: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n },\n },\n text: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a200,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n icon: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a200,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n },\n surface: {\n background: {\n primary: {\n intense: brandColors[600],\n subtle: brandColors[200],\n },\n },\n icon: {\n primary: {\n normal: brandColors[600],\n },\n },\n text: {\n primary: {\n normal: brandColors[600],\n },\n },\n },\n };\n\n return lightThemeOverrides;\n};\n\n/**\n *\n * @param brandColors - The brand colors to use to override the dark theme\n * @description Returns overrides for the dark theme with the brand colors passed in\n * @returns Overrides for the dark theme with the custom brand colors\n */\nconst getOnDarkOverrides = (\n brandColors: ColorChromaticScale,\n): DeepPartial<ThemeTokens['colors']['onDark']> => {\n // Select the most readable color to use as the foreground color on top of surface color\n // For example: On Secondary Button where the background color is surface color, the text color should be either the brand color or dark color depending on which is more readable on top of that surface color\n const foregroundOnSurface = tinycolor.isReadable(\n globalColors.neutral.blueGrayDark[1100],\n brandColors[400],\n WCAG2ContrastOptions,\n )\n ? brandColors[400]\n : globalColors.neutral.blueGrayDark[0];\n\n const foregroundOnBrand = tinycolor\n .mostReadable(\n brandColors[900],\n [globalColors.neutral.white[500], globalColors.neutral.black[500]],\n WCAG2ContrastOptions,\n )\n .toHslString();\n\n // Overrides for the dark theme with the brand colors passed in\n const darkThemeOverrides: DeepPartial<ThemeTokens['colors']['onDark']> = {\n interactive: {\n background: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n fadedHighlighted: brandColors.a150,\n },\n },\n border: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n },\n },\n text: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a400,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n icon: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a400,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n },\n surface: {\n background: {\n primary: {\n intense: brandColors[600],\n subtle: brandColors[200],\n },\n },\n icon: {\n primary: {\n normal: brandColors[600],\n },\n },\n },\n };\n\n return darkThemeOverrides;\n};\n\n/**\n * @param {Object} themeConfig - The brand color and overrides to apply to the theme\n * @param {string} themeConfig.brandColor - The brand color to use to generate the theme. Can be in hex, rgb, or hsl format.\n * @description\n * Creates a Blade Theme based on the custom brand color\n * @returns The Theme Tokens with the custom brand colors\n * @example\n * const { theme, brandColors } = createTheme({ brandColor: '#19BEA2'})\n **/\nexport const createTheme = ({\n brandColor,\n}: {\n brandColor: ColorInput;\n}): { theme: ThemeTokens; brandColors: ColorChromaticScale } => {\n const chromaticBrandColors = generateChromaticBrandColors(brandColor);\n // Get onLight overrides\n const brandedLightTheme = getOnLightOverrides(chromaticBrandColors);\n // Get onDark overrides\n const brandedDarkTheme = getOnDarkOverrides(chromaticBrandColors);\n // Override the payment theme with the brand colors\n const brandedThemeTokens = overrideTheme({\n baseThemeTokens: bladeTheme,\n overrides: {\n name: `custom-${tinycolor(brandColor).toHex()}`,\n colors: {\n onLight: {\n ...brandedLightTheme,\n },\n onDark: {\n ...brandedDarkTheme,\n },\n },\n },\n });\n\n return { theme: brandedThemeTokens, brandColors: chromaticBrandColors };\n};\n"],"names":["WCAG2ContrastOptions","level","size","getColorWithOpacity","color","opacity","tinycolor","setAlpha","toHslString","generateChromaticBrandColors","baseColorInput","baseColor","baseColorHslString","__DEV__","isValid","throwBladeError","message","moduleName","palette","brightness","getBrightness","lightnessFactor","darknessFactor","currentColor","lightShadeIndex","brighten","push","darkShadeIndex","darken","unshift","colorPalette","reverse","brandPrimaryColor","brandColors","a50","a150","a100","a200","a400","getOnLightOverrides","foregroundOnSurface","isReadable","globalColors","neutral","blueGrayLight","foregroundOnBrand","mostReadable","white","black","lightThemeOverrides","interactive","background","primary","default","highlighted","disabled","faded","fadedHighlighted","border","text","normal","muted","subtle","onPrimary","icon","surface","intense","getOnDarkOverrides","blueGrayDark","darkThemeOverrides","createTheme","_ref","brandColor","chromaticBrandColors","brandedLightTheme","brandedDarkTheme","brandedThemeTokens","overrideTheme","baseThemeTokens","bladeTheme","overrides","name","toHex","colors","onLight","Object","assign","onDark","theme"],"mappings":";;;;;;;;;AAWA,IAAMA,oBAAkC,CAAG,CACzCC,KAAK,CAAE,KAAK,CACZC,IAAI,CAAE,OACR,CAAC,CAWD,IAAMC,mBAAmB,CAAG,SAAtBA,mBAAmB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CACxBiB,MAAM,CAAEjB,iBACV,CACF,CACF,CAAC,CACDoB,OAAO,CAAE,CACPd,UAAU,CAAE,CACVC,OAAO,CAAE,CACPc,OAAO,CAAEjC,WAAW,CAAC,GAAG,CAAC,CACzB6B,MAAM,CAAE7B,WAAW,CAAC,GAAG,CACzB,CACF,CAAC,CACD+B,IAAI,CAAE,CACJZ,OAAO,CAAE,CACPQ,MAAM,CAAE3B,WAAW,CAAC,GAAG,CACzB,CACF,CACF,CACF,CAAC,CAED,OAAOoC,kBAAkB,CAC3B,CAAC,CAWY,IAAAC,WAAW,CAAG,SAAdA,WAAWA,CAAAC,IAAA,CAIwC,CAH9D,IAAAC,UAAU,CAAAD,IAAA,CAAVC,UAAU,CAIV,IAAMC,oBAAoB,CAAGhE,4BAA4B,CAAC+D,UAAU,CAAC,CAErE,IAAME,iBAAiB,CAAGnC,mBAAmB,CAACkC,oBAAoB,CAAC,CAEnE,IAAME,gBAAgB,CAAGR,kBAAkB,CAACM,oBAAoB,CAAC,CAEjE,IAAMG,kBAAkB,CAAGC,aAAa,CAAC,CACvCC,eAAe,CAAEC,UAAU,CAC3BC,SAAS,CAAE,CACTC,IAAI,CAAG,CAAS3E,OAAAA,EAAAA,SAAS,CAACkE,UAAU,CAAC,CAACU,KAAK,EAAG,EAAC,CAC/CC,MAAM,CAAE,CACNC,OAAO,CAAAC,MAAA,CAAAC,MAAA,CACFZ,EAAAA,CAAAA,iBAAiB,CACrB,CACDa,MAAM,CAAAF,MAAA,CAAAC,MAAA,CACDX,EAAAA,CAAAA,gBAAgB,CAEvB,CACF,CACF,CAAC,CAAC,CAEF,OAAO,CAAEa,KAAK,CAAEZ,kBAAkB,CAAE3C,WAAW,CAAEwC,oBAAqB,CAAC,CACzE;;;;"}
|
|
1
|
+
{"version":3,"file":"createTheme.js","sources":["../../../../../src/tokens/theme/createTheme.ts"],"sourcesContent":["import tinycolor from 'tinycolor2';\nimport type { WCAG2Options, ColorInput } from 'tinycolor2';\nimport type { ThemeTokens } from './theme';\nimport overrideTheme from './overrideTheme';\nimport bladeTheme from './bladeTheme';\nimport { colors as globalColors, opacity } from '~tokens/global';\nimport type { ColorChromaticScale } from '~tokens/global/colors';\nimport { throwBladeError } from '~utils/logger';\nimport type { DeepPartial } from '~utils/isPartialMatchObjectKeys';\n\n// WCAG2ContrastOptions are the options used to determine if a color is readable\nconst WCAG2ContrastOptions: WCAG2Options = {\n level: 'AAA',\n size: 'large',\n};\n\n/**\n * getColorWithOpacity\n * @param color - The color to add opacity to\n * @param opacity - The opacity to add to the color\n * @returns The color with the opacity added\n * @example\n * getColorWithOpacity('#fff', 0.5) // returns 'hsla(0, 0%, 100%, 0.5)'\n *\n **/\nconst getColorWithOpacity = (color: ColorInput, opacity: number): string => {\n return tinycolor(color).setAlpha(opacity).toHslString();\n};\n\n/**\n *\n * @description\n * Generates a chromatic color palette based on the base color passed in.\n * The base color is used to generate a palette of 11 colors, 5 shades lighter and 5 shades darker than the base color.\n * @param baseColorInput - The base color to generate the chromatic color palette from in hex, rgb, or hsl format\n * @returns Array of chromatic color palette\n */\nconst generateChromaticBrandColors = (baseColorInput: ColorInput): ColorChromaticScale => {\n const baseColor = tinycolor(baseColorInput);\n const baseColorHslString = baseColor.toHslString();\n if (__DEV__) {\n if (!baseColor.isValid()) {\n throwBladeError({\n message: 'Invalid brandColor passed',\n moduleName: 'createTheme',\n });\n }\n }\n\n const palette = [baseColorHslString]; // Include the original color\n const brightness = tinycolor(baseColor).getBrightness();\n // Determine how much to lighten or darken the colors depending on the brightness of the base color\n const lightnessFactor = brightness > 150 ? 3 : 6;\n const darknessFactor = brightness < 50 ? 3 : 5;\n\n let currentColor = baseColor;\n\n // Generate shades lighter\n for (let lightShadeIndex = 0; lightShadeIndex < 6; lightShadeIndex++) {\n currentColor = currentColor.brighten(lightnessFactor);\n palette.push(currentColor.toHslString());\n }\n\n currentColor = tinycolor(baseColorHslString); // Reset to the base color\n\n // Generate shades darker\n for (let darkShadeIndex = 0; darkShadeIndex < 4; darkShadeIndex++) {\n currentColor = currentColor.darken(darknessFactor);\n palette.unshift(currentColor.toHslString()); // Add shades at the beginning of the palette\n }\n\n const colorPalette = palette.reverse();\n const brandPrimaryColor = colorPalette[6];\n\n const brandColors: ColorChromaticScale = {\n '50': colorPalette[0],\n '100': colorPalette[1],\n '200': colorPalette[2],\n '300': colorPalette[3],\n '400': colorPalette[4],\n '500': colorPalette[5],\n '600': brandPrimaryColor,\n '700': colorPalette[7],\n '800': colorPalette[8],\n '900': colorPalette[9],\n '1000': colorPalette[10],\n a50: getColorWithOpacity(brandPrimaryColor, opacity[100]),\n a150: getColorWithOpacity(brandPrimaryColor, opacity[100]),\n a100: getColorWithOpacity(brandPrimaryColor, opacity[200]),\n a200: getColorWithOpacity(brandPrimaryColor, opacity[300]),\n a400: getColorWithOpacity(brandPrimaryColor, opacity[400]),\n };\n\n return brandColors;\n};\n\n/**\n *\n * @param brandColors - The brand colors to use to override the light theme\n * @description Returns overrides for the light theme with the brand colors passed in\n * @returns Overrides for the light theme with the custom brand colors\n */\nconst getOnLightOverrides = (\n brandColors: ColorChromaticScale,\n): DeepPartial<ThemeTokens['colors']['onLight']> => {\n // Select the most readable color to use as the foreground color on top of surface color\n // For example: On Secondary Button where the background color is surface color, the text color should be either the brand color or dark color depending on which is more readable on top of that surface color\n const foregroundOnSurface = tinycolor.isReadable(\n globalColors.neutral.blueGrayLight[50],\n brandColors[600],\n WCAG2ContrastOptions,\n )\n ? brandColors[600]\n : globalColors.neutral.blueGrayLight[1100];\n\n const foregroundOnBrand = tinycolor\n .mostReadable(\n brandColors[900],\n [globalColors.neutral.white[500], globalColors.neutral.black[500]],\n WCAG2ContrastOptions,\n )\n .toHslString();\n\n // Overrides for the light theme with the brand colors passed in\n const lightThemeOverrides: DeepPartial<ThemeTokens['colors']['onLight']> = {\n interactive: {\n background: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n fadedHighlighted: brandColors.a150,\n },\n },\n border: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n },\n },\n text: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a200,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n icon: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a200,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n },\n surface: {\n background: {\n primary: {\n intense: brandColors[600],\n subtle: brandColors[200],\n },\n },\n border: {\n primary: {\n normal: brandColors[600],\n muted: brandColors.a200,\n },\n },\n icon: {\n primary: {\n normal: brandColors[600],\n },\n },\n text: {\n primary: {\n normal: brandColors[600],\n },\n },\n },\n };\n\n return lightThemeOverrides;\n};\n\n/**\n *\n * @param brandColors - The brand colors to use to override the dark theme\n * @description Returns overrides for the dark theme with the brand colors passed in\n * @returns Overrides for the dark theme with the custom brand colors\n */\nconst getOnDarkOverrides = (\n brandColors: ColorChromaticScale,\n): DeepPartial<ThemeTokens['colors']['onDark']> => {\n // Select the most readable color to use as the foreground color on top of surface color\n // For example: On Secondary Button where the background color is surface color, the text color should be either the brand color or dark color depending on which is more readable on top of that surface color\n const foregroundOnSurface = tinycolor.isReadable(\n globalColors.neutral.blueGrayDark[1100],\n brandColors[400],\n WCAG2ContrastOptions,\n )\n ? brandColors[400]\n : globalColors.neutral.blueGrayDark[0];\n\n const foregroundOnBrand = tinycolor\n .mostReadable(\n brandColors[900],\n [globalColors.neutral.white[500], globalColors.neutral.black[500]],\n WCAG2ContrastOptions,\n )\n .toHslString();\n\n // Overrides for the dark theme with the brand colors passed in\n const darkThemeOverrides: DeepPartial<ThemeTokens['colors']['onDark']> = {\n interactive: {\n background: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n fadedHighlighted: brandColors.a150,\n },\n },\n border: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n },\n },\n text: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a400,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n icon: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a400,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n },\n surface: {\n background: {\n primary: {\n intense: brandColors[600],\n subtle: brandColors[200],\n },\n },\n border: {\n primary: {\n normal: brandColors[600],\n muted: brandColors.a200,\n },\n },\n icon: {\n primary: {\n normal: brandColors[600],\n },\n },\n },\n };\n\n return darkThemeOverrides;\n};\n\n/**\n * @param {Object} themeConfig - The brand color and overrides to apply to the theme\n * @param {string} themeConfig.brandColor - The brand color to use to generate the theme. Can be in hex, rgb, or hsl format.\n * @description\n * Creates a Blade Theme based on the custom brand color\n * @returns The Theme Tokens with the custom brand colors\n * @example\n * const { theme, brandColors } = createTheme({ brandColor: '#19BEA2'})\n **/\nexport const createTheme = ({\n brandColor,\n}: {\n brandColor: ColorInput;\n}): { theme: ThemeTokens; brandColors: ColorChromaticScale } => {\n const chromaticBrandColors = generateChromaticBrandColors(brandColor);\n // Get onLight overrides\n const brandedLightTheme = getOnLightOverrides(chromaticBrandColors);\n // Get onDark overrides\n const brandedDarkTheme = getOnDarkOverrides(chromaticBrandColors);\n // Override the payment theme with the brand colors\n const brandedThemeTokens = overrideTheme({\n baseThemeTokens: bladeTheme,\n overrides: {\n name: `custom-${tinycolor(brandColor).toHex()}`,\n colors: {\n onLight: {\n ...brandedLightTheme,\n },\n onDark: {\n ...brandedDarkTheme,\n },\n },\n },\n });\n\n return { theme: brandedThemeTokens, brandColors: chromaticBrandColors };\n};\n"],"names":["WCAG2ContrastOptions","level","size","getColorWithOpacity","color","opacity","tinycolor","setAlpha","toHslString","generateChromaticBrandColors","baseColorInput","baseColor","baseColorHslString","__DEV__","isValid","throwBladeError","message","moduleName","palette","brightness","getBrightness","lightnessFactor","darknessFactor","currentColor","lightShadeIndex","brighten","push","darkShadeIndex","darken","unshift","colorPalette","reverse","brandPrimaryColor","brandColors","a50","a150","a100","a200","a400","getOnLightOverrides","foregroundOnSurface","isReadable","globalColors","neutral","blueGrayLight","foregroundOnBrand","mostReadable","white","black","lightThemeOverrides","interactive","background","primary","default","highlighted","disabled","faded","fadedHighlighted","border","text","normal","muted","subtle","onPrimary","icon","surface","intense","getOnDarkOverrides","blueGrayDark","darkThemeOverrides","createTheme","_ref","brandColor","chromaticBrandColors","brandedLightTheme","brandedDarkTheme","brandedThemeTokens","overrideTheme","baseThemeTokens","bladeTheme","overrides","name","toHex","colors","onLight","Object","assign","onDark","theme"],"mappings":";;;;;;;;;AAWA,IAAMA,oBAAkC,CAAG,CACzCC,KAAK,CAAE,KAAK,CACZC,IAAI,CAAE,OACR,CAAC,CAWD,IAAMC,mBAAmB,CAAG,SAAtBA,mBAAmBA,CAAIC,KAAiB,CAAEC,OAAe,CAAa,CAC1E,OAAOC,SAAS,CAACF,KAAK,CAAC,CAACG,QAAQ,CAACF,OAAO,CAAC,CAACG,WAAW,EAAE,CACzD,CAAC,CAUD,IAAMC,4BAA4B,CAAG,SAA/BA,4BAA4BA,CAAIC,cAA0B,CAA0B,CACxF,IAAMC,SAAS,CAAGL,SAAS,CAACI,cAAc,CAAC,CAC3C,IAAME,kBAAkB,CAAGD,SAAS,CAACH,WAAW,EAAE,CAClD,G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GAAG,CACzB,CACF,CAAC,CACDyB,MAAM,CAAE,CACNN,OAAO,CAAE,CACPQ,MAAM,CAAE3B,WAAW,CAAC,GAAG,CAAC,CACxB4B,KAAK,CAAE5B,WAAW,CAACI,IACrB,CACF,CAAC,CACD2B,IAAI,CAAE,CACJZ,OAAO,CAAE,CACPQ,MAAM,CAAE3B,WAAW,CAAC,GAAG,CACzB,CACF,CACF,CACF,CAAC,CAED,OAAOoC,kBAAkB,CAC3B,CAAC,CAWY,IAAAC,WAAW,CAAG,SAAdA,WAAWA,CAAAC,IAAA,CAIwC,CAAA,IAH9DC,UAAU,CAAAD,IAAA,CAAVC,UAAU,CAIV,IAAMC,oBAAoB,CAAGhE,4BAA4B,CAAC+D,UAAU,CAAC,CAErE,IAAME,iBAAiB,CAAGnC,mBAAmB,CAACkC,oBAAoB,CAAC,CAEnE,IAAME,gBAAgB,CAAGR,kBAAkB,CAACM,oBAAoB,CAAC,CAEjE,IAAMG,kBAAkB,CAAGC,aAAa,CAAC,CACvCC,eAAe,CAAEC,UAAU,CAC3BC,SAAS,CAAE,CACTC,IAAI,CAAG,CAAS3E,OAAAA,EAAAA,SAAS,CAACkE,UAAU,CAAC,CAACU,KAAK,EAAG,CAAA,CAAC,CAC/CC,MAAM,CAAE,CACNC,OAAO,CAAAC,MAAA,CAAAC,MAAA,CACFZ,EAAAA,CAAAA,iBAAiB,CACrB,CACDa,MAAM,CAAAF,MAAA,CAAAC,MAAA,CAAA,EAAA,CACDX,gBAAgB,CAEvB,CACF,CACF,CAAC,CAAC,CAEF,OAAO,CAAEa,KAAK,CAAEZ,kBAAkB,CAAE3C,WAAW,CAAEwC,oBAAqB,CAAC,CACzE;;;;"}
|
|
@@ -102,6 +102,15 @@ var ListViewFilters = function ListViewFilters(_ref4) {
|
|
|
102
102
|
var _useTheme = useTheme(),
|
|
103
103
|
theme = _useTheme.theme;
|
|
104
104
|
var showSearchInput = onSearchChange || onSearchClear || searchValuePlaceholder || searchName;
|
|
105
|
+
var getFilterContainerWidth = function getFilterContainerWidth() {
|
|
106
|
+
if (isMobile && Boolean(children)) {
|
|
107
|
+
return '88%';
|
|
108
|
+
}
|
|
109
|
+
if (isMobile && !Boolean(children)) {
|
|
110
|
+
return '100%';
|
|
111
|
+
}
|
|
112
|
+
return 'auto';
|
|
113
|
+
};
|
|
105
114
|
return /*#__PURE__*/jsxs(ListViewFiltersProvider, {
|
|
106
115
|
value: {
|
|
107
116
|
listViewSelectedFilters: listViewSelectedFilters,
|
|
@@ -133,14 +142,14 @@ var ListViewFilters = function ListViewFilters(_ref4) {
|
|
|
133
142
|
position: "relative",
|
|
134
143
|
display: "flex",
|
|
135
144
|
flexDirection: "column",
|
|
136
|
-
width:
|
|
145
|
+
width: getFilterContainerWidth(),
|
|
137
146
|
marginRight: isMobile ? 'spacing.2' : 'spacing.0',
|
|
138
147
|
children: [/*#__PURE__*/jsx(StyledQuickFilterContainer, {
|
|
139
148
|
overflow: isMobile ? 'scroll' : 'visible',
|
|
140
149
|
width: isMobile ? '100%' : 'auto',
|
|
141
150
|
ref: function ref(node) {
|
|
142
151
|
if (node instanceof HTMLElement && quickFilters) {
|
|
143
|
-
setShouldShowDecorationInQuickFilters(node.scrollWidth > node.offsetWidth);
|
|
152
|
+
setShouldShowDecorationInQuickFilters(node.scrollWidth > node.offsetWidth && Boolean(children));
|
|
144
153
|
}
|
|
145
154
|
},
|
|
146
155
|
paddingY: "spacing.4",
|
|
@@ -164,7 +173,7 @@ var ListViewFilters = function ListViewFilters(_ref4) {
|
|
|
164
173
|
display: "flex",
|
|
165
174
|
gap: "spacing.4",
|
|
166
175
|
alignItems: "center",
|
|
167
|
-
children: [/*#__PURE__*/jsxs(Box, {
|
|
176
|
+
children: [children ? /*#__PURE__*/jsxs(Box, {
|
|
168
177
|
position: "relative",
|
|
169
178
|
display: "inline-block",
|
|
170
179
|
children: [/*#__PURE__*/jsx(Button, {
|
|
@@ -190,7 +199,7 @@ var ListViewFilters = function ListViewFilters(_ref4) {
|
|
|
190
199
|
size: "small"
|
|
191
200
|
})
|
|
192
201
|
})]
|
|
193
|
-
}), !isMobile && showSearchInput && /*#__PURE__*/jsx(Box, {
|
|
202
|
+
}) : null, !isMobile && showSearchInput && /*#__PURE__*/jsx(Box, {
|
|
194
203
|
width: "256px",
|
|
195
204
|
children: /*#__PURE__*/jsx(SearchInput, {
|
|
196
205
|
label: "",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListViewFilters.web.js","sources":["../../../../../../src/components/ListView/ListViewFilters.web.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { AnimatePresence, m } from 'framer-motion';\nimport styled from 'styled-components';\nimport type { ListViewFilterProps, ListViewSelectedFiltersType } from './types';\nimport { ListViewFiltersProvider } from './ListViewFiltersContext.web';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\nimport BaseBox from '~components/Box/BaseBox';\nimport { MetaConstants, metaAttribute } from '~utils/metaAttribute';\nimport { FilterIcon } from '~components/Icons';\nimport { Button } from '~components/Button';\nimport { Counter } from '~components/Counter';\nimport { Box } from '~components/Box';\nimport { SearchInput } from '~components/Input/SearchInput';\nimport { useId } from '~utils/useId';\nimport { useControllableState } from '~utils/useControllable';\nimport { useIsMobile } from '~utils/useIsMobile';\nimport { msToSeconds } from '~utils/msToSeconds';\nimport { useTheme } from '~components/BladeProvider';\nimport { cssBezierToArray } from '~utils/cssBezierToArray';\nimport { castWebType } from '~utils';\nimport { Divider } from '~components/Divider';\n\nconst gradientOverlyContainerWidth = '21px'; // 20px + 1px divider width\nconst gradientOverlyContainerHeight = '38px';\n\nconst StyledQuickFilterContainer = styled(BaseBox)({\n /* For Webkit (Chrome, Safari) */\n '::-webkit-scrollbar': {\n display: 'none',\n },\n /* For Firefox */\n scrollbarWidth: 'none',\n /* For Edge */\n msOverflowStyle: 'none',\n});\n\nconst GradientOverlay = styled.div<{\n gradientColorLeft: string;\n dividerColor: string;\n gradientColorRight: string;\n}>`\n height: 100%;\n width: 20px;\n background: linear-gradient(\n 270deg,\n ${({ gradientColorRight }) => gradientColorRight} 0%,\n ${({ gradientColorLeft }) => gradientColorLeft} 100%\n );\n pointer-events: none;\n &::after {\n content: '';\n position: absolute;\n right: 0;\n top: 0;\n height: 100%;\n width: 1px;\n background-color: ${({ dividerColor }) => dividerColor};\n }\n`;\n\nconst ListViewFilters = ({\n testID,\n children,\n quickFilters,\n onSearchChange,\n searchValue,\n searchValuePlaceholder,\n searchName,\n showQuickFilters,\n onShowQuickFiltersChange,\n onSearchClear,\n selectedFiltersCount = 0,\n ...rest\n}: ListViewFilterProps): React.ReactElement => {\n const [shouldShowDecorationInQuickFilters, setShouldShowDecorationInQuickFilters] = useState(\n false,\n );\n const [showFilters, setShowFilters] = useControllableState({\n defaultValue: showQuickFilters,\n value: showQuickFilters,\n onChange: onShowQuickFiltersChange,\n });\n const [\n listViewSelectedFilters,\n setListViewSelectedFilters,\n ] = useState<ListViewSelectedFiltersType>({});\n const searchId = useId('search-input');\n const searchNameValue = searchName || searchId;\n const isMobile = useIsMobile();\n const { theme } = useTheme();\n const showSearchInput = onSearchChange || onSearchClear || searchValuePlaceholder || searchName;\n\n return (\n <ListViewFiltersProvider\n value={{\n listViewSelectedFilters,\n setListViewSelectedFilters,\n selectedFiltersCount,\n }}\n >\n {isMobile && showSearchInput && (\n <SearchInput\n label=\"\"\n value={searchValue}\n placeholder={searchValuePlaceholder}\n name={searchNameValue || searchId}\n onChange={({ name, value }) => onSearchChange?.({ name, value })}\n onClearButtonClick={onSearchClear}\n />\n )}\n <BaseBox>\n <BaseBox\n {...metaAttribute({ name: MetaConstants.ListViewFilter, testID })}\n {...makeAnalyticsAttribute(rest)}\n display=\"flex\"\n justifyContent=\"space-between\"\n >\n <Box\n position=\"relative\"\n display=\"flex\"\n flexDirection=\"column\"\n width={isMobile ? '88%' : 'auto'}\n marginRight={isMobile ? 'spacing.2' : 'spacing.0'}\n >\n <StyledQuickFilterContainer\n overflow={isMobile ? 'scroll' : 'visible'}\n width={isMobile ? '100%' : 'auto'}\n ref={(node) => {\n if (node instanceof HTMLElement && quickFilters) {\n setShouldShowDecorationInQuickFilters(node.scrollWidth > node.offsetWidth);\n }\n }}\n paddingY=\"spacing.4\"\n paddingLeft={isMobile ? 'spacing.2' : 'spacing.0'}\n >\n {quickFilters}\n </StyledQuickFilterContainer>\n {isMobile && shouldShowDecorationInQuickFilters ? (\n <Box\n position=\"absolute\"\n right=\"-1px\"\n top=\"spacing.4\"\n width={gradientOverlyContainerWidth}\n height={gradientOverlyContainerHeight}\n >\n <GradientOverlay\n gradientColorLeft={theme.colors.transparent}\n gradientColorRight={theme.colors.surface.background.gray.intense}\n dividerColor={theme.colors.surface.border.gray.normal}\n />\n <Divider orientation=\"vertical\" />\n </Box>\n ) : null}\n </Box>\n\n <BaseBox display=\"flex\" gap=\"spacing.4\" alignItems=\"center\">\n <Box position=\"relative\" display=\"inline-block\">\n <Button\n variant=\"tertiary\"\n size=\"medium\"\n color=\"primary\"\n onClick={() => {\n setShowFilters((prev) => !prev);\n }}\n icon={FilterIcon}\n accessibilityLabel=\"Show More Filters\"\n />\n <Box\n position=\"absolute\"\n right=\"spacing.0\"\n top=\"spacing.0\"\n transform=\"translate(50%, -50%)\"\n >\n <Counter\n value={selectedFiltersCount || Object.keys(listViewSelectedFilters).length}\n color=\"primary\"\n emphasis=\"intense\"\n size=\"small\"\n />\n </Box>\n </Box>\n {!isMobile && showSearchInput && (\n <Box width=\"256px\">\n <SearchInput\n label=\"\"\n value={searchValue}\n placeholder={searchValuePlaceholder}\n name={searchNameValue || searchId}\n onChange={({ name, value }) => onSearchChange?.({ name, value })}\n onClearButtonClick={onSearchClear}\n size=\"medium\"\n />\n </Box>\n )}\n </BaseBox>\n </BaseBox>\n <AnimatePresence>\n {showFilters && (\n <m.div\n initial={{ height: 0 }}\n animate={{ height: showFilters ? 'auto' : 0 }}\n transition={{\n duration: msToSeconds(theme.motion.duration.moderate),\n ease: cssBezierToArray(castWebType(theme.motion.easing.standard)),\n }}\n exit={{ height: 0 }}\n >\n <BaseBox\n display=\"flex\"\n backgroundColor={\n isMobile ? 'surface.background.white' : 'surface.background.gray.moderate'\n }\n borderTop={!isMobile ? '1ps solid' : undefined}\n borderTopColor={!isMobile ? 'surface.border.gray.muted' : undefined}\n >\n {children}\n </BaseBox>\n </m.div>\n )}\n </AnimatePresence>\n </BaseBox>\n </ListViewFiltersProvider>\n );\n};\n\nexport { ListViewFilters };\n"],"names":["gradientOverlyContainerWidth","gradientOverlyContainerHeight","StyledQuickFilterContainer","styled","BaseBox","withConfig","displayName","componentId","display","scrollbarWidth","msOverflowStyle","GradientOverlay","div","_ref","gradientColorRight","_ref2","gradientColorLeft","_ref3","dividerColor","ListViewFilters","_ref4","testID","children","quickFilters","onSearchChange","searchValue","searchValuePlaceholder","searchName","showQuickFilters","onShowQuickFiltersChange","onSearchClear","_ref4$selectedFilters","selectedFiltersCount","rest","_objectWithoutProperties","_excluded","_useState","useState","_useState2","_slicedToArray","shouldShowDecorationInQuickFilters","setShouldShowDecorationInQuickFilters","_useControllableState","useControllableState","defaultValue","value","onChange","_useControllableState2","showFilters","setShowFilters","_useState3","_useState4","listViewSelectedFilters","setListViewSelectedFilters","searchId","useId","searchNameValue","isMobile","useIsMobile","_useTheme","useTheme","theme","showSearchInput","_jsxs","ListViewFiltersProvider","_jsx","SearchInput","label","placeholder","name","_ref5","onClearButtonClick","_objectSpread","metaAttribute","MetaConstants","ListViewFilter","makeAnalyticsAttribute","justifyContent","Box","position","flexDirection","width","marginRight","overflow","ref","node","HTMLElement","scrollWidth","offsetWidth","paddingY","paddingLeft","right","top","height","colors","transparent","surface","background","gray","intense","border","normal","Divider","orientation","gap","alignItems","Button","variant","size","color","onClick","prev","icon","FilterIcon","accessibilityLabel","transform","Counter","Object","keys","length","emphasis","_ref6","AnimatePresence","m","initial","animate","transition","duration","msToSeconds","motion","moderate","ease","cssBezierToArray","castWebType","easing","standard","exit","backgroundColor","borderTop","undefined","borderTopColor"],"mapp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A;eAAC;AACjE0B,cAAAA,kBAAkB,EAAEzC,aAAc;AAClC8E,cAAAA,IAAI,EAAC,QAAA;aACN,CAAA;AAAC,WACC,CACN,CAAA;AAAA,SACM,CAAC,CAAA;AAAA,OAAA,CACH,CAAC,eACV3C,GAAA,CAACyD,eAAe,EAAA;AAAApG,QAAAA,QAAA,EACb0B,WAAW,iBACViB,GAAA,CAAC0D,CAAC,CAAC/G,GAAG,EAAA;AACJgH,UAAAA,OAAO,EAAE;AAAE/B,YAAAA,MAAM,EAAE,CAAA;WAAI;AACvBgC,UAAAA,OAAO,EAAE;AAAEhC,YAAAA,MAAM,EAAE7C,WAAW,GAAG,MAAM,GAAG,CAAA;WAAI;AAC9C8E,UAAAA,UAAU,EAAE;YACVC,QAAQ,EAAEC,WAAW,CAACnE,KAAK,CAACoE,MAAM,CAACF,QAAQ,CAACG,QAAQ,CAAC;AACrDC,YAAAA,IAAI,EAAEC,gBAAgB,CAACC,WAAW,CAACxE,KAAK,CAACoE,MAAM,CAACK,MAAM,CAACC,QAAQ,CAAC,CAAA;WAChE;AACFC,UAAAA,IAAI,EAAE;AAAE3C,YAAAA,MAAM,EAAE,CAAA;WAAI;UAAAvE,QAAA,eAEpB2C,GAAA,CAAC7D,OAAO,EAAA;AACNI,YAAAA,OAAO,EAAC,MAAM;AACdiI,YAAAA,eAAe,EACbhF,QAAQ,GAAG,0BAA0B,GAAG,kCACzC;AACDiF,YAAAA,SAAS,EAAE,CAACjF,QAAQ,GAAG,WAAW,GAAGkF,SAAU;AAC/CC,YAAAA,cAAc,EAAE,CAACnF,QAAQ,GAAG,2BAA2B,GAAGkF,SAAU;AAAArH,YAAAA,QAAA,EAEnEA,QAAAA;WACM,CAAA;SACJ,CAAA;AACR,OACc,CAAC,CAAA;AAAA,KACX,CAAC,CAAA;AAAA,GACa,CAAC,CAAA;AAE9B;;;;"}
|
|
1
|
+
{"version":3,"file":"ListViewFilters.web.js","sources":["../../../../../../src/components/ListView/ListViewFilters.web.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { AnimatePresence, m } from 'framer-motion';\nimport styled from 'styled-components';\nimport type { ListViewFilterProps, ListViewSelectedFiltersType } from './types';\nimport { ListViewFiltersProvider } from './ListViewFiltersContext.web';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\nimport BaseBox from '~components/Box/BaseBox';\nimport { MetaConstants, metaAttribute } from '~utils/metaAttribute';\nimport { FilterIcon } from '~components/Icons';\nimport { Button } from '~components/Button';\nimport { Counter } from '~components/Counter';\nimport type { BoxProps } from '~components/Box';\nimport { Box } from '~components/Box';\nimport { SearchInput } from '~components/Input/SearchInput';\nimport { useId } from '~utils/useId';\nimport { useControllableState } from '~utils/useControllable';\nimport { useIsMobile } from '~utils/useIsMobile';\nimport { msToSeconds } from '~utils/msToSeconds';\nimport { useTheme } from '~components/BladeProvider';\nimport { cssBezierToArray } from '~utils/cssBezierToArray';\nimport { castWebType } from '~utils';\nimport { Divider } from '~components/Divider';\n\nconst gradientOverlyContainerWidth = '21px'; // 20px + 1px divider width\nconst gradientOverlyContainerHeight = '38px';\n\nconst StyledQuickFilterContainer = styled(BaseBox)({\n /* For Webkit (Chrome, Safari) */\n '::-webkit-scrollbar': {\n display: 'none',\n },\n /* For Firefox */\n scrollbarWidth: 'none',\n /* For Edge */\n msOverflowStyle: 'none',\n});\n\nconst GradientOverlay = styled.div<{\n gradientColorLeft: string;\n dividerColor: string;\n gradientColorRight: string;\n}>`\n height: 100%;\n width: 20px;\n background: linear-gradient(\n 270deg,\n ${({ gradientColorRight }) => gradientColorRight} 0%,\n ${({ gradientColorLeft }) => gradientColorLeft} 100%\n );\n pointer-events: none;\n &::after {\n content: '';\n position: absolute;\n right: 0;\n top: 0;\n height: 100%;\n width: 1px;\n background-color: ${({ dividerColor }) => dividerColor};\n }\n`;\n\nconst ListViewFilters = ({\n testID,\n children,\n quickFilters,\n onSearchChange,\n searchValue,\n searchValuePlaceholder,\n searchName,\n showQuickFilters,\n onShowQuickFiltersChange,\n onSearchClear,\n selectedFiltersCount = 0,\n ...rest\n}: ListViewFilterProps): React.ReactElement => {\n const [shouldShowDecorationInQuickFilters, setShouldShowDecorationInQuickFilters] = useState(\n false,\n );\n const [showFilters, setShowFilters] = useControllableState({\n defaultValue: showQuickFilters,\n value: showQuickFilters,\n onChange: onShowQuickFiltersChange,\n });\n const [\n listViewSelectedFilters,\n setListViewSelectedFilters,\n ] = useState<ListViewSelectedFiltersType>({});\n const searchId = useId('search-input');\n const searchNameValue = searchName || searchId;\n const isMobile = useIsMobile();\n const { theme } = useTheme();\n const showSearchInput = onSearchChange || onSearchClear || searchValuePlaceholder || searchName;\n const getFilterContainerWidth = (): BoxProps['width'] => {\n if (isMobile && Boolean(children)) {\n return '88%';\n }\n if (isMobile && !Boolean(children)) {\n return '100%';\n }\n return 'auto';\n };\n\n return (\n <ListViewFiltersProvider\n value={{\n listViewSelectedFilters,\n setListViewSelectedFilters,\n selectedFiltersCount,\n }}\n >\n {isMobile && showSearchInput && (\n <SearchInput\n label=\"\"\n value={searchValue}\n placeholder={searchValuePlaceholder}\n name={searchNameValue || searchId}\n onChange={({ name, value }) => onSearchChange?.({ name, value })}\n onClearButtonClick={onSearchClear}\n />\n )}\n <BaseBox>\n <BaseBox\n {...metaAttribute({ name: MetaConstants.ListViewFilter, testID })}\n {...makeAnalyticsAttribute(rest)}\n display=\"flex\"\n justifyContent=\"space-between\"\n >\n <Box\n position=\"relative\"\n display=\"flex\"\n flexDirection=\"column\"\n width={getFilterContainerWidth()}\n marginRight={isMobile ? 'spacing.2' : 'spacing.0'}\n >\n <StyledQuickFilterContainer\n overflow={isMobile ? 'scroll' : 'visible'}\n width={isMobile ? '100%' : 'auto'}\n ref={(node) => {\n if (node instanceof HTMLElement && quickFilters) {\n setShouldShowDecorationInQuickFilters(\n node.scrollWidth > node.offsetWidth && Boolean(children),\n );\n }\n }}\n paddingY=\"spacing.4\"\n paddingLeft={isMobile ? 'spacing.2' : 'spacing.0'}\n >\n {quickFilters}\n </StyledQuickFilterContainer>\n {isMobile && shouldShowDecorationInQuickFilters ? (\n <Box\n position=\"absolute\"\n right=\"-1px\"\n top=\"spacing.4\"\n width={gradientOverlyContainerWidth}\n height={gradientOverlyContainerHeight}\n >\n <GradientOverlay\n gradientColorLeft={theme.colors.transparent}\n gradientColorRight={theme.colors.surface.background.gray.intense}\n dividerColor={theme.colors.surface.border.gray.normal}\n />\n <Divider orientation=\"vertical\" />\n </Box>\n ) : null}\n </Box>\n\n <BaseBox display=\"flex\" gap=\"spacing.4\" alignItems=\"center\">\n {children ? (\n <Box position=\"relative\" display=\"inline-block\">\n <Button\n variant=\"tertiary\"\n size=\"medium\"\n color=\"primary\"\n onClick={() => {\n setShowFilters((prev) => !prev);\n }}\n icon={FilterIcon}\n accessibilityLabel=\"Show More Filters\"\n />\n\n <Box\n position=\"absolute\"\n right=\"spacing.0\"\n top=\"spacing.0\"\n transform=\"translate(50%, -50%)\"\n >\n <Counter\n value={selectedFiltersCount || Object.keys(listViewSelectedFilters).length}\n color=\"primary\"\n emphasis=\"intense\"\n size=\"small\"\n />\n </Box>\n </Box>\n ) : null}\n {!isMobile && showSearchInput && (\n <Box width=\"256px\">\n <SearchInput\n label=\"\"\n value={searchValue}\n placeholder={searchValuePlaceholder}\n name={searchNameValue || searchId}\n onChange={({ name, value }) => onSearchChange?.({ name, value })}\n onClearButtonClick={onSearchClear}\n size=\"medium\"\n />\n </Box>\n )}\n </BaseBox>\n </BaseBox>\n <AnimatePresence>\n {showFilters && (\n <m.div\n initial={{ height: 0 }}\n animate={{ height: showFilters ? 'auto' : 0 }}\n transition={{\n duration: msToSeconds(theme.motion.duration.moderate),\n ease: cssBezierToArray(castWebType(theme.motion.easing.standard)),\n }}\n exit={{ height: 0 }}\n >\n <BaseBox\n display=\"flex\"\n backgroundColor={\n isMobile ? 'surface.background.white' : 'surface.background.gray.moderate'\n }\n borderTop={!isMobile ? '1ps solid' : undefined}\n borderTopColor={!isMobile ? 'surface.border.gray.muted' : undefined}\n >\n {children}\n </BaseBox>\n </m.div>\n )}\n </AnimatePresence>\n </BaseBox>\n </ListViewFiltersProvider>\n );\n};\n\nexport { ListViewFilters };\n"],"names":["gradientOverlyContainerWidth","gradientOverlyContainerHeight","StyledQuickFilterContainer","styled","BaseBox","withConfig","displayName","componentId","display","scrollbarWidth","msOverflowStyle","GradientOverlay","div","_ref","gradientColorRight","_ref2","gradientColorLeft","_ref3","dividerColor","ListViewFilters","_ref4","testID","children","quickFilters","onSearchChange","searchValue","searchValuePlaceholder","searchName","showQuickFilters","onShowQuickFiltersChange","onSearchClear","_ref4$selectedFilters","selectedFiltersCount","rest","_objectWithoutProperties","_excluded","_useState","useState","_useState2","_slicedToArray","shouldShowDecorationInQuickFilters","setShouldShowDecorationInQuickFilters","_useControllableState","useControllableState","defaultValue","value","onChange","_useControllableState2","showFilters","setShowFilters","_useState3","_useState4","listViewSelectedFilters","setListViewSelectedFilters","searchId","useId","searchNameValue","isMobile","useIsMobile","_useTheme","useTheme","theme","showSearchInput","getFilterContainerWidth","Boolean","_jsxs","ListViewFiltersProvider","_jsx","SearchInput","label","placeholder","name","_ref5","onClearButtonClick","_objectSpread","metaAttribute","MetaConstants","ListViewFilter","makeAnalyticsAttribute","justifyContent","Box","position","flexDirection","width","marginRight","overflow","ref","node","HTMLElement","scrollWidth","offsetWidth","paddingY","paddingLeft","right","top","height","colors","transparent","surface","background","gray","intense","border","normal","Divider","orientation","gap","alignItems","Button","variant","size","color","onClick","prev","icon","FilterIcon","accessibilityLabel","transform","Counter","Object","keys","length","emphasis","_ref6","AnimatePresence","m","initial","animate","transition","duration","msToSeconds","motion","moderate","ease","cssBezierToArray","castWebType","easing","standard","exit","backgroundColor","borderTop","undefined","borderTopColor"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,IAAMA,4BAA4B,GAAG,MAAM,CAAC;AAC5C,IAAMC,6BAA6B,GAAG,MAAM,CAAA;AAE5C,IAAMC,0BA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,SAAU;AAAAvH,YAAAA,QAAA,EAEnEA,QAAAA;WACM,CAAA;SACJ,CAAA;AACR,OACc,CAAC,CAAA;AAAA,KACX,CAAC,CAAA;AAAA,GACa,CAAC,CAAA;AAE9B;;;;"}
|
|
@@ -158,6 +158,12 @@ var getOnLightOverrides = function getOnLightOverrides(brandColors) {
|
|
|
158
158
|
subtle: brandColors[200]
|
|
159
159
|
}
|
|
160
160
|
},
|
|
161
|
+
border: {
|
|
162
|
+
primary: {
|
|
163
|
+
normal: brandColors[600],
|
|
164
|
+
muted: brandColors.a200
|
|
165
|
+
}
|
|
166
|
+
},
|
|
161
167
|
icon: {
|
|
162
168
|
primary: {
|
|
163
169
|
normal: brandColors[600]
|
|
@@ -241,6 +247,12 @@ var getOnDarkOverrides = function getOnDarkOverrides(brandColors) {
|
|
|
241
247
|
subtle: brandColors[200]
|
|
242
248
|
}
|
|
243
249
|
},
|
|
250
|
+
border: {
|
|
251
|
+
primary: {
|
|
252
|
+
normal: brandColors[600],
|
|
253
|
+
muted: brandColors.a200
|
|
254
|
+
}
|
|
255
|
+
},
|
|
244
256
|
icon: {
|
|
245
257
|
primary: {
|
|
246
258
|
normal: brandColors[600]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTheme.js","sources":["../../../../../../src/tokens/theme/createTheme.ts"],"sourcesContent":["import tinycolor from 'tinycolor2';\nimport type { WCAG2Options, ColorInput } from 'tinycolor2';\nimport type { ThemeTokens } from './theme';\nimport overrideTheme from './overrideTheme';\nimport bladeTheme from './bladeTheme';\nimport { colors as globalColors, opacity } from '~tokens/global';\nimport type { ColorChromaticScale } from '~tokens/global/colors';\nimport { throwBladeError } from '~utils/logger';\nimport type { DeepPartial } from '~utils/isPartialMatchObjectKeys';\n\n// WCAG2ContrastOptions are the options used to determine if a color is readable\nconst WCAG2ContrastOptions: WCAG2Options = {\n level: 'AAA',\n size: 'large',\n};\n\n/**\n * getColorWithOpacity\n * @param color - The color to add opacity to\n * @param opacity - The opacity to add to the color\n * @returns The color with the opacity added\n * @example\n * getColorWithOpacity('#fff', 0.5) // returns 'hsla(0, 0%, 100%, 0.5)'\n *\n **/\nconst getColorWithOpacity = (color: ColorInput, opacity: number): string => {\n return tinycolor(color).setAlpha(opacity).toHslString();\n};\n\n/**\n *\n * @description\n * Generates a chromatic color palette based on the base color passed in.\n * The base color is used to generate a palette of 11 colors, 5 shades lighter and 5 shades darker than the base color.\n * @param baseColorInput - The base color to generate the chromatic color palette from in hex, rgb, or hsl format\n * @returns Array of chromatic color palette\n */\nconst generateChromaticBrandColors = (baseColorInput: ColorInput): ColorChromaticScale => {\n const baseColor = tinycolor(baseColorInput);\n const baseColorHslString = baseColor.toHslString();\n if (__DEV__) {\n if (!baseColor.isValid()) {\n throwBladeError({\n message: 'Invalid brandColor passed',\n moduleName: 'createTheme',\n });\n }\n }\n\n const palette = [baseColorHslString]; // Include the original color\n const brightness = tinycolor(baseColor).getBrightness();\n // Determine how much to lighten or darken the colors depending on the brightness of the base color\n const lightnessFactor = brightness > 150 ? 3 : 6;\n const darknessFactor = brightness < 50 ? 3 : 5;\n\n let currentColor = baseColor;\n\n // Generate shades lighter\n for (let lightShadeIndex = 0; lightShadeIndex < 6; lightShadeIndex++) {\n currentColor = currentColor.brighten(lightnessFactor);\n palette.push(currentColor.toHslString());\n }\n\n currentColor = tinycolor(baseColorHslString); // Reset to the base color\n\n // Generate shades darker\n for (let darkShadeIndex = 0; darkShadeIndex < 4; darkShadeIndex++) {\n currentColor = currentColor.darken(darknessFactor);\n palette.unshift(currentColor.toHslString()); // Add shades at the beginning of the palette\n }\n\n const colorPalette = palette.reverse();\n const brandPrimaryColor = colorPalette[6];\n\n const brandColors: ColorChromaticScale = {\n '50': colorPalette[0],\n '100': colorPalette[1],\n '200': colorPalette[2],\n '300': colorPalette[3],\n '400': colorPalette[4],\n '500': colorPalette[5],\n '600': brandPrimaryColor,\n '700': colorPalette[7],\n '800': colorPalette[8],\n '900': colorPalette[9],\n '1000': colorPalette[10],\n a50: getColorWithOpacity(brandPrimaryColor, opacity[100]),\n a150: getColorWithOpacity(brandPrimaryColor, opacity[100]),\n a100: getColorWithOpacity(brandPrimaryColor, opacity[200]),\n a200: getColorWithOpacity(brandPrimaryColor, opacity[300]),\n a400: getColorWithOpacity(brandPrimaryColor, opacity[400]),\n };\n\n return brandColors;\n};\n\n/**\n *\n * @param brandColors - The brand colors to use to override the light theme\n * @description Returns overrides for the light theme with the brand colors passed in\n * @returns Overrides for the light theme with the custom brand colors\n */\nconst getOnLightOverrides = (\n brandColors: ColorChromaticScale,\n): DeepPartial<ThemeTokens['colors']['onLight']> => {\n // Select the most readable color to use as the foreground color on top of surface color\n // For example: On Secondary Button where the background color is surface color, the text color should be either the brand color or dark color depending on which is more readable on top of that surface color\n const foregroundOnSurface = tinycolor.isReadable(\n globalColors.neutral.blueGrayLight[50],\n brandColors[600],\n WCAG2ContrastOptions,\n )\n ? brandColors[600]\n : globalColors.neutral.blueGrayLight[1100];\n\n const foregroundOnBrand = tinycolor\n .mostReadable(\n brandColors[900],\n [globalColors.neutral.white[500], globalColors.neutral.black[500]],\n WCAG2ContrastOptions,\n )\n .toHslString();\n\n // Overrides for the light theme with the brand colors passed in\n const lightThemeOverrides: DeepPartial<ThemeTokens['colors']['onLight']> = {\n interactive: {\n background: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n fadedHighlighted: brandColors.a150,\n },\n },\n border: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n },\n },\n text: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a200,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n icon: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a200,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n },\n surface: {\n background: {\n primary: {\n intense: brandColors[600],\n subtle: brandColors[200],\n },\n },\n icon: {\n primary: {\n normal: brandColors[600],\n },\n },\n text: {\n primary: {\n normal: brandColors[600],\n },\n },\n },\n };\n\n return lightThemeOverrides;\n};\n\n/**\n *\n * @param brandColors - The brand colors to use to override the dark theme\n * @description Returns overrides for the dark theme with the brand colors passed in\n * @returns Overrides for the dark theme with the custom brand colors\n */\nconst getOnDarkOverrides = (\n brandColors: ColorChromaticScale,\n): DeepPartial<ThemeTokens['colors']['onDark']> => {\n // Select the most readable color to use as the foreground color on top of surface color\n // For example: On Secondary Button where the background color is surface color, the text color should be either the brand color or dark color depending on which is more readable on top of that surface color\n const foregroundOnSurface = tinycolor.isReadable(\n globalColors.neutral.blueGrayDark[1100],\n brandColors[400],\n WCAG2ContrastOptions,\n )\n ? brandColors[400]\n : globalColors.neutral.blueGrayDark[0];\n\n const foregroundOnBrand = tinycolor\n .mostReadable(\n brandColors[900],\n [globalColors.neutral.white[500], globalColors.neutral.black[500]],\n WCAG2ContrastOptions,\n )\n .toHslString();\n\n // Overrides for the dark theme with the brand colors passed in\n const darkThemeOverrides: DeepPartial<ThemeTokens['colors']['onDark']> = {\n interactive: {\n background: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n fadedHighlighted: brandColors.a150,\n },\n },\n border: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n },\n },\n text: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a400,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n icon: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a400,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n },\n surface: {\n background: {\n primary: {\n intense: brandColors[600],\n subtle: brandColors[200],\n },\n },\n icon: {\n primary: {\n normal: brandColors[600],\n },\n },\n },\n };\n\n return darkThemeOverrides;\n};\n\n/**\n * @param {Object} themeConfig - The brand color and overrides to apply to the theme\n * @param {string} themeConfig.brandColor - The brand color to use to generate the theme. Can be in hex, rgb, or hsl format.\n * @description\n * Creates a Blade Theme based on the custom brand color\n * @returns The Theme Tokens with the custom brand colors\n * @example\n * const { theme, brandColors } = createTheme({ brandColor: '#19BEA2'})\n **/\nexport const createTheme = ({\n brandColor,\n}: {\n brandColor: ColorInput;\n}): { theme: ThemeTokens; brandColors: ColorChromaticScale } => {\n const chromaticBrandColors = generateChromaticBrandColors(brandColor);\n // Get onLight overrides\n const brandedLightTheme = getOnLightOverrides(chromaticBrandColors);\n // Get onDark overrides\n const brandedDarkTheme = getOnDarkOverrides(chromaticBrandColors);\n // Override the payment theme with the brand colors\n const brandedThemeTokens = overrideTheme({\n baseThemeTokens: bladeTheme,\n overrides: {\n name: `custom-${tinycolor(brandColor).toHex()}`,\n colors: {\n onLight: {\n ...brandedLightTheme,\n },\n onDark: {\n ...brandedDarkTheme,\n },\n },\n },\n });\n\n return { theme: brandedThemeTokens, brandColors: chromaticBrandColors };\n};\n"],"names":["WCAG2ContrastOptions","level","size","getColorWithOpacity","color","opacity","tinycolor","setAlpha","toHslString","generateChromaticBrandColors","baseColorInput","baseColor","baseColorHslString","isValid","throwBladeError","message","moduleName","palette","brightness","getBrightness","lightnessFactor","darknessFactor","currentColor","lightShadeIndex","brighten","push","darkShadeIndex","darken","unshift","colorPalette","reverse","brandPrimaryColor","brandColors","a50","a150","a100","a200","a400","getOnLightOverrides","foregroundOnSurface","isReadable","globalColors","neutral","blueGrayLight","foregroundOnBrand","mostReadable","white","black","lightThemeOverrides","interactive","background","primary","highlighted","disabled","faded","fadedHighlighted","border","text","normal","muted","subtle","onPrimary","icon","surface","intense","getOnDarkOverrides","blueGrayDark","darkThemeOverrides","createTheme","_ref","brandColor","chromaticBrandColors","brandedLightTheme","brandedDarkTheme","brandedThemeTokens","overrideTheme","baseThemeTokens","bladeTheme","overrides","name","concat","toHex","colors","onLight","_objectSpread","onDark","theme"],"mappings":";;;;;;;;;;;;AAUA;AACA,IAAMA,oBAAkC,GAAG;AACzCC,EAAAA,KAAK,EAAE,KAAK;AACZC,EAAAA,IAAI,EAAE,OAAA;AACR,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAIC,KAAiB,EAAEC,OAAe,EAAa;AAC1E,EAAA,OAAOC,SAAS,CAACF,KAAK,CAAC,CAACG,QAAQ,CAACF,OAAO,CAAC,CAACG,WAAW,EAAE,CAAA;AACzD,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,4BAA4B,GAAG,SAA/BA,4BAA4BA,CAAIC,cAA0B,EAA0B;AACxF,EAAA,IAAMC,SAAS,GAAGL,SAAS,CAACI,cAAc,CAAC,CAAA;AAC3C,EAAA,IAAME,kBAAkB,GAAGD,SAAS,CAACH,WAAW,EAAE,CAAA;AAClD,EAAA,IAAI,IAAO,EAAE;AACX,IAAA,IAAI,CAACG,SAAS,CAACE,OAAO,EAAE,EAAE;AACxBC,MAAAA,eAAe,CAAC;AACdC,QAAAA,OAAO,EAAE,2BAA2B;AACpCC,QAAAA,UAAU,EAAE,aAAA;AACd,OAAC,CAAC,CAAA;AACJ,KAAA;AACF,GAAA;AAEA,EAAA,IAAMC,OAAO,GAAG,CAACL,kBAAkB,CAAC,CAAC;EACr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AAGC,aAAa,CAAC;AACvCC,IAAAA,eAAe,EAAEC,UAAU;AAC3BC,IAAAA,SAAS,EAAE;MACTC,IAAI,EAAA,SAAA,CAAAC,MAAA,CAAY1E,SAAS,CAACgE,UAAU,CAAC,CAACW,KAAK,EAAE,CAAE;AAC/CC,MAAAA,MAAM,EAAE;AACNC,QAAAA,OAAO,EAAAC,aAAA,CACFZ,EAAAA,EAAAA,iBAAiB,CACrB;QACDa,MAAM,EAAAD,aAAA,CAAA,EAAA,EACDX,gBAAgB,CAAA;AAEvB,OAAA;AACF,KAAA;AACF,GAAC,CAAC,CAAA;EAEF,OAAO;AAAEa,IAAAA,KAAK,EAAEZ,kBAAkB;AAAE1C,IAAAA,WAAW,EAAEuC,oBAAAA;GAAsB,CAAA;AACzE;;;;"}
|
|
1
|
+
{"version":3,"file":"createTheme.js","sources":["../../../../../../src/tokens/theme/createTheme.ts"],"sourcesContent":["import tinycolor from 'tinycolor2';\nimport type { WCAG2Options, ColorInput } from 'tinycolor2';\nimport type { ThemeTokens } from './theme';\nimport overrideTheme from './overrideTheme';\nimport bladeTheme from './bladeTheme';\nimport { colors as globalColors, opacity } from '~tokens/global';\nimport type { ColorChromaticScale } from '~tokens/global/colors';\nimport { throwBladeError } from '~utils/logger';\nimport type { DeepPartial } from '~utils/isPartialMatchObjectKeys';\n\n// WCAG2ContrastOptions are the options used to determine if a color is readable\nconst WCAG2ContrastOptions: WCAG2Options = {\n level: 'AAA',\n size: 'large',\n};\n\n/**\n * getColorWithOpacity\n * @param color - The color to add opacity to\n * @param opacity - The opacity to add to the color\n * @returns The color with the opacity added\n * @example\n * getColorWithOpacity('#fff', 0.5) // returns 'hsla(0, 0%, 100%, 0.5)'\n *\n **/\nconst getColorWithOpacity = (color: ColorInput, opacity: number): string => {\n return tinycolor(color).setAlpha(opacity).toHslString();\n};\n\n/**\n *\n * @description\n * Generates a chromatic color palette based on the base color passed in.\n * The base color is used to generate a palette of 11 colors, 5 shades lighter and 5 shades darker than the base color.\n * @param baseColorInput - The base color to generate the chromatic color palette from in hex, rgb, or hsl format\n * @returns Array of chromatic color palette\n */\nconst generateChromaticBrandColors = (baseColorInput: ColorInput): ColorChromaticScale => {\n const baseColor = tinycolor(baseColorInput);\n const baseColorHslString = baseColor.toHslString();\n if (__DEV__) {\n if (!baseColor.isValid()) {\n throwBladeError({\n message: 'Invalid brandColor passed',\n moduleName: 'createTheme',\n });\n }\n }\n\n const palette = [baseColorHslString]; // Include the original color\n const brightness = tinycolor(baseColor).getBrightness();\n // Determine how much to lighten or darken the colors depending on the brightness of the base color\n const lightnessFactor = brightness > 150 ? 3 : 6;\n const darknessFactor = brightness < 50 ? 3 : 5;\n\n let currentColor = baseColor;\n\n // Generate shades lighter\n for (let lightShadeIndex = 0; lightShadeIndex < 6; lightShadeIndex++) {\n currentColor = currentColor.brighten(lightnessFactor);\n palette.push(currentColor.toHslString());\n }\n\n currentColor = tinycolor(baseColorHslString); // Reset to the base color\n\n // Generate shades darker\n for (let darkShadeIndex = 0; darkShadeIndex < 4; darkShadeIndex++) {\n currentColor = currentColor.darken(darknessFactor);\n palette.unshift(currentColor.toHslString()); // Add shades at the beginning of the palette\n }\n\n const colorPalette = palette.reverse();\n const brandPrimaryColor = colorPalette[6];\n\n const brandColors: ColorChromaticScale = {\n '50': colorPalette[0],\n '100': colorPalette[1],\n '200': colorPalette[2],\n '300': colorPalette[3],\n '400': colorPalette[4],\n '500': colorPalette[5],\n '600': brandPrimaryColor,\n '700': colorPalette[7],\n '800': colorPalette[8],\n '900': colorPalette[9],\n '1000': colorPalette[10],\n a50: getColorWithOpacity(brandPrimaryColor, opacity[100]),\n a150: getColorWithOpacity(brandPrimaryColor, opacity[100]),\n a100: getColorWithOpacity(brandPrimaryColor, opacity[200]),\n a200: getColorWithOpacity(brandPrimaryColor, opacity[300]),\n a400: getColorWithOpacity(brandPrimaryColor, opacity[400]),\n };\n\n return brandColors;\n};\n\n/**\n *\n * @param brandColors - The brand colors to use to override the light theme\n * @description Returns overrides for the light theme with the brand colors passed in\n * @returns Overrides for the light theme with the custom brand colors\n */\nconst getOnLightOverrides = (\n brandColors: ColorChromaticScale,\n): DeepPartial<ThemeTokens['colors']['onLight']> => {\n // Select the most readable color to use as the foreground color on top of surface color\n // For example: On Secondary Button where the background color is surface color, the text color should be either the brand color or dark color depending on which is more readable on top of that surface color\n const foregroundOnSurface = tinycolor.isReadable(\n globalColors.neutral.blueGrayLight[50],\n brandColors[600],\n WCAG2ContrastOptions,\n )\n ? brandColors[600]\n : globalColors.neutral.blueGrayLight[1100];\n\n const foregroundOnBrand = tinycolor\n .mostReadable(\n brandColors[900],\n [globalColors.neutral.white[500], globalColors.neutral.black[500]],\n WCAG2ContrastOptions,\n )\n .toHslString();\n\n // Overrides for the light theme with the brand colors passed in\n const lightThemeOverrides: DeepPartial<ThemeTokens['colors']['onLight']> = {\n interactive: {\n background: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n fadedHighlighted: brandColors.a150,\n },\n },\n border: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n },\n },\n text: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a200,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n icon: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a200,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n },\n surface: {\n background: {\n primary: {\n intense: brandColors[600],\n subtle: brandColors[200],\n },\n },\n border: {\n primary: {\n normal: brandColors[600],\n muted: brandColors.a200,\n },\n },\n icon: {\n primary: {\n normal: brandColors[600],\n },\n },\n text: {\n primary: {\n normal: brandColors[600],\n },\n },\n },\n };\n\n return lightThemeOverrides;\n};\n\n/**\n *\n * @param brandColors - The brand colors to use to override the dark theme\n * @description Returns overrides for the dark theme with the brand colors passed in\n * @returns Overrides for the dark theme with the custom brand colors\n */\nconst getOnDarkOverrides = (\n brandColors: ColorChromaticScale,\n): DeepPartial<ThemeTokens['colors']['onDark']> => {\n // Select the most readable color to use as the foreground color on top of surface color\n // For example: On Secondary Button where the background color is surface color, the text color should be either the brand color or dark color depending on which is more readable on top of that surface color\n const foregroundOnSurface = tinycolor.isReadable(\n globalColors.neutral.blueGrayDark[1100],\n brandColors[400],\n WCAG2ContrastOptions,\n )\n ? brandColors[400]\n : globalColors.neutral.blueGrayDark[0];\n\n const foregroundOnBrand = tinycolor\n .mostReadable(\n brandColors[900],\n [globalColors.neutral.white[500], globalColors.neutral.black[500]],\n WCAG2ContrastOptions,\n )\n .toHslString();\n\n // Overrides for the dark theme with the brand colors passed in\n const darkThemeOverrides: DeepPartial<ThemeTokens['colors']['onDark']> = {\n interactive: {\n background: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n fadedHighlighted: brandColors.a150,\n },\n },\n border: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n },\n },\n text: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a400,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n icon: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a400,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n },\n surface: {\n background: {\n primary: {\n intense: brandColors[600],\n subtle: brandColors[200],\n },\n },\n border: {\n primary: {\n normal: brandColors[600],\n muted: brandColors.a200,\n },\n },\n icon: {\n primary: {\n normal: brandColors[600],\n },\n },\n },\n };\n\n return darkThemeOverrides;\n};\n\n/**\n * @param {Object} themeConfig - The brand color and overrides to apply to the theme\n * @param {string} themeConfig.brandColor - The brand color to use to generate the theme. Can be in hex, rgb, or hsl format.\n * @description\n * Creates a Blade Theme based on the custom brand color\n * @returns The Theme Tokens with the custom brand colors\n * @example\n * const { theme, brandColors } = createTheme({ brandColor: '#19BEA2'})\n **/\nexport const createTheme = ({\n brandColor,\n}: {\n brandColor: ColorInput;\n}): { theme: ThemeTokens; brandColors: ColorChromaticScale } => {\n const chromaticBrandColors = generateChromaticBrandColors(brandColor);\n // Get onLight overrides\n const brandedLightTheme = getOnLightOverrides(chromaticBrandColors);\n // Get onDark overrides\n const brandedDarkTheme = getOnDarkOverrides(chromaticBrandColors);\n // Override the payment theme with the brand colors\n const brandedThemeTokens = overrideTheme({\n baseThemeTokens: bladeTheme,\n overrides: {\n name: `custom-${tinycolor(brandColor).toHex()}`,\n colors: {\n onLight: {\n ...brandedLightTheme,\n },\n onDark: {\n ...brandedDarkTheme,\n },\n },\n },\n });\n\n return { theme: brandedThemeTokens, brandColors: chromaticBrandColors };\n};\n"],"names":["WCAG2ContrastOptions","level","size","getColorWithOpacity","color","opacity","tinycolor","setAlpha","toHslString","generateChromaticBrandColors","baseColorInput","baseColor","baseColorHslString","isValid","throwBladeError","message","moduleName","palette","brightness","getBrightness","lightnessFactor","darknessFactor","currentColor","lightShadeIndex","brighten","push","darkShadeIndex","darken","unshift","colorPalette","reverse","brandPrimaryColor","brandColors","a50","a150","a100","a200","a400","getOnLightOverrides","foregroundOnSurface","isReadable","globalColors","neutral","blueGrayLight","foregroundOnBrand","mostReadable","white","black","lightThemeOverrides","interactive","background","primary","highlighted","disabled","faded","fadedHighlighted","border","text","normal","muted","subtle","onPrimary","icon","surface","intense","getOnDarkOverrides","blueGrayDark","darkThemeOverrides","createTheme","_ref","brandColor","chromaticBrandColors","brandedLightTheme","brandedDarkTheme","brandedThemeTokens","overrideTheme","baseThemeTokens","bladeTheme","overrides","name","concat","toHex","colors","onLight","_objectSpread","onDark","theme"],"mappings":";;;;;;;;;;;;AAUA;AACA,IAAMA,oBAAkC,GAAG;AACzCC,EAAAA,KAAK,EAAE,KAAK;AACZC,EAAAA,IAAI,EAAE,OAAA;AACR,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAIC,KAAiB,EAAEC,OAAe,EAAa;AAC1E,EAAA,OAAOC,SAAS,CAACF,KAAK,CAAC,CAACG,QAAQ,CAACF,OAAO,CAAC,CAACG,WAAW,EAAE,CAAA;AACzD,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,4BAA4B,GAAG,SAA/BA,4BAA4BA,CAAIC,cAA0B,EAA0B;AACxF,EAAA,IAAMC,SAAS,GAAGL,SAAS,CAACI,cAAc,CAAC,CAAA;AAC3C,EAAA,IAAME,kBAAkB,GAAGD,SAAS,CAACH,WAAW,EAAE,CAAA;AAClD,EAAA,IAAI,IAAO,EAAE;AACX,IAAA,IAAI,CAACG,SAAS,CAACE,OAAO,EAAE,EAAE;AACxBC,MAAAA,eAAe,CAAC;AACdC,QAAAA,OAAO,EAAE,2BAA2B;AACpCC,QAAAA,UAAU,EAAE,aAAA;AACd,OAAC,CAAC,CAAA;AACJ,KAAA;AACF,GAAA;AAEA,EAAA,IAAMC,OAAO,GAAG,CAACL,kBAAkB,CAAC,CAAC;EACrC,IAAMM,UAAU,GAAGZ,SAAS,CAACK,SAAS,CAAC,CAACQ,aAAa,EAAE,CAAA;AACvD;EACA,IAAMC,eAAe,GAAGF,UAAU,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAA;EAChD,IAAMG,c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AME,iBAAiB,GAAGlC,mBAAmB,CAACiC,oBAAoB,CAAC,CAAA;AACnE;AACA,EAAA,IAAME,gBAAgB,GAAGR,kBAAkB,CAACM,oBAAoB,CAAC,CAAA;AACjE;EACA,IAAMG,kBAAkB,GAAGC,aAAa,CAAC;AACvCC,IAAAA,eAAe,EAAEC,UAAU;AAC3BC,IAAAA,SAAS,EAAE;MACTC,IAAI,EAAA,SAAA,CAAAC,MAAA,CAAY1E,SAAS,CAACgE,UAAU,CAAC,CAACW,KAAK,EAAE,CAAE;AAC/CC,MAAAA,MAAM,EAAE;AACNC,QAAAA,OAAO,EAAAC,aAAA,CACFZ,EAAAA,EAAAA,iBAAiB,CACrB;QACDa,MAAM,EAAAD,aAAA,CAAA,EAAA,EACDX,gBAAgB,CAAA;AAEvB,OAAA;AACF,KAAA;AACF,GAAC,CAAC,CAAA;EAEF,OAAO;AAAEa,IAAAA,KAAK,EAAEZ,kBAAkB;AAAE1C,IAAAA,WAAW,EAAEuC,oBAAAA;GAAsB,CAAA;AACzE;;;;"}
|
|
@@ -102,6 +102,15 @@ var ListViewFilters = function ListViewFilters(_ref4) {
|
|
|
102
102
|
var _useTheme = useTheme(),
|
|
103
103
|
theme = _useTheme.theme;
|
|
104
104
|
var showSearchInput = onSearchChange || onSearchClear || searchValuePlaceholder || searchName;
|
|
105
|
+
var getFilterContainerWidth = function getFilterContainerWidth() {
|
|
106
|
+
if (isMobile && Boolean(children)) {
|
|
107
|
+
return '88%';
|
|
108
|
+
}
|
|
109
|
+
if (isMobile && !Boolean(children)) {
|
|
110
|
+
return '100%';
|
|
111
|
+
}
|
|
112
|
+
return 'auto';
|
|
113
|
+
};
|
|
105
114
|
return /*#__PURE__*/jsxs(ListViewFiltersProvider, {
|
|
106
115
|
value: {
|
|
107
116
|
listViewSelectedFilters: listViewSelectedFilters,
|
|
@@ -133,14 +142,14 @@ var ListViewFilters = function ListViewFilters(_ref4) {
|
|
|
133
142
|
position: "relative",
|
|
134
143
|
display: "flex",
|
|
135
144
|
flexDirection: "column",
|
|
136
|
-
width:
|
|
145
|
+
width: getFilterContainerWidth(),
|
|
137
146
|
marginRight: isMobile ? 'spacing.2' : 'spacing.0',
|
|
138
147
|
children: [/*#__PURE__*/jsx(StyledQuickFilterContainer, {
|
|
139
148
|
overflow: isMobile ? 'scroll' : 'visible',
|
|
140
149
|
width: isMobile ? '100%' : 'auto',
|
|
141
150
|
ref: function ref(node) {
|
|
142
151
|
if (node instanceof HTMLElement && quickFilters) {
|
|
143
|
-
setShouldShowDecorationInQuickFilters(node.scrollWidth > node.offsetWidth);
|
|
152
|
+
setShouldShowDecorationInQuickFilters(node.scrollWidth > node.offsetWidth && Boolean(children));
|
|
144
153
|
}
|
|
145
154
|
},
|
|
146
155
|
paddingY: "spacing.4",
|
|
@@ -164,7 +173,7 @@ var ListViewFilters = function ListViewFilters(_ref4) {
|
|
|
164
173
|
display: "flex",
|
|
165
174
|
gap: "spacing.4",
|
|
166
175
|
alignItems: "center",
|
|
167
|
-
children: [/*#__PURE__*/jsxs(Box, {
|
|
176
|
+
children: [children ? /*#__PURE__*/jsxs(Box, {
|
|
168
177
|
position: "relative",
|
|
169
178
|
display: "inline-block",
|
|
170
179
|
children: [/*#__PURE__*/jsx(Button, {
|
|
@@ -190,7 +199,7 @@ var ListViewFilters = function ListViewFilters(_ref4) {
|
|
|
190
199
|
size: "small"
|
|
191
200
|
})
|
|
192
201
|
})]
|
|
193
|
-
}), !isMobile && showSearchInput && /*#__PURE__*/jsx(Box, {
|
|
202
|
+
}) : null, !isMobile && showSearchInput && /*#__PURE__*/jsx(Box, {
|
|
194
203
|
width: "256px",
|
|
195
204
|
children: /*#__PURE__*/jsx(SearchInput, {
|
|
196
205
|
label: "",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListViewFilters.web.js","sources":["../../../../../../src/components/ListView/ListViewFilters.web.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { AnimatePresence, m } from 'framer-motion';\nimport styled from 'styled-components';\nimport type { ListViewFilterProps, ListViewSelectedFiltersType } from './types';\nimport { ListViewFiltersProvider } from './ListViewFiltersContext.web';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\nimport BaseBox from '~components/Box/BaseBox';\nimport { MetaConstants, metaAttribute } from '~utils/metaAttribute';\nimport { FilterIcon } from '~components/Icons';\nimport { Button } from '~components/Button';\nimport { Counter } from '~components/Counter';\nimport { Box } from '~components/Box';\nimport { SearchInput } from '~components/Input/SearchInput';\nimport { useId } from '~utils/useId';\nimport { useControllableState } from '~utils/useControllable';\nimport { useIsMobile } from '~utils/useIsMobile';\nimport { msToSeconds } from '~utils/msToSeconds';\nimport { useTheme } from '~components/BladeProvider';\nimport { cssBezierToArray } from '~utils/cssBezierToArray';\nimport { castWebType } from '~utils';\nimport { Divider } from '~components/Divider';\n\nconst gradientOverlyContainerWidth = '21px'; // 20px + 1px divider width\nconst gradientOverlyContainerHeight = '38px';\n\nconst StyledQuickFilterContainer = styled(BaseBox)({\n /* For Webkit (Chrome, Safari) */\n '::-webkit-scrollbar': {\n display: 'none',\n },\n /* For Firefox */\n scrollbarWidth: 'none',\n /* For Edge */\n msOverflowStyle: 'none',\n});\n\nconst GradientOverlay = styled.div<{\n gradientColorLeft: string;\n dividerColor: string;\n gradientColorRight: string;\n}>`\n height: 100%;\n width: 20px;\n background: linear-gradient(\n 270deg,\n ${({ gradientColorRight }) => gradientColorRight} 0%,\n ${({ gradientColorLeft }) => gradientColorLeft} 100%\n );\n pointer-events: none;\n &::after {\n content: '';\n position: absolute;\n right: 0;\n top: 0;\n height: 100%;\n width: 1px;\n background-color: ${({ dividerColor }) => dividerColor};\n }\n`;\n\nconst ListViewFilters = ({\n testID,\n children,\n quickFilters,\n onSearchChange,\n searchValue,\n searchValuePlaceholder,\n searchName,\n showQuickFilters,\n onShowQuickFiltersChange,\n onSearchClear,\n selectedFiltersCount = 0,\n ...rest\n}: ListViewFilterProps): React.ReactElement => {\n const [shouldShowDecorationInQuickFilters, setShouldShowDecorationInQuickFilters] = useState(\n false,\n );\n const [showFilters, setShowFilters] = useControllableState({\n defaultValue: showQuickFilters,\n value: showQuickFilters,\n onChange: onShowQuickFiltersChange,\n });\n const [\n listViewSelectedFilters,\n setListViewSelectedFilters,\n ] = useState<ListViewSelectedFiltersType>({});\n const searchId = useId('search-input');\n const searchNameValue = searchName || searchId;\n const isMobile = useIsMobile();\n const { theme } = useTheme();\n const showSearchInput = onSearchChange || onSearchClear || searchValuePlaceholder || searchName;\n\n return (\n <ListViewFiltersProvider\n value={{\n listViewSelectedFilters,\n setListViewSelectedFilters,\n selectedFiltersCount,\n }}\n >\n {isMobile && showSearchInput && (\n <SearchInput\n label=\"\"\n value={searchValue}\n placeholder={searchValuePlaceholder}\n name={searchNameValue || searchId}\n onChange={({ name, value }) => onSearchChange?.({ name, value })}\n onClearButtonClick={onSearchClear}\n />\n )}\n <BaseBox>\n <BaseBox\n {...metaAttribute({ name: MetaConstants.ListViewFilter, testID })}\n {...makeAnalyticsAttribute(rest)}\n display=\"flex\"\n justifyContent=\"space-between\"\n >\n <Box\n position=\"relative\"\n display=\"flex\"\n flexDirection=\"column\"\n width={isMobile ? '88%' : 'auto'}\n marginRight={isMobile ? 'spacing.2' : 'spacing.0'}\n >\n <StyledQuickFilterContainer\n overflow={isMobile ? 'scroll' : 'visible'}\n width={isMobile ? '100%' : 'auto'}\n ref={(node) => {\n if (node instanceof HTMLElement && quickFilters) {\n setShouldShowDecorationInQuickFilters(node.scrollWidth > node.offsetWidth);\n }\n }}\n paddingY=\"spacing.4\"\n paddingLeft={isMobile ? 'spacing.2' : 'spacing.0'}\n >\n {quickFilters}\n </StyledQuickFilterContainer>\n {isMobile && shouldShowDecorationInQuickFilters ? (\n <Box\n position=\"absolute\"\n right=\"-1px\"\n top=\"spacing.4\"\n width={gradientOverlyContainerWidth}\n height={gradientOverlyContainerHeight}\n >\n <GradientOverlay\n gradientColorLeft={theme.colors.transparent}\n gradientColorRight={theme.colors.surface.background.gray.intense}\n dividerColor={theme.colors.surface.border.gray.normal}\n />\n <Divider orientation=\"vertical\" />\n </Box>\n ) : null}\n </Box>\n\n <BaseBox display=\"flex\" gap=\"spacing.4\" alignItems=\"center\">\n <Box position=\"relative\" display=\"inline-block\">\n <Button\n variant=\"tertiary\"\n size=\"medium\"\n color=\"primary\"\n onClick={() => {\n setShowFilters((prev) => !prev);\n }}\n icon={FilterIcon}\n accessibilityLabel=\"Show More Filters\"\n />\n <Box\n position=\"absolute\"\n right=\"spacing.0\"\n top=\"spacing.0\"\n transform=\"translate(50%, -50%)\"\n >\n <Counter\n value={selectedFiltersCount || Object.keys(listViewSelectedFilters).length}\n color=\"primary\"\n emphasis=\"intense\"\n size=\"small\"\n />\n </Box>\n </Box>\n {!isMobile && showSearchInput && (\n <Box width=\"256px\">\n <SearchInput\n label=\"\"\n value={searchValue}\n placeholder={searchValuePlaceholder}\n name={searchNameValue || searchId}\n onChange={({ name, value }) => onSearchChange?.({ name, value })}\n onClearButtonClick={onSearchClear}\n size=\"medium\"\n />\n </Box>\n )}\n </BaseBox>\n </BaseBox>\n <AnimatePresence>\n {showFilters && (\n <m.div\n initial={{ height: 0 }}\n animate={{ height: showFilters ? 'auto' : 0 }}\n transition={{\n duration: msToSeconds(theme.motion.duration.moderate),\n ease: cssBezierToArray(castWebType(theme.motion.easing.standard)),\n }}\n exit={{ height: 0 }}\n >\n <BaseBox\n display=\"flex\"\n backgroundColor={\n isMobile ? 'surface.background.white' : 'surface.background.gray.moderate'\n }\n borderTop={!isMobile ? '1ps solid' : undefined}\n borderTopColor={!isMobile ? 'surface.border.gray.muted' : undefined}\n >\n {children}\n </BaseBox>\n </m.div>\n )}\n </AnimatePresence>\n </BaseBox>\n </ListViewFiltersProvider>\n );\n};\n\nexport { ListViewFilters };\n"],"names":["gradientOverlyContainerWidth","gradientOverlyContainerHeight","StyledQuickFilterContainer","styled","BaseBox","withConfig","displayName","componentId","display","scrollbarWidth","msOverflowStyle","GradientOverlay","div","_ref","gradientColorRight","_ref2","gradientColorLeft","_ref3","dividerColor","ListViewFilters","_ref4","testID","children","quickFilters","onSearchChange","searchValue","searchValuePlaceholder","searchName","showQuickFilters","onShowQuickFiltersChange","onSearchClear","_ref4$selectedFilters","selectedFiltersCount","rest","_objectWithoutProperties","_excluded","_useState","useState","_useState2","_slicedToArray","shouldShowDecorationInQuickFilters","setShouldShowDecorationInQuickFilters","_useControllableState","useControllableState","defaultValue","value","onChange","_useControllableState2","showFilters","setShowFilters","_useState3","_useState4","listViewSelectedFilters","setListViewSelectedFilters","searchId","useId","searchNameValue","isMobile","useIsMobile","_useTheme","useTheme","theme","showSearchInput","_jsxs","ListViewFiltersProvider","_jsx","SearchInput","label","placeholder","name","_ref5","onClearButtonClick","_objectSpread","metaAttribute","MetaConstants","ListViewFilter","makeAnalyticsAttribute","justifyContent","Box","position","flexDirection","width","marginRight","overflow","ref","node","HTMLElement","scrollWidth","offsetWidth","paddingY","paddingLeft","right","top","height","colors","transparent","surface","background","gray","intense","border","normal","Divider","orientation","gap","alignItems","Button","variant","size","color","onClick","prev","icon","FilterIcon","accessibilityLabel","transform","Counter","Object","keys","length","emphasis","_ref6","AnimatePresence","m","initial","animate","transition","duration","msToSeconds","motion","moderate","ease","cssBezierToArray","castWebType","easing","standard","exit","backgroundColor","borderTop","undefined","borderTopColor"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAMA,4BAA4B,GAAG,MAAM,CAAC;AAC5C,IAAMC,6BAA6B,GAAG,MAAM,CAAA;AAE5C,IAAMC,0BAA0B,gBAAGC,MAAM,CAACC,OAAO,CAAC,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,gDAAA;EAAAC,WAAA,EAAA,UAAA;AAAA,CAAC,CAAA,CAAA;AACjD;AACA,EAAA,qBAAqB,EAAE;AACrBC,IAAAA,OAAO,EAAE,MAAA;GACV;AACD;AACAC,EAAAA,cAAc,EAAE,MAAM;AACtB;AACAC,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AW,GAAG,MAAM,GAAG,CAAA;WAAI;AAC9C8E,UAAAA,UAAU,EAAE;YACVC,QAAQ,EAAEC,WAAW,CAACnE,KAAK,CAACoE,MAAM,CAACF,QAAQ,CAACG,QAAQ,CAAC;AACrDC,YAAAA,IAAI,EAAEC,gBAAgB,CAACC,WAAW,CAACxE,KAAK,CAACoE,MAAM,CAACK,MAAM,CAACC,QAAQ,CAAC,CAAA;WAChE;AACFC,UAAAA,IAAI,EAAE;AAAE3C,YAAAA,MAAM,EAAE,CAAA;WAAI;UAAAvE,QAAA,eAEpB2C,GAAA,CAAC7D,OAAO,EAAA;AACNI,YAAAA,OAAO,EAAC,MAAM;AACdiI,YAAAA,eAAe,EACbhF,QAAQ,GAAG,0BAA0B,GAAG,kCACzC;AACDiF,YAAAA,SAAS,EAAE,CAACjF,QAAQ,GAAG,WAAW,GAAGkF,SAAU;AAC/CC,YAAAA,cAAc,EAAE,CAACnF,QAAQ,GAAG,2BAA2B,GAAGkF,SAAU;AAAArH,YAAAA,QAAA,EAEnEA,QAAAA;WACM,CAAA;SACJ,CAAA;AACR,OACc,CAAC,CAAA;AAAA,KACX,CAAC,CAAA;AAAA,GACa,CAAC,CAAA;AAE9B;;;;"}
|
|
1
|
+
{"version":3,"file":"ListViewFilters.web.js","sources":["../../../../../../src/components/ListView/ListViewFilters.web.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { AnimatePresence, m } from 'framer-motion';\nimport styled from 'styled-components';\nimport type { ListViewFilterProps, ListViewSelectedFiltersType } from './types';\nimport { ListViewFiltersProvider } from './ListViewFiltersContext.web';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\nimport BaseBox from '~components/Box/BaseBox';\nimport { MetaConstants, metaAttribute } from '~utils/metaAttribute';\nimport { FilterIcon } from '~components/Icons';\nimport { Button } from '~components/Button';\nimport { Counter } from '~components/Counter';\nimport type { BoxProps } from '~components/Box';\nimport { Box } from '~components/Box';\nimport { SearchInput } from '~components/Input/SearchInput';\nimport { useId } from '~utils/useId';\nimport { useControllableState } from '~utils/useControllable';\nimport { useIsMobile } from '~utils/useIsMobile';\nimport { msToSeconds } from '~utils/msToSeconds';\nimport { useTheme } from '~components/BladeProvider';\nimport { cssBezierToArray } from '~utils/cssBezierToArray';\nimport { castWebType } from '~utils';\nimport { Divider } from '~components/Divider';\n\nconst gradientOverlyContainerWidth = '21px'; // 20px + 1px divider width\nconst gradientOverlyContainerHeight = '38px';\n\nconst StyledQuickFilterContainer = styled(BaseBox)({\n /* For Webkit (Chrome, Safari) */\n '::-webkit-scrollbar': {\n display: 'none',\n },\n /* For Firefox */\n scrollbarWidth: 'none',\n /* For Edge */\n msOverflowStyle: 'none',\n});\n\nconst GradientOverlay = styled.div<{\n gradientColorLeft: string;\n dividerColor: string;\n gradientColorRight: string;\n}>`\n height: 100%;\n width: 20px;\n background: linear-gradient(\n 270deg,\n ${({ gradientColorRight }) => gradientColorRight} 0%,\n ${({ gradientColorLeft }) => gradientColorLeft} 100%\n );\n pointer-events: none;\n &::after {\n content: '';\n position: absolute;\n right: 0;\n top: 0;\n height: 100%;\n width: 1px;\n background-color: ${({ dividerColor }) => dividerColor};\n }\n`;\n\nconst ListViewFilters = ({\n testID,\n children,\n quickFilters,\n onSearchChange,\n searchValue,\n searchValuePlaceholder,\n searchName,\n showQuickFilters,\n onShowQuickFiltersChange,\n onSearchClear,\n selectedFiltersCount = 0,\n ...rest\n}: ListViewFilterProps): React.ReactElement => {\n const [shouldShowDecorationInQuickFilters, setShouldShowDecorationInQuickFilters] = useState(\n false,\n );\n const [showFilters, setShowFilters] = useControllableState({\n defaultValue: showQuickFilters,\n value: showQuickFilters,\n onChange: onShowQuickFiltersChange,\n });\n const [\n listViewSelectedFilters,\n setListViewSelectedFilters,\n ] = useState<ListViewSelectedFiltersType>({});\n const searchId = useId('search-input');\n const searchNameValue = searchName || searchId;\n const isMobile = useIsMobile();\n const { theme } = useTheme();\n const showSearchInput = onSearchChange || onSearchClear || searchValuePlaceholder || searchName;\n const getFilterContainerWidth = (): BoxProps['width'] => {\n if (isMobile && Boolean(children)) {\n return '88%';\n }\n if (isMobile && !Boolean(children)) {\n return '100%';\n }\n return 'auto';\n };\n\n return (\n <ListViewFiltersProvider\n value={{\n listViewSelectedFilters,\n setListViewSelectedFilters,\n selectedFiltersCount,\n }}\n >\n {isMobile && showSearchInput && (\n <SearchInput\n label=\"\"\n value={searchValue}\n placeholder={searchValuePlaceholder}\n name={searchNameValue || searchId}\n onChange={({ name, value }) => onSearchChange?.({ name, value })}\n onClearButtonClick={onSearchClear}\n />\n )}\n <BaseBox>\n <BaseBox\n {...metaAttribute({ name: MetaConstants.ListViewFilter, testID })}\n {...makeAnalyticsAttribute(rest)}\n display=\"flex\"\n justifyContent=\"space-between\"\n >\n <Box\n position=\"relative\"\n display=\"flex\"\n flexDirection=\"column\"\n width={getFilterContainerWidth()}\n marginRight={isMobile ? 'spacing.2' : 'spacing.0'}\n >\n <StyledQuickFilterContainer\n overflow={isMobile ? 'scroll' : 'visible'}\n width={isMobile ? '100%' : 'auto'}\n ref={(node) => {\n if (node instanceof HTMLElement && quickFilters) {\n setShouldShowDecorationInQuickFilters(\n node.scrollWidth > node.offsetWidth && Boolean(children),\n );\n }\n }}\n paddingY=\"spacing.4\"\n paddingLeft={isMobile ? 'spacing.2' : 'spacing.0'}\n >\n {quickFilters}\n </StyledQuickFilterContainer>\n {isMobile && shouldShowDecorationInQuickFilters ? (\n <Box\n position=\"absolute\"\n right=\"-1px\"\n top=\"spacing.4\"\n width={gradientOverlyContainerWidth}\n height={gradientOverlyContainerHeight}\n >\n <GradientOverlay\n gradientColorLeft={theme.colors.transparent}\n gradientColorRight={theme.colors.surface.background.gray.intense}\n dividerColor={theme.colors.surface.border.gray.normal}\n />\n <Divider orientation=\"vertical\" />\n </Box>\n ) : null}\n </Box>\n\n <BaseBox display=\"flex\" gap=\"spacing.4\" alignItems=\"center\">\n {children ? (\n <Box position=\"relative\" display=\"inline-block\">\n <Button\n variant=\"tertiary\"\n size=\"medium\"\n color=\"primary\"\n onClick={() => {\n setShowFilters((prev) => !prev);\n }}\n icon={FilterIcon}\n accessibilityLabel=\"Show More Filters\"\n />\n\n <Box\n position=\"absolute\"\n right=\"spacing.0\"\n top=\"spacing.0\"\n transform=\"translate(50%, -50%)\"\n >\n <Counter\n value={selectedFiltersCount || Object.keys(listViewSelectedFilters).length}\n color=\"primary\"\n emphasis=\"intense\"\n size=\"small\"\n />\n </Box>\n </Box>\n ) : null}\n {!isMobile && showSearchInput && (\n <Box width=\"256px\">\n <SearchInput\n label=\"\"\n value={searchValue}\n placeholder={searchValuePlaceholder}\n name={searchNameValue || searchId}\n onChange={({ name, value }) => onSearchChange?.({ name, value })}\n onClearButtonClick={onSearchClear}\n size=\"medium\"\n />\n </Box>\n )}\n </BaseBox>\n </BaseBox>\n <AnimatePresence>\n {showFilters && (\n <m.div\n initial={{ height: 0 }}\n animate={{ height: showFilters ? 'auto' : 0 }}\n transition={{\n duration: msToSeconds(theme.motion.duration.moderate),\n ease: cssBezierToArray(castWebType(theme.motion.easing.standard)),\n }}\n exit={{ height: 0 }}\n >\n <BaseBox\n display=\"flex\"\n backgroundColor={\n isMobile ? 'surface.background.white' : 'surface.background.gray.moderate'\n }\n borderTop={!isMobile ? '1ps solid' : undefined}\n borderTopColor={!isMobile ? 'surface.border.gray.muted' : undefined}\n >\n {children}\n </BaseBox>\n </m.div>\n )}\n </AnimatePresence>\n </BaseBox>\n </ListViewFiltersProvider>\n );\n};\n\nexport { ListViewFilters };\n"],"names":["gradientOverlyContainerWidth","gradientOverlyContainerHeight","StyledQuickFilterContainer","styled","BaseBox","withConfig","displayName","componentId","display","scrollbarWidth","msOverflowStyle","GradientOverlay","div","_ref","gradientColorRight","_ref2","gradientColorLeft","_ref3","dividerColor","ListViewFilters","_ref4","testID","children","quickFilters","onSearchChange","searchValue","searchValuePlaceholder","searchName","showQuickFilters","onShowQuickFiltersChange","onSearchClear","_ref4$selectedFilters","selectedFiltersCount","rest","_objectWithoutProperties","_excluded","_useState","useState","_useState2","_slicedToArray","shouldShowDecorationInQuickFilters","setShouldShowDecorationInQuickFilters","_useControllableState","useControllableState","defaultValue","value","onChange","_useControllableState2","showFilters","setShowFilters","_useState3","_useState4","listViewSelectedFilters","setListViewSelectedFilters","searchId","useId","searchNameValue","isMobile","useIsMobile","_useTheme","useTheme","theme","showSearchInput","getFilterContainerWidth","Boolean","_jsxs","ListViewFiltersProvider","_jsx","SearchInput","label","placeholder","name","_ref5","onClearButtonClick","_objectSpread","metaAttribute","MetaConstants","ListViewFilter","makeAnalyticsAttribute","justifyContent","Box","position","flexDirection","width","marginRight","overflow","ref","node","HTMLElement","scrollWidth","offsetWidth","paddingY","paddingLeft","right","top","height","colors","transparent","surface","background","gray","intense","border","normal","Divider","orientation","gap","alignItems","Button","variant","size","color","onClick","prev","icon","FilterIcon","accessibilityLabel","transform","Counter","Object","keys","length","emphasis","_ref6","AnimatePresence","m","initial","animate","transition","duration","msToSeconds","motion","moderate","ease","cssBezierToArray","castWebType","easing","standard","exit","backgroundColor","borderTop","undefined","borderTopColor"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,IAAMA,4BAA4B,GAAG,MAAM,CAAC;AAC5C,IAAMC,6BAA6B,GAAG,MAAM,CAAA;AAE5C,IAAMC,0BAA0B,gBAAGC,MAAM,CAACC,OAAO,CAAC,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,gDAAA;EAAAC,WAAA,EAAA,UAAA;AAAA,CAAC,CAAA,CAAA;AACjD;AACA,EAAA,qBAAqB,EAAE;AACrBC,IAAAA,OAAO,EAAE,MAAA;GACV;AACD;AACAC,EAAAA,cAAc,EAAE,MAAM;AACtB;AACAC,EAAAA,eAAe,EAAE,MAAA;AACnB,CAAC,CAAC,CAAA;AAEF,IAAMC,eAAe,gBAAGR,MAAM,CAACS,GAAG,CAAAP,UAAA,CAAA;EAAAC,WAAA,EAAA,qCAAA;EAAAC,WA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ACyD,eAAe,EAAA;AAAAtG,QAAAA,QAAA,EACb0B,WAAW,iBACVmB,GAAA,CAAC0D,CAAC,CAACjH,GAAG,EAAA;AACJkH,UAAAA,OAAO,EAAE;AAAE/B,YAAAA,MAAM,EAAE,CAAA;WAAI;AACvBgC,UAAAA,OAAO,EAAE;AAAEhC,YAAAA,MAAM,EAAE/C,WAAW,GAAG,MAAM,GAAG,CAAA;WAAI;AAC9CgF,UAAAA,UAAU,EAAE;YACVC,QAAQ,EAAEC,WAAW,CAACrE,KAAK,CAACsE,MAAM,CAACF,QAAQ,CAACG,QAAQ,CAAC;AACrDC,YAAAA,IAAI,EAAEC,gBAAgB,CAACC,WAAW,CAAC1E,KAAK,CAACsE,MAAM,CAACK,MAAM,CAACC,QAAQ,CAAC,CAAA;WAChE;AACFC,UAAAA,IAAI,EAAE;AAAE3C,YAAAA,MAAM,EAAE,CAAA;WAAI;UAAAzE,QAAA,eAEpB6C,GAAA,CAAC/D,OAAO,EAAA;AACNI,YAAAA,OAAO,EAAC,MAAM;AACdmI,YAAAA,eAAe,EACblF,QAAQ,GAAG,0BAA0B,GAAG,kCACzC;AACDmF,YAAAA,SAAS,EAAE,CAACnF,QAAQ,GAAG,WAAW,GAAGoF,SAAU;AAC/CC,YAAAA,cAAc,EAAE,CAACrF,QAAQ,GAAG,2BAA2B,GAAGoF,SAAU;AAAAvH,YAAAA,QAAA,EAEnEA,QAAAA;WACM,CAAA;SACJ,CAAA;AACR,OACc,CAAC,CAAA;AAAA,KACX,CAAC,CAAA;AAAA,GACa,CAAC,CAAA;AAE9B;;;;"}
|
|
@@ -158,6 +158,12 @@ var getOnLightOverrides = function getOnLightOverrides(brandColors) {
|
|
|
158
158
|
subtle: brandColors[200]
|
|
159
159
|
}
|
|
160
160
|
},
|
|
161
|
+
border: {
|
|
162
|
+
primary: {
|
|
163
|
+
normal: brandColors[600],
|
|
164
|
+
muted: brandColors.a200
|
|
165
|
+
}
|
|
166
|
+
},
|
|
161
167
|
icon: {
|
|
162
168
|
primary: {
|
|
163
169
|
normal: brandColors[600]
|
|
@@ -241,6 +247,12 @@ var getOnDarkOverrides = function getOnDarkOverrides(brandColors) {
|
|
|
241
247
|
subtle: brandColors[200]
|
|
242
248
|
}
|
|
243
249
|
},
|
|
250
|
+
border: {
|
|
251
|
+
primary: {
|
|
252
|
+
normal: brandColors[600],
|
|
253
|
+
muted: brandColors.a200
|
|
254
|
+
}
|
|
255
|
+
},
|
|
244
256
|
icon: {
|
|
245
257
|
primary: {
|
|
246
258
|
normal: brandColors[600]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTheme.js","sources":["../../../../../../src/tokens/theme/createTheme.ts"],"sourcesContent":["import tinycolor from 'tinycolor2';\nimport type { WCAG2Options, ColorInput } from 'tinycolor2';\nimport type { ThemeTokens } from './theme';\nimport overrideTheme from './overrideTheme';\nimport bladeTheme from './bladeTheme';\nimport { colors as globalColors, opacity } from '~tokens/global';\nimport type { ColorChromaticScale } from '~tokens/global/colors';\nimport { throwBladeError } from '~utils/logger';\nimport type { DeepPartial } from '~utils/isPartialMatchObjectKeys';\n\n// WCAG2ContrastOptions are the options used to determine if a color is readable\nconst WCAG2ContrastOptions: WCAG2Options = {\n level: 'AAA',\n size: 'large',\n};\n\n/**\n * getColorWithOpacity\n * @param color - The color to add opacity to\n * @param opacity - The opacity to add to the color\n * @returns The color with the opacity added\n * @example\n * getColorWithOpacity('#fff', 0.5) // returns 'hsla(0, 0%, 100%, 0.5)'\n *\n **/\nconst getColorWithOpacity = (color: ColorInput, opacity: number): string => {\n return tinycolor(color).setAlpha(opacity).toHslString();\n};\n\n/**\n *\n * @description\n * Generates a chromatic color palette based on the base color passed in.\n * The base color is used to generate a palette of 11 colors, 5 shades lighter and 5 shades darker than the base color.\n * @param baseColorInput - The base color to generate the chromatic color palette from in hex, rgb, or hsl format\n * @returns Array of chromatic color palette\n */\nconst generateChromaticBrandColors = (baseColorInput: ColorInput): ColorChromaticScale => {\n const baseColor = tinycolor(baseColorInput);\n const baseColorHslString = baseColor.toHslString();\n if (__DEV__) {\n if (!baseColor.isValid()) {\n throwBladeError({\n message: 'Invalid brandColor passed',\n moduleName: 'createTheme',\n });\n }\n }\n\n const palette = [baseColorHslString]; // Include the original color\n const brightness = tinycolor(baseColor).getBrightness();\n // Determine how much to lighten or darken the colors depending on the brightness of the base color\n const lightnessFactor = brightness > 150 ? 3 : 6;\n const darknessFactor = brightness < 50 ? 3 : 5;\n\n let currentColor = baseColor;\n\n // Generate shades lighter\n for (let lightShadeIndex = 0; lightShadeIndex < 6; lightShadeIndex++) {\n currentColor = currentColor.brighten(lightnessFactor);\n palette.push(currentColor.toHslString());\n }\n\n currentColor = tinycolor(baseColorHslString); // Reset to the base color\n\n // Generate shades darker\n for (let darkShadeIndex = 0; darkShadeIndex < 4; darkShadeIndex++) {\n currentColor = currentColor.darken(darknessFactor);\n palette.unshift(currentColor.toHslString()); // Add shades at the beginning of the palette\n }\n\n const colorPalette = palette.reverse();\n const brandPrimaryColor = colorPalette[6];\n\n const brandColors: ColorChromaticScale = {\n '50': colorPalette[0],\n '100': colorPalette[1],\n '200': colorPalette[2],\n '300': colorPalette[3],\n '400': colorPalette[4],\n '500': colorPalette[5],\n '600': brandPrimaryColor,\n '700': colorPalette[7],\n '800': colorPalette[8],\n '900': colorPalette[9],\n '1000': colorPalette[10],\n a50: getColorWithOpacity(brandPrimaryColor, opacity[100]),\n a150: getColorWithOpacity(brandPrimaryColor, opacity[100]),\n a100: getColorWithOpacity(brandPrimaryColor, opacity[200]),\n a200: getColorWithOpacity(brandPrimaryColor, opacity[300]),\n a400: getColorWithOpacity(brandPrimaryColor, opacity[400]),\n };\n\n return brandColors;\n};\n\n/**\n *\n * @param brandColors - The brand colors to use to override the light theme\n * @description Returns overrides for the light theme with the brand colors passed in\n * @returns Overrides for the light theme with the custom brand colors\n */\nconst getOnLightOverrides = (\n brandColors: ColorChromaticScale,\n): DeepPartial<ThemeTokens['colors']['onLight']> => {\n // Select the most readable color to use as the foreground color on top of surface color\n // For example: On Secondary Button where the background color is surface color, the text color should be either the brand color or dark color depending on which is more readable on top of that surface color\n const foregroundOnSurface = tinycolor.isReadable(\n globalColors.neutral.blueGrayLight[50],\n brandColors[600],\n WCAG2ContrastOptions,\n )\n ? brandColors[600]\n : globalColors.neutral.blueGrayLight[1100];\n\n const foregroundOnBrand = tinycolor\n .mostReadable(\n brandColors[900],\n [globalColors.neutral.white[500], globalColors.neutral.black[500]],\n WCAG2ContrastOptions,\n )\n .toHslString();\n\n // Overrides for the light theme with the brand colors passed in\n const lightThemeOverrides: DeepPartial<ThemeTokens['colors']['onLight']> = {\n interactive: {\n background: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n fadedHighlighted: brandColors.a150,\n },\n },\n border: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n },\n },\n text: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a200,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n icon: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a200,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n },\n surface: {\n background: {\n primary: {\n intense: brandColors[600],\n subtle: brandColors[200],\n },\n },\n icon: {\n primary: {\n normal: brandColors[600],\n },\n },\n text: {\n primary: {\n normal: brandColors[600],\n },\n },\n },\n };\n\n return lightThemeOverrides;\n};\n\n/**\n *\n * @param brandColors - The brand colors to use to override the dark theme\n * @description Returns overrides for the dark theme with the brand colors passed in\n * @returns Overrides for the dark theme with the custom brand colors\n */\nconst getOnDarkOverrides = (\n brandColors: ColorChromaticScale,\n): DeepPartial<ThemeTokens['colors']['onDark']> => {\n // Select the most readable color to use as the foreground color on top of surface color\n // For example: On Secondary Button where the background color is surface color, the text color should be either the brand color or dark color depending on which is more readable on top of that surface color\n const foregroundOnSurface = tinycolor.isReadable(\n globalColors.neutral.blueGrayDark[1100],\n brandColors[400],\n WCAG2ContrastOptions,\n )\n ? brandColors[400]\n : globalColors.neutral.blueGrayDark[0];\n\n const foregroundOnBrand = tinycolor\n .mostReadable(\n brandColors[900],\n [globalColors.neutral.white[500], globalColors.neutral.black[500]],\n WCAG2ContrastOptions,\n )\n .toHslString();\n\n // Overrides for the dark theme with the brand colors passed in\n const darkThemeOverrides: DeepPartial<ThemeTokens['colors']['onDark']> = {\n interactive: {\n background: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n fadedHighlighted: brandColors.a150,\n },\n },\n border: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n },\n },\n text: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a400,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n icon: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a400,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n },\n surface: {\n background: {\n primary: {\n intense: brandColors[600],\n subtle: brandColors[200],\n },\n },\n icon: {\n primary: {\n normal: brandColors[600],\n },\n },\n },\n };\n\n return darkThemeOverrides;\n};\n\n/**\n * @param {Object} themeConfig - The brand color and overrides to apply to the theme\n * @param {string} themeConfig.brandColor - The brand color to use to generate the theme. Can be in hex, rgb, or hsl format.\n * @description\n * Creates a Blade Theme based on the custom brand color\n * @returns The Theme Tokens with the custom brand colors\n * @example\n * const { theme, brandColors } = createTheme({ brandColor: '#19BEA2'})\n **/\nexport const createTheme = ({\n brandColor,\n}: {\n brandColor: ColorInput;\n}): { theme: ThemeTokens; brandColors: ColorChromaticScale } => {\n const chromaticBrandColors = generateChromaticBrandColors(brandColor);\n // Get onLight overrides\n const brandedLightTheme = getOnLightOverrides(chromaticBrandColors);\n // Get onDark overrides\n const brandedDarkTheme = getOnDarkOverrides(chromaticBrandColors);\n // Override the payment theme with the brand colors\n const brandedThemeTokens = overrideTheme({\n baseThemeTokens: bladeTheme,\n overrides: {\n name: `custom-${tinycolor(brandColor).toHex()}`,\n colors: {\n onLight: {\n ...brandedLightTheme,\n },\n onDark: {\n ...brandedDarkTheme,\n },\n },\n },\n });\n\n return { theme: brandedThemeTokens, brandColors: chromaticBrandColors };\n};\n"],"names":["WCAG2ContrastOptions","level","size","getColorWithOpacity","color","opacity","tinycolor","setAlpha","toHslString","generateChromaticBrandColors","baseColorInput","baseColor","baseColorHslString","isValid","throwBladeError","message","moduleName","palette","brightness","getBrightness","lightnessFactor","darknessFactor","currentColor","lightShadeIndex","brighten","push","darkShadeIndex","darken","unshift","colorPalette","reverse","brandPrimaryColor","brandColors","a50","a150","a100","a200","a400","getOnLightOverrides","foregroundOnSurface","isReadable","globalColors","neutral","blueGrayLight","foregroundOnBrand","mostReadable","white","black","lightThemeOverrides","interactive","background","primary","highlighted","disabled","faded","fadedHighlighted","border","text","normal","muted","subtle","onPrimary","icon","surface","intense","getOnDarkOverrides","blueGrayDark","darkThemeOverrides","createTheme","_ref","brandColor","chromaticBrandColors","brandedLightTheme","brandedDarkTheme","brandedThemeTokens","overrideTheme","baseThemeTokens","bladeTheme","overrides","name","concat","toHex","colors","onLight","_objectSpread","onDark","theme"],"mappings":";;;;;;;;;;;;AAUA;AACA,IAAMA,oBAAkC,GAAG;AACzC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A,KAAK,EAAEZ,kBAAkB;AAAE1C,IAAAA,WAAW,EAAEuC,oBAAAA;GAAsB,CAAA;AACzE;;;;"}
|
|
1
|
+
{"version":3,"file":"createTheme.js","sources":["../../../../../../src/tokens/theme/createTheme.ts"],"sourcesContent":["import tinycolor from 'tinycolor2';\nimport type { WCAG2Options, ColorInput } from 'tinycolor2';\nimport type { ThemeTokens } from './theme';\nimport overrideTheme from './overrideTheme';\nimport bladeTheme from './bladeTheme';\nimport { colors as globalColors, opacity } from '~tokens/global';\nimport type { ColorChromaticScale } from '~tokens/global/colors';\nimport { throwBladeError } from '~utils/logger';\nimport type { DeepPartial } from '~utils/isPartialMatchObjectKeys';\n\n// WCAG2ContrastOptions are the options used to determine if a color is readable\nconst WCAG2ContrastOptions: WCAG2Options = {\n level: 'AAA',\n size: 'large',\n};\n\n/**\n * getColorWithOpacity\n * @param color - The color to add opacity to\n * @param opacity - The opacity to add to the color\n * @returns The color with the opacity added\n * @example\n * getColorWithOpacity('#fff', 0.5) // returns 'hsla(0, 0%, 100%, 0.5)'\n *\n **/\nconst getColorWithOpacity = (color: ColorInput, opacity: number): string => {\n return tinycolor(color).setAlpha(opacity).toHslString();\n};\n\n/**\n *\n * @description\n * Generates a chromatic color palette based on the base color passed in.\n * The base color is used to generate a palette of 11 colors, 5 shades lighter and 5 shades darker than the base color.\n * @param baseColorInput - The base color to generate the chromatic color palette from in hex, rgb, or hsl format\n * @returns Array of chromatic color palette\n */\nconst generateChromaticBrandColors = (baseColorInput: ColorInput): ColorChromaticScale => {\n const baseColor = tinycolor(baseColorInput);\n const baseColorHslString = baseColor.toHslString();\n if (__DEV__) {\n if (!baseColor.isValid()) {\n throwBladeError({\n message: 'Invalid brandColor passed',\n moduleName: 'createTheme',\n });\n }\n }\n\n const palette = [baseColorHslString]; // Include the original color\n const brightness = tinycolor(baseColor).getBrightness();\n // Determine how much to lighten or darken the colors depending on the brightness of the base color\n const lightnessFactor = brightness > 150 ? 3 : 6;\n const darknessFactor = brightness < 50 ? 3 : 5;\n\n let currentColor = baseColor;\n\n // Generate shades lighter\n for (let lightShadeIndex = 0; lightShadeIndex < 6; lightShadeIndex++) {\n currentColor = currentColor.brighten(lightnessFactor);\n palette.push(currentColor.toHslString());\n }\n\n currentColor = tinycolor(baseColorHslString); // Reset to the base color\n\n // Generate shades darker\n for (let darkShadeIndex = 0; darkShadeIndex < 4; darkShadeIndex++) {\n currentColor = currentColor.darken(darknessFactor);\n palette.unshift(currentColor.toHslString()); // Add shades at the beginning of the palette\n }\n\n const colorPalette = palette.reverse();\n const brandPrimaryColor = colorPalette[6];\n\n const brandColors: ColorChromaticScale = {\n '50': colorPalette[0],\n '100': colorPalette[1],\n '200': colorPalette[2],\n '300': colorPalette[3],\n '400': colorPalette[4],\n '500': colorPalette[5],\n '600': brandPrimaryColor,\n '700': colorPalette[7],\n '800': colorPalette[8],\n '900': colorPalette[9],\n '1000': colorPalette[10],\n a50: getColorWithOpacity(brandPrimaryColor, opacity[100]),\n a150: getColorWithOpacity(brandPrimaryColor, opacity[100]),\n a100: getColorWithOpacity(brandPrimaryColor, opacity[200]),\n a200: getColorWithOpacity(brandPrimaryColor, opacity[300]),\n a400: getColorWithOpacity(brandPrimaryColor, opacity[400]),\n };\n\n return brandColors;\n};\n\n/**\n *\n * @param brandColors - The brand colors to use to override the light theme\n * @description Returns overrides for the light theme with the brand colors passed in\n * @returns Overrides for the light theme with the custom brand colors\n */\nconst getOnLightOverrides = (\n brandColors: ColorChromaticScale,\n): DeepPartial<ThemeTokens['colors']['onLight']> => {\n // Select the most readable color to use as the foreground color on top of surface color\n // For example: On Secondary Button where the background color is surface color, the text color should be either the brand color or dark color depending on which is more readable on top of that surface color\n const foregroundOnSurface = tinycolor.isReadable(\n globalColors.neutral.blueGrayLight[50],\n brandColors[600],\n WCAG2ContrastOptions,\n )\n ? brandColors[600]\n : globalColors.neutral.blueGrayLight[1100];\n\n const foregroundOnBrand = tinycolor\n .mostReadable(\n brandColors[900],\n [globalColors.neutral.white[500], globalColors.neutral.black[500]],\n WCAG2ContrastOptions,\n )\n .toHslString();\n\n // Overrides for the light theme with the brand colors passed in\n const lightThemeOverrides: DeepPartial<ThemeTokens['colors']['onLight']> = {\n interactive: {\n background: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n fadedHighlighted: brandColors.a150,\n },\n },\n border: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n },\n },\n text: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a200,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n icon: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a200,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n },\n surface: {\n background: {\n primary: {\n intense: brandColors[600],\n subtle: brandColors[200],\n },\n },\n border: {\n primary: {\n normal: brandColors[600],\n muted: brandColors.a200,\n },\n },\n icon: {\n primary: {\n normal: brandColors[600],\n },\n },\n text: {\n primary: {\n normal: brandColors[600],\n },\n },\n },\n };\n\n return lightThemeOverrides;\n};\n\n/**\n *\n * @param brandColors - The brand colors to use to override the dark theme\n * @description Returns overrides for the dark theme with the brand colors passed in\n * @returns Overrides for the dark theme with the custom brand colors\n */\nconst getOnDarkOverrides = (\n brandColors: ColorChromaticScale,\n): DeepPartial<ThemeTokens['colors']['onDark']> => {\n // Select the most readable color to use as the foreground color on top of surface color\n // For example: On Secondary Button where the background color is surface color, the text color should be either the brand color or dark color depending on which is more readable on top of that surface color\n const foregroundOnSurface = tinycolor.isReadable(\n globalColors.neutral.blueGrayDark[1100],\n brandColors[400],\n WCAG2ContrastOptions,\n )\n ? brandColors[400]\n : globalColors.neutral.blueGrayDark[0];\n\n const foregroundOnBrand = tinycolor\n .mostReadable(\n brandColors[900],\n [globalColors.neutral.white[500], globalColors.neutral.black[500]],\n WCAG2ContrastOptions,\n )\n .toHslString();\n\n // Overrides for the dark theme with the brand colors passed in\n const darkThemeOverrides: DeepPartial<ThemeTokens['colors']['onDark']> = {\n interactive: {\n background: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n fadedHighlighted: brandColors.a150,\n },\n },\n border: {\n primary: {\n default: brandColors[600],\n highlighted: brandColors[700],\n disabled: brandColors.a100,\n faded: brandColors.a100,\n },\n },\n text: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a400,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n icon: {\n primary: {\n normal: foregroundOnSurface,\n disabled: brandColors.a400,\n muted: foregroundOnSurface,\n subtle: foregroundOnSurface,\n },\n onPrimary: {\n normal: foregroundOnBrand,\n disabled: foregroundOnBrand,\n muted: foregroundOnBrand,\n subtle: foregroundOnBrand,\n },\n },\n },\n surface: {\n background: {\n primary: {\n intense: brandColors[600],\n subtle: brandColors[200],\n },\n },\n border: {\n primary: {\n normal: brandColors[600],\n muted: brandColors.a200,\n },\n },\n icon: {\n primary: {\n normal: brandColors[600],\n },\n },\n },\n };\n\n return darkThemeOverrides;\n};\n\n/**\n * @param {Object} themeConfig - The brand color and overrides to apply to the theme\n * @param {string} themeConfig.brandColor - The brand color to use to generate the theme. Can be in hex, rgb, or hsl format.\n * @description\n * Creates a Blade Theme based on the custom brand color\n * @returns The Theme Tokens with the custom brand colors\n * @example\n * const { theme, brandColors } = createTheme({ brandColor: '#19BEA2'})\n **/\nexport const createTheme = ({\n brandColor,\n}: {\n brandColor: ColorInput;\n}): { theme: ThemeTokens; brandColors: ColorChromaticScale } => {\n const chromaticBrandColors = generateChromaticBrandColors(brandColor);\n // Get onLight overrides\n const brandedLightTheme = getOnLightOverrides(chromaticBrandColors);\n // Get onDark overrides\n const brandedDarkTheme = getOnDarkOverrides(chromaticBrandColors);\n // Override the payment theme with the brand colors\n const brandedThemeTokens = overrideTheme({\n baseThemeTokens: bladeTheme,\n overrides: {\n name: `custom-${tinycolor(brandColor).toHex()}`,\n colors: {\n onLight: {\n ...brandedLightTheme,\n },\n onDark: {\n ...brandedDarkTheme,\n },\n },\n },\n });\n\n return { theme: brandedThemeTokens, brandColors: chromaticBrandColors };\n};\n"],"names":["WCAG2ContrastOptions","level","size","getColorWithOpacity","color","opacity","tinycolor","setAlpha","toHslString","generateChromaticBrandColors","baseColorInput","baseColor","baseColorHslString","isValid","throwBladeError","message","moduleName","palette","brightness","getBrightness","lightnessFactor","darknessFactor","currentColor","lightShadeIndex","brighten","push","darkShadeIndex","darken","unshift","colorPalette","reverse","brandPrimaryColor","brandColors","a50","a150","a100","a200","a400","getOnLightOverrides","foregroundOnSurface","isReadable","globalColors","neutral","blueGrayLight","foregroundOnBrand","mostReadable","white","black","lightThemeOverrides","interactive","background","primary","highlighted","disabled","faded","fadedHighlighted","border","text","normal","muted","subtle","onPrimary","icon","surface","intense","getOnDarkOverrides","blueGrayDark","darkThemeOverrides","createTheme","_ref","brandColor","chromaticBrandColors","brandedLightTheme","brandedDarkTheme","brandedThemeTokens","overrideTheme","baseThemeTokens","bladeTheme","overrides","name","concat","toHex","colors","onLight","_objectSpread","onDark","theme"],"mappings":";;;;;;;;;;;;AAUA;AACA,IAAMA,oBAAkC,GAAG;AACzCC,EAAAA,KAAK,EAAE,KAAK;AACZC,EAAAA,IAAI,EAAE,OAAA;AACR,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAmBA,CA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