@wordpress/theme 0.2.1-next.16d95556a.0 → 0.2.1-next.dc3f6d3c1.0
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/color-ramps/index.js +16 -12
- package/build/color-ramps/index.js.map +2 -2
- package/build/color-ramps/lib/color-utils.js +5 -0
- package/build/color-ramps/lib/color-utils.js.map +2 -2
- package/build/color-ramps/lib/constants.js +1 -1
- package/build/color-ramps/lib/constants.js.map +1 -1
- package/build/color-ramps/lib/default-ramps.js +88 -88
- package/build/color-ramps/lib/default-ramps.js.map +1 -1
- package/build/color-ramps/lib/find-color-with-constraints.js +1 -1
- package/build/color-ramps/lib/find-color-with-constraints.js.map +2 -2
- package/build/color-ramps/lib/index.js +2 -2
- package/build/color-ramps/lib/index.js.map +2 -2
- package/build/color-ramps/lib/ramp-configs.js +2 -2
- package/build/color-ramps/lib/ramp-configs.js.map +1 -1
- package/build/color-ramps/lib/utils.js +4 -8
- package/build/color-ramps/lib/utils.js.map +2 -2
- package/build/prebuilt/json/figma.json +51 -51
- package/build-module/color-ramps/index.js +17 -13
- package/build-module/color-ramps/index.js.map +2 -2
- package/build-module/color-ramps/lib/color-utils.js +7 -1
- package/build-module/color-ramps/lib/color-utils.js.map +2 -2
- package/build-module/color-ramps/lib/constants.js +1 -1
- package/build-module/color-ramps/lib/constants.js.map +1 -1
- package/build-module/color-ramps/lib/default-ramps.js +88 -88
- package/build-module/color-ramps/lib/default-ramps.js.map +1 -1
- package/build-module/color-ramps/lib/find-color-with-constraints.js +2 -2
- package/build-module/color-ramps/lib/find-color-with-constraints.js.map +2 -2
- package/build-module/color-ramps/lib/index.js +1 -2
- package/build-module/color-ramps/lib/index.js.map +2 -2
- package/build-module/color-ramps/lib/ramp-configs.js +2 -2
- package/build-module/color-ramps/lib/ramp-configs.js.map +1 -1
- package/build-module/color-ramps/lib/utils.js +0 -3
- package/build-module/color-ramps/lib/utils.js.map +2 -2
- package/build-module/prebuilt/json/figma.json +51 -51
- package/build-types/color-ramps/index.d.ts +1 -0
- package/build-types/color-ramps/index.d.ts.map +1 -1
- package/build-types/color-ramps/lib/color-utils.d.ts +5 -0
- package/build-types/color-ramps/lib/color-utils.d.ts.map +1 -1
- package/build-types/color-ramps/lib/constants.d.ts +1 -1
- package/build-types/color-ramps/lib/constants.d.ts.map +1 -1
- package/build-types/color-ramps/lib/index.d.ts.map +1 -1
- package/build-types/color-ramps/lib/utils.d.ts +0 -5
- package/build-types/color-ramps/lib/utils.d.ts.map +1 -1
- package/build-types/color-ramps/stories/index.story.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/color-ramps/index.ts +16 -11
- package/src/color-ramps/lib/color-utils.ts +11 -0
- package/src/color-ramps/lib/constants.ts +3 -3
- package/src/color-ramps/lib/default-ramps.ts +88 -88
- package/src/color-ramps/lib/find-color-with-constraints.ts +2 -2
- package/src/color-ramps/lib/index.ts +1 -2
- package/src/color-ramps/lib/ramp-configs.ts +2 -2
- package/src/color-ramps/lib/utils.ts +1 -8
- package/src/color-ramps/stories/index.story.tsx +7 -4
- package/src/prebuilt/css/design-tokens.css +51 -51
- package/src/prebuilt/json/figma.json +51 -51
- package/tokens/color.json +88 -88
- package/tsconfig.bin.tsbuildinfo +1 -1
- package/tsconfig.src.tsbuildinfo +1 -1
package/src/color-ramps/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { get, OKLCH, parse
|
|
4
|
+
import { get, OKLCH, parse } from 'colorjs.io/fn';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
@@ -89,6 +89,7 @@ export function checkAccessibleCombinations( {
|
|
|
89
89
|
fgName: keyof Ramp;
|
|
90
90
|
fgColor: string;
|
|
91
91
|
unmetContrast: number;
|
|
92
|
+
achievedContrast: number;
|
|
92
93
|
}[] = [];
|
|
93
94
|
|
|
94
95
|
// Assess combinations within each ramp
|
|
@@ -96,15 +97,17 @@ export function checkAccessibleCombinations( {
|
|
|
96
97
|
CONTRAST_COMBINATIONS.forEach( ( { bgs, fgs, target } ) => {
|
|
97
98
|
for ( const bg of bgs ) {
|
|
98
99
|
for ( const fg of fgs ) {
|
|
99
|
-
const bgColor =
|
|
100
|
-
const fgColor =
|
|
101
|
-
|
|
100
|
+
const bgColor = ramp.ramp[ bg ];
|
|
101
|
+
const fgColor = ramp.ramp[ fg ];
|
|
102
|
+
const achievedContrast = getContrast( bgColor, fgColor );
|
|
103
|
+
if ( achievedContrast < target ) {
|
|
102
104
|
unmetTargets.push( {
|
|
103
105
|
bgName: bg,
|
|
104
|
-
bgColor
|
|
106
|
+
bgColor,
|
|
105
107
|
fgName: fg,
|
|
106
|
-
fgColor
|
|
108
|
+
fgColor,
|
|
107
109
|
unmetContrast: target,
|
|
110
|
+
achievedContrast,
|
|
108
111
|
} );
|
|
109
112
|
}
|
|
110
113
|
}
|
|
@@ -116,15 +119,17 @@ export function checkAccessibleCombinations( {
|
|
|
116
119
|
CONTRAST_COMBINATIONS.forEach( ( { bgs, fgs, target } ) => {
|
|
117
120
|
for ( const bg of bgs ) {
|
|
118
121
|
for ( const fg of fgs ) {
|
|
119
|
-
const bgColor =
|
|
120
|
-
const fgColor =
|
|
121
|
-
|
|
122
|
+
const bgColor = bgRamp.ramp[ bg ];
|
|
123
|
+
const fgColor = ramp.ramp[ fg ];
|
|
124
|
+
const achievedContrast = getContrast( bgColor, fgColor );
|
|
125
|
+
if ( achievedContrast < target ) {
|
|
122
126
|
unmetTargets.push( {
|
|
123
127
|
bgName: bg,
|
|
124
|
-
bgColor
|
|
128
|
+
bgColor,
|
|
125
129
|
fgName: fg,
|
|
126
|
-
fgColor
|
|
130
|
+
fgColor,
|
|
127
131
|
unmetContrast: target,
|
|
132
|
+
achievedContrast,
|
|
128
133
|
} );
|
|
129
134
|
}
|
|
130
135
|
}
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
5
|
to,
|
|
6
|
+
toGamut,
|
|
6
7
|
serialize,
|
|
7
8
|
contrastWCAG21,
|
|
8
9
|
sRGB,
|
|
10
|
+
OKLCH,
|
|
9
11
|
type ColorTypes,
|
|
10
12
|
} from 'colorjs.io/fn';
|
|
11
13
|
|
|
@@ -32,3 +34,12 @@ export function getColorString( color: ColorTypes ): string {
|
|
|
32
34
|
export function getContrast( colorA: ColorTypes, colorB: ColorTypes ): number {
|
|
33
35
|
return contrastWCAG21( colorA, colorB );
|
|
34
36
|
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Make sure that a color is valid in the sRGB gamut and convert it to OKLCH.
|
|
40
|
+
* @param c
|
|
41
|
+
*/
|
|
42
|
+
export function clampToGamut( c: ColorTypes ) {
|
|
43
|
+
// map into sRGB using CSS OKLCH method
|
|
44
|
+
return to( toGamut( c, { space: sRGB, method: 'css' } ), OKLCH );
|
|
45
|
+
}
|
|
@@ -14,9 +14,9 @@ export const BLACK = to( 'black', OKLCH );
|
|
|
14
14
|
|
|
15
15
|
// Margin added to target contrasts to counter for algorithm approximations and rounding errors.
|
|
16
16
|
// - the `CONTRAST_EPSILON` value is 0.004, so the real contrast can be lower by this amount.
|
|
17
|
-
// - the max contrast between adjacent RGB values is 1.016, so
|
|
18
|
-
// - the sum is 0.
|
|
19
|
-
export const UNIVERSAL_CONTRAST_TOPUP = 0.
|
|
17
|
+
// - the max contrast between adjacent RGB values is 1.016, so 0.016 is the maximum total rounding error between two values.
|
|
18
|
+
// - the sum is 0.02: the margin we add to ensure that the target contrast is met after all the rounding.
|
|
19
|
+
export const UNIVERSAL_CONTRAST_TOPUP = 0.02;
|
|
20
20
|
|
|
21
21
|
// When enabling "lighter direction" bias, this is the amount by which
|
|
22
22
|
// black text contrast needs to be greater than white text contrast.
|
|
@@ -13,19 +13,19 @@ export const DEFAULT_RAMPS: Record<
|
|
|
13
13
|
surface2: '#f8f8f8',
|
|
14
14
|
bgFill1: '#555',
|
|
15
15
|
fgFill: '#f0f0f0',
|
|
16
|
-
bgFill2: '#
|
|
17
|
-
surface6: '#
|
|
18
|
-
surface5: '#
|
|
16
|
+
bgFill2: '#484848',
|
|
17
|
+
surface6: '#d2d2d2',
|
|
18
|
+
surface5: '#e2e2e2',
|
|
19
19
|
surface4: '#eaeaea',
|
|
20
20
|
surface3: '#fff',
|
|
21
21
|
fgSurface4: '#1e1e1e',
|
|
22
|
-
fgSurface3: '#
|
|
23
|
-
fgSurface2: '#
|
|
24
|
-
fgSurface1: '#
|
|
25
|
-
stroke3: '#
|
|
26
|
-
stroke4: '#
|
|
27
|
-
stroke2: '#
|
|
28
|
-
stroke1: '#
|
|
22
|
+
fgSurface3: '#6d6d6d',
|
|
23
|
+
fgSurface2: '#8a8a8a',
|
|
24
|
+
fgSurface1: '#aaa',
|
|
25
|
+
stroke3: '#8a8a8a',
|
|
26
|
+
stroke4: '#6c6c6c',
|
|
27
|
+
stroke2: '#d8d8d8',
|
|
28
|
+
stroke1: '#e0e0e0',
|
|
29
29
|
bgFillDark: '#1e1e1e',
|
|
30
30
|
fgFillDark: '#f0f0f0',
|
|
31
31
|
bgFillInverted2: '#1e1e1e',
|
|
@@ -39,26 +39,26 @@ export const DEFAULT_RAMPS: Record<
|
|
|
39
39
|
ramp: {
|
|
40
40
|
bgFill1: '#3858e9',
|
|
41
41
|
fgFill: '#eff0f2',
|
|
42
|
-
bgFill2: '#
|
|
42
|
+
bgFill2: '#2e49d9',
|
|
43
43
|
surface2: '#f6f8fc',
|
|
44
|
-
surface6: '#
|
|
45
|
-
surface5: '#
|
|
46
|
-
surface4: '#
|
|
44
|
+
surface6: '#c7d2ee',
|
|
45
|
+
surface5: '#dbe2f4',
|
|
46
|
+
surface4: '#e4eaf7',
|
|
47
47
|
surface3: '#fff',
|
|
48
|
-
fgSurface4: '#
|
|
48
|
+
fgSurface4: '#0b0070',
|
|
49
49
|
fgSurface3: '#3858e9',
|
|
50
|
-
fgSurface2: '#
|
|
51
|
-
fgSurface1: '#
|
|
50
|
+
fgSurface2: '#5b82ff',
|
|
51
|
+
fgSurface1: '#85a9ff',
|
|
52
52
|
stroke3: '#3858e9',
|
|
53
53
|
stroke4: '#2337c8',
|
|
54
|
-
stroke2: '#
|
|
55
|
-
stroke1: '#
|
|
54
|
+
stroke2: '#9aaad3',
|
|
55
|
+
stroke1: '#a2b1d6',
|
|
56
56
|
bgFillDark: '#1b1e26',
|
|
57
57
|
fgFillDark: '#eff0f2',
|
|
58
58
|
bgFillInverted2: '#1b1e26',
|
|
59
|
-
bgFillInverted1: '#
|
|
59
|
+
bgFillInverted1: '#13009f',
|
|
60
60
|
fgFillInverted: '#eff0f2',
|
|
61
|
-
surface1: '#
|
|
61
|
+
surface1: '#ecf0f9',
|
|
62
62
|
},
|
|
63
63
|
direction: 'darker',
|
|
64
64
|
},
|
|
@@ -66,26 +66,26 @@ export const DEFAULT_RAMPS: Record<
|
|
|
66
66
|
ramp: {
|
|
67
67
|
bgFill1: '#0090ff',
|
|
68
68
|
fgFill: '#1b1e23',
|
|
69
|
-
bgFill2: '#
|
|
69
|
+
bgFill2: '#007fed',
|
|
70
70
|
surface2: '#f5f9fd',
|
|
71
|
-
surface6: '#
|
|
72
|
-
surface5: '#
|
|
73
|
-
surface4: '#
|
|
71
|
+
surface6: '#bdd5f1',
|
|
72
|
+
surface5: '#d4e4f6',
|
|
73
|
+
surface4: '#dfebf8',
|
|
74
74
|
surface3: '#fff',
|
|
75
|
-
fgSurface4: '#
|
|
76
|
-
fgSurface3: '#
|
|
77
|
-
fgSurface2: '#
|
|
78
|
-
fgSurface1: '#
|
|
79
|
-
stroke3: '#
|
|
80
|
-
stroke4: '#
|
|
81
|
-
stroke2: '#
|
|
82
|
-
stroke1: '#
|
|
75
|
+
fgSurface4: '#001b4f',
|
|
76
|
+
fgSurface3: '#006bd7',
|
|
77
|
+
fgSurface2: '#008bfa',
|
|
78
|
+
fgSurface1: '#59b0ff',
|
|
79
|
+
stroke3: '#006bd7',
|
|
80
|
+
stroke4: '#004fa9',
|
|
81
|
+
stroke2: '#94b5d9',
|
|
82
|
+
stroke1: '#9fbcdd',
|
|
83
83
|
bgFillDark: '#1b1e23',
|
|
84
84
|
fgFillDark: '#eff0f2',
|
|
85
85
|
bgFillInverted2: '#1b1e23',
|
|
86
|
-
bgFillInverted1: '#
|
|
86
|
+
bgFillInverted1: '#002a69',
|
|
87
87
|
fgFillInverted: '#eff0f2',
|
|
88
|
-
surface1: '#
|
|
88
|
+
surface1: '#e9f1fa',
|
|
89
89
|
},
|
|
90
90
|
direction: 'darker',
|
|
91
91
|
},
|
|
@@ -93,26 +93,26 @@ export const DEFAULT_RAMPS: Record<
|
|
|
93
93
|
ramp: {
|
|
94
94
|
bgFill1: '#4ab866',
|
|
95
95
|
fgFill: '#1b1f1c',
|
|
96
|
-
bgFill2: '#
|
|
96
|
+
bgFill2: '#37a756',
|
|
97
97
|
surface2: '#f0fcf2',
|
|
98
98
|
surface6: '#7eea95',
|
|
99
|
-
surface5: '#
|
|
100
|
-
surface4: '#
|
|
99
|
+
surface5: '#b5f1bf',
|
|
100
|
+
surface4: '#cbf5d1',
|
|
101
101
|
surface3: '#fff',
|
|
102
|
-
fgSurface4: '#
|
|
103
|
-
fgSurface3: '#
|
|
104
|
-
fgSurface2: '#
|
|
105
|
-
fgSurface1: '#
|
|
106
|
-
stroke3: '#
|
|
107
|
-
stroke4: '#
|
|
108
|
-
stroke2: '#
|
|
109
|
-
stroke1: '#
|
|
102
|
+
fgSurface4: '#002900',
|
|
103
|
+
fgSurface3: '#007f30',
|
|
104
|
+
fgSurface2: '#2b9e4e',
|
|
105
|
+
fgSurface1: '#53c06e',
|
|
106
|
+
stroke3: '#007f30',
|
|
107
|
+
stroke4: '#006013',
|
|
108
|
+
stroke2: '#7dc189',
|
|
109
|
+
stroke1: '#82c98f',
|
|
110
110
|
bgFillDark: '#1b1f1c',
|
|
111
111
|
fgFillDark: '#edf2ed',
|
|
112
112
|
bgFillInverted2: '#1b1f1c',
|
|
113
|
-
bgFillInverted1: '#
|
|
113
|
+
bgFillInverted1: '#003701',
|
|
114
114
|
fgFillInverted: '#edf2ed',
|
|
115
|
-
surface1: '#
|
|
115
|
+
surface1: '#dbf8df',
|
|
116
116
|
},
|
|
117
117
|
direction: 'darker',
|
|
118
118
|
},
|
|
@@ -120,26 +120,26 @@ export const DEFAULT_RAMPS: Record<
|
|
|
120
120
|
ramp: {
|
|
121
121
|
bgFill1: '#f0d149',
|
|
122
122
|
fgFill: '#1f1e1b',
|
|
123
|
-
bgFill2: '#
|
|
123
|
+
bgFill2: '#dcbe2f',
|
|
124
124
|
surface2: '#fdf9e7',
|
|
125
|
-
surface6: '#
|
|
126
|
-
surface5: '#
|
|
127
|
-
surface4: '#
|
|
125
|
+
surface6: '#ecd264',
|
|
126
|
+
surface5: '#f5e297',
|
|
127
|
+
surface4: '#f7eab3',
|
|
128
128
|
surface3: '#fff',
|
|
129
|
-
fgSurface4: '#
|
|
130
|
-
fgSurface3: '#
|
|
131
|
-
fgSurface2: '#
|
|
132
|
-
fgSurface1: '#
|
|
133
|
-
stroke3: '#
|
|
134
|
-
stroke4: '#
|
|
135
|
-
stroke2: '#
|
|
136
|
-
stroke1: '#
|
|
129
|
+
fgSurface4: '#281d00',
|
|
130
|
+
fgSurface3: '#836b00',
|
|
131
|
+
fgSurface2: '#a58700',
|
|
132
|
+
fgSurface1: '#c7a900',
|
|
133
|
+
stroke3: '#836b00',
|
|
134
|
+
stroke4: '#635000',
|
|
135
|
+
stroke2: '#bfb17a',
|
|
136
|
+
stroke1: '#c7b97f',
|
|
137
137
|
bgFillDark: '#1f1e1b',
|
|
138
138
|
fgFillDark: '#f6f1da',
|
|
139
139
|
bgFillInverted2: '#1f1e1b',
|
|
140
|
-
bgFillInverted1: '#
|
|
140
|
+
bgFillInverted1: '#392c00',
|
|
141
141
|
fgFillInverted: '#f6f1da',
|
|
142
|
-
surface1: '#
|
|
142
|
+
surface1: '#f9f0c8',
|
|
143
143
|
},
|
|
144
144
|
direction: 'darker',
|
|
145
145
|
},
|
|
@@ -147,26 +147,26 @@ export const DEFAULT_RAMPS: Record<
|
|
|
147
147
|
ramp: {
|
|
148
148
|
bgFill1: '#f0b849',
|
|
149
149
|
fgFill: '#1f1e1b',
|
|
150
|
-
bgFill2: '#
|
|
150
|
+
bgFill2: '#dda633',
|
|
151
151
|
surface2: '#fdf7ee',
|
|
152
|
-
surface6: '#
|
|
153
|
-
surface5: '#
|
|
154
|
-
surface4: '#
|
|
152
|
+
surface6: '#f1ce8f',
|
|
153
|
+
surface5: '#f6e0b9',
|
|
154
|
+
surface4: '#f8e8cc',
|
|
155
155
|
surface3: '#fff',
|
|
156
|
-
fgSurface4: '#
|
|
157
|
-
fgSurface3: '#
|
|
158
|
-
fgSurface2: '#
|
|
159
|
-
fgSurface1: '#
|
|
160
|
-
stroke3: '#
|
|
161
|
-
stroke4: '#
|
|
162
|
-
stroke2: '#
|
|
163
|
-
stroke1: '#
|
|
156
|
+
fgSurface4: '#2e1900',
|
|
157
|
+
fgSurface3: '#936400',
|
|
158
|
+
fgSurface2: '#b68000',
|
|
159
|
+
fgSurface1: '#d8a12c',
|
|
160
|
+
stroke3: '#936400',
|
|
161
|
+
stroke4: '#704a00',
|
|
162
|
+
stroke2: '#caae7c',
|
|
163
|
+
stroke1: '#d2b581',
|
|
164
164
|
bgFillDark: '#1f1e1b',
|
|
165
165
|
fgFillDark: '#f3f0e9',
|
|
166
166
|
bgFillInverted2: '#1f1e1b',
|
|
167
|
-
bgFillInverted1: '#
|
|
167
|
+
bgFillInverted1: '#422800',
|
|
168
168
|
fgFillInverted: '#f3f0e9',
|
|
169
|
-
surface1: '#
|
|
169
|
+
surface1: '#faeeda',
|
|
170
170
|
},
|
|
171
171
|
direction: 'darker',
|
|
172
172
|
},
|
|
@@ -174,26 +174,26 @@ export const DEFAULT_RAMPS: Record<
|
|
|
174
174
|
ramp: {
|
|
175
175
|
bgFill1: '#cc1818',
|
|
176
176
|
fgFill: '#f2efef',
|
|
177
|
-
bgFill2: '#
|
|
177
|
+
bgFill2: '#b90000',
|
|
178
178
|
surface2: '#fdf6f5',
|
|
179
|
-
surface6: '#
|
|
180
|
-
surface5: '#
|
|
181
|
-
surface4: '#
|
|
179
|
+
surface6: '#f5c8c1',
|
|
180
|
+
surface5: '#f9dbd7',
|
|
181
|
+
surface4: '#fae4e1',
|
|
182
182
|
surface3: '#fff',
|
|
183
|
-
fgSurface4: '#
|
|
183
|
+
fgSurface4: '#470000',
|
|
184
184
|
fgSurface3: '#cc1818',
|
|
185
|
-
fgSurface2: '#
|
|
186
|
-
fgSurface1: '#
|
|
185
|
+
fgSurface2: '#f74c40',
|
|
186
|
+
fgSurface1: '#ff8879',
|
|
187
187
|
stroke3: '#cc1818',
|
|
188
|
-
stroke4: '#
|
|
189
|
-
stroke2: '#
|
|
190
|
-
stroke1: '#
|
|
188
|
+
stroke4: '#9d0000',
|
|
189
|
+
stroke2: '#de988e',
|
|
190
|
+
stroke1: '#e1a198',
|
|
191
191
|
bgFillDark: '#231c1b',
|
|
192
192
|
fgFillDark: '#f2efef',
|
|
193
193
|
bgFillInverted2: '#231c1b',
|
|
194
|
-
bgFillInverted1: '#
|
|
194
|
+
bgFillInverted1: '#640000',
|
|
195
195
|
fgFillInverted: '#f2efef',
|
|
196
|
-
surface1: '#
|
|
196
|
+
surface1: '#fbece9',
|
|
197
197
|
},
|
|
198
198
|
direction: 'darker',
|
|
199
199
|
},
|
|
@@ -7,9 +7,9 @@ import { get, OKLCH, type ColorTypes } from 'colorjs.io/fn';
|
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
9
|
import './register-color-spaces';
|
|
10
|
-
import {
|
|
10
|
+
import { solveWithBisect } from './utils';
|
|
11
11
|
import { WHITE, BLACK, CONTRAST_EPSILON } from './constants';
|
|
12
|
-
import { getContrast } from './color-utils';
|
|
12
|
+
import { clampToGamut, getContrast } from './color-utils';
|
|
13
13
|
import { type TaperChromaOptions, taperChroma } from './taper-chroma';
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -15,10 +15,9 @@ import {
|
|
|
15
15
|
* Internal dependencies
|
|
16
16
|
*/
|
|
17
17
|
import './register-color-spaces';
|
|
18
|
-
import { getContrast, getColorString } from './color-utils';
|
|
18
|
+
import { clampToGamut, getContrast, getColorString } from './color-utils';
|
|
19
19
|
import { findColorMeetingRequirements } from './find-color-with-constraints';
|
|
20
20
|
import {
|
|
21
|
-
clampToGamut,
|
|
22
21
|
sortByDependency,
|
|
23
22
|
computeBetterFgColorDirection,
|
|
24
23
|
adjustContrastTarget,
|
|
@@ -142,7 +142,7 @@ export const BG_RAMP_CONFIG: RampConfig = {
|
|
|
142
142
|
contrast: {
|
|
143
143
|
reference: 'stroke3',
|
|
144
144
|
followDirection: 'opposite',
|
|
145
|
-
target: 2.
|
|
145
|
+
target: 2.6,
|
|
146
146
|
},
|
|
147
147
|
taperChromaOptions: STROKE_TAPER_CHROMA,
|
|
148
148
|
},
|
|
@@ -150,7 +150,7 @@ export const BG_RAMP_CONFIG: RampConfig = {
|
|
|
150
150
|
contrast: {
|
|
151
151
|
reference: 'stroke3',
|
|
152
152
|
followDirection: 'opposite',
|
|
153
|
-
target:
|
|
153
|
+
target: 2.4,
|
|
154
154
|
},
|
|
155
155
|
taperChromaOptions: STROKE_TAPER_CHROMA,
|
|
156
156
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { type ColorTypes } from 'colorjs.io/fn';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
@@ -19,13 +19,6 @@ import {
|
|
|
19
19
|
import type { Ramp, RampConfig, RampDirection } from './types';
|
|
20
20
|
import { getContrast } from './color-utils';
|
|
21
21
|
|
|
22
|
-
/**
|
|
23
|
-
* Make sure that a color is valid in the p3 gamut, and converts it to oklch.
|
|
24
|
-
* @param c
|
|
25
|
-
*/
|
|
26
|
-
export const clampToGamut = ( c: ColorTypes ) =>
|
|
27
|
-
to( toGamut( c, { space: P3, method: 'css' } ), OKLCH ); // map into Display-P3 using CSS OKLCH method
|
|
28
|
-
|
|
29
22
|
/**
|
|
30
23
|
* Build a dependency graph from the steps configuration
|
|
31
24
|
* @param config - The steps configuration object
|
|
@@ -133,10 +133,12 @@ export const Default: StoryObj< typeof ColorGen > = {
|
|
|
133
133
|
fgName,
|
|
134
134
|
fgColor,
|
|
135
135
|
unmetContrast,
|
|
136
|
+
achievedContrast,
|
|
136
137
|
},
|
|
137
138
|
i
|
|
138
139
|
) => (
|
|
139
140
|
<li key={ i }>
|
|
141
|
+
{ fgName } (
|
|
140
142
|
<span
|
|
141
143
|
style={ {
|
|
142
144
|
width: 20,
|
|
@@ -144,8 +146,8 @@ export const Default: StoryObj< typeof ColorGen > = {
|
|
|
144
146
|
backgroundColor: fgColor,
|
|
145
147
|
display: 'inline-block',
|
|
146
148
|
} }
|
|
147
|
-
|
|
148
|
-
{
|
|
149
|
+
/>
|
|
150
|
+
{ fgColor }) over { bgName } (
|
|
149
151
|
<span
|
|
150
152
|
style={ {
|
|
151
153
|
width: 20,
|
|
@@ -153,8 +155,9 @@ export const Default: StoryObj< typeof ColorGen > = {
|
|
|
153
155
|
backgroundColor: bgColor,
|
|
154
156
|
display: 'inline-block',
|
|
155
157
|
} }
|
|
156
|
-
|
|
157
|
-
{
|
|
158
|
+
/>
|
|
159
|
+
{ bgColor }) did not meet { unmetContrast },
|
|
160
|
+
achieved just { achievedContrast }
|
|
158
161
|
</li>
|
|
159
162
|
)
|
|
160
163
|
) }
|
|
@@ -10,91 +10,91 @@
|
|
|
10
10
|
--wpds-border-width-focus: 2px; /* Border width for focus ring */
|
|
11
11
|
--wpds-color-bg-interactive-brand: #00000000; /* Background color for interactive elements with brand tone and normal emphasis. */
|
|
12
12
|
--wpds-color-bg-interactive-brand-active: #f6f8fc; /* Background color for interactive elements with brand tone and normal emphasis that are hovered, focused, or active. */
|
|
13
|
-
--wpds-color-bg-interactive-brand-disabled: #
|
|
13
|
+
--wpds-color-bg-interactive-brand-disabled: #e2e2e2; /* Background color for interactive elements with brand tone and normal emphasis, in their disabled state. */
|
|
14
14
|
--wpds-color-bg-interactive-brand-strong: #3858e9; /* Background color for interactive elements with brand tone and strong emphasis. */
|
|
15
|
-
--wpds-color-bg-interactive-brand-strong-active: #
|
|
16
|
-
--wpds-color-bg-interactive-brand-strong-disabled: #
|
|
15
|
+
--wpds-color-bg-interactive-brand-strong-active: #2e49d9; /* Background color for interactive elements with brand tone and strong emphasis that are hovered, focused, or active. */
|
|
16
|
+
--wpds-color-bg-interactive-brand-strong-disabled: #d2d2d2; /* Background color for interactive elements with brand tone and strong emphasis, in their disabled state. */
|
|
17
17
|
--wpds-color-bg-interactive-brand-weak: #00000000; /* Background color for interactive elements with brand tone and weak emphasis. */
|
|
18
|
-
--wpds-color-bg-interactive-brand-weak-active: #
|
|
19
|
-
--wpds-color-bg-interactive-brand-weak-disabled: #
|
|
18
|
+
--wpds-color-bg-interactive-brand-weak-active: #e4eaf7; /* Background color for interactive elements with brand tone and weak emphasis that are hovered, focused, or active. */
|
|
19
|
+
--wpds-color-bg-interactive-brand-weak-disabled: #e2e2e2; /* Background color for interactive elements with brand tone and weak emphasis, in their disabled state. */
|
|
20
20
|
--wpds-color-bg-interactive-neutral: #00000000; /* Background color for interactive elements with neutral tone and normal emphasis. */
|
|
21
21
|
--wpds-color-bg-interactive-neutral-active: #eaeaea; /* Background color for interactive elements with neutral tone and normal emphasis that are hovered, focused, or active. */
|
|
22
|
-
--wpds-color-bg-interactive-neutral-disabled: #
|
|
22
|
+
--wpds-color-bg-interactive-neutral-disabled: #e2e2e2; /* Background color for interactive elements with neutral tone and normal emphasis, in their disabled state. */
|
|
23
23
|
--wpds-color-bg-interactive-neutral-strong: #2d2d2d; /* Background color for interactive elements with neutral tone and strong emphasis. */
|
|
24
24
|
--wpds-color-bg-interactive-neutral-strong-active: #1e1e1e; /* Background color for interactive elements with neutral tone and strong emphasis that are hovered, focused, or active. */
|
|
25
|
-
--wpds-color-bg-interactive-neutral-strong-disabled: #
|
|
25
|
+
--wpds-color-bg-interactive-neutral-strong-disabled: #d2d2d2; /* Background color for interactive elements with neutral tone and strong emphasis, in their disabled state. */
|
|
26
26
|
--wpds-color-bg-interactive-neutral-weak: #00000000; /* Background color for interactive elements with neutral tone and weak emphasis. */
|
|
27
27
|
--wpds-color-bg-interactive-neutral-weak-active: #eaeaea; /* Background color for interactive elements with neutral tone and weak emphasis that are hovered, focused, or active. */
|
|
28
|
-
--wpds-color-bg-interactive-neutral-weak-disabled: #
|
|
29
|
-
--wpds-color-bg-surface-brand: #
|
|
30
|
-
--wpds-color-bg-surface-caution: #
|
|
28
|
+
--wpds-color-bg-interactive-neutral-weak-disabled: #e2e2e2; /* Background color for interactive elements with neutral tone and weak emphasis, in their disabled state. */
|
|
29
|
+
--wpds-color-bg-surface-brand: #ecf0f9; /* Background color for surfaces with brand tone and normal emphasis. */
|
|
30
|
+
--wpds-color-bg-surface-caution: #f7eab3; /* Background color for surfaces with caution tone and normal emphasis. */
|
|
31
31
|
--wpds-color-bg-surface-caution-weak: #fdf9e7; /* Background color for surfaces with caution tone and weak emphasis. */
|
|
32
|
-
--wpds-color-bg-surface-error: #
|
|
32
|
+
--wpds-color-bg-surface-error: #fae4e1; /* Background color for surfaces with error tone and normal emphasis. */
|
|
33
33
|
--wpds-color-bg-surface-error-weak: #fdf6f5; /* Background color for surfaces with error tone and weak emphasis. */
|
|
34
|
-
--wpds-color-bg-surface-info: #
|
|
34
|
+
--wpds-color-bg-surface-info: #dfebf8; /* Background color for surfaces with info tone and normal emphasis. */
|
|
35
35
|
--wpds-color-bg-surface-info-weak: #f5f9fd; /* Background color for surfaces with info tone and weak emphasis. */
|
|
36
36
|
--wpds-color-bg-surface-neutral: #f8f8f8; /* Background color for surfaces with normal emphasis. */
|
|
37
37
|
--wpds-color-bg-surface-neutral-strong: #ffffff; /* Background color for surfaces with strong emphasis. */
|
|
38
38
|
--wpds-color-bg-surface-neutral-weak: #f0f0f0; /* Background color for surfaces with weak emphasis. */
|
|
39
|
-
--wpds-color-bg-surface-success: #
|
|
39
|
+
--wpds-color-bg-surface-success: #cbf5d1; /* Background color for surfaces with success tone and normal emphasis. */
|
|
40
40
|
--wpds-color-bg-surface-success-weak: #f0fcf2; /* Background color for surfaces with success tone and weak emphasis. */
|
|
41
|
-
--wpds-color-bg-surface-warning: #
|
|
41
|
+
--wpds-color-bg-surface-warning: #f8e8cc; /* Background color for surfaces with warning tone and normal emphasis. */
|
|
42
42
|
--wpds-color-bg-surface-warning-weak: #fdf7ee; /* Background color for surfaces with warning tone and weak emphasis. */
|
|
43
43
|
--wpds-color-bg-thumb-brand: #3858e9; /* Background color for thumbs with a brand tone and normal emphasis (eg. slider thumb and filled track). */
|
|
44
44
|
--wpds-color-bg-thumb-brand-active: #3858e9; /* Background color for thumbs with a brand tone and normal emphasis (eg. slider thumb and filled track) that are hovered, focused, or active. */
|
|
45
|
-
--wpds-color-bg-thumb-brand-disabled: #
|
|
46
|
-
--wpds-color-bg-thumb-neutral-weak: #
|
|
47
|
-
--wpds-color-bg-thumb-neutral-weak-active: #
|
|
48
|
-
--wpds-color-bg-track-neutral: #
|
|
49
|
-
--wpds-color-bg-track-neutral-weak: #
|
|
50
|
-
--wpds-color-fg-content-caution: #
|
|
51
|
-
--wpds-color-fg-content-caution-weak: #
|
|
52
|
-
--wpds-color-fg-content-error: #
|
|
45
|
+
--wpds-color-bg-thumb-brand-disabled: #d8d8d8; /* Background color for thumbs with a brand tone and normal emphasis (eg. slider thumb and filled track), in their disabled state. */
|
|
46
|
+
--wpds-color-bg-thumb-neutral-weak: #8a8a8a; /* Background color for thumbs with a neutral tone and weak emphasis (eg. scrollbar thumb). */
|
|
47
|
+
--wpds-color-bg-thumb-neutral-weak-active: #6c6c6c; /* Background color for thumbs with a neutral tone and weak emphasis (eg. scrollbar thumb) that are hovered, focused, or active. */
|
|
48
|
+
--wpds-color-bg-track-neutral: #d8d8d8; /* Background color for tracks with a neutral tone and normal emphasis (eg. slider or progressbar track). */
|
|
49
|
+
--wpds-color-bg-track-neutral-weak: #e0e0e0; /* Background color for tracks with a neutral tone and weak emphasis (eg. scrollbar track). */
|
|
50
|
+
--wpds-color-fg-content-caution: #281d00; /* Foreground color for content like text with caution tone and normal emphasis. */
|
|
51
|
+
--wpds-color-fg-content-caution-weak: #836b00; /* Foreground color for content like text with caution tone and weak emphasis. */
|
|
52
|
+
--wpds-color-fg-content-error: #470000; /* Foreground color for content like text with error tone and normal emphasis. */
|
|
53
53
|
--wpds-color-fg-content-error-weak: #cc1818; /* Foreground color for content like text with error tone and weak emphasis. */
|
|
54
|
-
--wpds-color-fg-content-info: #
|
|
55
|
-
--wpds-color-fg-content-info-weak: #
|
|
54
|
+
--wpds-color-fg-content-info: #001b4f; /* Foreground color for content like text with info tone and normal emphasis. */
|
|
55
|
+
--wpds-color-fg-content-info-weak: #006bd7; /* Foreground color for content like text with info tone and weak emphasis. */
|
|
56
56
|
--wpds-color-fg-content-neutral: #1e1e1e; /* Foreground color for content like text with normal emphasis. */
|
|
57
|
-
--wpds-color-fg-content-neutral-weak: #
|
|
58
|
-
--wpds-color-fg-content-success: #
|
|
59
|
-
--wpds-color-fg-content-success-weak: #
|
|
60
|
-
--wpds-color-fg-content-warning: #
|
|
61
|
-
--wpds-color-fg-content-warning-weak: #
|
|
57
|
+
--wpds-color-fg-content-neutral-weak: #6d6d6d; /* Foreground color for content like text with weak emphasis. */
|
|
58
|
+
--wpds-color-fg-content-success: #002900; /* Foreground color for content like text with success tone and normal emphasis. */
|
|
59
|
+
--wpds-color-fg-content-success-weak: #007f30; /* Foreground color for content like text with success tone and weak emphasis. */
|
|
60
|
+
--wpds-color-fg-content-warning: #2e1900; /* Foreground color for content like text with warning tone and normal emphasis. */
|
|
61
|
+
--wpds-color-fg-content-warning-weak: #936400; /* Foreground color for content like text with warning tone and weak emphasis. */
|
|
62
62
|
--wpds-color-fg-interactive-brand: #3858e9; /* Foreground color for interactive elements with brand tone and normal emphasis. */
|
|
63
63
|
--wpds-color-fg-interactive-brand-active: #3858e9; /* Foreground color for interactive elements with brand tone and normal emphasis that are hovered, focused, or active. */
|
|
64
|
-
--wpds-color-fg-interactive-brand-disabled: #
|
|
64
|
+
--wpds-color-fg-interactive-brand-disabled: #8a8a8a; /* Foreground color for interactive elements with brand tone and normal emphasis, in their disabled state. */
|
|
65
65
|
--wpds-color-fg-interactive-brand-strong: #eff0f2; /* Foreground color for interactive elements with brand tone and strong emphasis. */
|
|
66
66
|
--wpds-color-fg-interactive-brand-strong-active: #eff0f2; /* Foreground color for interactive elements with brand tone and strong emphasis that are hovered, focused, or active. */
|
|
67
|
-
--wpds-color-fg-interactive-brand-strong-disabled: #
|
|
67
|
+
--wpds-color-fg-interactive-brand-strong-disabled: #6d6d6d; /* Foreground color for interactive elements with brand tone and strong emphasis, in their disabled state. */
|
|
68
68
|
--wpds-color-fg-interactive-neutral: #1e1e1e; /* Foreground color for interactive elements with neutral tone and normal emphasis. */
|
|
69
69
|
--wpds-color-fg-interactive-neutral-active: #1e1e1e; /* Foreground color for interactive elements with neutral tone and normal emphasis that are hovered, focused, or active. */
|
|
70
|
-
--wpds-color-fg-interactive-neutral-disabled: #
|
|
70
|
+
--wpds-color-fg-interactive-neutral-disabled: #8a8a8a; /* Foreground color for interactive elements with neutral tone and normal emphasis, in their disabled state. */
|
|
71
71
|
--wpds-color-fg-interactive-neutral-strong: #f0f0f0; /* Foreground color for interactive elements with neutral tone and strong emphasis. */
|
|
72
72
|
--wpds-color-fg-interactive-neutral-strong-active: #f0f0f0; /* Foreground color for interactive elements with neutral tone and strong emphasis that are hovered, focused, or active. */
|
|
73
|
-
--wpds-color-fg-interactive-neutral-strong-disabled: #
|
|
74
|
-
--wpds-color-fg-interactive-neutral-weak: #
|
|
75
|
-
--wpds-color-fg-interactive-neutral-weak-disabled: #
|
|
73
|
+
--wpds-color-fg-interactive-neutral-strong-disabled: #6d6d6d; /* Foreground color for interactive elements with neutral tone and strong emphasis, in their disabled state. */
|
|
74
|
+
--wpds-color-fg-interactive-neutral-weak: #6d6d6d; /* Foreground color for interactive elements with neutral tone and weak emphasis. */
|
|
75
|
+
--wpds-color-fg-interactive-neutral-weak-disabled: #8a8a8a; /* Foreground color for interactive elements with neutral tone and weak emphasis, in their disabled state. */
|
|
76
76
|
--wpds-color-stroke-focus-brand: #3858e9; /* Accessible stroke color applied to focus rings. */
|
|
77
77
|
--wpds-color-stroke-interactive-brand: #3858e9; /* Accessible stroke color used for interactive brand-toned elements with normal emphasis. */
|
|
78
78
|
--wpds-color-stroke-interactive-brand-active: #2337c8; /* Accessible stroke color used for interactive brand-toned elements with normal emphasis that are hovered, focused, or active. */
|
|
79
|
-
--wpds-color-stroke-interactive-brand-disabled: #
|
|
79
|
+
--wpds-color-stroke-interactive-brand-disabled: #d8d8d8; /* Accessible stroke color used for interactive brand-toned elements with normal emphasis, in their disabled state. */
|
|
80
80
|
--wpds-color-stroke-interactive-error-strong: #cc1818; /* Accessible stroke color used for interactive error-toned elements with strong emphasis. */
|
|
81
|
-
--wpds-color-stroke-interactive-neutral: #
|
|
82
|
-
--wpds-color-stroke-interactive-neutral-active: #
|
|
83
|
-
--wpds-color-stroke-interactive-neutral-disabled: #
|
|
84
|
-
--wpds-color-stroke-interactive-neutral-strong: #
|
|
85
|
-
--wpds-color-stroke-surface-brand: #
|
|
81
|
+
--wpds-color-stroke-interactive-neutral: #8a8a8a; /* Accessible stroke color used for interactive neutrally-toned elements with normal emphasis. */
|
|
82
|
+
--wpds-color-stroke-interactive-neutral-active: #6c6c6c; /* Accessible stroke color used for interactive neutrally-toned elements with normal emphasis that are hovered, focused, or active. */
|
|
83
|
+
--wpds-color-stroke-interactive-neutral-disabled: #d8d8d8; /* Accessible stroke color used for interactive neutrally-toned elements with normal emphasis, in their disabled state. */
|
|
84
|
+
--wpds-color-stroke-interactive-neutral-strong: #6c6c6c; /* Accessible stroke color used for interactive neutrally-toned elements with strong emphasis. */
|
|
85
|
+
--wpds-color-stroke-surface-brand: #a2b1d6; /* Decorative stroke color used to define brand-toned surface boundaries with normal emphasis. */
|
|
86
86
|
--wpds-color-stroke-surface-brand-strong: #3858e9; /* Decorative stroke color used to define neutrally-toned surface boundaries with strong emphasis. */
|
|
87
|
-
--wpds-color-stroke-surface-error: #
|
|
87
|
+
--wpds-color-stroke-surface-error: #e1a198; /* Decorative stroke color used to define error-toned surface boundaries with normal emphasis. */
|
|
88
88
|
--wpds-color-stroke-surface-error-strong: #cc1818; /* Decorative stroke color used to define error-toned surface boundaries with strong emphasis. */
|
|
89
|
-
--wpds-color-stroke-surface-info: #
|
|
90
|
-
--wpds-color-stroke-surface-info-strong: #
|
|
91
|
-
--wpds-color-stroke-surface-neutral: #
|
|
92
|
-
--wpds-color-stroke-surface-neutral-strong: #
|
|
93
|
-
--wpds-color-stroke-surface-neutral-weak: #
|
|
94
|
-
--wpds-color-stroke-surface-success: #
|
|
95
|
-
--wpds-color-stroke-surface-success-strong: #
|
|
96
|
-
--wpds-color-stroke-surface-warning: #
|
|
97
|
-
--wpds-color-stroke-surface-warning-strong: #
|
|
89
|
+
--wpds-color-stroke-surface-info: #9fbcdd; /* Decorative stroke color used to define info-toned surface boundaries with normal emphasis. */
|
|
90
|
+
--wpds-color-stroke-surface-info-strong: #006bd7; /* Decorative stroke color used to define info-toned surface boundaries with strong emphasis. */
|
|
91
|
+
--wpds-color-stroke-surface-neutral: #d8d8d8; /* Decorative stroke color used to define neutrally-toned surface boundaries with normal emphasis. */
|
|
92
|
+
--wpds-color-stroke-surface-neutral-strong: #8a8a8a; /* Decorative stroke color used to define neutrally-toned surface boundaries with strong emphasis. */
|
|
93
|
+
--wpds-color-stroke-surface-neutral-weak: #e0e0e0; /* Decorative stroke color used to define neutrally-toned surface boundaries with weak emphasis. */
|
|
94
|
+
--wpds-color-stroke-surface-success: #82c98f; /* Decorative stroke color used to define success-toned surface boundaries with normal emphasis. */
|
|
95
|
+
--wpds-color-stroke-surface-success-strong: #007f30; /* Decorative stroke color used to define success-toned surface boundaries with strong emphasis. */
|
|
96
|
+
--wpds-color-stroke-surface-warning: #d2b581; /* Decorative stroke color used to define warning-toned surface boundaries with normal emphasis. */
|
|
97
|
+
--wpds-color-stroke-surface-warning-strong: #936400; /* Decorative stroke color used to define warning-toned surface boundaries with strong emphasis. */
|
|
98
98
|
--wpds-dimension-base: 4px; /* Base dimension unit */
|
|
99
99
|
--wpds-dimension-padding-surface-large: 24px; /* Large spacing for surfaces */
|
|
100
100
|
--wpds-dimension-padding-surface-medium: 16px; /* Medium spacing for surfaces */
|