reshaped 3.6.0-canary.4 → 3.6.0-canary.6
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/CHANGELOG.md +10 -1
- package/dist/bundle.css +1 -1
- package/dist/bundle.js +6 -6
- package/dist/cjs/cli/theming/index.d.ts +3 -3
- package/dist/cjs/cli/theming/index.js +2 -2
- package/dist/cjs/cli/theming/tailwind.d.ts +2 -3
- package/dist/cjs/cli/theming/tailwind.js +1 -1
- package/dist/cjs/themes/_generator/definitions/slate.js +1 -1
- package/dist/cjs/themes/_generator/tokens/color/color.transforms.d.ts +2 -2
- package/dist/cjs/themes/_generator/tokens/color/color.transforms.js +29 -7
- package/dist/cjs/themes/_generator/tokens/color/color.types.d.ts +28 -3
- package/dist/cjs/themes/_generator/tokens/color/utilities/a11y.d.ts +20 -0
- package/dist/cjs/themes/_generator/tokens/color/utilities/a11y.js +64 -0
- package/dist/cjs/themes/_generator/tokens/color/utilities/convert.d.ts +11 -0
- package/dist/cjs/themes/_generator/tokens/color/utilities/convert.js +33 -0
- package/dist/cjs/themes/_generator/tokens/color/utilities/generateColors.d.ts +4 -0
- package/dist/cjs/themes/_generator/tokens/color/utilities/generateColors.js +152 -0
- package/dist/cjs/themes/_generator/tokens/color/utilities/generateMetaColors.d.ts +4 -0
- package/dist/cjs/themes/_generator/tokens/color/utilities/generateMetaColors.js +68 -0
- package/dist/cjs/themes/_generator/tokens/color/utilities/tests/a11y.test.js +38 -0
- package/dist/cjs/themes/_generator/tokens/color/utilities/tests/convert.test.d.ts +1 -0
- package/dist/cjs/themes/_generator/tokens/color/utilities/tests/convert.test.js +48 -0
- package/dist/cjs/themes/_generator/tokens/color/utilities/tests/generateColors.test.d.ts +1 -0
- package/dist/cjs/themes/_generator/tokens/color/utilities/tests/generateColors.test.js +21 -0
- package/dist/{themes/_generator/utilities → cjs/themes/_generator/tokens}/css.d.ts +1 -1
- package/dist/cjs/themes/_generator/tokens/duration/duration.transforms.d.ts +2 -2
- package/dist/cjs/themes/_generator/tokens/duration/duration.transforms.js +2 -2
- package/dist/cjs/themes/_generator/tokens/easing/easing.transforms.d.ts +2 -2
- package/dist/cjs/themes/_generator/tokens/easing/easing.transforms.js +2 -2
- package/dist/cjs/themes/_generator/tokens/font/font.transforms.d.ts +2 -2
- package/dist/cjs/themes/_generator/tokens/font/font.transforms.js +3 -3
- package/dist/cjs/themes/_generator/tokens/fontFamily/fontFamily.transforms.d.ts +2 -2
- package/dist/cjs/themes/_generator/tokens/fontFamily/fontFamily.transforms.js +2 -2
- package/dist/cjs/themes/_generator/tokens/fontWeight/fontWeight.transforms.d.ts +2 -2
- package/dist/cjs/themes/_generator/tokens/fontWeight/fontWeight.transforms.js +2 -2
- package/dist/cjs/themes/_generator/tokens/radius/radius.transforms.d.ts +2 -2
- package/dist/cjs/themes/_generator/tokens/radius/radius.transforms.js +2 -2
- package/dist/cjs/themes/_generator/tokens/shadow/shadow.transforms.d.ts +2 -2
- package/dist/cjs/themes/_generator/tokens/shadow/shadow.transforms.js +4 -4
- package/dist/cjs/themes/_generator/tokens/types.d.ts +19 -17
- package/dist/cjs/themes/_generator/tokens/unit/unit.transforms.d.ts +2 -2
- package/dist/cjs/themes/_generator/tokens/unit/unit.transforms.js +2 -2
- package/dist/cjs/themes/_generator/tokens/unit/utilities/generate.d.ts +5 -0
- package/dist/cjs/themes/_generator/{utilities/generateUnits.js → tokens/unit/utilities/generate.js} +5 -4
- package/dist/cjs/themes/_generator/tokens/viewport/viewport.transforms.d.ts +2 -2
- package/dist/cjs/themes/_generator/tokens/viewport/viewport.transforms.js +2 -2
- package/dist/cjs/themes/_generator/transform.d.ts +3 -2
- package/dist/cjs/themes/_generator/transform.js +45 -11
- package/dist/cjs/themes/_generator/types.d.ts +4 -8
- package/dist/cjs/themes/_generator/utilities/mergeDefinitions.d.ts +1 -3
- package/dist/cjs/themes/_generator/utilities/mergeDefinitions.js +6 -4
- package/dist/cjs/themes/figma/tailwind.css +1 -1
- package/dist/cjs/themes/figma/theme.css +1 -1
- package/dist/cjs/themes/fragments/twitter/tailwind.css +1 -1
- package/dist/cjs/themes/fragments/twitter/theme.css +1 -1
- package/dist/cjs/themes/index.d.ts +4 -11
- package/dist/cjs/themes/index.js +2 -5
- package/dist/cjs/themes/reshaped/tailwind.css +1 -1
- package/dist/cjs/themes/reshaped/theme.css +1 -1
- package/dist/cjs/themes/slate/tailwind.css +1 -1
- package/dist/cjs/themes/slate/theme.css +1 -1
- package/dist/cjs/types/config.d.ts +11 -7
- package/dist/cli/theming/index.d.ts +3 -3
- package/dist/cli/theming/index.js +2 -2
- package/dist/cli/theming/tailwind.d.ts +2 -3
- package/dist/cli/theming/tailwind.js +1 -1
- package/dist/components/Accordion/Accordion.types.d.ts +2 -1
- package/dist/components/Accordion/AccordionContent.js +3 -2
- package/dist/components/Accordion/AccordionControlled.js +3 -2
- package/dist/components/Accordion/tests/Accordion.stories.d.ts +4 -0
- package/dist/components/Accordion/tests/Accordion.stories.js +11 -0
- package/dist/components/Autocomplete/tests/Autocomplete.stories.js +3 -6
- package/dist/components/DropdownMenu/DropdownMenu.types.d.ts +1 -1
- package/dist/components/FormControl/FormControl.context.d.ts +1 -1
- package/dist/components/ScrollArea/ScrollArea.js +1 -1
- package/dist/components/TextField/TextField.js +2 -2
- package/dist/components/TextField/TextField.module.css +1 -1
- package/dist/tests/ThemesPlayground.d.ts +2 -0
- package/dist/tests/ThemesPlayground.js +90 -0
- package/dist/tests/themes.stories.d.ts +16 -0
- package/dist/{themes/_generator/tests → tests}/themes.stories.js +74 -15
- package/dist/themes/_generator/definitions/slate.js +1 -1
- package/dist/themes/_generator/tokens/color/color.transforms.d.ts +2 -2
- package/dist/themes/_generator/tokens/color/color.transforms.js +29 -7
- package/dist/themes/_generator/tokens/color/color.types.d.ts +28 -3
- package/dist/themes/_generator/tokens/color/utilities/a11y.d.ts +20 -0
- package/dist/themes/_generator/tokens/color/utilities/a11y.js +58 -0
- package/dist/themes/_generator/tokens/color/utilities/convert.d.ts +11 -0
- package/dist/themes/_generator/tokens/color/utilities/convert.js +27 -0
- package/dist/themes/_generator/tokens/color/utilities/generateColors.d.ts +4 -0
- package/dist/themes/_generator/tokens/color/utilities/generateColors.js +150 -0
- package/dist/themes/_generator/tokens/color/utilities/generateMetaColors.d.ts +4 -0
- package/dist/themes/_generator/tokens/color/utilities/generateMetaColors.js +66 -0
- package/dist/{cjs/themes/_generator/utilities → themes/_generator/tokens}/css.d.ts +1 -1
- package/dist/themes/_generator/tokens/duration/duration.transforms.d.ts +2 -2
- package/dist/themes/_generator/tokens/duration/duration.transforms.js +2 -2
- package/dist/themes/_generator/tokens/easing/easing.transforms.d.ts +2 -2
- package/dist/themes/_generator/tokens/easing/easing.transforms.js +2 -2
- package/dist/themes/_generator/tokens/font/font.transforms.d.ts +2 -2
- package/dist/themes/_generator/tokens/font/font.transforms.js +3 -3
- package/dist/themes/_generator/tokens/fontFamily/fontFamily.transforms.d.ts +2 -2
- package/dist/themes/_generator/tokens/fontFamily/fontFamily.transforms.js +2 -2
- package/dist/themes/_generator/tokens/fontWeight/fontWeight.transforms.d.ts +2 -2
- package/dist/themes/_generator/tokens/fontWeight/fontWeight.transforms.js +2 -2
- package/dist/themes/_generator/tokens/radius/radius.transforms.d.ts +2 -2
- package/dist/themes/_generator/tokens/radius/radius.transforms.js +2 -2
- package/dist/themes/_generator/tokens/shadow/shadow.transforms.d.ts +2 -2
- package/dist/themes/_generator/tokens/shadow/shadow.transforms.js +4 -4
- package/dist/themes/_generator/tokens/types.d.ts +19 -17
- package/dist/themes/_generator/tokens/unit/unit.transforms.d.ts +2 -2
- package/dist/themes/_generator/tokens/unit/unit.transforms.js +2 -2
- package/dist/themes/_generator/tokens/unit/utilities/generate.d.ts +5 -0
- package/dist/themes/_generator/{utilities/generateUnits.js → tokens/unit/utilities/generate.js} +4 -5
- package/dist/themes/_generator/tokens/viewport/viewport.transforms.d.ts +2 -2
- package/dist/themes/_generator/tokens/viewport/viewport.transforms.js +2 -2
- package/dist/themes/_generator/transform.d.ts +3 -2
- package/dist/themes/_generator/transform.js +45 -11
- package/dist/themes/_generator/types.d.ts +4 -8
- package/dist/themes/_generator/utilities/mergeDefinitions.d.ts +1 -3
- package/dist/themes/_generator/utilities/mergeDefinitions.js +6 -4
- package/dist/themes/figma/tailwind.css +1 -1
- package/dist/themes/figma/theme.css +1 -1
- package/dist/themes/fragments/twitter/tailwind.css +1 -1
- package/dist/themes/fragments/twitter/theme.css +1 -1
- package/dist/themes/index.d.ts +4 -11
- package/dist/themes/index.js +1 -4
- package/dist/themes/reshaped/tailwind.css +1 -1
- package/dist/themes/reshaped/theme.css +1 -1
- package/dist/themes/slate/tailwind.css +1 -1
- package/dist/themes/slate/theme.css +1 -1
- package/dist/types/config.d.ts +11 -7
- package/dist/types/global.d.ts +3 -0
- package/package.json +24 -23
- package/dist/cjs/themes/_generator/utilities/color.d.ts +0 -105
- package/dist/cjs/themes/_generator/utilities/color.js +0 -409
- package/dist/cjs/themes/_generator/utilities/generateBackgroundColors.d.ts +0 -4
- package/dist/cjs/themes/_generator/utilities/generateBackgroundColors.js +0 -59
- package/dist/cjs/themes/_generator/utilities/generateColors.d.ts +0 -11
- package/dist/cjs/themes/_generator/utilities/generateColors.js +0 -178
- package/dist/cjs/themes/_generator/utilities/generateUnits.d.ts +0 -4
- package/dist/cjs/themes/_generator/utilities/mergeDeep.d.ts +0 -5
- package/dist/cjs/themes/_generator/utilities/mergeDeep.js +0 -24
- package/dist/cjs/themes/_generator/utilities/resolveTokenReference.d.ts +0 -3
- package/dist/cjs/themes/_generator/utilities/resolveTokenReference.js +0 -18
- package/dist/cjs/themes/_generator/utilities/tests/color.test.js +0 -81
- package/dist/themes/_generator/tests/themes.stories.d.ts +0 -16
- package/dist/themes/_generator/utilities/color.d.ts +0 -105
- package/dist/themes/_generator/utilities/color.js +0 -377
- package/dist/themes/_generator/utilities/generateBackgroundColors.d.ts +0 -4
- package/dist/themes/_generator/utilities/generateBackgroundColors.js +0 -57
- package/dist/themes/_generator/utilities/generateColors.d.ts +0 -11
- package/dist/themes/_generator/utilities/generateColors.js +0 -176
- package/dist/themes/_generator/utilities/generateUnits.d.ts +0 -4
- package/dist/themes/_generator/utilities/mergeDeep.d.ts +0 -5
- package/dist/themes/_generator/utilities/mergeDeep.js +0 -22
- package/dist/themes/_generator/utilities/resolveTokenReference.d.ts +0 -3
- package/dist/themes/_generator/utilities/resolveTokenReference.js +0 -16
- /package/dist/cjs/themes/_generator/{utilities/tests/color.test.d.ts → tokens/color/utilities/tests/a11y.test.d.ts} +0 -0
- /package/dist/cjs/themes/_generator/{utilities → tokens}/css.js +0 -0
- /package/dist/themes/_generator/{utilities → tokens}/css.js +0 -0
package/dist/types/config.d.ts
CHANGED
@@ -1,14 +1,18 @@
|
|
1
|
-
import type {
|
1
|
+
import type { PassedThemeDefinition } from "../themes/_generator/tokens/types";
|
2
|
+
import type { HexColor, Hue, OklchColor } from "../themes/_generator/tokens/color/color.types";
|
2
3
|
export type ReshapedConfig = {
|
3
|
-
themes?: Record<string,
|
4
|
-
themeFragments?: Record<string,
|
4
|
+
themes?: Record<string, PassedThemeDefinition>;
|
5
|
+
themeFragments?: Record<string, PassedThemeDefinition>;
|
5
6
|
themeOptions?: {
|
6
|
-
generateOnColorsFor?: string[];
|
7
7
|
colorContrastAlgorithm?: "wcag" | "apca";
|
8
|
+
generateOnColorsFor?: string[];
|
8
9
|
onColorValues?: {
|
9
|
-
[key in
|
10
|
-
hexDark:
|
11
|
-
hexLight:
|
10
|
+
[key in Hue]?: {
|
11
|
+
hexDark: HexColor;
|
12
|
+
hexLight: HexColor;
|
13
|
+
} | {
|
14
|
+
oklchDark: OklchColor;
|
15
|
+
oklchLight: OklchColor;
|
12
16
|
};
|
13
17
|
};
|
14
18
|
};
|
package/dist/types/global.d.ts
CHANGED
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "reshaped",
|
3
3
|
"description": "Professionally crafted design system in React & Figma for building products of any scale and complexity",
|
4
|
-
"version": "3.6.0-canary.
|
4
|
+
"version": "3.6.0-canary.6",
|
5
5
|
"license": "MIT",
|
6
6
|
"email": "hello@reshaped.so",
|
7
7
|
"homepage": "https://reshaped.so",
|
@@ -96,33 +96,33 @@
|
|
96
96
|
"@commitlint/cli": "19.8.1",
|
97
97
|
"@commitlint/config-conventional": "19.8.1",
|
98
98
|
"@commitlint/types": "19.8.1",
|
99
|
-
"@eslint/js": "9.
|
99
|
+
"@eslint/js": "9.28.0",
|
100
100
|
"@size-limit/preset-big-lib": "11.2.0",
|
101
|
-
"@storybook/addon-a11y": "9.0.
|
102
|
-
"@storybook/addon-docs": "9.0.
|
103
|
-
"@storybook/addon-vitest": "9.0.
|
104
|
-
"@storybook/react-vite": "9.0.
|
101
|
+
"@storybook/addon-a11y": "9.0.4",
|
102
|
+
"@storybook/addon-docs": "9.0.4",
|
103
|
+
"@storybook/addon-vitest": "9.0.4",
|
104
|
+
"@storybook/react-vite": "9.0.4",
|
105
105
|
"@types/culori": "4.0.0",
|
106
106
|
"@types/events": "3.0.3",
|
107
|
-
"@types/node": "22.15.
|
108
|
-
"@types/react": "19.1.
|
107
|
+
"@types/node": "22.15.29",
|
108
|
+
"@types/react": "19.1.6",
|
109
109
|
"@types/react-dom": "19.1.5",
|
110
|
-
"@vitejs/plugin-react": "4.
|
111
|
-
"@vitest/browser": "3.
|
112
|
-
"@vitest/coverage-istanbul": "3.
|
113
|
-
"@vitest/coverage-v8": "3.
|
114
|
-
"chromatic": "
|
110
|
+
"@vitejs/plugin-react": "4.5.0",
|
111
|
+
"@vitest/browser": "3.2.0",
|
112
|
+
"@vitest/coverage-istanbul": "3.2.0",
|
113
|
+
"@vitest/coverage-v8": "3.2.0",
|
114
|
+
"chromatic": "12.0.0",
|
115
115
|
"conventional-changelog-cli": "5.0.0",
|
116
116
|
"cz-conventional-changelog": "3.3.0",
|
117
|
-
"eslint": "9.
|
117
|
+
"eslint": "9.28.0",
|
118
118
|
"eslint-config-prettier": "10.1.5",
|
119
119
|
"eslint-plugin-jsx-a11y": "6.10.2",
|
120
|
-
"eslint-plugin-prettier": "5.4.
|
120
|
+
"eslint-plugin-prettier": "5.4.1",
|
121
121
|
"eslint-plugin-react": "7.37.5",
|
122
122
|
"eslint-plugin-react-hooks": "5.2.0",
|
123
123
|
"lefthook": "1.11.13",
|
124
124
|
"playwright": "1.52.0",
|
125
|
-
"postcss": "8.5.
|
125
|
+
"postcss": "8.5.4",
|
126
126
|
"postcss-cli": "11.0.1",
|
127
127
|
"postcss-each": "1.1.0",
|
128
128
|
"postcss-nested": "7.0.2",
|
@@ -132,16 +132,16 @@
|
|
132
132
|
"react-shadow": "20.6.0",
|
133
133
|
"resolve-tspaths": "0.8.23",
|
134
134
|
"size-limit": "11.2.0",
|
135
|
-
"storybook": "9.0.
|
136
|
-
"stylelint": "16.
|
135
|
+
"storybook": "9.0.4",
|
136
|
+
"stylelint": "16.20.0",
|
137
137
|
"stylelint-config-prettier": "9.0.5",
|
138
138
|
"stylelint-config-standard": "38.0.0",
|
139
139
|
"ts-node": "10.9.2",
|
140
140
|
"typescript": "5.8.3",
|
141
|
-
"typescript-eslint": "8.
|
141
|
+
"typescript-eslint": "8.33.1",
|
142
142
|
"vite": "6.3.5",
|
143
143
|
"vite-tsconfig-paths": "5.1.4",
|
144
|
-
"vitest": "3.
|
144
|
+
"vitest": "3.2.0",
|
145
145
|
"vitest-browser-react": "0.2.0"
|
146
146
|
},
|
147
147
|
"peerDependencies": {
|
@@ -152,11 +152,11 @@
|
|
152
152
|
"dependencies": {
|
153
153
|
"@csstools/postcss-global-data": "3.0.0",
|
154
154
|
"chalk": "4.1.2",
|
155
|
-
"commander": "
|
155
|
+
"commander": "14.0.0",
|
156
156
|
"cssnano": "7.0.7",
|
157
157
|
"csstype": "3.1.3",
|
158
158
|
"culori": "4.0.1",
|
159
|
-
"postcss-custom-media": "11.0.
|
159
|
+
"postcss-custom-media": "11.0.6"
|
160
160
|
},
|
161
161
|
"size-limit": [
|
162
162
|
{
|
@@ -181,6 +181,7 @@
|
|
181
181
|
}
|
182
182
|
],
|
183
183
|
"engines": {
|
184
|
-
"yarn": ">=1.0.0"
|
184
|
+
"yarn": ">=1.0.0",
|
185
|
+
"node": ">=20"
|
185
186
|
}
|
186
187
|
}
|
@@ -1,105 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Some of the color conversion utilities are taken from https://github.com/hsluv/hsluv-javascript
|
3
|
-
* They have been rewritten for easier color transformations in the theme generation case
|
4
|
-
*/
|
5
|
-
type RgbColor = {
|
6
|
-
r: number;
|
7
|
-
g: number;
|
8
|
-
b: number;
|
9
|
-
};
|
10
|
-
type HslColor = {
|
11
|
-
h: number;
|
12
|
-
s: number;
|
13
|
-
l: number;
|
14
|
-
};
|
15
|
-
type XyzColor = {
|
16
|
-
x: number;
|
17
|
-
y: number;
|
18
|
-
z: number;
|
19
|
-
};
|
20
|
-
type LuvColor = {
|
21
|
-
l: number;
|
22
|
-
u: number;
|
23
|
-
v: number;
|
24
|
-
};
|
25
|
-
type LchColor = {
|
26
|
-
l: number;
|
27
|
-
c: number;
|
28
|
-
h: number;
|
29
|
-
};
|
30
|
-
type BoundingLines = {
|
31
|
-
r0s: number;
|
32
|
-
r0i: number;
|
33
|
-
r1s: number;
|
34
|
-
r1i: number;
|
35
|
-
g0s: number;
|
36
|
-
g0i: number;
|
37
|
-
g1s: number;
|
38
|
-
g1i: number;
|
39
|
-
b0s: number;
|
40
|
-
b0i: number;
|
41
|
-
b1s: number;
|
42
|
-
b1i: number;
|
43
|
-
};
|
44
|
-
/**
|
45
|
-
* Color utilities
|
46
|
-
*/
|
47
|
-
export declare const calculateBoundingLines: (l: number) => BoundingLines;
|
48
|
-
export declare const distanceFromOriginAngle: (slope: number, intercept: number, angle: number) => number;
|
49
|
-
export declare const calcMaxChromaHsluv: (h: number, boundingLines: BoundingLines) => number;
|
50
|
-
export declare function hexToRgb(hex: string): RgbColor;
|
51
|
-
export declare const rgbToHsl: ({ r, g, b }: RgbColor) => HslColor;
|
52
|
-
export declare const hslToRgb: ({ h, s, l }: HslColor) => RgbColor;
|
53
|
-
export declare const rgbToHex: ({ r, g, b }: RgbColor) => string;
|
54
|
-
export declare const toLinear: (c: number) => number;
|
55
|
-
export declare const fromLinear: (c: number) => number;
|
56
|
-
export declare const rgbToXyz: ({ r, g, b }: RgbColor) => {
|
57
|
-
x: number;
|
58
|
-
y: number;
|
59
|
-
z: number;
|
60
|
-
};
|
61
|
-
export declare const xyzToRgb: ({ x, y, z }: XyzColor) => RgbColor;
|
62
|
-
export declare const yToL: (y: number) => number;
|
63
|
-
export declare const lToY: (l: number) => number;
|
64
|
-
export declare const xyzToLuv: ({ x, y, z }: XyzColor) => LuvColor;
|
65
|
-
export declare const luvToXyz: ({ l, u, v }: LuvColor) => XyzColor;
|
66
|
-
export declare const luvToLch: ({ l, u, v }: LuvColor) => LchColor;
|
67
|
-
export declare const lchToLuv: ({ l, c, h }: LchColor) => LuvColor;
|
68
|
-
export declare const lchToHsluv: ({ l, c, h }: LchColor) => HslColor;
|
69
|
-
export declare const hsluvToLch: ({ h, s, l }: HslColor) => LchColor;
|
70
|
-
export declare const hsluvToHex: (hsl: HslColor) => string;
|
71
|
-
export declare const hexToHsl: (H: string) => HslColor;
|
72
|
-
export declare const hexToHsluv: (hex: string) => HslColor;
|
73
|
-
export declare const hslToHex: (hsl: HslColor) => string;
|
74
|
-
/**
|
75
|
-
* Normalizing utilities
|
76
|
-
*/
|
77
|
-
export declare const getDarkModeColor: (hsl: HslColor) => {
|
78
|
-
s: number;
|
79
|
-
l: number;
|
80
|
-
h: number;
|
81
|
-
};
|
82
|
-
export declare const getLuminanceDelta: (luminance: number) => number;
|
83
|
-
export declare function getRgbLuminance({ r, g, b }: RgbColor): number;
|
84
|
-
export declare const getOnColorWCAG: (args: {
|
85
|
-
bgHexColor: string;
|
86
|
-
lightHexColor?: string;
|
87
|
-
darkHexColor?: string;
|
88
|
-
}) => string;
|
89
|
-
export declare const getOnColorAPCA: (args: {
|
90
|
-
bgHexColor: string;
|
91
|
-
mode: "light" | "dark";
|
92
|
-
lightHexColor?: string;
|
93
|
-
darkHexColor?: string;
|
94
|
-
}) => string;
|
95
|
-
/**
|
96
|
-
* On color resolver
|
97
|
-
*/
|
98
|
-
export declare const getOnColor: (args: {
|
99
|
-
bgHexColor: string;
|
100
|
-
lightHexColor?: string;
|
101
|
-
darkHexColor?: string;
|
102
|
-
mode: "light" | "dark";
|
103
|
-
algorithm?: "wcag" | "apca";
|
104
|
-
}) => string;
|
105
|
-
export {};
|
@@ -1,409 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
/**
|
3
|
-
* Some of the color conversion utilities are taken from https://github.com/hsluv/hsluv-javascript
|
4
|
-
* They have been rewritten for easier color transformations in the theme generation case
|
5
|
-
*/
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
7
|
-
exports.getOnColor = exports.getOnColorAPCA = exports.getOnColorWCAG = exports.getLuminanceDelta = exports.getDarkModeColor = exports.hslToHex = exports.hexToHsluv = exports.hexToHsl = exports.hsluvToHex = exports.hsluvToLch = exports.lchToHsluv = exports.lchToLuv = exports.luvToLch = exports.luvToXyz = exports.xyzToLuv = exports.lToY = exports.yToL = exports.xyzToRgb = exports.rgbToXyz = exports.fromLinear = exports.toLinear = exports.rgbToHex = exports.hslToRgb = exports.rgbToHsl = exports.calcMaxChromaHsluv = exports.distanceFromOriginAngle = exports.calculateBoundingLines = void 0;
|
8
|
-
exports.hexToRgb = hexToRgb;
|
9
|
-
exports.getRgbLuminance = getRgbLuminance;
|
10
|
-
/**
|
11
|
-
* Constants
|
12
|
-
*/
|
13
|
-
const epsilon = 0.0088564516;
|
14
|
-
const refY = 1.0;
|
15
|
-
const refU = 0.19783000664283;
|
16
|
-
const refV = 0.46831999493879;
|
17
|
-
const kappa = 903.2962962;
|
18
|
-
const mr0 = 3.240969941904521;
|
19
|
-
const mr1 = -1.537383177570093;
|
20
|
-
const mr2 = -0.498610760293;
|
21
|
-
const mg0 = -0.96924363628087;
|
22
|
-
const mg1 = 1.87596750150772;
|
23
|
-
const mg2 = 0.041555057407175;
|
24
|
-
const mb0 = 0.055630079696993;
|
25
|
-
const mb1 = -0.20397695888897;
|
26
|
-
const mb2 = 1.056971514242878;
|
27
|
-
/**
|
28
|
-
* Color utilities
|
29
|
-
*/
|
30
|
-
const calculateBoundingLines = (l) => {
|
31
|
-
const sub1 = Math.pow(l + 16, 3) / 1560896;
|
32
|
-
const sub2 = sub1 > epsilon ? sub1 : l / kappa;
|
33
|
-
const s1r = sub2 * (284517 * mr0 - 94839 * mr2);
|
34
|
-
const s2r = sub2 * (838422 * mr2 + 769860 * mr1 + 731718 * mr0);
|
35
|
-
const s3r = sub2 * (632260 * mr2 - 126452 * mr1);
|
36
|
-
const s1g = sub2 * (284517 * mg0 - 94839 * mg2);
|
37
|
-
const s2g = sub2 * (838422 * mg2 + 769860 * mg1 + 731718 * mg0);
|
38
|
-
const s3g = sub2 * (632260 * mg2 - 126452 * mg1);
|
39
|
-
const s1b = sub2 * (284517 * mb0 - 94839 * mb2);
|
40
|
-
const s2b = sub2 * (838422 * mb2 + 769860 * mb1 + 731718 * mb0);
|
41
|
-
const s3b = sub2 * (632260 * mb2 - 126452 * mb1);
|
42
|
-
return {
|
43
|
-
r0s: s1r / s3r,
|
44
|
-
r0i: (s2r * l) / s3r,
|
45
|
-
r1s: s1r / (s3r + 126452),
|
46
|
-
r1i: ((s2r - 769860) * l) / (s3r + 126452),
|
47
|
-
g0s: s1g / s3g,
|
48
|
-
g0i: (s2g * l) / s3g,
|
49
|
-
g1s: s1g / (s3g + 126452),
|
50
|
-
g1i: ((s2g - 769860) * l) / (s3g + 126452),
|
51
|
-
b0s: s1b / s3b,
|
52
|
-
b0i: (s2b * l) / s3b,
|
53
|
-
b1s: s1b / (s3b + 126452),
|
54
|
-
b1i: ((s2b - 769860) * l) / (s3b + 126452),
|
55
|
-
};
|
56
|
-
};
|
57
|
-
exports.calculateBoundingLines = calculateBoundingLines;
|
58
|
-
const distanceFromOriginAngle = (slope, intercept, angle) => {
|
59
|
-
const d = intercept / (Math.sin(angle) - slope * Math.cos(angle));
|
60
|
-
return d < 0 ? Infinity : d;
|
61
|
-
};
|
62
|
-
exports.distanceFromOriginAngle = distanceFromOriginAngle;
|
63
|
-
const calcMaxChromaHsluv = (h, boundingLines) => {
|
64
|
-
const hueRad = (h / 360) * Math.PI * 2;
|
65
|
-
const r0 = (0, exports.distanceFromOriginAngle)(boundingLines.r0s, boundingLines.r0i, hueRad);
|
66
|
-
const r1 = (0, exports.distanceFromOriginAngle)(boundingLines.r1s, boundingLines.r1i, hueRad);
|
67
|
-
const g0 = (0, exports.distanceFromOriginAngle)(boundingLines.g0s, boundingLines.g0i, hueRad);
|
68
|
-
const g1 = (0, exports.distanceFromOriginAngle)(boundingLines.g1s, boundingLines.g1i, hueRad);
|
69
|
-
const b0 = (0, exports.distanceFromOriginAngle)(boundingLines.b0s, boundingLines.b0i, hueRad);
|
70
|
-
const b1 = (0, exports.distanceFromOriginAngle)(boundingLines.b1s, boundingLines.b1i, hueRad);
|
71
|
-
return Math.min(r0, r1, g0, g1, b0, b1);
|
72
|
-
};
|
73
|
-
exports.calcMaxChromaHsluv = calcMaxChromaHsluv;
|
74
|
-
function hexToRgb(hex) {
|
75
|
-
hex = hex.replace("#", "");
|
76
|
-
const r = parseInt(hex.substring(0, 2), 16);
|
77
|
-
const g = parseInt(hex.substring(2, 4), 16);
|
78
|
-
const b = parseInt(hex.substring(4, 6), 16);
|
79
|
-
return { r, g, b };
|
80
|
-
}
|
81
|
-
const rgbToHsl = ({ r, g, b }) => {
|
82
|
-
r /= 255;
|
83
|
-
g /= 255;
|
84
|
-
b /= 255;
|
85
|
-
const cmin = Math.min(r, g, b);
|
86
|
-
const cmax = Math.max(r, g, b);
|
87
|
-
const delta = cmax - cmin;
|
88
|
-
let h = 0;
|
89
|
-
let s = 0;
|
90
|
-
let l = 0;
|
91
|
-
if (delta == 0)
|
92
|
-
h = 0;
|
93
|
-
else if (cmax == r)
|
94
|
-
h = ((g - b) / delta) % 6;
|
95
|
-
else if (cmax == g)
|
96
|
-
h = (b - r) / delta + 2;
|
97
|
-
else
|
98
|
-
h = (r - g) / delta + 4;
|
99
|
-
h = Math.round(h * 60);
|
100
|
-
if (h < 0)
|
101
|
-
h += 360;
|
102
|
-
l = (cmax + cmin) / 2;
|
103
|
-
s = delta == 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));
|
104
|
-
s = +(s * 100).toFixed(1);
|
105
|
-
l = +(l * 100).toFixed(1);
|
106
|
-
return { h, s: Math.round(s), l: Math.round(l) };
|
107
|
-
};
|
108
|
-
exports.rgbToHsl = rgbToHsl;
|
109
|
-
const hslToRgb = ({ h, s, l }) => {
|
110
|
-
s /= 100;
|
111
|
-
l /= 100;
|
112
|
-
const c = (1 - Math.abs(2 * l - 1)) * s;
|
113
|
-
const x = c * (1 - Math.abs(((h / 60) % 2) - 1));
|
114
|
-
const m = l - c / 2;
|
115
|
-
const isSector1 = 0 <= h && h < 60;
|
116
|
-
const isSector2 = 60 <= h && h < 120;
|
117
|
-
const isSector3 = 120 <= h && h < 180;
|
118
|
-
const isSector4 = 180 <= h && h < 240;
|
119
|
-
const isSector5 = 240 <= h && h < 300;
|
120
|
-
const isSector6 = 300 <= h && h < 360;
|
121
|
-
const r = isSector1 || isSector6 ? c : isSector2 || isSector5 ? x : 0;
|
122
|
-
const g = isSector1 || isSector4 ? x : isSector2 || isSector3 ? c : 0;
|
123
|
-
const b = isSector1 || isSector2 ? 0 : isSector3 || isSector6 ? x : c;
|
124
|
-
return {
|
125
|
-
r: Math.round((r + m) * 255),
|
126
|
-
g: Math.round((g + m) * 255),
|
127
|
-
b: Math.round((b + m) * 255),
|
128
|
-
};
|
129
|
-
};
|
130
|
-
exports.hslToRgb = hslToRgb;
|
131
|
-
const rgbToHex = ({ r, g, b }) => {
|
132
|
-
const red = Math.round(r).toString(16).padStart(2, "0");
|
133
|
-
const green = Math.round(g).toString(16).padStart(2, "0");
|
134
|
-
const blue = Math.round(b).toString(16).padStart(2, "0");
|
135
|
-
return `#${red}${green}${blue}`;
|
136
|
-
};
|
137
|
-
exports.rgbToHex = rgbToHex;
|
138
|
-
const toLinear = (c) => {
|
139
|
-
if (c > 0.04045)
|
140
|
-
return Math.pow((c + 0.055) / 1.055, 2.4);
|
141
|
-
return c / 12.92;
|
142
|
-
};
|
143
|
-
exports.toLinear = toLinear;
|
144
|
-
const fromLinear = (c) => {
|
145
|
-
if (c <= 0.0031308)
|
146
|
-
return 12.92 * c;
|
147
|
-
return 1.055 * Math.pow(c, 1 / 2.4) - 0.055;
|
148
|
-
};
|
149
|
-
exports.fromLinear = fromLinear;
|
150
|
-
const rgbToXyz = ({ r, g, b }) => {
|
151
|
-
const lr = (0, exports.toLinear)(r / 255);
|
152
|
-
const lg = (0, exports.toLinear)(g / 255);
|
153
|
-
const lb = (0, exports.toLinear)(b / 255);
|
154
|
-
return {
|
155
|
-
x: 0.41239079926595 * lr + 0.35758433938387 * lg + 0.18048078840183 * lb,
|
156
|
-
y: 0.21263900587151 * lr + 0.71516867876775 * lg + 0.072192315360733 * lb,
|
157
|
-
z: 0.019330818715591 * lr + 0.11919477979462 * lg + 0.95053215224966 * lb,
|
158
|
-
};
|
159
|
-
};
|
160
|
-
exports.rgbToXyz = rgbToXyz;
|
161
|
-
const xyzToRgb = ({ x, y, z }) => {
|
162
|
-
return {
|
163
|
-
r: (0, exports.fromLinear)(mr0 * x + mr1 * y + mr2 * z) * 255,
|
164
|
-
g: (0, exports.fromLinear)(mg0 * x + mg1 * y + mg2 * z) * 255,
|
165
|
-
b: (0, exports.fromLinear)(mb0 * x + mb1 * y + mb2 * z) * 255,
|
166
|
-
};
|
167
|
-
};
|
168
|
-
exports.xyzToRgb = xyzToRgb;
|
169
|
-
const yToL = (y) => {
|
170
|
-
if (y <= epsilon)
|
171
|
-
return (y / refY) * kappa;
|
172
|
-
return 116 * Math.pow(y / refY, 1 / 3) - 16;
|
173
|
-
};
|
174
|
-
exports.yToL = yToL;
|
175
|
-
const lToY = (l) => {
|
176
|
-
if (l <= 8)
|
177
|
-
return (refY * l) / kappa;
|
178
|
-
return refY * Math.pow((l + 16) / 116, 3);
|
179
|
-
};
|
180
|
-
exports.lToY = lToY;
|
181
|
-
const xyzToLuv = ({ x, y, z }) => {
|
182
|
-
const divider = x + 15 * y + 3 * z;
|
183
|
-
const varU = divider !== 0 ? (4 * x) / divider : NaN;
|
184
|
-
const varV = divider !== 0 ? (9 * y) / divider : NaN;
|
185
|
-
const l = (0, exports.yToL)(y);
|
186
|
-
return {
|
187
|
-
l,
|
188
|
-
u: l === 0 ? 0 : 13 * l * (varU - refU),
|
189
|
-
v: l === 0 ? 0 : 13 * l * (varV - refV),
|
190
|
-
};
|
191
|
-
};
|
192
|
-
exports.xyzToLuv = xyzToLuv;
|
193
|
-
const luvToXyz = ({ l, u, v }) => {
|
194
|
-
if (l === 0)
|
195
|
-
return { x: 0, y: 0, z: 0 };
|
196
|
-
const varU = u / (13 * l) + refU;
|
197
|
-
const varV = v / (13 * l) + refV;
|
198
|
-
const y = (0, exports.lToY)(l);
|
199
|
-
const x = 0 - (9 * y * varU) / ((varU - 4) * varV - varU * varV);
|
200
|
-
const z = (9 * y - 15 * varV * y - varV * x) / (3 * varV);
|
201
|
-
return { x, y, z };
|
202
|
-
};
|
203
|
-
exports.luvToXyz = luvToXyz;
|
204
|
-
const luvToLch = ({ l, u, v }) => {
|
205
|
-
const c = Math.sqrt(u * u + v * v);
|
206
|
-
let h;
|
207
|
-
if (c < 0.00000001) {
|
208
|
-
h = 0;
|
209
|
-
}
|
210
|
-
else {
|
211
|
-
const hrad = Math.atan2(v, u);
|
212
|
-
h = (hrad * 180.0) / Math.PI;
|
213
|
-
if (h < 0)
|
214
|
-
h = 360 + h;
|
215
|
-
}
|
216
|
-
return { l, c, h };
|
217
|
-
};
|
218
|
-
exports.luvToLch = luvToLch;
|
219
|
-
const lchToLuv = ({ l, c, h }) => {
|
220
|
-
const hrad = (h / 180.0) * Math.PI;
|
221
|
-
return {
|
222
|
-
l,
|
223
|
-
u: Math.cos(hrad) * c,
|
224
|
-
v: Math.sin(hrad) * c,
|
225
|
-
};
|
226
|
-
};
|
227
|
-
exports.lchToLuv = lchToLuv;
|
228
|
-
const lchToHsluv = ({ l, c, h }) => {
|
229
|
-
let s;
|
230
|
-
let newL;
|
231
|
-
if (l > 99.9999999) {
|
232
|
-
s = 0;
|
233
|
-
newL = 100;
|
234
|
-
}
|
235
|
-
else if (l < 0.00000001) {
|
236
|
-
s = 0;
|
237
|
-
newL = 0;
|
238
|
-
}
|
239
|
-
else {
|
240
|
-
const boundingLines = (0, exports.calculateBoundingLines)(l);
|
241
|
-
const max = (0, exports.calcMaxChromaHsluv)(h, boundingLines);
|
242
|
-
s = (c / max) * 100;
|
243
|
-
newL = l;
|
244
|
-
}
|
245
|
-
return { h, s, l: newL };
|
246
|
-
};
|
247
|
-
exports.lchToHsluv = lchToHsluv;
|
248
|
-
const hsluvToLch = ({ h, s, l }) => {
|
249
|
-
let newL;
|
250
|
-
let c;
|
251
|
-
if (l > 99.9999999) {
|
252
|
-
newL = 100;
|
253
|
-
c = 0;
|
254
|
-
}
|
255
|
-
else if (l < 0.00000001) {
|
256
|
-
newL = 0;
|
257
|
-
c = 0;
|
258
|
-
}
|
259
|
-
else {
|
260
|
-
const boundingLines = (0, exports.calculateBoundingLines)(l);
|
261
|
-
const max = (0, exports.calcMaxChromaHsluv)(h, boundingLines);
|
262
|
-
newL = l;
|
263
|
-
c = (max / 100) * s;
|
264
|
-
}
|
265
|
-
return { l: newL, c, h };
|
266
|
-
};
|
267
|
-
exports.hsluvToLch = hsluvToLch;
|
268
|
-
const hsluvToHex = (hsl) => {
|
269
|
-
const lch = (0, exports.hsluvToLch)(hsl);
|
270
|
-
const luv = (0, exports.lchToLuv)(lch);
|
271
|
-
const xyz = (0, exports.luvToXyz)(luv);
|
272
|
-
const rgb = (0, exports.xyzToRgb)(xyz);
|
273
|
-
return (0, exports.rgbToHex)(rgb);
|
274
|
-
};
|
275
|
-
exports.hsluvToHex = hsluvToHex;
|
276
|
-
const hexToHsl = (H) => {
|
277
|
-
const rgb = hexToRgb(H);
|
278
|
-
return (0, exports.rgbToHsl)(rgb);
|
279
|
-
};
|
280
|
-
exports.hexToHsl = hexToHsl;
|
281
|
-
const hexToHsluv = (hex) => {
|
282
|
-
const rgb = hexToRgb(hex);
|
283
|
-
const xyz = (0, exports.rgbToXyz)(rgb);
|
284
|
-
const luv = (0, exports.xyzToLuv)(xyz);
|
285
|
-
const lch = (0, exports.luvToLch)(luv);
|
286
|
-
return (0, exports.lchToHsluv)(lch);
|
287
|
-
};
|
288
|
-
exports.hexToHsluv = hexToHsluv;
|
289
|
-
const hslToHex = (hsl) => {
|
290
|
-
const rgb = (0, exports.hslToRgb)(hsl);
|
291
|
-
return (0, exports.rgbToHex)(rgb);
|
292
|
-
};
|
293
|
-
exports.hslToHex = hslToHex;
|
294
|
-
/**
|
295
|
-
* Normalizing utilities
|
296
|
-
*/
|
297
|
-
const getDarkModeColor = (hsl) => {
|
298
|
-
const { s, l } = hsl;
|
299
|
-
/**
|
300
|
-
* Colors with lower saturation should have bigger lightness delta, for example it can be
|
301
|
-
* Neutral: l: 97 -> l dark: 13
|
302
|
-
* Warning: l: 53 -> l dark: 47
|
303
|
-
*
|
304
|
-
* Therefor we calculate the dark mode lightness based on a saturation modifier, which should be between 0 and 1
|
305
|
-
* We take base saturation:
|
306
|
-
* Neutral: 20 -> 0.2 modifier, Warning: 96 -> 0.96 modifier
|
307
|
-
*
|
308
|
-
* And we also adjust that value with a modifier of 0.9-2 based on the saturation
|
309
|
-
* That way satured colors won't change much from its original value
|
310
|
-
*/
|
311
|
-
const sModifier = (s / 100) * (0.96 + (100 - s) / 100);
|
312
|
-
return { ...hsl, s: Math.max(0, s - 7), l: l * sModifier };
|
313
|
-
};
|
314
|
-
exports.getDarkModeColor = getDarkModeColor;
|
315
|
-
const getLuminanceDelta = (luminance) => {
|
316
|
-
return Math.max(0, luminance - 50) / 5;
|
317
|
-
};
|
318
|
-
exports.getLuminanceDelta = getLuminanceDelta;
|
319
|
-
function getRgbLuminance({ r, g, b }) {
|
320
|
-
r /= 255;
|
321
|
-
g /= 255;
|
322
|
-
b /= 255;
|
323
|
-
const y = 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
324
|
-
// The CIE standard states 0.008856 but 216/24389 is the intent for 0.008856451679036
|
325
|
-
if (y <= 216 / 24389) {
|
326
|
-
// The CIE standard states 903.3, but 24389/27 is the intent, making 903.296296296296296
|
327
|
-
return y * (24389 / 27);
|
328
|
-
}
|
329
|
-
else {
|
330
|
-
return Math.pow(y, 1 / 3) * 116 - 16;
|
331
|
-
}
|
332
|
-
}
|
333
|
-
/**
|
334
|
-
* WCAG contrast
|
335
|
-
*/
|
336
|
-
const RED = 0.2126;
|
337
|
-
const GREEN = 0.7152;
|
338
|
-
const BLUE = 0.0722;
|
339
|
-
const GAMMA = 2.4;
|
340
|
-
function luminanceWCAG(r, g, b) {
|
341
|
-
const a = [r, g, b].map((v) => {
|
342
|
-
v /= 255;
|
343
|
-
return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, GAMMA);
|
344
|
-
});
|
345
|
-
return a[0] * RED + a[1] * GREEN + a[2] * BLUE;
|
346
|
-
}
|
347
|
-
function contrastWCAG(rgb1, rgb2) {
|
348
|
-
const lum1 = luminanceWCAG(...rgb1);
|
349
|
-
const lum2 = luminanceWCAG(...rgb2);
|
350
|
-
const brightest = Math.max(lum1, lum2);
|
351
|
-
const darkest = Math.min(lum1, lum2);
|
352
|
-
return (brightest + 0.05) / (darkest + 0.05);
|
353
|
-
}
|
354
|
-
const getOnColorWCAG = (args) => {
|
355
|
-
const { bgHexColor, lightHexColor = "#ffffff", darkHexColor = "#000000" } = args;
|
356
|
-
const bgRgb = hexToRgb(bgHexColor);
|
357
|
-
const lightRgb = hexToRgb(lightHexColor);
|
358
|
-
return contrastWCAG([bgRgb.r, bgRgb.g, bgRgb.b], [lightRgb.r, lightRgb.g, lightRgb.b]) > 4.5
|
359
|
-
? lightHexColor
|
360
|
-
: darkHexColor;
|
361
|
-
};
|
362
|
-
exports.getOnColorWCAG = getOnColorWCAG;
|
363
|
-
/**
|
364
|
-
* APCA contrast
|
365
|
-
*/
|
366
|
-
function luminanceAPCA({ r, g, b }) {
|
367
|
-
return (0.2126 * Math.pow(r / 255, 2.2) +
|
368
|
-
0.7152 * Math.pow(g / 255, 2.2) +
|
369
|
-
0.0722 * Math.pow(b / 255, 2.2));
|
370
|
-
}
|
371
|
-
function contrastAPCA(backgroundLuminance, textLuminance) {
|
372
|
-
// Calculate the contrast based on APCA
|
373
|
-
const Lc = textLuminance - backgroundLuminance;
|
374
|
-
return Math.abs(Lc); // Return the absolute value of contrast
|
375
|
-
}
|
376
|
-
const getOnColorAPCA = (args) => {
|
377
|
-
const { bgHexColor, mode, lightHexColor = "#ffffff", darkHexColor = "#000000" } = args;
|
378
|
-
const bgHexAlpha = bgHexColor.slice(7);
|
379
|
-
const bgAlpha = bgHexAlpha ? Number((parseInt(bgHexAlpha, 16) / 255).toFixed(2)) : 1;
|
380
|
-
const bgColor = hexToRgb(bgHexColor.slice(0, 7));
|
381
|
-
const baseColor = mode === "light" ? { r: 255, g: 255, b: 255 } : { r: 0, g: 0, b: 0 };
|
382
|
-
const { r, g, b } = {
|
383
|
-
r: (1 - bgAlpha) * baseColor.r + bgAlpha * bgColor.r,
|
384
|
-
g: (1 - bgAlpha) * baseColor.g + bgAlpha * bgColor.g,
|
385
|
-
b: (1 - bgAlpha) * baseColor.b + bgAlpha * bgColor.b,
|
386
|
-
};
|
387
|
-
// Calculate luminance for background and for white & black
|
388
|
-
const backgroundLuminance = luminanceAPCA({ r, g, b });
|
389
|
-
const whiteLuminance = luminanceAPCA({ r: 255, g: 255, b: 255 });
|
390
|
-
const blackLuminance = luminanceAPCA({ r: 0, g: 0, b: 0 });
|
391
|
-
// Calculate contrast
|
392
|
-
const contrastWithWhite = contrastAPCA(backgroundLuminance, whiteLuminance);
|
393
|
-
const contrastWithBlack = contrastAPCA(backgroundLuminance, blackLuminance);
|
394
|
-
// Choose the color with higher contrast
|
395
|
-
return contrastWithWhite > contrastWithBlack ? lightHexColor : darkHexColor;
|
396
|
-
};
|
397
|
-
exports.getOnColorAPCA = getOnColorAPCA;
|
398
|
-
/**
|
399
|
-
* On color resolver
|
400
|
-
*/
|
401
|
-
const getOnColor = (args) => {
|
402
|
-
if (args.algorithm === "apca") {
|
403
|
-
return (0, exports.getOnColorAPCA)(args);
|
404
|
-
}
|
405
|
-
else {
|
406
|
-
return (0, exports.getOnColorWCAG)(args);
|
407
|
-
}
|
408
|
-
};
|
409
|
-
exports.getOnColor = getOnColor;
|
@@ -1,4 +0,0 @@
|
|
1
|
-
import type * as T from "../types";
|
2
|
-
import type { FullThemeDefinition } from "../tokens/types";
|
3
|
-
declare const generateBackgroundColors: (definition: T.PartialDeep<FullThemeDefinition>, themeOptions?: T.PublicOptions["themeOptions"]) => void;
|
4
|
-
export default generateBackgroundColors;
|