@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
|
@@ -2,190 +2,190 @@
|
|
|
2
2
|
var DEFAULT_RAMPS = {
|
|
3
3
|
bg: {
|
|
4
4
|
ramp: {
|
|
5
|
-
surface2:
|
|
6
|
-
bgFill1:
|
|
7
|
-
fgFill:
|
|
8
|
-
bgFill2:
|
|
9
|
-
surface6:
|
|
10
|
-
surface5:
|
|
11
|
-
surface4:
|
|
12
|
-
surface3:
|
|
13
|
-
fgSurface4:
|
|
14
|
-
fgSurface3:
|
|
15
|
-
fgSurface2:
|
|
16
|
-
fgSurface1:
|
|
17
|
-
stroke3:
|
|
18
|
-
stroke4:
|
|
19
|
-
stroke2:
|
|
20
|
-
stroke1:
|
|
21
|
-
bgFillDark:
|
|
22
|
-
fgFillDark:
|
|
23
|
-
bgFillInverted2:
|
|
24
|
-
bgFillInverted1:
|
|
25
|
-
fgFillInverted:
|
|
26
|
-
surface1:
|
|
5
|
+
surface2: "#f8f8f8",
|
|
6
|
+
bgFill1: "#555",
|
|
7
|
+
fgFill: "#f0f0f0",
|
|
8
|
+
bgFill2: "#484848",
|
|
9
|
+
surface6: "#d2d2d2",
|
|
10
|
+
surface5: "#e2e2e2",
|
|
11
|
+
surface4: "#eaeaea",
|
|
12
|
+
surface3: "#fff",
|
|
13
|
+
fgSurface4: "#1e1e1e",
|
|
14
|
+
fgSurface3: "#6d6d6d",
|
|
15
|
+
fgSurface2: "#8a8a8a",
|
|
16
|
+
fgSurface1: "#aaa",
|
|
17
|
+
stroke3: "#8a8a8a",
|
|
18
|
+
stroke4: "#6c6c6c",
|
|
19
|
+
stroke2: "#d8d8d8",
|
|
20
|
+
stroke1: "#e0e0e0",
|
|
21
|
+
bgFillDark: "#1e1e1e",
|
|
22
|
+
fgFillDark: "#f0f0f0",
|
|
23
|
+
bgFillInverted2: "#1e1e1e",
|
|
24
|
+
bgFillInverted1: "#2d2d2d",
|
|
25
|
+
fgFillInverted: "#f0f0f0",
|
|
26
|
+
surface1: "#f0f0f0"
|
|
27
27
|
},
|
|
28
28
|
direction: "darker"
|
|
29
29
|
},
|
|
30
30
|
primary: {
|
|
31
31
|
ramp: {
|
|
32
|
-
bgFill1:
|
|
33
|
-
fgFill:
|
|
34
|
-
bgFill2:
|
|
35
|
-
surface2:
|
|
36
|
-
surface6:
|
|
37
|
-
surface5:
|
|
38
|
-
surface4:
|
|
39
|
-
surface3:
|
|
40
|
-
fgSurface4:
|
|
41
|
-
fgSurface3:
|
|
42
|
-
fgSurface2:
|
|
43
|
-
fgSurface1:
|
|
44
|
-
stroke3:
|
|
45
|
-
stroke4:
|
|
46
|
-
stroke2:
|
|
47
|
-
stroke1:
|
|
48
|
-
bgFillDark:
|
|
49
|
-
fgFillDark:
|
|
50
|
-
bgFillInverted2:
|
|
51
|
-
bgFillInverted1:
|
|
52
|
-
fgFillInverted:
|
|
53
|
-
surface1:
|
|
32
|
+
bgFill1: "#3858e9",
|
|
33
|
+
fgFill: "#eff0f2",
|
|
34
|
+
bgFill2: "#2e49d9",
|
|
35
|
+
surface2: "#f6f8fc",
|
|
36
|
+
surface6: "#c7d2ee",
|
|
37
|
+
surface5: "#dbe2f4",
|
|
38
|
+
surface4: "#e4eaf7",
|
|
39
|
+
surface3: "#fff",
|
|
40
|
+
fgSurface4: "#0b0070",
|
|
41
|
+
fgSurface3: "#3858e9",
|
|
42
|
+
fgSurface2: "#5b82ff",
|
|
43
|
+
fgSurface1: "#85a9ff",
|
|
44
|
+
stroke3: "#3858e9",
|
|
45
|
+
stroke4: "#2337c8",
|
|
46
|
+
stroke2: "#9aaad3",
|
|
47
|
+
stroke1: "#a2b1d6",
|
|
48
|
+
bgFillDark: "#1b1e26",
|
|
49
|
+
fgFillDark: "#eff0f2",
|
|
50
|
+
bgFillInverted2: "#1b1e26",
|
|
51
|
+
bgFillInverted1: "#13009f",
|
|
52
|
+
fgFillInverted: "#eff0f2",
|
|
53
|
+
surface1: "#ecf0f9"
|
|
54
54
|
},
|
|
55
55
|
direction: "darker"
|
|
56
56
|
},
|
|
57
57
|
info: {
|
|
58
58
|
ramp: {
|
|
59
|
-
bgFill1:
|
|
60
|
-
fgFill:
|
|
61
|
-
bgFill2:
|
|
62
|
-
surface2:
|
|
63
|
-
surface6:
|
|
64
|
-
surface5:
|
|
65
|
-
surface4:
|
|
66
|
-
surface3:
|
|
67
|
-
fgSurface4:
|
|
68
|
-
fgSurface3:
|
|
69
|
-
fgSurface2:
|
|
70
|
-
fgSurface1:
|
|
71
|
-
stroke3:
|
|
72
|
-
stroke4:
|
|
73
|
-
stroke2:
|
|
74
|
-
stroke1:
|
|
75
|
-
bgFillDark:
|
|
76
|
-
fgFillDark:
|
|
77
|
-
bgFillInverted2:
|
|
78
|
-
bgFillInverted1:
|
|
79
|
-
fgFillInverted:
|
|
80
|
-
surface1:
|
|
59
|
+
bgFill1: "#0090ff",
|
|
60
|
+
fgFill: "#1b1e23",
|
|
61
|
+
bgFill2: "#007fed",
|
|
62
|
+
surface2: "#f5f9fd",
|
|
63
|
+
surface6: "#bdd5f1",
|
|
64
|
+
surface5: "#d4e4f6",
|
|
65
|
+
surface4: "#dfebf8",
|
|
66
|
+
surface3: "#fff",
|
|
67
|
+
fgSurface4: "#001b4f",
|
|
68
|
+
fgSurface3: "#006bd7",
|
|
69
|
+
fgSurface2: "#008bfa",
|
|
70
|
+
fgSurface1: "#59b0ff",
|
|
71
|
+
stroke3: "#006bd7",
|
|
72
|
+
stroke4: "#004fa9",
|
|
73
|
+
stroke2: "#94b5d9",
|
|
74
|
+
stroke1: "#9fbcdd",
|
|
75
|
+
bgFillDark: "#1b1e23",
|
|
76
|
+
fgFillDark: "#eff0f2",
|
|
77
|
+
bgFillInverted2: "#1b1e23",
|
|
78
|
+
bgFillInverted1: "#002a69",
|
|
79
|
+
fgFillInverted: "#eff0f2",
|
|
80
|
+
surface1: "#e9f1fa"
|
|
81
81
|
},
|
|
82
82
|
direction: "darker"
|
|
83
83
|
},
|
|
84
84
|
success: {
|
|
85
85
|
ramp: {
|
|
86
|
-
bgFill1:
|
|
87
|
-
fgFill:
|
|
88
|
-
bgFill2:
|
|
89
|
-
surface2:
|
|
90
|
-
surface6:
|
|
91
|
-
surface5:
|
|
92
|
-
surface4:
|
|
93
|
-
surface3:
|
|
94
|
-
fgSurface4:
|
|
95
|
-
fgSurface3:
|
|
96
|
-
fgSurface2:
|
|
97
|
-
fgSurface1:
|
|
98
|
-
stroke3:
|
|
99
|
-
stroke4:
|
|
100
|
-
stroke2:
|
|
101
|
-
stroke1:
|
|
102
|
-
bgFillDark:
|
|
103
|
-
fgFillDark:
|
|
104
|
-
bgFillInverted2:
|
|
105
|
-
bgFillInverted1:
|
|
106
|
-
fgFillInverted:
|
|
107
|
-
surface1:
|
|
86
|
+
bgFill1: "#4ab866",
|
|
87
|
+
fgFill: "#1b1f1c",
|
|
88
|
+
bgFill2: "#37a756",
|
|
89
|
+
surface2: "#f0fcf2",
|
|
90
|
+
surface6: "#7eea95",
|
|
91
|
+
surface5: "#b5f1bf",
|
|
92
|
+
surface4: "#cbf5d1",
|
|
93
|
+
surface3: "#fff",
|
|
94
|
+
fgSurface4: "#002900",
|
|
95
|
+
fgSurface3: "#007f30",
|
|
96
|
+
fgSurface2: "#2b9e4e",
|
|
97
|
+
fgSurface1: "#53c06e",
|
|
98
|
+
stroke3: "#007f30",
|
|
99
|
+
stroke4: "#006013",
|
|
100
|
+
stroke2: "#7dc189",
|
|
101
|
+
stroke1: "#82c98f",
|
|
102
|
+
bgFillDark: "#1b1f1c",
|
|
103
|
+
fgFillDark: "#edf2ed",
|
|
104
|
+
bgFillInverted2: "#1b1f1c",
|
|
105
|
+
bgFillInverted1: "#003701",
|
|
106
|
+
fgFillInverted: "#edf2ed",
|
|
107
|
+
surface1: "#dbf8df"
|
|
108
108
|
},
|
|
109
109
|
direction: "darker"
|
|
110
110
|
},
|
|
111
111
|
caution: {
|
|
112
112
|
ramp: {
|
|
113
|
-
bgFill1:
|
|
114
|
-
fgFill:
|
|
115
|
-
bgFill2:
|
|
116
|
-
surface2:
|
|
117
|
-
surface6:
|
|
118
|
-
surface5:
|
|
119
|
-
surface4:
|
|
120
|
-
surface3:
|
|
121
|
-
fgSurface4:
|
|
122
|
-
fgSurface3:
|
|
123
|
-
fgSurface2:
|
|
124
|
-
fgSurface1:
|
|
125
|
-
stroke3:
|
|
126
|
-
stroke4:
|
|
127
|
-
stroke2:
|
|
128
|
-
stroke1:
|
|
129
|
-
bgFillDark:
|
|
130
|
-
fgFillDark:
|
|
131
|
-
bgFillInverted2:
|
|
132
|
-
bgFillInverted1:
|
|
133
|
-
fgFillInverted:
|
|
134
|
-
surface1:
|
|
113
|
+
bgFill1: "#f0d149",
|
|
114
|
+
fgFill: "#1f1e1b",
|
|
115
|
+
bgFill2: "#dcbe2f",
|
|
116
|
+
surface2: "#fdf9e7",
|
|
117
|
+
surface6: "#ecd264",
|
|
118
|
+
surface5: "#f5e297",
|
|
119
|
+
surface4: "#f7eab3",
|
|
120
|
+
surface3: "#fff",
|
|
121
|
+
fgSurface4: "#281d00",
|
|
122
|
+
fgSurface3: "#836b00",
|
|
123
|
+
fgSurface2: "#a58700",
|
|
124
|
+
fgSurface1: "#c7a900",
|
|
125
|
+
stroke3: "#836b00",
|
|
126
|
+
stroke4: "#635000",
|
|
127
|
+
stroke2: "#bfb17a",
|
|
128
|
+
stroke1: "#c7b97f",
|
|
129
|
+
bgFillDark: "#1f1e1b",
|
|
130
|
+
fgFillDark: "#f6f1da",
|
|
131
|
+
bgFillInverted2: "#1f1e1b",
|
|
132
|
+
bgFillInverted1: "#392c00",
|
|
133
|
+
fgFillInverted: "#f6f1da",
|
|
134
|
+
surface1: "#f9f0c8"
|
|
135
135
|
},
|
|
136
136
|
direction: "darker"
|
|
137
137
|
},
|
|
138
138
|
warning: {
|
|
139
139
|
ramp: {
|
|
140
|
-
bgFill1:
|
|
141
|
-
fgFill:
|
|
142
|
-
bgFill2:
|
|
143
|
-
surface2:
|
|
144
|
-
surface6:
|
|
145
|
-
surface5:
|
|
146
|
-
surface4:
|
|
147
|
-
surface3:
|
|
148
|
-
fgSurface4:
|
|
149
|
-
fgSurface3:
|
|
150
|
-
fgSurface2:
|
|
151
|
-
fgSurface1:
|
|
152
|
-
stroke3:
|
|
153
|
-
stroke4:
|
|
154
|
-
stroke2:
|
|
155
|
-
stroke1:
|
|
156
|
-
bgFillDark:
|
|
157
|
-
fgFillDark:
|
|
158
|
-
bgFillInverted2:
|
|
159
|
-
bgFillInverted1:
|
|
160
|
-
fgFillInverted:
|
|
161
|
-
surface1:
|
|
140
|
+
bgFill1: "#f0b849",
|
|
141
|
+
fgFill: "#1f1e1b",
|
|
142
|
+
bgFill2: "#dda633",
|
|
143
|
+
surface2: "#fdf7ee",
|
|
144
|
+
surface6: "#f1ce8f",
|
|
145
|
+
surface5: "#f6e0b9",
|
|
146
|
+
surface4: "#f8e8cc",
|
|
147
|
+
surface3: "#fff",
|
|
148
|
+
fgSurface4: "#2e1900",
|
|
149
|
+
fgSurface3: "#936400",
|
|
150
|
+
fgSurface2: "#b68000",
|
|
151
|
+
fgSurface1: "#d8a12c",
|
|
152
|
+
stroke3: "#936400",
|
|
153
|
+
stroke4: "#704a00",
|
|
154
|
+
stroke2: "#caae7c",
|
|
155
|
+
stroke1: "#d2b581",
|
|
156
|
+
bgFillDark: "#1f1e1b",
|
|
157
|
+
fgFillDark: "#f3f0e9",
|
|
158
|
+
bgFillInverted2: "#1f1e1b",
|
|
159
|
+
bgFillInverted1: "#422800",
|
|
160
|
+
fgFillInverted: "#f3f0e9",
|
|
161
|
+
surface1: "#faeeda"
|
|
162
162
|
},
|
|
163
163
|
direction: "darker"
|
|
164
164
|
},
|
|
165
165
|
error: {
|
|
166
166
|
ramp: {
|
|
167
|
-
bgFill1:
|
|
168
|
-
fgFill:
|
|
169
|
-
bgFill2:
|
|
170
|
-
surface2:
|
|
171
|
-
surface6:
|
|
172
|
-
surface5:
|
|
173
|
-
surface4:
|
|
174
|
-
surface3:
|
|
175
|
-
fgSurface4:
|
|
176
|
-
fgSurface3:
|
|
177
|
-
fgSurface2:
|
|
178
|
-
fgSurface1:
|
|
179
|
-
stroke3:
|
|
180
|
-
stroke4:
|
|
181
|
-
stroke2:
|
|
182
|
-
stroke1:
|
|
183
|
-
bgFillDark:
|
|
184
|
-
fgFillDark:
|
|
185
|
-
bgFillInverted2:
|
|
186
|
-
bgFillInverted1:
|
|
187
|
-
fgFillInverted:
|
|
188
|
-
surface1:
|
|
167
|
+
bgFill1: "#cc1818",
|
|
168
|
+
fgFill: "#f2efef",
|
|
169
|
+
bgFill2: "#b90000",
|
|
170
|
+
surface2: "#fdf6f5",
|
|
171
|
+
surface6: "#f5c8c1",
|
|
172
|
+
surface5: "#f9dbd7",
|
|
173
|
+
surface4: "#fae4e1",
|
|
174
|
+
surface3: "#fff",
|
|
175
|
+
fgSurface4: "#470000",
|
|
176
|
+
fgSurface3: "#cc1818",
|
|
177
|
+
fgSurface2: "#f74c40",
|
|
178
|
+
fgSurface1: "#ff8879",
|
|
179
|
+
stroke3: "#cc1818",
|
|
180
|
+
stroke4: "#9d0000",
|
|
181
|
+
stroke2: "#de988e",
|
|
182
|
+
stroke1: "#e1a198",
|
|
183
|
+
bgFillDark: "#231c1b",
|
|
184
|
+
fgFillDark: "#f2efef",
|
|
185
|
+
bgFillInverted2: "#231c1b",
|
|
186
|
+
bgFillInverted1: "#640000",
|
|
187
|
+
fgFillInverted: "#f2efef",
|
|
188
|
+
surface1: "#fbece9"
|
|
189
189
|
},
|
|
190
190
|
direction: "darker"
|
|
191
191
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/color-ramps/lib/default-ramps.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RampResult } from './types';\nimport type { DEFAULT_SEED_COLORS } from './constants';\n\nexport const DEFAULT_RAMPS: Record<\n\tkeyof typeof DEFAULT_SEED_COLORS,\n\tRampResult\n> = {\n\tbg: {\n\t\tramp: {\n\t\t\tsurface2:
|
|
5
|
-
"mappings": ";AAMO,IAAM,gBAGT;AAAA,EACH,IAAI;AAAA,IACH,MAAM;AAAA,MACL,UAAU
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RampResult } from './types';\nimport type { DEFAULT_SEED_COLORS } from './constants';\n\nexport const DEFAULT_RAMPS: Record<\n\tkeyof typeof DEFAULT_SEED_COLORS,\n\tRampResult\n> = {\n\tbg: {\n\t\tramp: {\n\t\t\tsurface2: '#f8f8f8',\n\t\t\tbgFill1: '#555',\n\t\t\tfgFill: '#f0f0f0',\n\t\t\tbgFill2: '#484848',\n\t\t\tsurface6: '#d2d2d2',\n\t\t\tsurface5: '#e2e2e2',\n\t\t\tsurface4: '#eaeaea',\n\t\t\tsurface3: '#fff',\n\t\t\tfgSurface4: '#1e1e1e',\n\t\t\tfgSurface3: '#6d6d6d',\n\t\t\tfgSurface2: '#8a8a8a',\n\t\t\tfgSurface1: '#aaa',\n\t\t\tstroke3: '#8a8a8a',\n\t\t\tstroke4: '#6c6c6c',\n\t\t\tstroke2: '#d8d8d8',\n\t\t\tstroke1: '#e0e0e0',\n\t\t\tbgFillDark: '#1e1e1e',\n\t\t\tfgFillDark: '#f0f0f0',\n\t\t\tbgFillInverted2: '#1e1e1e',\n\t\t\tbgFillInverted1: '#2d2d2d',\n\t\t\tfgFillInverted: '#f0f0f0',\n\t\t\tsurface1: '#f0f0f0',\n\t\t},\n\t\tdirection: 'darker',\n\t},\n\tprimary: {\n\t\tramp: {\n\t\t\tbgFill1: '#3858e9',\n\t\t\tfgFill: '#eff0f2',\n\t\t\tbgFill2: '#2e49d9',\n\t\t\tsurface2: '#f6f8fc',\n\t\t\tsurface6: '#c7d2ee',\n\t\t\tsurface5: '#dbe2f4',\n\t\t\tsurface4: '#e4eaf7',\n\t\t\tsurface3: '#fff',\n\t\t\tfgSurface4: '#0b0070',\n\t\t\tfgSurface3: '#3858e9',\n\t\t\tfgSurface2: '#5b82ff',\n\t\t\tfgSurface1: '#85a9ff',\n\t\t\tstroke3: '#3858e9',\n\t\t\tstroke4: '#2337c8',\n\t\t\tstroke2: '#9aaad3',\n\t\t\tstroke1: '#a2b1d6',\n\t\t\tbgFillDark: '#1b1e26',\n\t\t\tfgFillDark: '#eff0f2',\n\t\t\tbgFillInverted2: '#1b1e26',\n\t\t\tbgFillInverted1: '#13009f',\n\t\t\tfgFillInverted: '#eff0f2',\n\t\t\tsurface1: '#ecf0f9',\n\t\t},\n\t\tdirection: 'darker',\n\t},\n\tinfo: {\n\t\tramp: {\n\t\t\tbgFill1: '#0090ff',\n\t\t\tfgFill: '#1b1e23',\n\t\t\tbgFill2: '#007fed',\n\t\t\tsurface2: '#f5f9fd',\n\t\t\tsurface6: '#bdd5f1',\n\t\t\tsurface5: '#d4e4f6',\n\t\t\tsurface4: '#dfebf8',\n\t\t\tsurface3: '#fff',\n\t\t\tfgSurface4: '#001b4f',\n\t\t\tfgSurface3: '#006bd7',\n\t\t\tfgSurface2: '#008bfa',\n\t\t\tfgSurface1: '#59b0ff',\n\t\t\tstroke3: '#006bd7',\n\t\t\tstroke4: '#004fa9',\n\t\t\tstroke2: '#94b5d9',\n\t\t\tstroke1: '#9fbcdd',\n\t\t\tbgFillDark: '#1b1e23',\n\t\t\tfgFillDark: '#eff0f2',\n\t\t\tbgFillInverted2: '#1b1e23',\n\t\t\tbgFillInverted1: '#002a69',\n\t\t\tfgFillInverted: '#eff0f2',\n\t\t\tsurface1: '#e9f1fa',\n\t\t},\n\t\tdirection: 'darker',\n\t},\n\tsuccess: {\n\t\tramp: {\n\t\t\tbgFill1: '#4ab866',\n\t\t\tfgFill: '#1b1f1c',\n\t\t\tbgFill2: '#37a756',\n\t\t\tsurface2: '#f0fcf2',\n\t\t\tsurface6: '#7eea95',\n\t\t\tsurface5: '#b5f1bf',\n\t\t\tsurface4: '#cbf5d1',\n\t\t\tsurface3: '#fff',\n\t\t\tfgSurface4: '#002900',\n\t\t\tfgSurface3: '#007f30',\n\t\t\tfgSurface2: '#2b9e4e',\n\t\t\tfgSurface1: '#53c06e',\n\t\t\tstroke3: '#007f30',\n\t\t\tstroke4: '#006013',\n\t\t\tstroke2: '#7dc189',\n\t\t\tstroke1: '#82c98f',\n\t\t\tbgFillDark: '#1b1f1c',\n\t\t\tfgFillDark: '#edf2ed',\n\t\t\tbgFillInverted2: '#1b1f1c',\n\t\t\tbgFillInverted1: '#003701',\n\t\t\tfgFillInverted: '#edf2ed',\n\t\t\tsurface1: '#dbf8df',\n\t\t},\n\t\tdirection: 'darker',\n\t},\n\tcaution: {\n\t\tramp: {\n\t\t\tbgFill1: '#f0d149',\n\t\t\tfgFill: '#1f1e1b',\n\t\t\tbgFill2: '#dcbe2f',\n\t\t\tsurface2: '#fdf9e7',\n\t\t\tsurface6: '#ecd264',\n\t\t\tsurface5: '#f5e297',\n\t\t\tsurface4: '#f7eab3',\n\t\t\tsurface3: '#fff',\n\t\t\tfgSurface4: '#281d00',\n\t\t\tfgSurface3: '#836b00',\n\t\t\tfgSurface2: '#a58700',\n\t\t\tfgSurface1: '#c7a900',\n\t\t\tstroke3: '#836b00',\n\t\t\tstroke4: '#635000',\n\t\t\tstroke2: '#bfb17a',\n\t\t\tstroke1: '#c7b97f',\n\t\t\tbgFillDark: '#1f1e1b',\n\t\t\tfgFillDark: '#f6f1da',\n\t\t\tbgFillInverted2: '#1f1e1b',\n\t\t\tbgFillInverted1: '#392c00',\n\t\t\tfgFillInverted: '#f6f1da',\n\t\t\tsurface1: '#f9f0c8',\n\t\t},\n\t\tdirection: 'darker',\n\t},\n\twarning: {\n\t\tramp: {\n\t\t\tbgFill1: '#f0b849',\n\t\t\tfgFill: '#1f1e1b',\n\t\t\tbgFill2: '#dda633',\n\t\t\tsurface2: '#fdf7ee',\n\t\t\tsurface6: '#f1ce8f',\n\t\t\tsurface5: '#f6e0b9',\n\t\t\tsurface4: '#f8e8cc',\n\t\t\tsurface3: '#fff',\n\t\t\tfgSurface4: '#2e1900',\n\t\t\tfgSurface3: '#936400',\n\t\t\tfgSurface2: '#b68000',\n\t\t\tfgSurface1: '#d8a12c',\n\t\t\tstroke3: '#936400',\n\t\t\tstroke4: '#704a00',\n\t\t\tstroke2: '#caae7c',\n\t\t\tstroke1: '#d2b581',\n\t\t\tbgFillDark: '#1f1e1b',\n\t\t\tfgFillDark: '#f3f0e9',\n\t\t\tbgFillInverted2: '#1f1e1b',\n\t\t\tbgFillInverted1: '#422800',\n\t\t\tfgFillInverted: '#f3f0e9',\n\t\t\tsurface1: '#faeeda',\n\t\t},\n\t\tdirection: 'darker',\n\t},\n\terror: {\n\t\tramp: {\n\t\t\tbgFill1: '#cc1818',\n\t\t\tfgFill: '#f2efef',\n\t\t\tbgFill2: '#b90000',\n\t\t\tsurface2: '#fdf6f5',\n\t\t\tsurface6: '#f5c8c1',\n\t\t\tsurface5: '#f9dbd7',\n\t\t\tsurface4: '#fae4e1',\n\t\t\tsurface3: '#fff',\n\t\t\tfgSurface4: '#470000',\n\t\t\tfgSurface3: '#cc1818',\n\t\t\tfgSurface2: '#f74c40',\n\t\t\tfgSurface1: '#ff8879',\n\t\t\tstroke3: '#cc1818',\n\t\t\tstroke4: '#9d0000',\n\t\t\tstroke2: '#de988e',\n\t\t\tstroke1: '#e1a198',\n\t\t\tbgFillDark: '#231c1b',\n\t\t\tfgFillDark: '#f2efef',\n\t\t\tbgFillInverted2: '#231c1b',\n\t\t\tbgFillInverted1: '#640000',\n\t\t\tfgFillInverted: '#f2efef',\n\t\t\tsurface1: '#fbece9',\n\t\t},\n\t\tdirection: 'darker',\n\t},\n};\n"],
|
|
5
|
+
"mappings": ";AAMO,IAAM,gBAGT;AAAA,EACH,IAAI;AAAA,IACH,MAAM;AAAA,MACL,UAAU;AAAA,MACV,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,S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,MACZ,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,iBAAiB;AAAA,MACjB,iBAAiB;AAAA,MACjB,gBAAgB;AAAA,MAChB,UAAU;AAAA,IACX;AAAA,IACA,WAAW;AAAA,EACZ;AAAA,EACA,OAAO;AAAA,IACN,MAAM;AAAA,MACL,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,UAAU;AAAA,MACV,UAAU;AAAA,MACV,UAAU;AAAA,MACV,UAAU;AAAA,MACV,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,iBAAiB;AAAA,MACjB,iBAAiB;AAAA,MACjB,gBAAgB;AAAA,MAChB,UAAU;AAAA,IACX;AAAA,IACA,WAAW;AAAA,EACZ;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// packages/theme/src/color-ramps/lib/find-color-with-constraints.ts
|
|
2
2
|
import { get, OKLCH } from "colorjs.io/fn";
|
|
3
3
|
import "./register-color-spaces";
|
|
4
|
-
import {
|
|
4
|
+
import { solveWithBisect } from "./utils";
|
|
5
5
|
import { WHITE, BLACK, CONTRAST_EPSILON } from "./constants";
|
|
6
|
-
import { getContrast } from "./color-utils";
|
|
6
|
+
import { clampToGamut, getContrast } from "./color-utils";
|
|
7
7
|
import { taperChroma } from "./taper-chroma";
|
|
8
8
|
function cdiff(c1, c2) {
|
|
9
9
|
return Math.log(c1 / c2);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/color-ramps/lib/find-color-with-constraints.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport { get, OKLCH, type ColorTypes } from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\nimport {
|
|
5
|
-
"mappings": ";AAGA,SAAS,KAAK,aAA8B;AAK5C,OAAO;AACP,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport { get, OKLCH, type ColorTypes } from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\nimport { solveWithBisect } from './utils';\nimport { WHITE, BLACK, CONTRAST_EPSILON } from './constants';\nimport { clampToGamut, getContrast } from './color-utils';\nimport { type TaperChromaOptions, taperChroma } from './taper-chroma';\n\n/**\n * Difference of contrast values that grows linearly with the Y luminance.\n * We get more precise linear interpolations when we use this.\n * @param c1 First contrast.\n * @param c2 Second contrast.\n * @return Difference of logarithms.\n */\nfunction cdiff( c1: number, c2: number ) {\n\treturn Math.log( c1 / c2 );\n}\n\n/**\n * Solve for L such that:\n * - the L applied to the seed meets the contrast target against the reference\n * - the search is performed in one direction (ie lighter / darker)\n * - more constraints can be applied around lightness\n * - chroma could be tapered\n * @param reference\n * @param seed\n * @param target\n * @param direction\n * @param options\n * @param options.lightnessConstraint\n * @param options.lightnessConstraint.type\n * @param options.lightnessConstraint.value\n * @param options.taperChromaOptions\n */\nexport function findColorMeetingRequirements(\n\treference: ColorTypes,\n\tseed: ColorTypes,\n\ttarget: number,\n\tdirection: 'lighter' | 'darker',\n\t{\n\t\tlightnessConstraint,\n\t\ttaperChromaOptions,\n\t}: {\n\t\tlightnessConstraint?: {\n\t\t\ttype: 'force' | 'onlyIfSucceeds';\n\t\t\tvalue: number;\n\t\t};\n\t\ttaperChromaOptions?: TaperChromaOptions;\n\t} = {}\n): { color: ColorTypes; reached: boolean; achieved: number; deficit?: number } {\n\t// A target of 1 means same color.\n\t// A target lower than 1 doesn't make sense.\n\tif ( target <= 1 ) {\n\t\treturn {\n\t\t\tcolor: reference,\n\t\t\treached: true,\n\t\t\tachieved: 1,\n\t\t};\n\t}\n\n\tfunction getColorForL( l: number ): ColorTypes {\n\t\tlet newL = l;\n\t\tlet newC = get( seed, [ OKLCH, 'c' ] );\n\n\t\tif ( taperChromaOptions ) {\n\t\t\tconst tapered = taperChroma( seed, newL, taperChromaOptions );\n\t\t\t// taperChroma returns either { l, c } or a ColorObject\n\t\t\tif ( 'l' in tapered && 'c' in tapered ) {\n\t\t\t\tnewL = tapered.l;\n\t\t\t\tnewC = tapered.c;\n\t\t\t} else {\n\t\t\t\t// It's already a ColorObject, return it directly\n\t\t\t\treturn tapered;\n\t\t\t}\n\t\t}\n\n\t\treturn clampToGamut( {\n\t\t\tspaceId: 'oklch',\n\t\t\tcoords: [ newL, newC, get( seed, [ OKLCH, 'h' ] ) ],\n\t\t} );\n\t}\n\n\t// Set the boundary based on the direction.\n\tconst mostContrastingL = direction === 'lighter' ? 1 : 0;\n\tconst mostContrastingColor = direction === 'lighter' ? WHITE : BLACK;\n\tconst highestContrast = getContrast( reference, mostContrastingColor );\n\n\tif ( lightnessConstraint ) {\n\t\t// Apply a specific L value.\n\t\t// Useful when pinning a step to a specific lightness, of to specify\n\t\t// min/max L values.\n\t\tconst colorWithExactL = getColorForL( lightnessConstraint.value );\n\t\tconst exactLContrast = getContrast( reference, colorWithExactL );\n\t\tconst exactLContrastMeetsTarget =\n\t\t\tcdiff( exactLContrast, target ) >= -CONTRAST_EPSILON;\n\n\t\t// If the L constraint is of \"force\" type, apply it even when it doesn't\n\t\t// meet the contrast target.\n\t\tif (\n\t\t\texactLContrastMeetsTarget ||\n\t\t\tlightnessConstraint.type === 'force'\n\t\t) {\n\t\t\treturn {\n\t\t\t\tcolor: colorWithExactL,\n\t\t\t\treached: exactLContrastMeetsTarget,\n\t\t\t\tachieved: exactLContrast,\n\t\t\t\tdeficit: exactLContrastMeetsTarget\n\t\t\t\t\t? cdiff( exactLContrast, highestContrast )\n\t\t\t\t\t: cdiff( target, exactLContrast ),\n\t\t\t};\n\t\t}\n\t}\n\n\t// If even the most contrasting color can't reach the target, the target is unreachable.\n\t// On the other hand, if the contrast is very close to the target, we consider it reached.\n\tif ( cdiff( highestContrast, target ) <= CONTRAST_EPSILON ) {\n\t\treturn {\n\t\t\tcolor: mostContrastingColor,\n\t\t\treached: cdiff( highestContrast, target ) >= -CONTRAST_EPSILON,\n\t\t\tachieved: highestContrast,\n\t\t\tdeficit: cdiff( target, highestContrast ),\n\t\t};\n\t}\n\n\t// Bracket: low fails, high meets.\n\t// Originally this was seed.oklch.l \u2014 although it's an assumption that works\n\t// only when we know for sure the direction of the search.\n\t// TODO: can we bring this back to seed.oklch.l ?\n\tconst lowerL = get( reference, [ OKLCH, 'l' ] );\n\tconst lowerContrast = cdiff( 1, target );\n\tconst upperL = mostContrastingL;\n\tconst upperContrast = cdiff( highestContrast, target );\n\n\tconst bestColor = solveWithBisect(\n\t\tgetColorForL,\n\t\t( c: ColorTypes ) => cdiff( getContrast( reference, c ), target ),\n\t\tlowerL,\n\t\tlowerContrast,\n\t\tupperL,\n\t\tupperContrast\n\t);\n\n\treturn {\n\t\tcolor: bestColor,\n\t\treached: true,\n\t\tachieved: target,\n\t\t// Negative number that specifies how much room we have.\n\t\tdeficit: cdiff( target, highestContrast ),\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,KAAK,aAA8B;AAK5C,OAAO;AACP,SAAS,uBAAuB;AAChC,SAAS,OAAO,OAAO,wBAAwB;AAC/C,SAAS,cAAc,mBAAmB;AAC1C,SAAkC,mBAAmB;AASrD,SAAS,MAAO,IAAY,IAAa;AACxC,SAAO,KAAK,IAAK,KAAK,EAAG;AAC1B;AAkBO,SAAS,6BACf,WACA,MACA,QACA,WACA;AAAA,EACC;AAAA,EACA;AACD,IAMI,CAAC,GACyE;AAG9E,MAAK,UAAU,GAAI;AAClB,WAAO;AAAA,MACN,OAAO;AAAA,MACP,SAAS;AAAA,MACT,UAAU;AAAA,IACX;AA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AAS;AACf,QAAM,gBAAgB,MAAO,iBAAiB,MAAO;AAErD,QAAM,YAAY;AAAA,IACjB;AAAA,IACA,CAAE,MAAmB,MAAO,YAAa,WAAW,CAAE,GAAG,MAAO;AAAA,IAChE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,SAAO;AAAA,IACN,OAAO;AAAA,IACP,SAAS;AAAA,IACT,UAAU;AAAA;AAAA,IAEV,SAAS,MAAO,QAAQ,eAAgB;AAAA,EACzC;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -7,10 +7,9 @@ import {
|
|
|
7
7
|
set
|
|
8
8
|
} from "colorjs.io/fn";
|
|
9
9
|
import "./register-color-spaces";
|
|
10
|
-
import { getContrast, getColorString } from "./color-utils";
|
|
10
|
+
import { clampToGamut, getContrast, getColorString } from "./color-utils";
|
|
11
11
|
import { findColorMeetingRequirements } from "./find-color-with-constraints";
|
|
12
12
|
import {
|
|
13
|
-
clampToGamut,
|
|
14
13
|
sortByDependency,
|
|
15
14
|
computeBetterFgColorDirection,
|
|
16
15
|
adjustContrastTarget,
|
|
@@ -27,6 +26,7 @@ function calculateRamp({
|
|
|
27
26
|
pinLightness
|
|
28
27
|
}) {
|
|
29
28
|
const rampResults = {};
|
|
29
|
+
let warnings;
|
|
30
30
|
let maxDeficit = -Infinity;
|
|
31
31
|
let maxDeficitDirection = "lighter";
|
|
32
32
|
let maxDeficitStep;
|
|
@@ -74,10 +74,7 @@ function calculateRamp({
|
|
|
74
74
|
const adjustedTarget2 = adjustContrastTarget(contrast.target);
|
|
75
75
|
if (candidateContrast >= adjustedTarget2) {
|
|
76
76
|
calculatedColors.set(stepName, candidateColor);
|
|
77
|
-
rampResults[stepName] =
|
|
78
|
-
color: getColorString(candidateColor),
|
|
79
|
-
warning: false
|
|
80
|
-
};
|
|
77
|
+
rampResults[stepName] = getColorString(candidateColor);
|
|
81
78
|
continue;
|
|
82
79
|
}
|
|
83
80
|
}
|
|
@@ -114,13 +111,15 @@ function calculateRamp({
|
|
|
114
111
|
maxDeficitStep = stepName;
|
|
115
112
|
}
|
|
116
113
|
calculatedColors.set(stepName, searchResults.color);
|
|
117
|
-
rampResults[stepName] =
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
114
|
+
rampResults[stepName] = getColorString(searchResults.color);
|
|
115
|
+
if (!searchResults.reached && !contrast.ignoreWhenAdjustingSeed) {
|
|
116
|
+
warnings ??= [];
|
|
117
|
+
warnings.push(stepName);
|
|
118
|
+
}
|
|
121
119
|
}
|
|
122
120
|
return {
|
|
123
121
|
rampResults,
|
|
122
|
+
warnings,
|
|
124
123
|
maxDeficit,
|
|
125
124
|
maxDeficitDirection,
|
|
126
125
|
maxDeficitStep
|
|
@@ -150,7 +149,13 @@ function buildRamp(seedArg, config, {
|
|
|
150
149
|
oppDir = worse;
|
|
151
150
|
}
|
|
152
151
|
const sortedSteps = sortByDependency(config);
|
|
153
|
-
const {
|
|
152
|
+
const {
|
|
153
|
+
rampResults,
|
|
154
|
+
warnings,
|
|
155
|
+
maxDeficit,
|
|
156
|
+
maxDeficitDirection,
|
|
157
|
+
maxDeficitStep
|
|
158
|
+
} = calculateRamp({
|
|
154
159
|
seed,
|
|
155
160
|
sortedSteps,
|
|
156
161
|
config,
|
|
@@ -202,6 +207,7 @@ function buildRamp(seedArg, config, {
|
|
|
202
207
|
}
|
|
203
208
|
return {
|
|
204
209
|
ramp: bestRamp,
|
|
210
|
+
warnings,
|
|
205
211
|
direction: mainDir
|
|
206
212
|
};
|
|
207
213
|
}
|