@sanity/ui 2.9.0-corel.0 → 2.9.1
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/dist/_chunks-cjs/getTheme_v2.js +110 -54
- package/dist/_chunks-cjs/getTheme_v2.js.map +1 -1
- package/dist/_chunks-es/getTheme_v2.mjs +110 -54
- package/dist/_chunks-es/getTheme_v2.mjs.map +1 -1
- package/dist/_legacy/getTheme_v2.esm.js +110 -54
- package/dist/_legacy/getTheme_v2.esm.js.map +1 -1
- package/dist/index.d.mts +14 -21
- package/dist/index.d.ts +14 -21
- package/dist/index.esm.js +3327 -3068
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3328 -3070
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3327 -3068
- package/dist/index.mjs.map +1 -1
- package/dist/theme.d.mts +8 -8
- package/dist/theme.d.ts +8 -8
- package/dist/theme.esm.js +1144 -592
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +1144 -592
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +1144 -592
- package/dist/theme.mjs.map +1 -1
- package/package.json +60 -52
- package/src/core/__workshop__/constants.ts +15 -19
- package/src/core/components/breadcrumbs/__workshop__/example.tsx +1 -3
- package/src/core/components/breadcrumbs/__workshop__/index.ts +0 -5
- package/src/core/components/breadcrumbs/breadcrumbs.styles.ts +13 -1
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +31 -39
- package/src/core/components/dialog/dialog.tsx +4 -2
- package/src/core/components/menu/__workshop__/tones.tsx +5 -6
- package/src/core/components/menu/menu.tsx +15 -11
- package/src/core/components/menu/menuButton.tsx +14 -36
- package/src/core/components/menu/menuGroup.tsx +2 -1
- package/src/core/components/menu/menuItem.tsx +4 -2
- package/src/core/components/tab/tabList.tsx +3 -11
- package/src/core/components/toast/__workshop__/hook.tsx +1 -1
- package/src/core/components/toast/toast.tsx +2 -2
- package/src/core/components/toast/toastProvider.tsx +5 -6
- package/src/core/components/toast/toastState.ts +6 -0
- package/src/core/constants.ts +1 -1
- package/src/core/hooks/useArrayProp.ts +14 -9
- package/src/core/hooks/useElementRect/__workshop__/example.tsx +2 -2
- package/src/core/primitives/avatar/avatarStack.tsx +2 -5
- package/src/core/primitives/badge/__workshop__/tones.tsx +6 -13
- package/src/core/primitives/button/__workshop__/custom.tsx +4 -3
- package/src/core/primitives/button/__workshop__/props.tsx +1 -1
- package/src/core/primitives/button/button.tsx +6 -11
- package/src/core/primitives/button/styles.ts +1 -1
- package/src/core/primitives/card/__workshop__/allTones.tsx +6 -8
- package/src/core/primitives/card/__workshop__/asButton.tsx +42 -24
- package/src/core/primitives/card/__workshop__/asComponent.tsx +1 -1
- package/src/core/primitives/card/__workshop__/checkered.tsx +17 -7
- package/src/core/primitives/card/__workshop__/interactive.tsx +10 -3
- package/src/core/primitives/card/__workshop__/listNavigation.tsx +5 -3
- package/src/core/primitives/card/__workshop__/props.tsx +7 -5
- package/src/core/primitives/card/__workshop__/selected.tsx +4 -1
- package/src/core/primitives/checkbox/__workshop__/tones.tsx +6 -0
- package/src/core/primitives/code/__workshop__/props.tsx +1 -1
- package/src/core/primitives/container/__workshop__/example.tsx +1 -1
- package/src/core/primitives/flex/__workshop__/example.tsx +3 -3
- package/src/core/primitives/flex/flex.tsx +1 -5
- package/src/core/primitives/grid/__workshop__/responsive.tsx +12 -12
- package/src/core/primitives/heading/__workshop__/opticalAlignment.tsx +13 -25
- package/src/core/primitives/heading/heading.tsx +1 -1
- package/src/core/primitives/inline/__workshop__/plain.tsx +3 -3
- package/src/core/primitives/label/__workshop__/opticalAlignment.tsx +6 -6
- package/src/core/primitives/popover/__workshop__/AlignedStory.tsx +1 -1
- package/src/core/primitives/popover/__workshop__/MatchReferenceWidthStory.tsx +3 -3
- package/src/core/primitives/popover/__workshop__/OpenOnMountStory.tsx +1 -1
- package/src/core/primitives/popover/__workshop__/PlainStory.tsx +1 -1
- package/src/core/primitives/popover/popover.tsx +6 -5
- package/src/core/primitives/radio/__workshop__/plain.tsx +2 -2
- package/src/core/primitives/select/__workshop__/readOnly.tsx +1 -1
- package/src/core/primitives/text/__workshop__/example.tsx +6 -6
- package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +11 -21
- package/src/core/primitives/text/styles.ts +0 -1
- package/src/core/primitives/text/text.tsx +2 -4
- package/src/core/primitives/textArea/__workshop__/plain.tsx +1 -1
- package/src/core/primitives/textInput/__workshop__/index.ts +0 -5
- package/src/core/primitives/textInput/__workshop__/plain.tsx +1 -2
- package/src/core/primitives/textInput/__workshop__/readOnly.tsx +6 -2
- package/src/core/primitives/textInput/__workshop__/tones.tsx +38 -0
- package/src/core/styles/card/_cardColorStyle.ts +8 -8
- package/src/core/styles/flex/flexStyle.ts +0 -18
- package/src/core/styles/flex/types.ts +0 -2
- package/src/core/theme/__workshop__/debug/story.tsx +18 -11
- package/src/core/theme/themeProvider.tsx +4 -6
- package/src/core/utils/elementQuery/elementQuery.tsx +16 -17
- package/src/core/utils/layer/layerProvider.tsx +1 -1
- package/src/theme/build/_deprecated/color/muted/createMuted.ts +2 -2
- package/src/theme/build/buildColorTheme.ts +12 -8
- package/src/theme/build/renderColorTheme.ts +54 -232
- package/src/theme/defaults/colorTokens.ts +13 -18
- package/src/theme/system/color/_constants.ts +6 -10
- package/src/theme/versioning/themeColor_v0_v2.ts +26 -26
- package/src/theme/versioning/v0_v2.ts +4 -4
- package/src/core/components/breadcrumbs/__workshop__/buttons.tsx +0 -58
- package/src/core/primitives/textInput/__workshop__/multipleTones.tsx +0 -20
package/dist/theme.mjs
CHANGED
|
@@ -57,46 +57,226 @@ function _createSelectableStates(opts, base, dark, solid, muted, tone) {
|
|
|
57
57
|
function createSolidTones(opts, base, dark, name) {
|
|
58
58
|
return {
|
|
59
59
|
default: {
|
|
60
|
-
enabled: opts.solid({
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
enabled: opts.solid({
|
|
61
|
+
base,
|
|
62
|
+
dark,
|
|
63
|
+
tone: "default",
|
|
64
|
+
name,
|
|
65
|
+
state: "enabled"
|
|
66
|
+
}),
|
|
67
|
+
disabled: opts.solid({
|
|
68
|
+
base,
|
|
69
|
+
dark,
|
|
70
|
+
tone: "default",
|
|
71
|
+
name,
|
|
72
|
+
state: "disabled"
|
|
73
|
+
}),
|
|
74
|
+
hovered: opts.solid({
|
|
75
|
+
base,
|
|
76
|
+
dark,
|
|
77
|
+
tone: "default",
|
|
78
|
+
name,
|
|
79
|
+
state: "hovered"
|
|
80
|
+
}),
|
|
81
|
+
pressed: opts.solid({
|
|
82
|
+
base,
|
|
83
|
+
dark,
|
|
84
|
+
tone: "default",
|
|
85
|
+
name,
|
|
86
|
+
state: "pressed"
|
|
87
|
+
}),
|
|
88
|
+
selected: opts.solid({
|
|
89
|
+
base,
|
|
90
|
+
dark,
|
|
91
|
+
tone: "default",
|
|
92
|
+
name,
|
|
93
|
+
state: "selected"
|
|
94
|
+
})
|
|
65
95
|
},
|
|
66
96
|
transparent: {
|
|
67
|
-
enabled: opts.solid({
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
97
|
+
enabled: opts.solid({
|
|
98
|
+
base,
|
|
99
|
+
dark,
|
|
100
|
+
tone: "transparent",
|
|
101
|
+
name,
|
|
102
|
+
state: "enabled"
|
|
103
|
+
}),
|
|
104
|
+
disabled: opts.solid({
|
|
105
|
+
base,
|
|
106
|
+
dark,
|
|
107
|
+
tone: "transparent",
|
|
108
|
+
name,
|
|
109
|
+
state: "disabled"
|
|
110
|
+
}),
|
|
111
|
+
hovered: opts.solid({
|
|
112
|
+
base,
|
|
113
|
+
dark,
|
|
114
|
+
tone: "transparent",
|
|
115
|
+
name,
|
|
116
|
+
state: "hovered"
|
|
117
|
+
}),
|
|
118
|
+
pressed: opts.solid({
|
|
119
|
+
base,
|
|
120
|
+
dark,
|
|
121
|
+
tone: "transparent",
|
|
122
|
+
name,
|
|
123
|
+
state: "pressed"
|
|
124
|
+
}),
|
|
125
|
+
selected: opts.solid({
|
|
126
|
+
base,
|
|
127
|
+
dark,
|
|
128
|
+
tone: "transparent",
|
|
129
|
+
name,
|
|
130
|
+
state: "selected"
|
|
131
|
+
})
|
|
72
132
|
},
|
|
73
133
|
primary: {
|
|
74
|
-
enabled: opts.solid({
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
134
|
+
enabled: opts.solid({
|
|
135
|
+
base,
|
|
136
|
+
dark,
|
|
137
|
+
tone: "primary",
|
|
138
|
+
name,
|
|
139
|
+
state: "enabled"
|
|
140
|
+
}),
|
|
141
|
+
disabled: opts.solid({
|
|
142
|
+
base,
|
|
143
|
+
dark,
|
|
144
|
+
tone: "primary",
|
|
145
|
+
name,
|
|
146
|
+
state: "disabled"
|
|
147
|
+
}),
|
|
148
|
+
hovered: opts.solid({
|
|
149
|
+
base,
|
|
150
|
+
dark,
|
|
151
|
+
tone: "primary",
|
|
152
|
+
name,
|
|
153
|
+
state: "hovered"
|
|
154
|
+
}),
|
|
155
|
+
pressed: opts.solid({
|
|
156
|
+
base,
|
|
157
|
+
dark,
|
|
158
|
+
tone: "primary",
|
|
159
|
+
name,
|
|
160
|
+
state: "pressed"
|
|
161
|
+
}),
|
|
162
|
+
selected: opts.solid({
|
|
163
|
+
base,
|
|
164
|
+
dark,
|
|
165
|
+
tone: "primary",
|
|
166
|
+
name,
|
|
167
|
+
state: "selected"
|
|
168
|
+
})
|
|
79
169
|
},
|
|
80
170
|
positive: {
|
|
81
|
-
enabled: opts.solid({
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
171
|
+
enabled: opts.solid({
|
|
172
|
+
base,
|
|
173
|
+
dark,
|
|
174
|
+
tone: "positive",
|
|
175
|
+
name,
|
|
176
|
+
state: "enabled"
|
|
177
|
+
}),
|
|
178
|
+
disabled: opts.solid({
|
|
179
|
+
base,
|
|
180
|
+
dark,
|
|
181
|
+
tone: "positive",
|
|
182
|
+
name,
|
|
183
|
+
state: "disabled"
|
|
184
|
+
}),
|
|
185
|
+
hovered: opts.solid({
|
|
186
|
+
base,
|
|
187
|
+
dark,
|
|
188
|
+
tone: "positive",
|
|
189
|
+
name,
|
|
190
|
+
state: "hovered"
|
|
191
|
+
}),
|
|
192
|
+
pressed: opts.solid({
|
|
193
|
+
base,
|
|
194
|
+
dark,
|
|
195
|
+
tone: "positive",
|
|
196
|
+
name,
|
|
197
|
+
state: "pressed"
|
|
198
|
+
}),
|
|
199
|
+
selected: opts.solid({
|
|
200
|
+
base,
|
|
201
|
+
dark,
|
|
202
|
+
tone: "positive",
|
|
203
|
+
name,
|
|
204
|
+
state: "selected"
|
|
205
|
+
})
|
|
86
206
|
},
|
|
87
207
|
caution: {
|
|
88
|
-
enabled: opts.solid({
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
208
|
+
enabled: opts.solid({
|
|
209
|
+
base,
|
|
210
|
+
dark,
|
|
211
|
+
tone: "caution",
|
|
212
|
+
name,
|
|
213
|
+
state: "enabled"
|
|
214
|
+
}),
|
|
215
|
+
disabled: opts.solid({
|
|
216
|
+
base,
|
|
217
|
+
dark,
|
|
218
|
+
tone: "caution",
|
|
219
|
+
name,
|
|
220
|
+
state: "disabled"
|
|
221
|
+
}),
|
|
222
|
+
hovered: opts.solid({
|
|
223
|
+
base,
|
|
224
|
+
dark,
|
|
225
|
+
tone: "caution",
|
|
226
|
+
name,
|
|
227
|
+
state: "hovered"
|
|
228
|
+
}),
|
|
229
|
+
pressed: opts.solid({
|
|
230
|
+
base,
|
|
231
|
+
dark,
|
|
232
|
+
tone: "caution",
|
|
233
|
+
name,
|
|
234
|
+
state: "pressed"
|
|
235
|
+
}),
|
|
236
|
+
selected: opts.solid({
|
|
237
|
+
base,
|
|
238
|
+
dark,
|
|
239
|
+
tone: "caution",
|
|
240
|
+
name,
|
|
241
|
+
state: "selected"
|
|
242
|
+
})
|
|
93
243
|
},
|
|
94
244
|
critical: {
|
|
95
|
-
enabled: opts.solid({
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
245
|
+
enabled: opts.solid({
|
|
246
|
+
base,
|
|
247
|
+
dark,
|
|
248
|
+
tone: "critical",
|
|
249
|
+
name,
|
|
250
|
+
state: "enabled"
|
|
251
|
+
}),
|
|
252
|
+
disabled: opts.solid({
|
|
253
|
+
base,
|
|
254
|
+
dark,
|
|
255
|
+
tone: "critical",
|
|
256
|
+
name,
|
|
257
|
+
state: "disabled"
|
|
258
|
+
}),
|
|
259
|
+
hovered: opts.solid({
|
|
260
|
+
base,
|
|
261
|
+
dark,
|
|
262
|
+
tone: "critical",
|
|
263
|
+
name,
|
|
264
|
+
state: "hovered"
|
|
265
|
+
}),
|
|
266
|
+
pressed: opts.solid({
|
|
267
|
+
base,
|
|
268
|
+
dark,
|
|
269
|
+
tone: "critical",
|
|
270
|
+
name,
|
|
271
|
+
state: "pressed"
|
|
272
|
+
}),
|
|
273
|
+
selected: opts.solid({
|
|
274
|
+
base,
|
|
275
|
+
dark,
|
|
276
|
+
tone: "critical",
|
|
277
|
+
name,
|
|
278
|
+
state: "selected"
|
|
279
|
+
})
|
|
100
280
|
}
|
|
101
281
|
};
|
|
102
282
|
}
|
|
@@ -287,7 +467,10 @@ const black = "hsl(0, 0%, 0%)", white = "hsl(0, 0%, 100%)", colors = {
|
|
|
287
467
|
focusRing: [colors.critical.base, colors.critical.base]
|
|
288
468
|
}
|
|
289
469
|
}, defaultOpts = {
|
|
290
|
-
base: ({
|
|
470
|
+
base: ({
|
|
471
|
+
dark,
|
|
472
|
+
name
|
|
473
|
+
}) => name === "default" ? {
|
|
291
474
|
bg: dark ? black : white,
|
|
292
475
|
fg: dark ? white : black,
|
|
293
476
|
border: dark ? colors.default.darkest : colors.default.lightest,
|
|
@@ -318,7 +501,12 @@ const black = "hsl(0, 0%, 0%)", white = "hsl(0, 0%, 100%)", colors = {
|
|
|
318
501
|
to: dark ? white : black
|
|
319
502
|
}
|
|
320
503
|
},
|
|
321
|
-
solid: ({
|
|
504
|
+
solid: ({
|
|
505
|
+
base,
|
|
506
|
+
dark,
|
|
507
|
+
state,
|
|
508
|
+
tone
|
|
509
|
+
}) => {
|
|
322
510
|
const color2 = colors[tone];
|
|
323
511
|
return state === "hovered" ? {
|
|
324
512
|
bg: dark ? color2.light : color2.dark,
|
|
@@ -362,7 +550,12 @@ const black = "hsl(0, 0%, 0%)", white = "hsl(0, 0%, 100%)", colors = {
|
|
|
362
550
|
skeleton: base.skeleton
|
|
363
551
|
};
|
|
364
552
|
},
|
|
365
|
-
muted: ({
|
|
553
|
+
muted: ({
|
|
554
|
+
base,
|
|
555
|
+
dark,
|
|
556
|
+
state,
|
|
557
|
+
tone
|
|
558
|
+
}) => {
|
|
366
559
|
const color2 = colors[tone];
|
|
367
560
|
return state === "hovered" ? {
|
|
368
561
|
bg: dark ? color2.darker : color2.lighter,
|
|
@@ -406,7 +599,12 @@ const black = "hsl(0, 0%, 0%)", white = "hsl(0, 0%, 100%)", colors = {
|
|
|
406
599
|
skeleton: base.skeleton
|
|
407
600
|
};
|
|
408
601
|
},
|
|
409
|
-
button: ({
|
|
602
|
+
button: ({
|
|
603
|
+
base,
|
|
604
|
+
mode,
|
|
605
|
+
muted,
|
|
606
|
+
solid
|
|
607
|
+
}) => mode === "bleed" ? {
|
|
410
608
|
...muted,
|
|
411
609
|
enabled: {
|
|
412
610
|
bg: "transparent",
|
|
@@ -454,7 +652,9 @@ const black = "hsl(0, 0%, 0%)", white = "hsl(0, 0%, 100%)", colors = {
|
|
|
454
652
|
...solid,
|
|
455
653
|
enabled: muted.enabled
|
|
456
654
|
} : solid,
|
|
457
|
-
card: ({
|
|
655
|
+
card: ({
|
|
656
|
+
base
|
|
657
|
+
}) => ({
|
|
458
658
|
bg: black,
|
|
459
659
|
bg2: black,
|
|
460
660
|
fg: black,
|
|
@@ -482,8 +682,14 @@ const black = "hsl(0, 0%, 0%)", white = "hsl(0, 0%, 100%)", colors = {
|
|
|
482
682
|
border: black,
|
|
483
683
|
placeholder: black
|
|
484
684
|
}),
|
|
485
|
-
selectable: ({
|
|
486
|
-
|
|
685
|
+
selectable: ({
|
|
686
|
+
muted,
|
|
687
|
+
state,
|
|
688
|
+
tone
|
|
689
|
+
}) => muted[tone][state],
|
|
690
|
+
spot: ({
|
|
691
|
+
key
|
|
692
|
+
}) => spots[key],
|
|
487
693
|
syntax: () => ({
|
|
488
694
|
atrule: black,
|
|
489
695
|
attrName: black,
|
|
@@ -598,64 +804,283 @@ function createInputModes(opts, base, dark, solid, muted) {
|
|
|
598
804
|
function createMutedTones(opts, base, dark, name) {
|
|
599
805
|
return {
|
|
600
806
|
default: {
|
|
601
|
-
enabled: opts.muted({
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
807
|
+
enabled: opts.muted({
|
|
808
|
+
base,
|
|
809
|
+
dark,
|
|
810
|
+
tone: "default",
|
|
811
|
+
name,
|
|
812
|
+
state: "enabled"
|
|
813
|
+
}),
|
|
814
|
+
disabled: opts.muted({
|
|
815
|
+
base,
|
|
816
|
+
dark,
|
|
817
|
+
tone: "default",
|
|
818
|
+
name,
|
|
819
|
+
state: "disabled"
|
|
820
|
+
}),
|
|
821
|
+
hovered: opts.muted({
|
|
822
|
+
base,
|
|
823
|
+
dark,
|
|
824
|
+
tone: "default",
|
|
825
|
+
name,
|
|
826
|
+
state: "hovered"
|
|
827
|
+
}),
|
|
828
|
+
pressed: opts.muted({
|
|
829
|
+
base,
|
|
830
|
+
dark,
|
|
831
|
+
tone: "default",
|
|
832
|
+
name,
|
|
833
|
+
state: "pressed"
|
|
834
|
+
}),
|
|
835
|
+
selected: opts.muted({
|
|
836
|
+
base,
|
|
837
|
+
dark,
|
|
838
|
+
tone: "default",
|
|
839
|
+
name,
|
|
840
|
+
state: "selected"
|
|
841
|
+
})
|
|
606
842
|
},
|
|
607
843
|
transparent: {
|
|
608
|
-
enabled: opts.muted({
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
844
|
+
enabled: opts.muted({
|
|
845
|
+
base,
|
|
846
|
+
dark,
|
|
847
|
+
tone: "transparent",
|
|
848
|
+
name,
|
|
849
|
+
state: "enabled"
|
|
850
|
+
}),
|
|
851
|
+
disabled: opts.muted({
|
|
852
|
+
base,
|
|
853
|
+
dark,
|
|
854
|
+
tone: "transparent",
|
|
855
|
+
name,
|
|
856
|
+
state: "disabled"
|
|
857
|
+
}),
|
|
858
|
+
hovered: opts.muted({
|
|
859
|
+
base,
|
|
860
|
+
dark,
|
|
861
|
+
tone: "transparent",
|
|
862
|
+
name,
|
|
863
|
+
state: "hovered"
|
|
864
|
+
}),
|
|
865
|
+
pressed: opts.muted({
|
|
866
|
+
base,
|
|
867
|
+
dark,
|
|
868
|
+
tone: "transparent",
|
|
869
|
+
name,
|
|
870
|
+
state: "pressed"
|
|
871
|
+
}),
|
|
872
|
+
selected: opts.muted({
|
|
873
|
+
base,
|
|
874
|
+
dark,
|
|
875
|
+
tone: "transparent",
|
|
876
|
+
name,
|
|
877
|
+
state: "selected"
|
|
878
|
+
})
|
|
613
879
|
},
|
|
614
880
|
primary: {
|
|
615
|
-
enabled: opts.muted({
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
881
|
+
enabled: opts.muted({
|
|
882
|
+
base,
|
|
883
|
+
dark,
|
|
884
|
+
tone: "primary",
|
|
885
|
+
name,
|
|
886
|
+
state: "enabled"
|
|
887
|
+
}),
|
|
888
|
+
disabled: opts.muted({
|
|
889
|
+
base,
|
|
890
|
+
dark,
|
|
891
|
+
tone: "primary",
|
|
892
|
+
name,
|
|
893
|
+
state: "disabled"
|
|
894
|
+
}),
|
|
895
|
+
hovered: opts.muted({
|
|
896
|
+
base,
|
|
897
|
+
dark,
|
|
898
|
+
tone: "primary",
|
|
899
|
+
name,
|
|
900
|
+
state: "hovered"
|
|
901
|
+
}),
|
|
902
|
+
pressed: opts.muted({
|
|
903
|
+
base,
|
|
904
|
+
dark,
|
|
905
|
+
tone: "primary",
|
|
906
|
+
name,
|
|
907
|
+
state: "pressed"
|
|
908
|
+
}),
|
|
909
|
+
selected: opts.muted({
|
|
910
|
+
base,
|
|
911
|
+
dark,
|
|
912
|
+
tone: "primary",
|
|
913
|
+
name,
|
|
914
|
+
state: "selected"
|
|
915
|
+
})
|
|
620
916
|
},
|
|
621
917
|
positive: {
|
|
622
|
-
enabled: opts.muted({
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
918
|
+
enabled: opts.muted({
|
|
919
|
+
base,
|
|
920
|
+
dark,
|
|
921
|
+
tone: "positive",
|
|
922
|
+
name,
|
|
923
|
+
state: "enabled"
|
|
924
|
+
}),
|
|
925
|
+
disabled: opts.muted({
|
|
926
|
+
base,
|
|
927
|
+
dark,
|
|
928
|
+
tone: "positive",
|
|
929
|
+
name,
|
|
930
|
+
state: "disabled"
|
|
931
|
+
}),
|
|
932
|
+
hovered: opts.muted({
|
|
933
|
+
base,
|
|
934
|
+
dark,
|
|
935
|
+
tone: "positive",
|
|
936
|
+
name,
|
|
937
|
+
state: "hovered"
|
|
938
|
+
}),
|
|
939
|
+
pressed: opts.muted({
|
|
940
|
+
base,
|
|
941
|
+
dark,
|
|
942
|
+
tone: "positive",
|
|
943
|
+
name,
|
|
944
|
+
state: "pressed"
|
|
945
|
+
}),
|
|
946
|
+
selected: opts.muted({
|
|
947
|
+
base,
|
|
948
|
+
dark,
|
|
949
|
+
tone: "positive",
|
|
950
|
+
name,
|
|
951
|
+
state: "selected"
|
|
952
|
+
})
|
|
627
953
|
},
|
|
628
954
|
caution: {
|
|
629
|
-
enabled: opts.muted({
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
955
|
+
enabled: opts.muted({
|
|
956
|
+
base,
|
|
957
|
+
dark,
|
|
958
|
+
tone: "caution",
|
|
959
|
+
name,
|
|
960
|
+
state: "enabled"
|
|
961
|
+
}),
|
|
962
|
+
disabled: opts.muted({
|
|
963
|
+
base,
|
|
964
|
+
dark,
|
|
965
|
+
tone: "caution",
|
|
966
|
+
name,
|
|
967
|
+
state: "disabled"
|
|
968
|
+
}),
|
|
969
|
+
hovered: opts.muted({
|
|
970
|
+
base,
|
|
971
|
+
dark,
|
|
972
|
+
tone: "caution",
|
|
973
|
+
name,
|
|
974
|
+
state: "hovered"
|
|
975
|
+
}),
|
|
976
|
+
pressed: opts.muted({
|
|
977
|
+
base,
|
|
978
|
+
dark,
|
|
979
|
+
tone: "caution",
|
|
980
|
+
name,
|
|
981
|
+
state: "pressed"
|
|
982
|
+
}),
|
|
983
|
+
selected: opts.muted({
|
|
984
|
+
base,
|
|
985
|
+
dark,
|
|
986
|
+
tone: "caution",
|
|
987
|
+
name,
|
|
988
|
+
state: "selected"
|
|
989
|
+
})
|
|
634
990
|
},
|
|
635
991
|
critical: {
|
|
636
|
-
enabled: opts.muted({
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
992
|
+
enabled: opts.muted({
|
|
993
|
+
base,
|
|
994
|
+
dark,
|
|
995
|
+
tone: "critical",
|
|
996
|
+
name,
|
|
997
|
+
state: "enabled"
|
|
998
|
+
}),
|
|
999
|
+
disabled: opts.muted({
|
|
1000
|
+
base,
|
|
1001
|
+
dark,
|
|
1002
|
+
tone: "critical",
|
|
1003
|
+
name,
|
|
1004
|
+
state: "disabled"
|
|
1005
|
+
}),
|
|
1006
|
+
hovered: opts.muted({
|
|
1007
|
+
base,
|
|
1008
|
+
dark,
|
|
1009
|
+
tone: "critical",
|
|
1010
|
+
name,
|
|
1011
|
+
state: "hovered"
|
|
1012
|
+
}),
|
|
1013
|
+
pressed: opts.muted({
|
|
1014
|
+
base,
|
|
1015
|
+
dark,
|
|
1016
|
+
tone: "critical",
|
|
1017
|
+
name,
|
|
1018
|
+
state: "pressed"
|
|
1019
|
+
}),
|
|
1020
|
+
selected: opts.muted({
|
|
1021
|
+
base,
|
|
1022
|
+
dark,
|
|
1023
|
+
tone: "critical",
|
|
1024
|
+
name,
|
|
1025
|
+
state: "selected"
|
|
1026
|
+
})
|
|
641
1027
|
}
|
|
642
1028
|
};
|
|
643
1029
|
}
|
|
644
1030
|
function createSpot(opts, base, dark) {
|
|
645
1031
|
return {
|
|
646
|
-
gray: opts.spot({
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
1032
|
+
gray: opts.spot({
|
|
1033
|
+
base,
|
|
1034
|
+
dark,
|
|
1035
|
+
key: "gray"
|
|
1036
|
+
}),
|
|
1037
|
+
blue: opts.spot({
|
|
1038
|
+
base,
|
|
1039
|
+
dark,
|
|
1040
|
+
key: "blue"
|
|
1041
|
+
}),
|
|
1042
|
+
purple: opts.spot({
|
|
1043
|
+
base,
|
|
1044
|
+
dark,
|
|
1045
|
+
key: "purple"
|
|
1046
|
+
}),
|
|
1047
|
+
magenta: opts.spot({
|
|
1048
|
+
base,
|
|
1049
|
+
dark,
|
|
1050
|
+
key: "magenta"
|
|
1051
|
+
}),
|
|
1052
|
+
red: opts.spot({
|
|
1053
|
+
base,
|
|
1054
|
+
dark,
|
|
1055
|
+
key: "red"
|
|
1056
|
+
}),
|
|
1057
|
+
orange: opts.spot({
|
|
1058
|
+
base,
|
|
1059
|
+
dark,
|
|
1060
|
+
key: "orange"
|
|
1061
|
+
}),
|
|
1062
|
+
yellow: opts.spot({
|
|
1063
|
+
base,
|
|
1064
|
+
dark,
|
|
1065
|
+
key: "yellow"
|
|
1066
|
+
}),
|
|
1067
|
+
green: opts.spot({
|
|
1068
|
+
base,
|
|
1069
|
+
dark,
|
|
1070
|
+
key: "green"
|
|
1071
|
+
}),
|
|
1072
|
+
cyan: opts.spot({
|
|
1073
|
+
base,
|
|
1074
|
+
dark,
|
|
1075
|
+
key: "cyan"
|
|
1076
|
+
})
|
|
655
1077
|
};
|
|
656
1078
|
}
|
|
657
1079
|
function createColorTheme(partialOpts = {}) {
|
|
658
|
-
const builders = {
|
|
1080
|
+
const builders = {
|
|
1081
|
+
...defaultOpts,
|
|
1082
|
+
...partialOpts
|
|
1083
|
+
};
|
|
659
1084
|
return {
|
|
660
1085
|
light: _createColorScheme(builders, !1),
|
|
661
1086
|
dark: _createColorScheme(builders, !0)
|
|
@@ -672,7 +1097,10 @@ function _createColorScheme(opts, dark) {
|
|
|
672
1097
|
};
|
|
673
1098
|
}
|
|
674
1099
|
function _createColor(opts, dark, name) {
|
|
675
|
-
const base = opts.base({
|
|
1100
|
+
const base = opts.base({
|
|
1101
|
+
dark,
|
|
1102
|
+
name
|
|
1103
|
+
}), solid = createSolidTones(opts, base, dark, name), muted = createMutedTones(opts, base, dark, name);
|
|
676
1104
|
return {
|
|
677
1105
|
base,
|
|
678
1106
|
button: createButtonModes(opts, base, dark, solid, muted),
|
|
@@ -681,7 +1109,10 @@ function _createColor(opts, dark, name) {
|
|
|
681
1109
|
input: createInputModes(opts, base, dark, solid, muted),
|
|
682
1110
|
selectable: createSelectableTones(opts, base, dark, solid, muted),
|
|
683
1111
|
spot: createSpot(opts, base, dark),
|
|
684
|
-
syntax: opts.syntax({
|
|
1112
|
+
syntax: opts.syntax({
|
|
1113
|
+
base,
|
|
1114
|
+
dark
|
|
1115
|
+
}),
|
|
685
1116
|
solid,
|
|
686
1117
|
muted
|
|
687
1118
|
};
|
|
@@ -695,48 +1126,42 @@ const defaultThemeFonts = {
|
|
|
695
1126
|
semibold: 600,
|
|
696
1127
|
bold: 700
|
|
697
1128
|
},
|
|
698
|
-
sizes: [
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
fontSize: 22,
|
|
735
|
-
iconSize: 33,
|
|
736
|
-
lineHeight: 31,
|
|
737
|
-
letterSpacing: 0
|
|
738
|
-
}
|
|
739
|
-
]
|
|
1129
|
+
sizes: [{
|
|
1130
|
+
ascenderHeight: 4,
|
|
1131
|
+
descenderHeight: 4,
|
|
1132
|
+
fontSize: 10,
|
|
1133
|
+
iconSize: 17,
|
|
1134
|
+
lineHeight: 15,
|
|
1135
|
+
letterSpacing: 0
|
|
1136
|
+
}, {
|
|
1137
|
+
ascenderHeight: 5,
|
|
1138
|
+
descenderHeight: 5,
|
|
1139
|
+
fontSize: 13,
|
|
1140
|
+
iconSize: 21,
|
|
1141
|
+
lineHeight: 19,
|
|
1142
|
+
letterSpacing: 0
|
|
1143
|
+
}, {
|
|
1144
|
+
ascenderHeight: 6,
|
|
1145
|
+
descenderHeight: 6,
|
|
1146
|
+
fontSize: 16,
|
|
1147
|
+
iconSize: 25,
|
|
1148
|
+
lineHeight: 23,
|
|
1149
|
+
letterSpacing: 0
|
|
1150
|
+
}, {
|
|
1151
|
+
ascenderHeight: 7,
|
|
1152
|
+
descenderHeight: 7,
|
|
1153
|
+
fontSize: 19,
|
|
1154
|
+
iconSize: 29,
|
|
1155
|
+
lineHeight: 27,
|
|
1156
|
+
letterSpacing: 0
|
|
1157
|
+
}, {
|
|
1158
|
+
ascenderHeight: 8,
|
|
1159
|
+
descenderHeight: 8,
|
|
1160
|
+
fontSize: 22,
|
|
1161
|
+
iconSize: 33,
|
|
1162
|
+
lineHeight: 31,
|
|
1163
|
+
letterSpacing: 0
|
|
1164
|
+
}]
|
|
740
1165
|
},
|
|
741
1166
|
heading: {
|
|
742
1167
|
family: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Helvetica, Arial, system-ui, sans-serif',
|
|
@@ -746,56 +1171,49 @@ const defaultThemeFonts = {
|
|
|
746
1171
|
semibold: 900,
|
|
747
1172
|
bold: 900
|
|
748
1173
|
},
|
|
749
|
-
sizes: [
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
descenderHeight: 9.5,
|
|
793
|
-
fontSize: 38,
|
|
794
|
-
iconSize: 53,
|
|
795
|
-
lineHeight: 47,
|
|
796
|
-
letterSpacing: 0
|
|
797
|
-
}
|
|
798
|
-
]
|
|
1174
|
+
sizes: [{
|
|
1175
|
+
ascenderHeight: 5,
|
|
1176
|
+
descenderHeight: 5,
|
|
1177
|
+
fontSize: 13,
|
|
1178
|
+
iconSize: 17,
|
|
1179
|
+
lineHeight: 19,
|
|
1180
|
+
letterSpacing: 0
|
|
1181
|
+
}, {
|
|
1182
|
+
ascenderHeight: 6,
|
|
1183
|
+
descenderHeight: 6,
|
|
1184
|
+
fontSize: 16,
|
|
1185
|
+
iconSize: 25,
|
|
1186
|
+
lineHeight: 23,
|
|
1187
|
+
letterSpacing: 0
|
|
1188
|
+
}, {
|
|
1189
|
+
ascenderHeight: 7,
|
|
1190
|
+
descenderHeight: 7,
|
|
1191
|
+
fontSize: 21,
|
|
1192
|
+
iconSize: 33,
|
|
1193
|
+
lineHeight: 29,
|
|
1194
|
+
letterSpacing: 0
|
|
1195
|
+
}, {
|
|
1196
|
+
ascenderHeight: 8,
|
|
1197
|
+
descenderHeight: 8,
|
|
1198
|
+
fontSize: 27,
|
|
1199
|
+
iconSize: 41,
|
|
1200
|
+
lineHeight: 35,
|
|
1201
|
+
letterSpacing: 0
|
|
1202
|
+
}, {
|
|
1203
|
+
ascenderHeight: 9.5,
|
|
1204
|
+
descenderHeight: 8.5,
|
|
1205
|
+
fontSize: 33,
|
|
1206
|
+
iconSize: 49,
|
|
1207
|
+
lineHeight: 41,
|
|
1208
|
+
letterSpacing: 0
|
|
1209
|
+
}, {
|
|
1210
|
+
ascenderHeight: 10.5,
|
|
1211
|
+
descenderHeight: 9.5,
|
|
1212
|
+
fontSize: 38,
|
|
1213
|
+
iconSize: 53,
|
|
1214
|
+
lineHeight: 47,
|
|
1215
|
+
letterSpacing: 0
|
|
1216
|
+
}]
|
|
799
1217
|
},
|
|
800
1218
|
label: {
|
|
801
1219
|
family: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", system-ui, sans-serif',
|
|
@@ -805,56 +1223,49 @@ const defaultThemeFonts = {
|
|
|
805
1223
|
semibold: 800,
|
|
806
1224
|
bold: 900
|
|
807
1225
|
},
|
|
808
|
-
sizes: [
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
descenderHeight: 2,
|
|
852
|
-
fontSize: 15,
|
|
853
|
-
iconSize: 23,
|
|
854
|
-
lineHeight: 15,
|
|
855
|
-
letterSpacing: 0.5
|
|
856
|
-
}
|
|
857
|
-
]
|
|
1226
|
+
sizes: [{
|
|
1227
|
+
ascenderHeight: 2,
|
|
1228
|
+
descenderHeight: 2,
|
|
1229
|
+
fontSize: 8.1,
|
|
1230
|
+
iconSize: 13,
|
|
1231
|
+
lineHeight: 10,
|
|
1232
|
+
letterSpacing: 0.5
|
|
1233
|
+
}, {
|
|
1234
|
+
ascenderHeight: 2,
|
|
1235
|
+
descenderHeight: 2,
|
|
1236
|
+
fontSize: 9.5,
|
|
1237
|
+
iconSize: 15,
|
|
1238
|
+
lineHeight: 11,
|
|
1239
|
+
letterSpacing: 0.5
|
|
1240
|
+
}, {
|
|
1241
|
+
ascenderHeight: 2,
|
|
1242
|
+
descenderHeight: 2,
|
|
1243
|
+
fontSize: 10.8,
|
|
1244
|
+
iconSize: 17,
|
|
1245
|
+
lineHeight: 12,
|
|
1246
|
+
letterSpacing: 0.5
|
|
1247
|
+
}, {
|
|
1248
|
+
ascenderHeight: 2,
|
|
1249
|
+
descenderHeight: 2,
|
|
1250
|
+
fontSize: 12.25,
|
|
1251
|
+
iconSize: 19,
|
|
1252
|
+
lineHeight: 13,
|
|
1253
|
+
letterSpacing: 0.5
|
|
1254
|
+
}, {
|
|
1255
|
+
ascenderHeight: 2,
|
|
1256
|
+
descenderHeight: 2,
|
|
1257
|
+
fontSize: 13.6,
|
|
1258
|
+
iconSize: 21,
|
|
1259
|
+
lineHeight: 14,
|
|
1260
|
+
letterSpacing: 0.5
|
|
1261
|
+
}, {
|
|
1262
|
+
ascenderHeight: 2,
|
|
1263
|
+
descenderHeight: 2,
|
|
1264
|
+
fontSize: 15,
|
|
1265
|
+
iconSize: 23,
|
|
1266
|
+
lineHeight: 15,
|
|
1267
|
+
letterSpacing: 0.5
|
|
1268
|
+
}]
|
|
858
1269
|
},
|
|
859
1270
|
text: {
|
|
860
1271
|
family: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Helvetica, Arial, system-ui, sans-serif',
|
|
@@ -864,48 +1275,42 @@ const defaultThemeFonts = {
|
|
|
864
1275
|
semibold: 600,
|
|
865
1276
|
bold: 700
|
|
866
1277
|
},
|
|
867
|
-
sizes: [
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
fontSize: 21,
|
|
904
|
-
iconSize: 33,
|
|
905
|
-
lineHeight: 31,
|
|
906
|
-
letterSpacing: 0
|
|
907
|
-
}
|
|
908
|
-
]
|
|
1278
|
+
sizes: [{
|
|
1279
|
+
ascenderHeight: 4,
|
|
1280
|
+
descenderHeight: 4,
|
|
1281
|
+
fontSize: 10,
|
|
1282
|
+
iconSize: 17,
|
|
1283
|
+
lineHeight: 15,
|
|
1284
|
+
letterSpacing: 0
|
|
1285
|
+
}, {
|
|
1286
|
+
ascenderHeight: 5,
|
|
1287
|
+
descenderHeight: 5,
|
|
1288
|
+
fontSize: 13,
|
|
1289
|
+
iconSize: 21,
|
|
1290
|
+
lineHeight: 19,
|
|
1291
|
+
letterSpacing: 0
|
|
1292
|
+
}, {
|
|
1293
|
+
ascenderHeight: 6,
|
|
1294
|
+
descenderHeight: 6,
|
|
1295
|
+
fontSize: 15,
|
|
1296
|
+
iconSize: 25,
|
|
1297
|
+
lineHeight: 23,
|
|
1298
|
+
letterSpacing: 0
|
|
1299
|
+
}, {
|
|
1300
|
+
ascenderHeight: 7,
|
|
1301
|
+
descenderHeight: 7,
|
|
1302
|
+
fontSize: 18,
|
|
1303
|
+
iconSize: 29,
|
|
1304
|
+
lineHeight: 27,
|
|
1305
|
+
letterSpacing: 0
|
|
1306
|
+
}, {
|
|
1307
|
+
ascenderHeight: 8,
|
|
1308
|
+
descenderHeight: 8,
|
|
1309
|
+
fontSize: 21,
|
|
1310
|
+
iconSize: 33,
|
|
1311
|
+
lineHeight: 31,
|
|
1312
|
+
letterSpacing: 0
|
|
1313
|
+
}]
|
|
909
1314
|
}
|
|
910
1315
|
};
|
|
911
1316
|
function is_v0(themeProp) {
|
|
@@ -949,22 +1354,22 @@ function v0_v2(v0) {
|
|
|
949
1354
|
light: {
|
|
950
1355
|
transparent: themeColor_v0_v2(color2.light.transparent),
|
|
951
1356
|
default: themeColor_v0_v2(color2.light.default),
|
|
1357
|
+
neutral: themeColor_v0_v2(color2.light.transparent),
|
|
952
1358
|
primary: themeColor_v0_v2(color2.light.primary),
|
|
1359
|
+
suggest: themeColor_v0_v2(color2.light.primary),
|
|
953
1360
|
positive: themeColor_v0_v2(color2.light.positive),
|
|
954
1361
|
caution: themeColor_v0_v2(color2.light.caution),
|
|
955
|
-
critical: themeColor_v0_v2(color2.light.critical)
|
|
956
|
-
prospect: themeColor_v0_v2(color2.light.default),
|
|
957
|
-
explore: themeColor_v0_v2(color2.light.default)
|
|
1362
|
+
critical: themeColor_v0_v2(color2.light.critical)
|
|
958
1363
|
},
|
|
959
1364
|
dark: {
|
|
960
1365
|
transparent: themeColor_v0_v2(color2.dark.transparent),
|
|
961
1366
|
default: themeColor_v0_v2(color2.dark.default),
|
|
1367
|
+
neutral: themeColor_v0_v2(color2.dark.transparent),
|
|
962
1368
|
primary: themeColor_v0_v2(color2.dark.primary),
|
|
1369
|
+
suggest: themeColor_v0_v2(color2.dark.primary),
|
|
963
1370
|
positive: themeColor_v0_v2(color2.dark.positive),
|
|
964
1371
|
caution: themeColor_v0_v2(color2.dark.caution),
|
|
965
|
-
critical: themeColor_v0_v2(color2.dark.critical)
|
|
966
|
-
prospect: themeColor_v0_v2(color2.dark.default),
|
|
967
|
-
explore: themeColor_v0_v2(color2.dark.default)
|
|
1372
|
+
critical: themeColor_v0_v2(color2.dark.critical)
|
|
968
1373
|
}
|
|
969
1374
|
},
|
|
970
1375
|
container,
|
|
@@ -1104,22 +1509,22 @@ function inputStateThemeColor_v2_v0(t) {
|
|
|
1104
1509
|
const THEME_COLOR_SCHEMES = ["light", "dark"], THEME_COLOR_BLEND_MODES = ["multiply", "screen"], THEME_COLOR_CARD_TONES = [
|
|
1105
1510
|
"transparent",
|
|
1106
1511
|
"default",
|
|
1512
|
+
"neutral",
|
|
1107
1513
|
"primary",
|
|
1514
|
+
// deprecated
|
|
1515
|
+
"suggest",
|
|
1108
1516
|
"positive",
|
|
1109
1517
|
"caution",
|
|
1110
|
-
"critical"
|
|
1111
|
-
// new
|
|
1112
|
-
"prospect",
|
|
1113
|
-
"explore"
|
|
1518
|
+
"critical"
|
|
1114
1519
|
], THEME_COLOR_STATE_TONES = [
|
|
1115
1520
|
"default",
|
|
1521
|
+
"neutral",
|
|
1116
1522
|
"primary",
|
|
1523
|
+
// deprecated
|
|
1524
|
+
"suggest",
|
|
1117
1525
|
"positive",
|
|
1118
1526
|
"caution",
|
|
1119
|
-
"critical"
|
|
1120
|
-
// new
|
|
1121
|
-
"prospect",
|
|
1122
|
-
"explore"
|
|
1527
|
+
"critical"
|
|
1123
1528
|
], THEME_COLOR_STATES = ["enabled", "hovered", "pressed", "selected", "disabled"], THEME_COLOR_BUTTON_MODES = ["default", "ghost", "bleed"], THEME_COLOR_INPUT_MODES = ["default", "invalid"], THEME_COLOR_INPUT_STATES = ["enabled", "hovered", "readOnly", "disabled"], THEME_COLOR_AVATAR_COLORS = COLOR_HUES;
|
|
1124
1529
|
function isColorBlendModeValue(str) {
|
|
1125
1530
|
return THEME_COLOR_BLEND_MODES.includes(str);
|
|
@@ -1133,33 +1538,7 @@ function isColorTintKey(str) {
|
|
|
1133
1538
|
function isColorButtonMode(str) {
|
|
1134
1539
|
return THEME_COLOR_BUTTON_MODES.includes(str);
|
|
1135
1540
|
}
|
|
1136
|
-
const COLOR_CONFIG_STATE_KEYS = [
|
|
1137
|
-
"_hue",
|
|
1138
|
-
"bg",
|
|
1139
|
-
"fg",
|
|
1140
|
-
"border",
|
|
1141
|
-
"focusRing",
|
|
1142
|
-
"muted/fg",
|
|
1143
|
-
"accent/fg",
|
|
1144
|
-
"link/fg",
|
|
1145
|
-
"code/bg",
|
|
1146
|
-
"code/fg",
|
|
1147
|
-
"skeleton/from",
|
|
1148
|
-
"skeleton/to",
|
|
1149
|
-
"status/dot",
|
|
1150
|
-
"status/icon"
|
|
1151
|
-
], COLOR_CONFIG_CARD_KEYS = [
|
|
1152
|
-
...COLOR_CONFIG_STATE_KEYS,
|
|
1153
|
-
"_hue",
|
|
1154
|
-
"bg",
|
|
1155
|
-
"fg",
|
|
1156
|
-
"border",
|
|
1157
|
-
"focusRing",
|
|
1158
|
-
"shadow/outline",
|
|
1159
|
-
"shadow/umbra",
|
|
1160
|
-
"shadow/penumbra",
|
|
1161
|
-
"shadow/ambient"
|
|
1162
|
-
], COLOR_CONFIG_BLEND_KEYS = ["_blend"], COLOR_CONFIG_AVATAR_COLORS = ["*", ...THEME_COLOR_AVATAR_COLORS], COLOR_CONFIG_CARD_TONES = ["*", ...THEME_COLOR_CARD_TONES], COLOR_CONFIG_STATE_TONES = ["*", ...THEME_COLOR_STATE_TONES], COLOR_CONFIG_STATES = ["*", ...THEME_COLOR_STATES], COLOR_CONFIG_INPUT_MODES = ["*", ...THEME_COLOR_INPUT_MODES], COLOR_CONFIG_INPUT_STATES = ["*", ...THEME_COLOR_INPUT_STATES];
|
|
1541
|
+
const COLOR_CONFIG_STATE_KEYS = ["_hue", "bg", "fg", "border", "focusRing", "muted/fg", "accent/fg", "link/fg", "code/bg", "code/fg", "skeleton/from", "skeleton/to", "status/dot", "status/icon"], COLOR_CONFIG_CARD_KEYS = [...COLOR_CONFIG_STATE_KEYS, "_hue", "bg", "fg", "border", "focusRing", "shadow/outline", "shadow/umbra", "shadow/penumbra", "shadow/ambient"], COLOR_CONFIG_BLEND_KEYS = ["_blend"], COLOR_CONFIG_AVATAR_COLORS = ["*", ...THEME_COLOR_AVATAR_COLORS], COLOR_CONFIG_CARD_TONES = ["*", ...THEME_COLOR_CARD_TONES], COLOR_CONFIG_STATE_TONES = ["*", ...THEME_COLOR_STATE_TONES], COLOR_CONFIG_STATES = ["*", ...THEME_COLOR_STATES], COLOR_CONFIG_INPUT_MODES = ["*", ...THEME_COLOR_INPUT_MODES], COLOR_CONFIG_INPUT_STATES = ["*", ...THEME_COLOR_INPUT_STATES];
|
|
1163
1542
|
function parseTokenKey(str) {
|
|
1164
1543
|
const segments = str.split("/"), segment0 = segments.shift() || "";
|
|
1165
1544
|
if (isColorConfigBaseTone(segment0)) {
|
|
@@ -1325,10 +1704,16 @@ function compileColorTokenValue(node) {
|
|
|
1325
1704
|
}
|
|
1326
1705
|
const DEFAULT_COLOR_TOKEN_VALUE = ["500", "500"];
|
|
1327
1706
|
function resolveColorTokenValue(context, value = DEFAULT_COLOR_TOKEN_VALUE) {
|
|
1328
|
-
const {
|
|
1707
|
+
const {
|
|
1708
|
+
hue,
|
|
1709
|
+
scheme
|
|
1710
|
+
} = context, node = parseTokenValue(value[scheme === "light" ? 0 : 1]);
|
|
1329
1711
|
if (!node || node.type !== "color")
|
|
1330
1712
|
throw new Error(`Invalid color token: ${value[0]}`);
|
|
1331
|
-
return compileColorTokenValue({
|
|
1713
|
+
return compileColorTokenValue({
|
|
1714
|
+
...node,
|
|
1715
|
+
hue: node.hue || hue
|
|
1716
|
+
});
|
|
1332
1717
|
}
|
|
1333
1718
|
const defaultColorTokens = {
|
|
1334
1719
|
base: {
|
|
@@ -1352,9 +1737,6 @@ const defaultColorTokens = {
|
|
|
1352
1737
|
icon: ["500", "500"],
|
|
1353
1738
|
dot: ["500", "500"]
|
|
1354
1739
|
},
|
|
1355
|
-
default: {
|
|
1356
|
-
_hue: "gray"
|
|
1357
|
-
},
|
|
1358
1740
|
positive: {
|
|
1359
1741
|
bg: ["200 50%", "900"],
|
|
1360
1742
|
fg: ["600", "500"]
|
|
@@ -1371,7 +1753,7 @@ const defaultColorTokens = {
|
|
|
1371
1753
|
fg: ["600", "400"]
|
|
1372
1754
|
},
|
|
1373
1755
|
fg: ["800", "200"],
|
|
1374
|
-
focusRing: ["
|
|
1756
|
+
focusRing: ["blue/500", "blue/500"],
|
|
1375
1757
|
icon: ["600", "400"],
|
|
1376
1758
|
kbd: {
|
|
1377
1759
|
bg: ["white", "black"],
|
|
@@ -1379,7 +1761,7 @@ const defaultColorTokens = {
|
|
|
1379
1761
|
border: ["200", "800"]
|
|
1380
1762
|
},
|
|
1381
1763
|
link: {
|
|
1382
|
-
fg: ["
|
|
1764
|
+
fg: ["blue/600", "blue/300"]
|
|
1383
1765
|
},
|
|
1384
1766
|
muted: {
|
|
1385
1767
|
bg: ["50", "950"],
|
|
@@ -1406,18 +1788,27 @@ const defaultColorTokens = {
|
|
|
1406
1788
|
fg: ["600", "400"]
|
|
1407
1789
|
}
|
|
1408
1790
|
},
|
|
1409
|
-
primary: {
|
|
1791
|
+
primary: {
|
|
1792
|
+
_hue: "blue"
|
|
1793
|
+
},
|
|
1794
|
+
suggest: {
|
|
1795
|
+
_hue: "purple"
|
|
1796
|
+
},
|
|
1410
1797
|
positive: {
|
|
1411
1798
|
_hue: "green",
|
|
1412
|
-
shadow: {
|
|
1799
|
+
shadow: {
|
|
1800
|
+
outline: ["500/0.4", "500/0.4"]
|
|
1801
|
+
}
|
|
1413
1802
|
},
|
|
1414
1803
|
caution: {
|
|
1415
1804
|
_hue: "yellow",
|
|
1416
|
-
shadow: {
|
|
1805
|
+
shadow: {
|
|
1806
|
+
outline: ["600/0.3", "500/0.4"]
|
|
1807
|
+
}
|
|
1417
1808
|
},
|
|
1418
|
-
critical: {
|
|
1419
|
-
|
|
1420
|
-
|
|
1809
|
+
critical: {
|
|
1810
|
+
_hue: "red"
|
|
1811
|
+
}
|
|
1421
1812
|
},
|
|
1422
1813
|
button: {
|
|
1423
1814
|
default: {
|
|
@@ -1456,7 +1847,7 @@ const defaultColorTokens = {
|
|
|
1456
1847
|
border: ["800", "200"]
|
|
1457
1848
|
},
|
|
1458
1849
|
link: {
|
|
1459
|
-
fg: ["
|
|
1850
|
+
fg: ["blue/200", "blue/600"]
|
|
1460
1851
|
},
|
|
1461
1852
|
muted: {
|
|
1462
1853
|
bg: ["950", "50"],
|
|
@@ -1468,7 +1859,7 @@ const defaultColorTokens = {
|
|
|
1468
1859
|
}
|
|
1469
1860
|
},
|
|
1470
1861
|
hovered: {
|
|
1471
|
-
bg: ["
|
|
1862
|
+
bg: ["600", "300"],
|
|
1472
1863
|
border: ["700/0", "300/0"]
|
|
1473
1864
|
},
|
|
1474
1865
|
pressed: {
|
|
@@ -1579,7 +1970,7 @@ const defaultColorTokens = {
|
|
|
1579
1970
|
border: ["200", "800"]
|
|
1580
1971
|
},
|
|
1581
1972
|
link: {
|
|
1582
|
-
fg: ["
|
|
1973
|
+
fg: ["blue/700 60%", "blue/300 60%"]
|
|
1583
1974
|
},
|
|
1584
1975
|
muted: {
|
|
1585
1976
|
bg: ["100", "950"],
|
|
@@ -1595,11 +1986,11 @@ const defaultColorTokens = {
|
|
|
1595
1986
|
fg: ["700", "300"]
|
|
1596
1987
|
},
|
|
1597
1988
|
pressed: {
|
|
1598
|
-
bg: ["
|
|
1989
|
+
bg: ["200", "800"],
|
|
1599
1990
|
fg: ["800", "200"]
|
|
1600
1991
|
},
|
|
1601
1992
|
selected: {
|
|
1602
|
-
bg: ["
|
|
1993
|
+
bg: ["200", "800"],
|
|
1603
1994
|
fg: ["800", "200"]
|
|
1604
1995
|
},
|
|
1605
1996
|
disabled: {
|
|
@@ -1690,7 +2081,7 @@ const defaultColorTokens = {
|
|
|
1690
2081
|
border: ["200", "800"]
|
|
1691
2082
|
},
|
|
1692
2083
|
link: {
|
|
1693
|
-
fg: ["
|
|
2084
|
+
fg: ["blue/700 70%", "blue/300 70%"]
|
|
1694
2085
|
},
|
|
1695
2086
|
muted: {
|
|
1696
2087
|
bg: ["100", "950"],
|
|
@@ -1828,7 +2219,7 @@ const defaultColorTokens = {
|
|
|
1828
2219
|
border: ["200", "800"]
|
|
1829
2220
|
},
|
|
1830
2221
|
link: {
|
|
1831
|
-
fg: ["
|
|
2222
|
+
fg: ["blue/700 70%", "blue/300 70%"]
|
|
1832
2223
|
},
|
|
1833
2224
|
muted: {
|
|
1834
2225
|
bg: ["50", "950"],
|
|
@@ -1843,7 +2234,6 @@ const defaultColorTokens = {
|
|
|
1843
2234
|
bg: ["50", "950"]
|
|
1844
2235
|
},
|
|
1845
2236
|
pressed: {
|
|
1846
|
-
// _hue: 'purple',
|
|
1847
2237
|
bg: ["100", "900"]
|
|
1848
2238
|
},
|
|
1849
2239
|
selected: {
|
|
@@ -1880,7 +2270,7 @@ const defaultColorTokens = {
|
|
|
1880
2270
|
border: ["800", "200"]
|
|
1881
2271
|
},
|
|
1882
2272
|
link: {
|
|
1883
|
-
fg: ["
|
|
2273
|
+
fg: ["blue/200", "blue/600"]
|
|
1884
2274
|
},
|
|
1885
2275
|
muted: {
|
|
1886
2276
|
bg: ["500 10%", "400 10%"],
|
|
@@ -1935,7 +2325,7 @@ const defaultColorTokens = {
|
|
|
1935
2325
|
},
|
|
1936
2326
|
default: {
|
|
1937
2327
|
selected: {
|
|
1938
|
-
_hue: "
|
|
2328
|
+
_hue: "blue"
|
|
1939
2329
|
}
|
|
1940
2330
|
},
|
|
1941
2331
|
critical: {
|
|
@@ -2018,7 +2408,9 @@ function resolveBaseColorTones(inputTokens, tone) {
|
|
|
2018
2408
|
_hue: hue,
|
|
2019
2409
|
avatar: COLOR_HUES.reduce((acc, hue2) => ({
|
|
2020
2410
|
...acc,
|
|
2021
|
-
[hue2]: merge({
|
|
2411
|
+
[hue2]: merge({
|
|
2412
|
+
_hue: hue2
|
|
2413
|
+
}, spec.avatar?.["*"], spec.avatar?.[hue2])
|
|
2022
2414
|
}), {}),
|
|
2023
2415
|
badge: THEME_COLOR_STATE_TONES.reduce((acc, tone2) => ({
|
|
2024
2416
|
...acc,
|
|
@@ -2049,18 +2441,15 @@ function resolveButtonModeColorTokens(inputTokens, mode, tone) {
|
|
|
2049
2441
|
return tokens;
|
|
2050
2442
|
}
|
|
2051
2443
|
function resolveButtonStateColorTokens(inputTokens, tone, mode, state) {
|
|
2052
|
-
const spec = merge(
|
|
2053
|
-
inputTokens?.button?.[mode]?.["*"]?.["*"],
|
|
2054
|
-
inputTokens?.button?.[mode]?.[tone]?.["*"],
|
|
2055
|
-
inputTokens?.button?.[mode]?.["*"]?.[state],
|
|
2056
|
-
inputTokens?.button?.[mode]?.[tone]?.[state]
|
|
2057
|
-
), hue = spec._hue || inputTokens?.base?.[tone]?._hue;
|
|
2444
|
+
const spec = merge(inputTokens?.button?.[mode]?.["*"]?.["*"], inputTokens?.button?.[mode]?.[tone]?.["*"], inputTokens?.button?.[mode]?.["*"]?.[state], inputTokens?.button?.[mode]?.[tone]?.[state]), hue = spec._hue || inputTokens?.base?.[tone]?._hue;
|
|
2058
2445
|
return {
|
|
2059
2446
|
...spec,
|
|
2060
2447
|
_hue: hue,
|
|
2061
2448
|
avatar: COLOR_HUES.reduce((acc, hue2) => ({
|
|
2062
2449
|
...acc,
|
|
2063
|
-
[hue2]: merge({
|
|
2450
|
+
[hue2]: merge({
|
|
2451
|
+
_hue: hue2
|
|
2452
|
+
}, spec.avatar?.["*"], spec.avatar?.[hue2])
|
|
2064
2453
|
}), {}),
|
|
2065
2454
|
badge: THEME_COLOR_STATE_TONES.reduce((acc, tone2) => ({
|
|
2066
2455
|
...acc,
|
|
@@ -2085,13 +2474,11 @@ function resolveInputModeColorTokens(inputTokens, mode) {
|
|
|
2085
2474
|
return states;
|
|
2086
2475
|
}
|
|
2087
2476
|
function resolveInputStateColorTokens(inputTokens, mode, state) {
|
|
2088
|
-
const spec = merge(
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
), hue = spec._hue || inputTokens?.input?.[mode]?._hue;
|
|
2094
|
-
return { ...spec, _hue: hue };
|
|
2477
|
+
const spec = merge(inputTokens?.input?.["*"]?.["*"], inputTokens?.input?.[mode]?.["*"], inputTokens?.input?.["*"]?.[state], inputTokens?.input?.[mode]?.[state]), hue = spec._hue || inputTokens?.input?.[mode]?._hue;
|
|
2478
|
+
return {
|
|
2479
|
+
...spec,
|
|
2480
|
+
_hue: hue
|
|
2481
|
+
};
|
|
2095
2482
|
}
|
|
2096
2483
|
function resolveSelectableColorTokens(inputTokens) {
|
|
2097
2484
|
const tokens = {};
|
|
@@ -2108,18 +2495,15 @@ function resolveSelectableToneColorTokens(inputTokens, tone) {
|
|
|
2108
2495
|
return states;
|
|
2109
2496
|
}
|
|
2110
2497
|
function resolveSelectableStateColorTokens(inputTokens, tone, state) {
|
|
2111
|
-
const spec = merge(
|
|
2112
|
-
inputTokens?.selectable?.["*"]?.["*"],
|
|
2113
|
-
inputTokens?.selectable?.[tone]?.["*"],
|
|
2114
|
-
inputTokens?.selectable?.["*"]?.[state],
|
|
2115
|
-
inputTokens?.selectable?.[tone]?.[state]
|
|
2116
|
-
), hue = spec._hue || inputTokens?.base?.[tone]?._hue;
|
|
2498
|
+
const spec = merge(inputTokens?.selectable?.["*"]?.["*"], inputTokens?.selectable?.[tone]?.["*"], inputTokens?.selectable?.["*"]?.[state], inputTokens?.selectable?.[tone]?.[state]), hue = spec._hue || inputTokens?.base?.[tone]?._hue;
|
|
2117
2499
|
return {
|
|
2118
2500
|
...spec,
|
|
2119
2501
|
_hue: hue,
|
|
2120
2502
|
avatar: COLOR_HUES.reduce((acc, hue2) => ({
|
|
2121
2503
|
...acc,
|
|
2122
|
-
[hue2]: merge({
|
|
2504
|
+
[hue2]: merge({
|
|
2505
|
+
_hue: hue2
|
|
2506
|
+
}, spec.avatar?.["*"], spec.avatar?.[hue2])
|
|
2123
2507
|
}), {}),
|
|
2124
2508
|
badge: THEME_COLOR_STATE_TONES.reduce((acc, tone2) => ({
|
|
2125
2509
|
...acc,
|
|
@@ -2137,28 +2521,52 @@ function buildColorTheme(config) {
|
|
|
2137
2521
|
color: resolveColorTokens(config?.color)
|
|
2138
2522
|
};
|
|
2139
2523
|
return {
|
|
2140
|
-
light: buildColorScheme({
|
|
2141
|
-
|
|
2524
|
+
light: buildColorScheme({
|
|
2525
|
+
scheme: "light"
|
|
2526
|
+
}, resolvedConfig),
|
|
2527
|
+
dark: buildColorScheme({
|
|
2528
|
+
scheme: "dark"
|
|
2529
|
+
}, resolvedConfig)
|
|
2142
2530
|
};
|
|
2143
2531
|
}
|
|
2144
2532
|
function buildColorScheme(options, config) {
|
|
2145
|
-
const {
|
|
2146
|
-
|
|
2533
|
+
const {
|
|
2534
|
+
scheme
|
|
2535
|
+
} = options, colorScheme = {};
|
|
2536
|
+
for (const tone of THEME_COLOR_CARD_TONES)
|
|
2537
|
+
colorScheme[tone] = buildCardColorTheme({
|
|
2538
|
+
scheme,
|
|
2539
|
+
tone
|
|
2540
|
+
}, config);
|
|
2541
|
+
return colorScheme;
|
|
2147
2542
|
}
|
|
2148
2543
|
function buildCardColorTheme(options, config) {
|
|
2149
|
-
const {
|
|
2544
|
+
const {
|
|
2545
|
+
scheme,
|
|
2546
|
+
tone
|
|
2547
|
+
} = options, tokens = config?.color?.base?.[tone], context = {
|
|
2548
|
+
hue: tokens?._hue || "gray",
|
|
2549
|
+
scheme
|
|
2550
|
+
};
|
|
2150
2551
|
return {
|
|
2151
2552
|
_blend: (tokens?._blend || ["multiply", "screen"])[scheme === "light" ? 0 : 1],
|
|
2152
2553
|
_dark: scheme === "dark",
|
|
2153
2554
|
accent: {
|
|
2154
2555
|
fg: resolveColorTokenValue(context, tokens?.accent?.fg)
|
|
2155
2556
|
},
|
|
2156
|
-
avatar: buildAvatarColorTheme({
|
|
2557
|
+
avatar: buildAvatarColorTheme({
|
|
2558
|
+
scheme
|
|
2559
|
+
}, tokens),
|
|
2157
2560
|
backdrop: resolveColorTokenValue(context, tokens?.backdrop),
|
|
2158
|
-
badge: buildBadgeColorTheme(tokens?.badge, {
|
|
2561
|
+
badge: buildBadgeColorTheme(tokens?.badge, {
|
|
2562
|
+
scheme
|
|
2563
|
+
}, config),
|
|
2159
2564
|
bg: resolveColorTokenValue(context, tokens?.bg),
|
|
2160
2565
|
border: resolveColorTokenValue(context, tokens?.border),
|
|
2161
|
-
button: buildButtonColorTheme({
|
|
2566
|
+
button: buildButtonColorTheme({
|
|
2567
|
+
scheme,
|
|
2568
|
+
tone
|
|
2569
|
+
}, config),
|
|
2162
2570
|
code: {
|
|
2163
2571
|
bg: resolveColorTokenValue(context, tokens?.code?.bg),
|
|
2164
2572
|
fg: resolveColorTokenValue(context, tokens?.code?.fg)
|
|
@@ -2166,7 +2574,10 @@ function buildCardColorTheme(options, config) {
|
|
|
2166
2574
|
fg: resolveColorTokenValue(context, tokens?.fg),
|
|
2167
2575
|
focusRing: resolveColorTokenValue(context, tokens?.focusRing),
|
|
2168
2576
|
icon: resolveColorTokenValue(context, tokens?.icon),
|
|
2169
|
-
input: buildInputColorTheme({
|
|
2577
|
+
input: buildInputColorTheme({
|
|
2578
|
+
scheme,
|
|
2579
|
+
tone
|
|
2580
|
+
}, config),
|
|
2170
2581
|
kbd: {
|
|
2171
2582
|
bg: resolveColorTokenValue(context, tokens?.kbd?.bg),
|
|
2172
2583
|
fg: resolveColorTokenValue(context, tokens?.kbd?.fg),
|
|
@@ -2179,17 +2590,31 @@ function buildCardColorTheme(options, config) {
|
|
|
2179
2590
|
bg: resolveColorTokenValue(context, tokens?.muted?.bg),
|
|
2180
2591
|
fg: resolveColorTokenValue(context, tokens?.muted?.fg)
|
|
2181
2592
|
},
|
|
2182
|
-
selectable: buildSelectableColorTheme({
|
|
2183
|
-
|
|
2593
|
+
selectable: buildSelectableColorTheme({
|
|
2594
|
+
scheme,
|
|
2595
|
+
tone
|
|
2596
|
+
}, config),
|
|
2597
|
+
shadow: buildShadowColorTheme({
|
|
2598
|
+
scheme,
|
|
2599
|
+
tone
|
|
2600
|
+
}, config),
|
|
2184
2601
|
skeleton: {
|
|
2185
2602
|
from: resolveColorTokenValue(context, tokens?.skeleton?.from),
|
|
2186
2603
|
to: resolveColorTokenValue(context, tokens?.skeleton?.to)
|
|
2187
2604
|
},
|
|
2188
|
-
syntax: buildSyntaxColorTheme({
|
|
2605
|
+
syntax: buildSyntaxColorTheme({
|
|
2606
|
+
scheme
|
|
2607
|
+
}, config)
|
|
2189
2608
|
};
|
|
2190
2609
|
}
|
|
2191
2610
|
function buildShadowColorTheme(options, config) {
|
|
2192
|
-
const {
|
|
2611
|
+
const {
|
|
2612
|
+
scheme,
|
|
2613
|
+
tone
|
|
2614
|
+
} = options, tokens = config?.color?.base?.[tone], context = {
|
|
2615
|
+
hue: tokens?._hue || "gray",
|
|
2616
|
+
scheme
|
|
2617
|
+
};
|
|
2193
2618
|
return {
|
|
2194
2619
|
outline: resolveColorTokenValue(context, tokens?.shadow?.outline),
|
|
2195
2620
|
umbra: resolveColorTokenValue(context, tokens?.shadow?.umbra),
|
|
@@ -2198,21 +2623,56 @@ function buildShadowColorTheme(options, config) {
|
|
|
2198
2623
|
};
|
|
2199
2624
|
}
|
|
2200
2625
|
function buildAvatarColorTheme(options, stateTokens) {
|
|
2201
|
-
const {
|
|
2626
|
+
const {
|
|
2627
|
+
scheme
|
|
2628
|
+
} = options;
|
|
2202
2629
|
return {
|
|
2203
|
-
gray: _buildAvatarColorTheme({
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2630
|
+
gray: _buildAvatarColorTheme({
|
|
2631
|
+
color: "gray",
|
|
2632
|
+
scheme
|
|
2633
|
+
}, stateTokens),
|
|
2634
|
+
blue: _buildAvatarColorTheme({
|
|
2635
|
+
color: "blue",
|
|
2636
|
+
scheme
|
|
2637
|
+
}, stateTokens),
|
|
2638
|
+
purple: _buildAvatarColorTheme({
|
|
2639
|
+
color: "purple",
|
|
2640
|
+
scheme
|
|
2641
|
+
}, stateTokens),
|
|
2642
|
+
magenta: _buildAvatarColorTheme({
|
|
2643
|
+
color: "magenta",
|
|
2644
|
+
scheme
|
|
2645
|
+
}, stateTokens),
|
|
2646
|
+
red: _buildAvatarColorTheme({
|
|
2647
|
+
color: "red",
|
|
2648
|
+
scheme
|
|
2649
|
+
}, stateTokens),
|
|
2650
|
+
orange: _buildAvatarColorTheme({
|
|
2651
|
+
color: "orange",
|
|
2652
|
+
scheme
|
|
2653
|
+
}, stateTokens),
|
|
2654
|
+
yellow: _buildAvatarColorTheme({
|
|
2655
|
+
color: "yellow",
|
|
2656
|
+
scheme
|
|
2657
|
+
}, stateTokens),
|
|
2658
|
+
green: _buildAvatarColorTheme({
|
|
2659
|
+
color: "green",
|
|
2660
|
+
scheme
|
|
2661
|
+
}, stateTokens),
|
|
2662
|
+
cyan: _buildAvatarColorTheme({
|
|
2663
|
+
color: "cyan",
|
|
2664
|
+
scheme
|
|
2665
|
+
}, stateTokens)
|
|
2212
2666
|
};
|
|
2213
2667
|
}
|
|
2214
2668
|
function _buildAvatarColorTheme(options, stateTokens) {
|
|
2215
|
-
const {
|
|
2669
|
+
const {
|
|
2670
|
+
color: color2,
|
|
2671
|
+
scheme
|
|
2672
|
+
} = options, tokens = stateTokens?.avatar?.[color2], context = {
|
|
2673
|
+
hue: tokens?._hue || "gray",
|
|
2674
|
+
scheme
|
|
2675
|
+
};
|
|
2216
2676
|
return {
|
|
2217
2677
|
_blend: (tokens?._blend || ["screen", "multiply"])[scheme === "light" ? 0 : 1],
|
|
2218
2678
|
bg: resolveColorTokenValue(context, tokens?.bg),
|
|
@@ -2220,11 +2680,24 @@ function _buildAvatarColorTheme(options, stateTokens) {
|
|
|
2220
2680
|
};
|
|
2221
2681
|
}
|
|
2222
2682
|
function buildBadgeColorTheme(tokens, options, config) {
|
|
2223
|
-
const {
|
|
2224
|
-
|
|
2683
|
+
const {
|
|
2684
|
+
scheme
|
|
2685
|
+
} = options, colorBadge = {};
|
|
2686
|
+
for (const tone of THEME_COLOR_STATE_TONES)
|
|
2687
|
+
colorBadge[tone] = _buildBadgeColorTheme(tokens, {
|
|
2688
|
+
scheme,
|
|
2689
|
+
tone
|
|
2690
|
+
}, config);
|
|
2691
|
+
return colorBadge;
|
|
2225
2692
|
}
|
|
2226
2693
|
function _buildBadgeColorTheme(parentTokens, options, config) {
|
|
2227
|
-
const {
|
|
2694
|
+
const {
|
|
2695
|
+
scheme,
|
|
2696
|
+
tone
|
|
2697
|
+
} = options, tokens = parentTokens?.[tone], context = {
|
|
2698
|
+
hue: tokens?._hue || config?.color?.base?.[tone]?._hue || "gray",
|
|
2699
|
+
scheme
|
|
2700
|
+
};
|
|
2228
2701
|
return {
|
|
2229
2702
|
bg: resolveColorTokenValue(context, tokens?.bg),
|
|
2230
2703
|
fg: resolveColorTokenValue(context, tokens?.fg),
|
|
@@ -2233,32 +2706,72 @@ function _buildBadgeColorTheme(parentTokens, options, config) {
|
|
|
2233
2706
|
};
|
|
2234
2707
|
}
|
|
2235
2708
|
function buildButtonColorTheme(options, config) {
|
|
2236
|
-
const {
|
|
2709
|
+
const {
|
|
2710
|
+
scheme,
|
|
2711
|
+
tone: cardTone
|
|
2712
|
+
} = options, modes = {};
|
|
2237
2713
|
for (const mode of THEME_COLOR_BUTTON_MODES)
|
|
2238
|
-
modes[mode] = buildButtonTonesColorTheme({
|
|
2714
|
+
modes[mode] = buildButtonTonesColorTheme({
|
|
2715
|
+
cardTone,
|
|
2716
|
+
scheme,
|
|
2717
|
+
mode
|
|
2718
|
+
}, config);
|
|
2239
2719
|
return modes;
|
|
2240
2720
|
}
|
|
2241
2721
|
function buildButtonTonesColorTheme(options, config) {
|
|
2242
|
-
const {
|
|
2722
|
+
const {
|
|
2723
|
+
cardTone,
|
|
2724
|
+
mode,
|
|
2725
|
+
scheme
|
|
2726
|
+
} = options, tones2 = {};
|
|
2243
2727
|
for (const tone of THEME_COLOR_STATE_TONES)
|
|
2244
|
-
tones2[tone] = buildButtonStatesColorTheme({
|
|
2728
|
+
tones2[tone] = buildButtonStatesColorTheme({
|
|
2729
|
+
cardTone,
|
|
2730
|
+
mode,
|
|
2731
|
+
scheme,
|
|
2732
|
+
tone
|
|
2733
|
+
}, config);
|
|
2245
2734
|
return tones2;
|
|
2246
2735
|
}
|
|
2247
2736
|
function buildButtonStatesColorTheme(options, config) {
|
|
2248
|
-
const {
|
|
2737
|
+
const {
|
|
2738
|
+
cardTone,
|
|
2739
|
+
mode,
|
|
2740
|
+
scheme,
|
|
2741
|
+
tone
|
|
2742
|
+
} = options, states = {};
|
|
2249
2743
|
for (const state of THEME_COLOR_STATES)
|
|
2250
|
-
states[state] = buildButtonStateColorTheme({
|
|
2744
|
+
states[state] = buildButtonStateColorTheme({
|
|
2745
|
+
cardTone,
|
|
2746
|
+
mode,
|
|
2747
|
+
tone,
|
|
2748
|
+
scheme,
|
|
2749
|
+
state
|
|
2750
|
+
}, config);
|
|
2251
2751
|
return states;
|
|
2252
2752
|
}
|
|
2253
2753
|
function buildButtonStateColorTheme(options, config) {
|
|
2254
|
-
const {
|
|
2754
|
+
const {
|
|
2755
|
+
cardTone,
|
|
2756
|
+
mode,
|
|
2757
|
+
tone,
|
|
2758
|
+
scheme,
|
|
2759
|
+
state
|
|
2760
|
+
} = options, cardTokens = config?.color?.base?.[cardTone], tokens = config?.color?.button?.[mode]?.[tone]?.[state], hue = tokens?._hue || cardTokens?._hue || "gray", blendMode = tokens?._blend || ["screen", "multiply"], context = {
|
|
2761
|
+
hue,
|
|
2762
|
+
scheme
|
|
2763
|
+
};
|
|
2255
2764
|
return {
|
|
2256
2765
|
_blend: blendMode[scheme === "light" ? 0 : 1],
|
|
2257
2766
|
accent: {
|
|
2258
2767
|
fg: resolveColorTokenValue(context, tokens?.accent?.fg)
|
|
2259
2768
|
},
|
|
2260
|
-
avatar: buildAvatarColorTheme({
|
|
2261
|
-
|
|
2769
|
+
avatar: buildAvatarColorTheme({
|
|
2770
|
+
scheme
|
|
2771
|
+
}, tokens),
|
|
2772
|
+
badge: buildBadgeColorTheme(tokens?.badge, {
|
|
2773
|
+
scheme
|
|
2774
|
+
}, config),
|
|
2262
2775
|
bg: resolveColorTokenValue(context, tokens?.bg),
|
|
2263
2776
|
border: resolveColorTokenValue(context, tokens?.border),
|
|
2264
2777
|
code: {
|
|
@@ -2286,23 +2799,66 @@ function buildButtonStateColorTheme(options, config) {
|
|
|
2286
2799
|
};
|
|
2287
2800
|
}
|
|
2288
2801
|
function buildInputColorTheme(options, config) {
|
|
2289
|
-
const {
|
|
2802
|
+
const {
|
|
2803
|
+
scheme,
|
|
2804
|
+
tone
|
|
2805
|
+
} = options;
|
|
2290
2806
|
return {
|
|
2291
|
-
default: buildInputStatesColorTheme({
|
|
2292
|
-
|
|
2807
|
+
default: buildInputStatesColorTheme({
|
|
2808
|
+
mode: "default",
|
|
2809
|
+
scheme,
|
|
2810
|
+
tone
|
|
2811
|
+
}, config),
|
|
2812
|
+
invalid: buildInputStatesColorTheme({
|
|
2813
|
+
mode: "invalid",
|
|
2814
|
+
scheme,
|
|
2815
|
+
tone
|
|
2816
|
+
}, config)
|
|
2293
2817
|
};
|
|
2294
2818
|
}
|
|
2295
2819
|
function buildInputStatesColorTheme(options, config) {
|
|
2296
|
-
const {
|
|
2820
|
+
const {
|
|
2821
|
+
mode,
|
|
2822
|
+
scheme,
|
|
2823
|
+
tone
|
|
2824
|
+
} = options;
|
|
2297
2825
|
return {
|
|
2298
|
-
enabled: buildInputStateColorTheme({
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2826
|
+
enabled: buildInputStateColorTheme({
|
|
2827
|
+
mode,
|
|
2828
|
+
scheme,
|
|
2829
|
+
state: "enabled",
|
|
2830
|
+
cardTone: tone
|
|
2831
|
+
}, config),
|
|
2832
|
+
hovered: buildInputStateColorTheme({
|
|
2833
|
+
mode,
|
|
2834
|
+
scheme,
|
|
2835
|
+
state: "hovered",
|
|
2836
|
+
cardTone: tone
|
|
2837
|
+
}, config),
|
|
2838
|
+
readOnly: buildInputStateColorTheme({
|
|
2839
|
+
mode,
|
|
2840
|
+
scheme,
|
|
2841
|
+
state: "readOnly",
|
|
2842
|
+
cardTone: tone
|
|
2843
|
+
}, config),
|
|
2844
|
+
disabled: buildInputStateColorTheme({
|
|
2845
|
+
mode,
|
|
2846
|
+
scheme,
|
|
2847
|
+
state: "disabled",
|
|
2848
|
+
cardTone: tone
|
|
2849
|
+
}, config)
|
|
2302
2850
|
};
|
|
2303
2851
|
}
|
|
2304
2852
|
function buildInputStateColorTheme(options, config) {
|
|
2305
|
-
const {
|
|
2853
|
+
const {
|
|
2854
|
+
cardTone,
|
|
2855
|
+
mode,
|
|
2856
|
+
scheme,
|
|
2857
|
+
state
|
|
2858
|
+
} = options, cardTokens = config?.color?.base?.[cardTone], tokens = config?.color?.input?.[mode]?.[state], hue = tokens?._hue || cardTokens?._hue || "gray", blendMode = tokens?._blend || ["screen", "multiply"], context = {
|
|
2859
|
+
hue,
|
|
2860
|
+
scheme
|
|
2861
|
+
};
|
|
2306
2862
|
return {
|
|
2307
2863
|
_blend: blendMode[scheme === "light" ? 0 : 1],
|
|
2308
2864
|
bg: resolveColorTokenValue(context, tokens?.bg),
|
|
@@ -2315,26 +2871,54 @@ function buildInputStateColorTheme(options, config) {
|
|
|
2315
2871
|
};
|
|
2316
2872
|
}
|
|
2317
2873
|
function buildSelectableColorTheme(options, config) {
|
|
2318
|
-
const {
|
|
2874
|
+
const {
|
|
2875
|
+
scheme,
|
|
2876
|
+
tone: cardTone
|
|
2877
|
+
} = options, tones2 = {};
|
|
2319
2878
|
for (const tone of THEME_COLOR_STATE_TONES)
|
|
2320
|
-
tones2[tone] = buildSelectableStatesColorTheme({
|
|
2879
|
+
tones2[tone] = buildSelectableStatesColorTheme({
|
|
2880
|
+
cardTone,
|
|
2881
|
+
scheme,
|
|
2882
|
+
tone
|
|
2883
|
+
}, config);
|
|
2321
2884
|
return tones2;
|
|
2322
2885
|
}
|
|
2323
2886
|
function buildSelectableStatesColorTheme(options, config) {
|
|
2324
|
-
const {
|
|
2887
|
+
const {
|
|
2888
|
+
cardTone,
|
|
2889
|
+
scheme,
|
|
2890
|
+
tone
|
|
2891
|
+
} = options, states = {};
|
|
2325
2892
|
for (const state of THEME_COLOR_STATES)
|
|
2326
|
-
states[state] = buildSelectableStateColorTheme({
|
|
2893
|
+
states[state] = buildSelectableStateColorTheme({
|
|
2894
|
+
cardTone,
|
|
2895
|
+
tone,
|
|
2896
|
+
scheme,
|
|
2897
|
+
state
|
|
2898
|
+
}, config);
|
|
2327
2899
|
return states;
|
|
2328
2900
|
}
|
|
2329
2901
|
function buildSelectableStateColorTheme(options, config) {
|
|
2330
|
-
const {
|
|
2902
|
+
const {
|
|
2903
|
+
cardTone,
|
|
2904
|
+
scheme,
|
|
2905
|
+
state,
|
|
2906
|
+
tone
|
|
2907
|
+
} = options, cardTokens = config?.color?.base?.[cardTone], tokens = config?.color?.selectable?.[tone]?.[state], hue = tokens?._hue || cardTokens?._hue || "gray", blendMode = tokens?._blend || ["screen", "multiply"], context = {
|
|
2908
|
+
hue,
|
|
2909
|
+
scheme
|
|
2910
|
+
};
|
|
2331
2911
|
return {
|
|
2332
2912
|
_blend: blendMode[scheme === "light" ? 0 : 1],
|
|
2333
2913
|
accent: {
|
|
2334
2914
|
fg: resolveColorTokenValue(context, tokens?.accent?.fg)
|
|
2335
2915
|
},
|
|
2336
|
-
avatar: buildAvatarColorTheme({
|
|
2337
|
-
|
|
2916
|
+
avatar: buildAvatarColorTheme({
|
|
2917
|
+
scheme
|
|
2918
|
+
}, tokens),
|
|
2919
|
+
badge: buildBadgeColorTheme(tokens?.badge, {
|
|
2920
|
+
scheme
|
|
2921
|
+
}, config),
|
|
2338
2922
|
bg: resolveColorTokenValue(context, tokens?.bg),
|
|
2339
2923
|
border: resolveColorTokenValue(context, tokens?.border),
|
|
2340
2924
|
code: {
|
|
@@ -2362,7 +2946,12 @@ function buildSelectableStateColorTheme(options, config) {
|
|
|
2362
2946
|
};
|
|
2363
2947
|
}
|
|
2364
2948
|
function buildSyntaxColorTheme(options, config) {
|
|
2365
|
-
const {
|
|
2949
|
+
const {
|
|
2950
|
+
scheme
|
|
2951
|
+
} = options, tokens = config?.color?.syntax, context = {
|
|
2952
|
+
hue: "gray",
|
|
2953
|
+
scheme
|
|
2954
|
+
};
|
|
2366
2955
|
return {
|
|
2367
2956
|
atrule: resolveColorTokenValue(context, tokens?.atrule),
|
|
2368
2957
|
attrName: resolveColorTokenValue(context, tokens?.attrName),
|
|
@@ -2477,11 +3066,19 @@ function rgbToHex(color2) {
|
|
|
2477
3066
|
const r = round(clamp(Math.round(color2.r), 0, 255)), g = round(clamp(Math.round(color2.g), 0, 255)), b = round(clamp(Math.round(color2.b), 0, 255));
|
|
2478
3067
|
return "a" in color2 ? `rgba(${r},${g},${b},${color2.a})` : "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
|
|
2479
3068
|
}
|
|
2480
|
-
function rgbToHsl({
|
|
3069
|
+
function rgbToHsl({
|
|
3070
|
+
r,
|
|
3071
|
+
g,
|
|
3072
|
+
b
|
|
3073
|
+
}) {
|
|
2481
3074
|
r /= 255, g /= 255, b /= 255;
|
|
2482
3075
|
const cmin = Math.min(r, g, b), cmax = Math.max(r, g, b), delta = cmax - cmin;
|
|
2483
3076
|
let h = 0, s = 0, l = 0;
|
|
2484
|
-
return delta == 0 ? h = 0 : cmax == r ? h = (g - b) / delta % 6 : cmax == g ? h = (b - r) / delta + 2 : h = (r - g) / delta + 4, h = Math.round(h * 60), h < 0 && (h += 360), l = (cmax + cmin) / 2, s = delta == 0 ? 0 : delta / (1 - Math.abs(2 * l - 1)), s = +(s * 100).toFixed(1), l = +(l * 100).toFixed(1), {
|
|
3077
|
+
return delta == 0 ? h = 0 : cmax == r ? h = (g - b) / delta % 6 : cmax == g ? h = (b - r) / delta + 2 : h = (r - g) / delta + 4, h = Math.round(h * 60), h < 0 && (h += 360), l = (cmax + cmin) / 2, s = delta == 0 ? 0 : delta / (1 - Math.abs(2 * l - 1)), s = +(s * 100).toFixed(1), l = +(l * 100).toFixed(1), {
|
|
3078
|
+
h,
|
|
3079
|
+
s,
|
|
3080
|
+
l
|
|
3081
|
+
};
|
|
2485
3082
|
}
|
|
2486
3083
|
function hslToRgb(hsl) {
|
|
2487
3084
|
const s = hsl.s / 100, l = hsl.l / 100, c = (1 - Math.abs(2 * l - 1)) * s, x = c * (1 - Math.abs(hsl.h / 60 % 2 - 1)), m = l - c / 2;
|
|
@@ -2506,10 +3103,18 @@ function parseHsl(str) {
|
|
|
2506
3103
|
const res = HSL_RE.exec(str);
|
|
2507
3104
|
if (!res)
|
|
2508
3105
|
throw new Error(`parseHsl: string is not a HSL color: "${str}"`);
|
|
2509
|
-
return {
|
|
3106
|
+
return {
|
|
3107
|
+
h: parseInt(res[1]),
|
|
3108
|
+
s: parseFloat(res[3]),
|
|
3109
|
+
l: parseFloat(res[5])
|
|
3110
|
+
};
|
|
2510
3111
|
}
|
|
2511
3112
|
function parseColor(color2) {
|
|
2512
|
-
if (!color2) return {
|
|
3113
|
+
if (!color2) return {
|
|
3114
|
+
r: 0,
|
|
3115
|
+
g: 0,
|
|
3116
|
+
b: 0
|
|
3117
|
+
};
|
|
2513
3118
|
if (typeof color2 != "string")
|
|
2514
3119
|
throw new Error("parseColor: expected a string");
|
|
2515
3120
|
if (isHex(color2))
|
|
@@ -2524,7 +3129,11 @@ function getContrastRatio(bg, fg) {
|
|
|
2524
3129
|
const rgb1 = parseColor(bg), rgb2 = parseColor(fg), c1 = rgb_lrgb(rgb1), c2 = rgb_lrgb(rgb2), l1 = lrgb_luminance(c1), l2 = lrgb_luminance(c2);
|
|
2525
3130
|
return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
|
|
2526
3131
|
}
|
|
2527
|
-
function rgb_lrgb({
|
|
3132
|
+
function rgb_lrgb({
|
|
3133
|
+
r,
|
|
3134
|
+
g,
|
|
3135
|
+
b
|
|
3136
|
+
}) {
|
|
2528
3137
|
return [rgb_lrgb1(r / 255), rgb_lrgb1(g / 255), rgb_lrgb1(b / 255)];
|
|
2529
3138
|
}
|
|
2530
3139
|
function rgb_lrgb1(v) {
|
|
@@ -2539,7 +3148,9 @@ function rgba(color2, a) {
|
|
|
2539
3148
|
}
|
|
2540
3149
|
const RGB_RANGE = [0, 255];
|
|
2541
3150
|
function mixThemeColor(value, options) {
|
|
2542
|
-
const {
|
|
3151
|
+
const {
|
|
3152
|
+
blendMode
|
|
3153
|
+
} = options, color2 = parseColor(value), black2 = parseColor(options.black), white2 = parseColor(options.white), bg = options.bg ? parseColor(options.bg) : blendMode === "multiply" ? white2 : black2, paletteRange = {
|
|
2543
3154
|
r: [black2.r, white2.r],
|
|
2544
3155
|
g: [black2.g, white2.g],
|
|
2545
3156
|
b: [black2.b, white2.b]
|
|
@@ -2559,7 +3170,11 @@ function mixThemeColor(value, options) {
|
|
|
2559
3170
|
return rgbToHex(v);
|
|
2560
3171
|
}
|
|
2561
3172
|
function renderColorValue(str, options) {
|
|
2562
|
-
const {
|
|
3173
|
+
const {
|
|
3174
|
+
bg,
|
|
3175
|
+
blendMode,
|
|
3176
|
+
colorPalette
|
|
3177
|
+
} = options;
|
|
2563
3178
|
if (bg === "white")
|
|
2564
3179
|
throw new Error("Cannot blend with white background");
|
|
2565
3180
|
const node = parseTokenValue(str);
|
|
@@ -2591,60 +3206,68 @@ function renderColorHex(color2) {
|
|
|
2591
3206
|
function renderThemeColorSchemes(value, config) {
|
|
2592
3207
|
const colorPalette = config?.palette ?? defaultColorPalette;
|
|
2593
3208
|
return {
|
|
2594
|
-
light: renderThemeColorScheme(colorPalette, value.light
|
|
2595
|
-
dark: renderThemeColorScheme(colorPalette, value.dark
|
|
3209
|
+
light: renderThemeColorScheme(colorPalette, value.light),
|
|
3210
|
+
dark: renderThemeColorScheme(colorPalette, value.dark)
|
|
2596
3211
|
};
|
|
2597
3212
|
}
|
|
2598
|
-
function renderThemeColorScheme(colorPalette, value
|
|
2599
|
-
const
|
|
2600
|
-
colorPalette
|
|
2601
|
-
debugPath: `${debugPath}.transparent`
|
|
3213
|
+
function renderThemeColorScheme(colorPalette, value) {
|
|
3214
|
+
const toneEntries = Object.entries(value), [, transparentTone] = toneEntries.find(([k]) => k === "transparent"), [, defaultTone] = toneEntries.find(([k]) => k === "default"), renderedTransparentTone = renderThemeColor(transparentTone, {
|
|
3215
|
+
colorPalette
|
|
2602
3216
|
}), renderedDefaultTone = renderThemeColor(defaultTone, {
|
|
2603
|
-
colorPalette
|
|
2604
|
-
debugPath: `${debugPath}.default`
|
|
3217
|
+
colorPalette
|
|
2605
3218
|
}), bg = renderedDefaultTone.bg;
|
|
2606
3219
|
if (bg === "white")
|
|
2607
3220
|
throw new Error("Cannot blend with white background");
|
|
2608
|
-
return Object.fromEntries([
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
k,
|
|
2613
|
-
renderThemeColor(v, {
|
|
2614
|
-
bg,
|
|
2615
|
-
colorPalette,
|
|
2616
|
-
debugPath: `${debugPath}.${k}`
|
|
2617
|
-
})
|
|
2618
|
-
])
|
|
2619
|
-
]);
|
|
3221
|
+
return Object.fromEntries([["transparent", renderedTransparentTone], ["default", renderedDefaultTone], ...toneEntries.filter(([k]) => k !== "default" && k !== "transparent").map(([k, v]) => [k, renderThemeColor(v, {
|
|
3222
|
+
bg,
|
|
3223
|
+
colorPalette
|
|
3224
|
+
})])]);
|
|
2620
3225
|
}
|
|
2621
3226
|
function renderThemeColor(value, options) {
|
|
2622
|
-
const {
|
|
3227
|
+
const {
|
|
3228
|
+
colorPalette,
|
|
3229
|
+
bg
|
|
3230
|
+
} = options, blendMode = value._blend || "multiply", baseBg = renderColorValue(value.bg, {
|
|
3231
|
+
colorPalette,
|
|
3232
|
+
bg,
|
|
3233
|
+
blendMode
|
|
3234
|
+
}), colorOptions = {
|
|
3235
|
+
colorPalette,
|
|
3236
|
+
bg: baseBg,
|
|
3237
|
+
blendMode
|
|
3238
|
+
}, button = renderThemeColorButton(value.button, {
|
|
2623
3239
|
baseBg,
|
|
2624
3240
|
blendMode,
|
|
2625
|
-
colorPalette
|
|
2626
|
-
debugPath: `${debugPath}.button`
|
|
3241
|
+
colorPalette
|
|
2627
3242
|
}), selectable = renderThemeColorSelectable(value.selectable, {
|
|
2628
3243
|
colorPalette,
|
|
2629
3244
|
baseBg,
|
|
2630
|
-
blendMode
|
|
2631
|
-
debugPath: `${debugPath}.selectable`
|
|
3245
|
+
blendMode
|
|
2632
3246
|
}), shadow = {
|
|
2633
3247
|
outline: renderColorValue(value.shadow.outline, colorOptions),
|
|
2634
3248
|
umbra: renderColorValue(value.shadow.umbra, {
|
|
2635
3249
|
...colorOptions,
|
|
2636
3250
|
bg: void 0,
|
|
2637
|
-
colorPalette: {
|
|
3251
|
+
colorPalette: {
|
|
3252
|
+
...colorPalette,
|
|
3253
|
+
black: "#000000"
|
|
3254
|
+
}
|
|
2638
3255
|
}),
|
|
2639
3256
|
penumbra: renderColorValue(value.shadow.penumbra, {
|
|
2640
3257
|
...colorOptions,
|
|
2641
3258
|
bg: void 0,
|
|
2642
|
-
colorPalette: {
|
|
3259
|
+
colorPalette: {
|
|
3260
|
+
...colorPalette,
|
|
3261
|
+
black: "#000000"
|
|
3262
|
+
}
|
|
2643
3263
|
}),
|
|
2644
3264
|
ambient: renderColorValue(value.shadow.ambient, {
|
|
2645
3265
|
...colorOptions,
|
|
2646
3266
|
bg: void 0,
|
|
2647
|
-
colorPalette: {
|
|
3267
|
+
colorPalette: {
|
|
3268
|
+
...colorPalette,
|
|
3269
|
+
black: "#000000"
|
|
3270
|
+
}
|
|
2648
3271
|
})
|
|
2649
3272
|
};
|
|
2650
3273
|
return {
|
|
@@ -2656,15 +3279,13 @@ function renderThemeColor(value, options) {
|
|
|
2656
3279
|
avatar: renderThemeColorAvatar(value.avatar, {
|
|
2657
3280
|
baseBg,
|
|
2658
3281
|
colorPalette,
|
|
2659
|
-
blendMode
|
|
2660
|
-
debugPath: `${debugPath}.avatar`
|
|
3282
|
+
blendMode
|
|
2661
3283
|
}),
|
|
2662
3284
|
backdrop: renderColorValue(value.backdrop, colorOptions),
|
|
2663
3285
|
badge: renderThemeColorBadge(value.badge, {
|
|
2664
3286
|
baseBg,
|
|
2665
3287
|
colorPalette,
|
|
2666
|
-
blendMode
|
|
2667
|
-
debugPath: `${debugPath}.badge`
|
|
3288
|
+
blendMode
|
|
2668
3289
|
}),
|
|
2669
3290
|
bg: baseBg,
|
|
2670
3291
|
border: renderColorValue(value.border, colorOptions),
|
|
@@ -2679,14 +3300,12 @@ function renderThemeColor(value, options) {
|
|
|
2679
3300
|
input: renderThemeColorInput(value.input, {
|
|
2680
3301
|
baseBg,
|
|
2681
3302
|
colorPalette,
|
|
2682
|
-
blendMode
|
|
2683
|
-
debugPath: `${debugPath}.input`
|
|
3303
|
+
blendMode
|
|
2684
3304
|
}),
|
|
2685
3305
|
kbd: renderThemeColorKBD(value.kbd, {
|
|
2686
3306
|
baseBg,
|
|
2687
3307
|
colorPalette,
|
|
2688
|
-
blendMode
|
|
2689
|
-
debugPath: `${debugPath}.kbd`
|
|
3308
|
+
blendMode
|
|
2690
3309
|
}),
|
|
2691
3310
|
link: {
|
|
2692
3311
|
fg: renderColorValue(value.link.fg, colorOptions)
|
|
@@ -2703,14 +3322,17 @@ function renderThemeColor(value, options) {
|
|
|
2703
3322
|
syntax: renderSyntaxColorTheme(value.syntax, {
|
|
2704
3323
|
baseBg,
|
|
2705
3324
|
colorPalette,
|
|
2706
|
-
blendMode
|
|
2707
|
-
debugPath: `${debugPath}.syntax`
|
|
3325
|
+
blendMode
|
|
2708
3326
|
}),
|
|
2709
3327
|
selectable
|
|
2710
3328
|
};
|
|
2711
3329
|
}
|
|
2712
3330
|
function renderThemeColorKBD(value, options) {
|
|
2713
|
-
const {
|
|
3331
|
+
const {
|
|
3332
|
+
baseBg,
|
|
3333
|
+
blendMode,
|
|
3334
|
+
colorPalette
|
|
3335
|
+
} = options, rootOptions = {
|
|
2714
3336
|
bg: baseBg,
|
|
2715
3337
|
blendMode,
|
|
2716
3338
|
colorPalette
|
|
@@ -2726,48 +3348,17 @@ function renderThemeColorKBD(value, options) {
|
|
|
2726
3348
|
};
|
|
2727
3349
|
}
|
|
2728
3350
|
function renderThemeColorAvatar(value, options) {
|
|
2729
|
-
const
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
debugPath: `${debugPath}.gray`
|
|
2734
|
-
}),
|
|
2735
|
-
blue: renderThemeColorAvatarColor(value.blue, {
|
|
2736
|
-
...options,
|
|
2737
|
-
debugPath: `${debugPath}.blue`
|
|
2738
|
-
}),
|
|
2739
|
-
purple: renderThemeColorAvatarColor(value.purple, {
|
|
2740
|
-
...options,
|
|
2741
|
-
debugPath: `${debugPath}.purple`
|
|
2742
|
-
}),
|
|
2743
|
-
magenta: renderThemeColorAvatarColor(value.magenta, {
|
|
2744
|
-
...options,
|
|
2745
|
-
debugPath: `${debugPath}.magenta`
|
|
2746
|
-
}),
|
|
2747
|
-
red: renderThemeColorAvatarColor(value.red, {
|
|
2748
|
-
...options,
|
|
2749
|
-
debugPath: `${debugPath}.red`
|
|
2750
|
-
}),
|
|
2751
|
-
orange: renderThemeColorAvatarColor(value.orange, {
|
|
2752
|
-
...options,
|
|
2753
|
-
debugPath: `${debugPath}.orange`
|
|
2754
|
-
}),
|
|
2755
|
-
yellow: renderThemeColorAvatarColor(value.yellow, {
|
|
2756
|
-
...options,
|
|
2757
|
-
debugPath: `${debugPath}.yellow`
|
|
2758
|
-
}),
|
|
2759
|
-
green: renderThemeColorAvatarColor(value.green, {
|
|
2760
|
-
...options,
|
|
2761
|
-
debugPath: `${debugPath}.green`
|
|
2762
|
-
}),
|
|
2763
|
-
cyan: renderThemeColorAvatarColor(value.cyan, {
|
|
2764
|
-
...options,
|
|
2765
|
-
debugPath: `${debugPath}.cyan`
|
|
2766
|
-
})
|
|
2767
|
-
};
|
|
3351
|
+
const colorAvatar = {};
|
|
3352
|
+
for (const hue of COLOR_HUES)
|
|
3353
|
+
colorAvatar[hue] = renderThemeColorAvatarColor(value[hue], options);
|
|
3354
|
+
return colorAvatar;
|
|
2768
3355
|
}
|
|
2769
3356
|
function renderThemeColorAvatarColor(value, options) {
|
|
2770
|
-
const {
|
|
3357
|
+
const {
|
|
3358
|
+
baseBg,
|
|
3359
|
+
blendMode: rootBlendMode,
|
|
3360
|
+
colorPalette
|
|
3361
|
+
} = options, blendMode = value._blend || "multiply", rootOptions = {
|
|
2771
3362
|
bg: baseBg,
|
|
2772
3363
|
blendMode: rootBlendMode,
|
|
2773
3364
|
colorPalette
|
|
@@ -2783,14 +3374,17 @@ function renderThemeColorAvatarColor(value, options) {
|
|
|
2783
3374
|
};
|
|
2784
3375
|
}
|
|
2785
3376
|
function renderThemeColorBadge(value, options) {
|
|
2786
|
-
const
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
}), acc), {});
|
|
3377
|
+
const colorBadge = {};
|
|
3378
|
+
for (const tone of THEME_COLOR_STATE_TONES)
|
|
3379
|
+
colorBadge[tone] = renderThemeColorBadgeColor(value[tone], options);
|
|
3380
|
+
return colorBadge;
|
|
2791
3381
|
}
|
|
2792
3382
|
function renderThemeColorBadgeColor(value, options) {
|
|
2793
|
-
const {
|
|
3383
|
+
const {
|
|
3384
|
+
baseBg,
|
|
3385
|
+
blendMode: rootBlendMode,
|
|
3386
|
+
colorPalette
|
|
3387
|
+
} = options, blendMode = rootBlendMode, rootOptions = {
|
|
2794
3388
|
bg: baseBg,
|
|
2795
3389
|
blendMode: rootBlendMode,
|
|
2796
3390
|
colorPalette
|
|
@@ -2807,56 +3401,33 @@ function renderThemeColorBadgeColor(value, options) {
|
|
|
2807
3401
|
};
|
|
2808
3402
|
}
|
|
2809
3403
|
function renderThemeColorButton(value, options) {
|
|
2810
|
-
const { debugPath } = options;
|
|
2811
3404
|
return {
|
|
2812
|
-
default: renderThemeColorButtonTones(value.default,
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
}),
|
|
2816
|
-
ghost: renderThemeColorButtonTones(value.ghost, {
|
|
2817
|
-
...options,
|
|
2818
|
-
debugPath: `${debugPath}.ghost`
|
|
2819
|
-
}),
|
|
2820
|
-
bleed: renderThemeColorButtonTones(value.bleed, {
|
|
2821
|
-
...options,
|
|
2822
|
-
debugPath: `${debugPath}.bleed`
|
|
2823
|
-
})
|
|
3405
|
+
default: renderThemeColorButtonTones(value.default, options),
|
|
3406
|
+
ghost: renderThemeColorButtonTones(value.ghost, options),
|
|
3407
|
+
bleed: renderThemeColorButtonTones(value.bleed, options)
|
|
2824
3408
|
};
|
|
2825
3409
|
}
|
|
2826
3410
|
function renderThemeColorButtonTones(value, options) {
|
|
2827
|
-
const
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
}), acc), {});
|
|
3411
|
+
const colorButtonMode = {};
|
|
3412
|
+
for (const tone of THEME_COLOR_STATE_TONES)
|
|
3413
|
+
colorButtonMode[tone] = renderThemeColorButtonStates(value[tone], options);
|
|
3414
|
+
return colorButtonMode;
|
|
2832
3415
|
}
|
|
2833
3416
|
function renderThemeColorButtonStates(value, options) {
|
|
2834
|
-
const { debugPath } = options;
|
|
2835
3417
|
return {
|
|
2836
|
-
enabled: renderThemeColorState(value.enabled,
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
...options,
|
|
2842
|
-
debugPath: `${debugPath}.hovered`
|
|
2843
|
-
}),
|
|
2844
|
-
pressed: renderThemeColorState(value.pressed, {
|
|
2845
|
-
...options,
|
|
2846
|
-
debugPath: `${debugPath}.pressed`
|
|
2847
|
-
}),
|
|
2848
|
-
selected: renderThemeColorState(value.selected, {
|
|
2849
|
-
...options,
|
|
2850
|
-
debugPath: `${debugPath}.selected`
|
|
2851
|
-
}),
|
|
2852
|
-
disabled: renderThemeColorState(value.disabled, {
|
|
2853
|
-
...options,
|
|
2854
|
-
debugPath: `${debugPath}.disabled`
|
|
2855
|
-
})
|
|
3418
|
+
enabled: renderThemeColorState(value.enabled, options),
|
|
3419
|
+
hovered: renderThemeColorState(value.hovered, options),
|
|
3420
|
+
pressed: renderThemeColorState(value.pressed, options),
|
|
3421
|
+
selected: renderThemeColorState(value.selected, options),
|
|
3422
|
+
disabled: renderThemeColorState(value.disabled, options)
|
|
2856
3423
|
};
|
|
2857
3424
|
}
|
|
2858
3425
|
function renderThemeColorState(value, options) {
|
|
2859
|
-
const {
|
|
3426
|
+
const {
|
|
3427
|
+
baseBg,
|
|
3428
|
+
blendMode: rootBlendMode,
|
|
3429
|
+
colorPalette
|
|
3430
|
+
} = options, blendMode = value._blend || "multiply", rootOptions = {
|
|
2860
3431
|
bg: baseBg,
|
|
2861
3432
|
blendMode: rootBlendMode,
|
|
2862
3433
|
colorPalette
|
|
@@ -2873,14 +3444,12 @@ function renderThemeColorState(value, options) {
|
|
|
2873
3444
|
avatar: renderThemeColorAvatar(value.avatar, {
|
|
2874
3445
|
baseBg: bg,
|
|
2875
3446
|
colorPalette,
|
|
2876
|
-
blendMode
|
|
2877
|
-
debugPath: `${debugPath}.avatar`
|
|
3447
|
+
blendMode
|
|
2878
3448
|
}),
|
|
2879
3449
|
badge: renderThemeColorBadge(value.badge, {
|
|
2880
3450
|
baseBg: bg,
|
|
2881
3451
|
colorPalette,
|
|
2882
|
-
blendMode
|
|
2883
|
-
debugPath: `${debugPath}.badge`
|
|
3452
|
+
blendMode
|
|
2884
3453
|
}),
|
|
2885
3454
|
bg,
|
|
2886
3455
|
border: renderColorValue(value.border, colorOptions),
|
|
@@ -2909,41 +3478,33 @@ function renderThemeColorState(value, options) {
|
|
|
2909
3478
|
};
|
|
2910
3479
|
}
|
|
2911
3480
|
function renderThemeColorInput(value, options) {
|
|
2912
|
-
const { debugPath } = options;
|
|
2913
3481
|
return {
|
|
2914
|
-
default: renderInputStatesColorTheme(value.default,
|
|
2915
|
-
|
|
2916
|
-
debugPath: `${debugPath}.default`
|
|
2917
|
-
}),
|
|
2918
|
-
invalid: renderInputStatesColorTheme(value.invalid, {
|
|
2919
|
-
...options,
|
|
2920
|
-
debugPath: `${debugPath}.invalid`
|
|
2921
|
-
})
|
|
3482
|
+
default: renderInputStatesColorTheme(value.default, options),
|
|
3483
|
+
invalid: renderInputStatesColorTheme(value.invalid, options)
|
|
2922
3484
|
};
|
|
2923
3485
|
}
|
|
2924
3486
|
function renderInputStatesColorTheme(value, options) {
|
|
2925
|
-
const { debugPath } = options;
|
|
2926
3487
|
return {
|
|
2927
|
-
enabled: renderInputStateColorTheme(value.enabled,
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
hovered: renderInputStateColorTheme(value.hovered, {
|
|
2932
|
-
...options,
|
|
2933
|
-
debugPath: `${debugPath}.hovered`
|
|
2934
|
-
}),
|
|
2935
|
-
readOnly: renderInputStateColorTheme(value.readOnly, {
|
|
2936
|
-
...options,
|
|
2937
|
-
debugPath: `${debugPath}.readOnly`
|
|
2938
|
-
}),
|
|
2939
|
-
disabled: renderInputStateColorTheme(value.disabled, {
|
|
2940
|
-
...options,
|
|
2941
|
-
debugPath: `${debugPath}.disabled`
|
|
2942
|
-
})
|
|
3488
|
+
enabled: renderInputStateColorTheme(value.enabled, options),
|
|
3489
|
+
hovered: renderInputStateColorTheme(value.hovered, options),
|
|
3490
|
+
readOnly: renderInputStateColorTheme(value.readOnly, options),
|
|
3491
|
+
disabled: renderInputStateColorTheme(value.disabled, options)
|
|
2943
3492
|
};
|
|
2944
3493
|
}
|
|
2945
3494
|
function renderInputStateColorTheme(value, options) {
|
|
2946
|
-
const {
|
|
3495
|
+
const {
|
|
3496
|
+
baseBg,
|
|
3497
|
+
blendMode: rootBlendMode,
|
|
3498
|
+
colorPalette
|
|
3499
|
+
} = options, blendMode = value._blend || "multiply", rootOptions = {
|
|
3500
|
+
colorPalette,
|
|
3501
|
+
bg: baseBg,
|
|
3502
|
+
blendMode: rootBlendMode
|
|
3503
|
+
}, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
|
|
3504
|
+
colorPalette,
|
|
3505
|
+
bg,
|
|
3506
|
+
blendMode
|
|
3507
|
+
};
|
|
2947
3508
|
return {
|
|
2948
3509
|
_blend: blendMode,
|
|
2949
3510
|
bg,
|
|
@@ -2956,39 +3517,30 @@ function renderInputStateColorTheme(value, options) {
|
|
|
2956
3517
|
};
|
|
2957
3518
|
}
|
|
2958
3519
|
function renderThemeColorSelectable(value, options) {
|
|
2959
|
-
const
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
}), acc), {});
|
|
3520
|
+
const colorSelectable = {};
|
|
3521
|
+
for (const tone of THEME_COLOR_STATE_TONES)
|
|
3522
|
+
colorSelectable[tone] = renderThemeColorSelectableStates(value[tone], options);
|
|
3523
|
+
return colorSelectable;
|
|
2964
3524
|
}
|
|
2965
3525
|
function renderThemeColorSelectableStates(value, options) {
|
|
2966
|
-
const { debugPath } = options;
|
|
2967
3526
|
return {
|
|
2968
|
-
enabled: renderThemeColorState(value.enabled,
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
...options,
|
|
2974
|
-
debugPath: `${debugPath}.hovered`
|
|
2975
|
-
}),
|
|
2976
|
-
pressed: renderThemeColorState(value.pressed, {
|
|
2977
|
-
...options,
|
|
2978
|
-
debugPath: `${debugPath}.pressed`
|
|
2979
|
-
}),
|
|
2980
|
-
selected: renderThemeColorState(value.selected, {
|
|
2981
|
-
...options,
|
|
2982
|
-
debugPath: `${debugPath}.selected`
|
|
2983
|
-
}),
|
|
2984
|
-
disabled: renderThemeColorState(value.disabled, {
|
|
2985
|
-
...options,
|
|
2986
|
-
debugPath: `${debugPath}.disabled`
|
|
2987
|
-
})
|
|
3527
|
+
enabled: renderThemeColorState(value.enabled, options),
|
|
3528
|
+
hovered: renderThemeColorState(value.hovered, options),
|
|
3529
|
+
pressed: renderThemeColorState(value.pressed, options),
|
|
3530
|
+
selected: renderThemeColorState(value.selected, options),
|
|
3531
|
+
disabled: renderThemeColorState(value.disabled, options)
|
|
2988
3532
|
};
|
|
2989
3533
|
}
|
|
2990
3534
|
function renderSyntaxColorTheme(value, options) {
|
|
2991
|
-
const {
|
|
3535
|
+
const {
|
|
3536
|
+
colorPalette,
|
|
3537
|
+
baseBg,
|
|
3538
|
+
blendMode
|
|
3539
|
+
} = options, colorOptions = {
|
|
3540
|
+
colorPalette,
|
|
3541
|
+
bg: baseBg,
|
|
3542
|
+
blendMode
|
|
3543
|
+
};
|
|
2992
3544
|
return {
|
|
2993
3545
|
atrule: renderColorValue(value.atrule, colorOptions),
|
|
2994
3546
|
attrName: renderColorValue(value.attrName, colorOptions),
|