@wordpress/theme 0.2.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/README.md +5 -1
- package/bin/generate-primitive-tokens/index.ts +1 -1
- package/build/color-ramps/index.js +17 -13
- 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 +154 -154
- package/build/color-ramps/lib/default-ramps.js.map +2 -2
- 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 +18 -11
- 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/types.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/use-theme-provider-styles.js +1 -4
- package/build/use-theme-provider-styles.js.map +2 -2
- package/build-module/color-ramps/index.js +18 -14
- 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 +154 -154
- package/build-module/color-ramps/lib/default-ramps.js.map +2 -2
- 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 +17 -11
- 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-module/use-theme-provider-styles.js +1 -4
- package/build-module/use-theme-provider-styles.js.map +2 -2
- 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/types.d.ts +2 -4
- package/build-types/color-ramps/lib/types.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/build-types/color-ramps/stories/ramp-table.d.ts +2 -4
- package/build-types/color-ramps/stories/ramp-table.d.ts.map +1 -1
- package/build-types/use-theme-provider-styles.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/color-ramps/index.ts +17 -12
- 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 +154 -154
- package/src/color-ramps/lib/find-color-with-constraints.ts +2 -2
- package/src/color-ramps/lib/index.ts +27 -24
- package/src/color-ramps/lib/ramp-configs.ts +2 -2
- package/src/color-ramps/lib/types.ts +2 -7
- package/src/color-ramps/lib/utils.ts +1 -8
- package/src/color-ramps/stories/index.story.tsx +11 -5
- package/src/color-ramps/stories/ramp-table.tsx +15 -26
- package/src/color-ramps/test/__snapshots__/index.test.ts.snap +11717 -41231
- package/src/color-ramps/test/index.test.ts +2 -2
- package/src/prebuilt/css/design-tokens.css +51 -51
- package/src/prebuilt/json/figma.json +51 -51
- package/src/use-theme-provider-styles.ts +1 -4
- package/tokens/color.json +88 -88
- package/tsconfig.bin.tsbuildinfo +1 -1
- package/tsconfig.src.tsbuildinfo +1 -1
|
@@ -10,190 +10,190 @@ export const DEFAULT_RAMPS: Record<
|
|
|
10
10
|
> = {
|
|
11
11
|
bg: {
|
|
12
12
|
ramp: {
|
|
13
|
-
surface2:
|
|
14
|
-
bgFill1:
|
|
15
|
-
fgFill:
|
|
16
|
-
bgFill2:
|
|
17
|
-
surface6:
|
|
18
|
-
surface5:
|
|
19
|
-
surface4:
|
|
20
|
-
surface3:
|
|
21
|
-
fgSurface4:
|
|
22
|
-
fgSurface3:
|
|
23
|
-
fgSurface2:
|
|
24
|
-
fgSurface1:
|
|
25
|
-
stroke3:
|
|
26
|
-
stroke4:
|
|
27
|
-
stroke2:
|
|
28
|
-
stroke1:
|
|
29
|
-
bgFillDark:
|
|
30
|
-
fgFillDark:
|
|
31
|
-
bgFillInverted2:
|
|
32
|
-
bgFillInverted1:
|
|
33
|
-
fgFillInverted:
|
|
34
|
-
surface1:
|
|
13
|
+
surface2: '#f8f8f8',
|
|
14
|
+
bgFill1: '#555',
|
|
15
|
+
fgFill: '#f0f0f0',
|
|
16
|
+
bgFill2: '#484848',
|
|
17
|
+
surface6: '#d2d2d2',
|
|
18
|
+
surface5: '#e2e2e2',
|
|
19
|
+
surface4: '#eaeaea',
|
|
20
|
+
surface3: '#fff',
|
|
21
|
+
fgSurface4: '#1e1e1e',
|
|
22
|
+
fgSurface3: '#6d6d6d',
|
|
23
|
+
fgSurface2: '#8a8a8a',
|
|
24
|
+
fgSurface1: '#aaa',
|
|
25
|
+
stroke3: '#8a8a8a',
|
|
26
|
+
stroke4: '#6c6c6c',
|
|
27
|
+
stroke2: '#d8d8d8',
|
|
28
|
+
stroke1: '#e0e0e0',
|
|
29
|
+
bgFillDark: '#1e1e1e',
|
|
30
|
+
fgFillDark: '#f0f0f0',
|
|
31
|
+
bgFillInverted2: '#1e1e1e',
|
|
32
|
+
bgFillInverted1: '#2d2d2d',
|
|
33
|
+
fgFillInverted: '#f0f0f0',
|
|
34
|
+
surface1: '#f0f0f0',
|
|
35
35
|
},
|
|
36
36
|
direction: 'darker',
|
|
37
37
|
},
|
|
38
38
|
primary: {
|
|
39
39
|
ramp: {
|
|
40
|
-
bgFill1:
|
|
41
|
-
fgFill:
|
|
42
|
-
bgFill2:
|
|
43
|
-
surface2:
|
|
44
|
-
surface6:
|
|
45
|
-
surface5:
|
|
46
|
-
surface4:
|
|
47
|
-
surface3:
|
|
48
|
-
fgSurface4:
|
|
49
|
-
fgSurface3:
|
|
50
|
-
fgSurface2:
|
|
51
|
-
fgSurface1:
|
|
52
|
-
stroke3:
|
|
53
|
-
stroke4:
|
|
54
|
-
stroke2:
|
|
55
|
-
stroke1:
|
|
56
|
-
bgFillDark:
|
|
57
|
-
fgFillDark:
|
|
58
|
-
bgFillInverted2:
|
|
59
|
-
bgFillInverted1:
|
|
60
|
-
fgFillInverted:
|
|
61
|
-
surface1:
|
|
40
|
+
bgFill1: '#3858e9',
|
|
41
|
+
fgFill: '#eff0f2',
|
|
42
|
+
bgFill2: '#2e49d9',
|
|
43
|
+
surface2: '#f6f8fc',
|
|
44
|
+
surface6: '#c7d2ee',
|
|
45
|
+
surface5: '#dbe2f4',
|
|
46
|
+
surface4: '#e4eaf7',
|
|
47
|
+
surface3: '#fff',
|
|
48
|
+
fgSurface4: '#0b0070',
|
|
49
|
+
fgSurface3: '#3858e9',
|
|
50
|
+
fgSurface2: '#5b82ff',
|
|
51
|
+
fgSurface1: '#85a9ff',
|
|
52
|
+
stroke3: '#3858e9',
|
|
53
|
+
stroke4: '#2337c8',
|
|
54
|
+
stroke2: '#9aaad3',
|
|
55
|
+
stroke1: '#a2b1d6',
|
|
56
|
+
bgFillDark: '#1b1e26',
|
|
57
|
+
fgFillDark: '#eff0f2',
|
|
58
|
+
bgFillInverted2: '#1b1e26',
|
|
59
|
+
bgFillInverted1: '#13009f',
|
|
60
|
+
fgFillInverted: '#eff0f2',
|
|
61
|
+
surface1: '#ecf0f9',
|
|
62
62
|
},
|
|
63
63
|
direction: 'darker',
|
|
64
64
|
},
|
|
65
65
|
info: {
|
|
66
66
|
ramp: {
|
|
67
|
-
bgFill1:
|
|
68
|
-
fgFill:
|
|
69
|
-
bgFill2:
|
|
70
|
-
surface2:
|
|
71
|
-
surface6:
|
|
72
|
-
surface5:
|
|
73
|
-
surface4:
|
|
74
|
-
surface3:
|
|
75
|
-
fgSurface4:
|
|
76
|
-
fgSurface3:
|
|
77
|
-
fgSurface2:
|
|
78
|
-
fgSurface1:
|
|
79
|
-
stroke3:
|
|
80
|
-
stroke4:
|
|
81
|
-
stroke2:
|
|
82
|
-
stroke1:
|
|
83
|
-
bgFillDark:
|
|
84
|
-
fgFillDark:
|
|
85
|
-
bgFillInverted2:
|
|
86
|
-
bgFillInverted1:
|
|
87
|
-
fgFillInverted:
|
|
88
|
-
surface1:
|
|
67
|
+
bgFill1: '#0090ff',
|
|
68
|
+
fgFill: '#1b1e23',
|
|
69
|
+
bgFill2: '#007fed',
|
|
70
|
+
surface2: '#f5f9fd',
|
|
71
|
+
surface6: '#bdd5f1',
|
|
72
|
+
surface5: '#d4e4f6',
|
|
73
|
+
surface4: '#dfebf8',
|
|
74
|
+
surface3: '#fff',
|
|
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
|
+
bgFillDark: '#1b1e23',
|
|
84
|
+
fgFillDark: '#eff0f2',
|
|
85
|
+
bgFillInverted2: '#1b1e23',
|
|
86
|
+
bgFillInverted1: '#002a69',
|
|
87
|
+
fgFillInverted: '#eff0f2',
|
|
88
|
+
surface1: '#e9f1fa',
|
|
89
89
|
},
|
|
90
90
|
direction: 'darker',
|
|
91
91
|
},
|
|
92
92
|
success: {
|
|
93
93
|
ramp: {
|
|
94
|
-
bgFill1:
|
|
95
|
-
fgFill:
|
|
96
|
-
bgFill2:
|
|
97
|
-
surface2:
|
|
98
|
-
surface6:
|
|
99
|
-
surface5:
|
|
100
|
-
surface4:
|
|
101
|
-
surface3:
|
|
102
|
-
fgSurface4:
|
|
103
|
-
fgSurface3:
|
|
104
|
-
fgSurface2:
|
|
105
|
-
fgSurface1:
|
|
106
|
-
stroke3:
|
|
107
|
-
stroke4:
|
|
108
|
-
stroke2:
|
|
109
|
-
stroke1:
|
|
110
|
-
bgFillDark:
|
|
111
|
-
fgFillDark:
|
|
112
|
-
bgFillInverted2:
|
|
113
|
-
bgFillInverted1:
|
|
114
|
-
fgFillInverted:
|
|
115
|
-
surface1:
|
|
94
|
+
bgFill1: '#4ab866',
|
|
95
|
+
fgFill: '#1b1f1c',
|
|
96
|
+
bgFill2: '#37a756',
|
|
97
|
+
surface2: '#f0fcf2',
|
|
98
|
+
surface6: '#7eea95',
|
|
99
|
+
surface5: '#b5f1bf',
|
|
100
|
+
surface4: '#cbf5d1',
|
|
101
|
+
surface3: '#fff',
|
|
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
|
+
bgFillDark: '#1b1f1c',
|
|
111
|
+
fgFillDark: '#edf2ed',
|
|
112
|
+
bgFillInverted2: '#1b1f1c',
|
|
113
|
+
bgFillInverted1: '#003701',
|
|
114
|
+
fgFillInverted: '#edf2ed',
|
|
115
|
+
surface1: '#dbf8df',
|
|
116
116
|
},
|
|
117
117
|
direction: 'darker',
|
|
118
118
|
},
|
|
119
119
|
caution: {
|
|
120
120
|
ramp: {
|
|
121
|
-
bgFill1:
|
|
122
|
-
fgFill:
|
|
123
|
-
bgFill2:
|
|
124
|
-
surface2:
|
|
125
|
-
surface6:
|
|
126
|
-
surface5:
|
|
127
|
-
surface4:
|
|
128
|
-
surface3:
|
|
129
|
-
fgSurface4:
|
|
130
|
-
fgSurface3:
|
|
131
|
-
fgSurface2:
|
|
132
|
-
fgSurface1:
|
|
133
|
-
stroke3:
|
|
134
|
-
stroke4:
|
|
135
|
-
stroke2:
|
|
136
|
-
stroke1:
|
|
137
|
-
bgFillDark:
|
|
138
|
-
fgFillDark:
|
|
139
|
-
bgFillInverted2:
|
|
140
|
-
bgFillInverted1:
|
|
141
|
-
fgFillInverted:
|
|
142
|
-
surface1:
|
|
121
|
+
bgFill1: '#f0d149',
|
|
122
|
+
fgFill: '#1f1e1b',
|
|
123
|
+
bgFill2: '#dcbe2f',
|
|
124
|
+
surface2: '#fdf9e7',
|
|
125
|
+
surface6: '#ecd264',
|
|
126
|
+
surface5: '#f5e297',
|
|
127
|
+
surface4: '#f7eab3',
|
|
128
|
+
surface3: '#fff',
|
|
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
|
+
bgFillDark: '#1f1e1b',
|
|
138
|
+
fgFillDark: '#f6f1da',
|
|
139
|
+
bgFillInverted2: '#1f1e1b',
|
|
140
|
+
bgFillInverted1: '#392c00',
|
|
141
|
+
fgFillInverted: '#f6f1da',
|
|
142
|
+
surface1: '#f9f0c8',
|
|
143
143
|
},
|
|
144
144
|
direction: 'darker',
|
|
145
145
|
},
|
|
146
146
|
warning: {
|
|
147
147
|
ramp: {
|
|
148
|
-
bgFill1:
|
|
149
|
-
fgFill:
|
|
150
|
-
bgFill2:
|
|
151
|
-
surface2:
|
|
152
|
-
surface6:
|
|
153
|
-
surface5:
|
|
154
|
-
surface4:
|
|
155
|
-
surface3:
|
|
156
|
-
fgSurface4:
|
|
157
|
-
fgSurface3:
|
|
158
|
-
fgSurface2:
|
|
159
|
-
fgSurface1:
|
|
160
|
-
stroke3:
|
|
161
|
-
stroke4:
|
|
162
|
-
stroke2:
|
|
163
|
-
stroke1:
|
|
164
|
-
bgFillDark:
|
|
165
|
-
fgFillDark:
|
|
166
|
-
bgFillInverted2:
|
|
167
|
-
bgFillInverted1:
|
|
168
|
-
fgFillInverted:
|
|
169
|
-
surface1:
|
|
148
|
+
bgFill1: '#f0b849',
|
|
149
|
+
fgFill: '#1f1e1b',
|
|
150
|
+
bgFill2: '#dda633',
|
|
151
|
+
surface2: '#fdf7ee',
|
|
152
|
+
surface6: '#f1ce8f',
|
|
153
|
+
surface5: '#f6e0b9',
|
|
154
|
+
surface4: '#f8e8cc',
|
|
155
|
+
surface3: '#fff',
|
|
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
|
+
bgFillDark: '#1f1e1b',
|
|
165
|
+
fgFillDark: '#f3f0e9',
|
|
166
|
+
bgFillInverted2: '#1f1e1b',
|
|
167
|
+
bgFillInverted1: '#422800',
|
|
168
|
+
fgFillInverted: '#f3f0e9',
|
|
169
|
+
surface1: '#faeeda',
|
|
170
170
|
},
|
|
171
171
|
direction: 'darker',
|
|
172
172
|
},
|
|
173
173
|
error: {
|
|
174
174
|
ramp: {
|
|
175
|
-
bgFill1:
|
|
176
|
-
fgFill:
|
|
177
|
-
bgFill2:
|
|
178
|
-
surface2:
|
|
179
|
-
surface6:
|
|
180
|
-
surface5:
|
|
181
|
-
surface4:
|
|
182
|
-
surface3:
|
|
183
|
-
fgSurface4:
|
|
184
|
-
fgSurface3:
|
|
185
|
-
fgSurface2:
|
|
186
|
-
fgSurface1:
|
|
187
|
-
stroke3:
|
|
188
|
-
stroke4:
|
|
189
|
-
stroke2:
|
|
190
|
-
stroke1:
|
|
191
|
-
bgFillDark:
|
|
192
|
-
fgFillDark:
|
|
193
|
-
bgFillInverted2:
|
|
194
|
-
bgFillInverted1:
|
|
195
|
-
fgFillInverted:
|
|
196
|
-
surface1:
|
|
175
|
+
bgFill1: '#cc1818',
|
|
176
|
+
fgFill: '#f2efef',
|
|
177
|
+
bgFill2: '#b90000',
|
|
178
|
+
surface2: '#fdf6f5',
|
|
179
|
+
surface6: '#f5c8c1',
|
|
180
|
+
surface5: '#f9dbd7',
|
|
181
|
+
surface4: '#fae4e1',
|
|
182
|
+
surface3: '#fff',
|
|
183
|
+
fgSurface4: '#470000',
|
|
184
|
+
fgSurface3: '#cc1818',
|
|
185
|
+
fgSurface2: '#f74c40',
|
|
186
|
+
fgSurface1: '#ff8879',
|
|
187
|
+
stroke3: '#cc1818',
|
|
188
|
+
stroke4: '#9d0000',
|
|
189
|
+
stroke2: '#de988e',
|
|
190
|
+
stroke1: '#e1a198',
|
|
191
|
+
bgFillDark: '#231c1b',
|
|
192
|
+
fgFillDark: '#f2efef',
|
|
193
|
+
bgFillInverted2: '#231c1b',
|
|
194
|
+
bgFillInverted1: '#640000',
|
|
195
|
+
fgFillInverted: '#f2efef',
|
|
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,
|
|
@@ -67,10 +66,8 @@ function calculateRamp( {
|
|
|
67
66
|
value: number;
|
|
68
67
|
};
|
|
69
68
|
} ) {
|
|
70
|
-
const rampResults = {} as Record<
|
|
71
|
-
|
|
72
|
-
{ color: string; warning: boolean }
|
|
73
|
-
>;
|
|
69
|
+
const rampResults = {} as Record< keyof Ramp, string >;
|
|
70
|
+
let warnings: string[] | undefined;
|
|
74
71
|
let maxDeficit = -Infinity;
|
|
75
72
|
let maxDeficitDirection: RampDirection = 'lighter';
|
|
76
73
|
let maxDeficitStep;
|
|
@@ -113,10 +110,7 @@ function calculateRamp( {
|
|
|
113
110
|
if ( candidateContrast >= adjustedTarget ) {
|
|
114
111
|
// Store the reused color
|
|
115
112
|
calculatedColors.set( stepName, candidateColor );
|
|
116
|
-
rampResults[ stepName ] =
|
|
117
|
-
color: getColorString( candidateColor ),
|
|
118
|
-
warning: false,
|
|
119
|
-
};
|
|
113
|
+
rampResults[ stepName ] = getColorString( candidateColor );
|
|
120
114
|
|
|
121
115
|
continue; // Skip to next step
|
|
122
116
|
}
|
|
@@ -193,14 +187,17 @@ function calculateRamp( {
|
|
|
193
187
|
calculatedColors.set( stepName, searchResults.color );
|
|
194
188
|
|
|
195
189
|
// Add to results
|
|
196
|
-
rampResults[ stepName ] =
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
190
|
+
rampResults[ stepName ] = getColorString( searchResults.color );
|
|
191
|
+
|
|
192
|
+
if ( ! searchResults.reached && ! contrast.ignoreWhenAdjustingSeed ) {
|
|
193
|
+
warnings ??= [];
|
|
194
|
+
warnings.push( stepName );
|
|
195
|
+
}
|
|
201
196
|
}
|
|
197
|
+
|
|
202
198
|
return {
|
|
203
199
|
rampResults,
|
|
200
|
+
warnings,
|
|
204
201
|
maxDeficit,
|
|
205
202
|
maxDeficitDirection,
|
|
206
203
|
maxDeficitStep,
|
|
@@ -250,15 +247,20 @@ export function buildRamp(
|
|
|
250
247
|
const sortedSteps = sortByDependency( config );
|
|
251
248
|
|
|
252
249
|
// Calculate the ramp with the initial seed.
|
|
253
|
-
const {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
250
|
+
const {
|
|
251
|
+
rampResults,
|
|
252
|
+
warnings,
|
|
253
|
+
maxDeficit,
|
|
254
|
+
maxDeficitDirection,
|
|
255
|
+
maxDeficitStep,
|
|
256
|
+
} = calculateRamp( {
|
|
257
|
+
seed,
|
|
258
|
+
sortedSteps,
|
|
259
|
+
config,
|
|
260
|
+
mainDir,
|
|
261
|
+
oppDir,
|
|
262
|
+
pinLightness,
|
|
263
|
+
} );
|
|
262
264
|
|
|
263
265
|
let bestRamp = rampResults;
|
|
264
266
|
|
|
@@ -326,6 +328,7 @@ export function buildRamp(
|
|
|
326
328
|
|
|
327
329
|
return {
|
|
328
330
|
ramp: bestRamp,
|
|
331
|
+
warnings,
|
|
329
332
|
direction: mainDir,
|
|
330
333
|
};
|
|
331
334
|
}
|
|
@@ -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
|
},
|
|
@@ -79,12 +79,7 @@ export type RampStepConfig = {
|
|
|
79
79
|
export type RampConfig = Record< keyof Ramp, RampStepConfig >;
|
|
80
80
|
|
|
81
81
|
export type RampResult = {
|
|
82
|
-
ramp: Record<
|
|
83
|
-
|
|
84
|
-
{
|
|
85
|
-
color: string;
|
|
86
|
-
warning: boolean;
|
|
87
|
-
}
|
|
88
|
-
>;
|
|
82
|
+
ramp: Record< keyof Ramp, string >;
|
|
83
|
+
warnings?: string[];
|
|
89
84
|
direction: RampDirection;
|
|
90
85
|
};
|
|
@@ -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
|
) }
|
|
@@ -224,14 +227,17 @@ export const SampleCombinations: StoryObj< typeof ColorGen > = {
|
|
|
224
227
|
value: background,
|
|
225
228
|
},
|
|
226
229
|
ramp: bgRamp.ramp,
|
|
230
|
+
warnings: bgRamp.warnings,
|
|
227
231
|
};
|
|
228
232
|
|
|
233
|
+
const primaryRamp = buildAccentRamp( primary, bgRamp );
|
|
229
234
|
const primaryRampObj = {
|
|
230
235
|
seed: {
|
|
231
236
|
name: 'bgFill1' as const,
|
|
232
237
|
value: primary,
|
|
233
238
|
},
|
|
234
|
-
ramp:
|
|
239
|
+
ramp: primaryRamp.ramp,
|
|
240
|
+
warnings: primaryRamp.warnings,
|
|
235
241
|
};
|
|
236
242
|
|
|
237
243
|
return [ bgRampObj, primaryRampObj ];
|