@sanity/ui 2.9.0-canary.6 → 2.9.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/dist/_chunks-cjs/getTheme_v2.js +26 -0
- package/dist/_chunks-cjs/getTheme_v2.js.map +1 -1
- package/dist/_chunks-es/getTheme_v2.mjs +26 -0
- package/dist/_chunks-es/getTheme_v2.mjs.map +1 -1
- package/dist/_legacy/getTheme_v2.esm.js +26 -0
- package/dist/_legacy/getTheme_v2.esm.js.map +1 -1
- package/dist/index.esm.js +652 -1048
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +651 -1047
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +652 -1048
- package/dist/index.mjs.map +1 -1
- package/dist/theme.d.mts +22 -28
- package/dist/theme.d.ts +22 -28
- package/dist/theme.esm.js +124 -260
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +124 -260
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +124 -260
- package/dist/theme.mjs.map +1 -1
- package/package.json +60 -53
- package/src/core/__workshop__/constants.ts +27 -31
- package/src/core/components/autocomplete/autocomplete.tsx +31 -42
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +47 -35
- package/src/core/components/dialog/dialog.tsx +1 -1
- package/src/core/components/menu/__workshop__/tones.tsx +5 -6
- package/src/core/components/menu/useMenuController.ts +21 -18
- package/src/core/components/toast/__workshop__/hook.tsx +1 -1
- package/src/core/components/toast/toast.tsx +2 -2
- package/src/core/components/tree/treeItem.tsx +15 -18
- package/src/core/hooks/useElementRect/__workshop__/example.tsx +2 -2
- package/src/core/hooks/useMatchMedia.ts +22 -12
- package/src/core/primitives/badge/__workshop__/tones.tsx +6 -13
- package/src/core/primitives/button/__workshop__/custom.tsx +4 -3
- 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/grid/__workshop__/responsive.tsx +12 -12
- package/src/core/primitives/heading/__workshop__/opticalAlignment.tsx +13 -25
- 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 +140 -74
- package/src/core/primitives/popover/popoverCard.tsx +4 -1
- 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/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/primitives/tooltip/tooltip.tsx +17 -47
- package/src/core/styles/card/_cardColorStyle.ts +8 -0
- package/src/core/theme/__workshop__/debug/story.tsx +18 -11
- package/src/core/utils/portal/portalProvider.tsx +5 -5
- package/src/theme/build/_deprecated/color/factory.ts +1 -1
- package/src/theme/build/_deprecated/color/muted/createMuted.ts +2 -2
- package/src/theme/build/buildColorTheme.ts +47 -37
- package/src/theme/build/renderColorTheme.ts +26 -30
- package/src/theme/build/resolveColorTokens.ts +51 -115
- package/src/theme/config/tokens/color/types.ts +4 -18
- package/src/theme/defaults/colorTokens.ts +8 -5
- package/src/theme/getScopedTheme.ts +9 -2
- package/src/theme/system/color/_constants.ts +6 -2
- package/src/theme/system/color/badge.ts +3 -7
- package/src/theme/system/v0/color/_system.ts +8 -4
- package/src/theme/system/v0/color/color.ts +3 -2
- package/src/theme/versioning/themeColor_v0_v2.ts +26 -0
- package/src/theme/versioning/v0_v2.ts +4 -0
- package/src/core/primitives/textInput/__workshop__/multipleTones.tsx +0 -20
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
ThemeColorInput_v2,
|
|
25
25
|
ThemeColorInputMode_v2,
|
|
26
26
|
ThemeColorInputState_v2,
|
|
27
|
+
THEME_COLOR_CARD_TONES,
|
|
27
28
|
} from '../system'
|
|
28
29
|
import {ColorTokenContext, resolveColorTokenValue as _color} from './colorToken'
|
|
29
30
|
import {resolveColorTokens} from './resolveColorTokens'
|
|
@@ -46,14 +47,13 @@ function buildColorScheme(
|
|
|
46
47
|
): ThemeColorScheme_v2 {
|
|
47
48
|
const {scheme} = options
|
|
48
49
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
positive: buildCardColorTheme({scheme, tone: 'positive'}, config),
|
|
54
|
-
caution: buildCardColorTheme({scheme, tone: 'caution'}, config),
|
|
55
|
-
critical: buildCardColorTheme({scheme, tone: 'critical'}, config),
|
|
50
|
+
const colorScheme = {} as ThemeColorScheme_v2
|
|
51
|
+
|
|
52
|
+
for (const tone of THEME_COLOR_CARD_TONES) {
|
|
53
|
+
colorScheme[tone] = buildCardColorTheme({scheme, tone}, config)
|
|
56
54
|
}
|
|
55
|
+
|
|
56
|
+
return colorScheme
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
function buildCardColorTheme(
|
|
@@ -77,7 +77,7 @@ function buildCardColorTheme(
|
|
|
77
77
|
badge: buildBadgeColorTheme(tokens?.badge, {scheme}, config),
|
|
78
78
|
bg: _color(context, tokens?.bg),
|
|
79
79
|
border: _color(context, tokens?.border),
|
|
80
|
-
button: buildButtonColorTheme({scheme}, config),
|
|
80
|
+
button: buildButtonColorTheme({scheme, tone}, config),
|
|
81
81
|
code: {
|
|
82
82
|
bg: _color(context, tokens?.code?.bg),
|
|
83
83
|
fg: _color(context, tokens?.code?.fg),
|
|
@@ -98,7 +98,7 @@ function buildCardColorTheme(
|
|
|
98
98
|
bg: _color(context, tokens?.muted?.bg),
|
|
99
99
|
fg: _color(context, tokens?.muted?.fg),
|
|
100
100
|
},
|
|
101
|
-
selectable: buildSelectableColorTheme({scheme}, config),
|
|
101
|
+
selectable: buildSelectableColorTheme({scheme, tone}, config),
|
|
102
102
|
shadow: buildShadowColorTheme({scheme, tone}, config),
|
|
103
103
|
skeleton: {
|
|
104
104
|
from: _color(context, tokens?.skeleton?.from),
|
|
@@ -167,13 +167,13 @@ function buildBadgeColorTheme(
|
|
|
167
167
|
): ThemeColorBadge_v2 {
|
|
168
168
|
const {scheme} = options
|
|
169
169
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
caution: _buildBadgeColorTheme(tokens, {scheme, tone: 'caution'}, config),
|
|
175
|
-
critical: _buildBadgeColorTheme(tokens, {scheme, tone: 'critical'}, config),
|
|
170
|
+
const colorBadge = {} as ThemeColorBadge_v2
|
|
171
|
+
|
|
172
|
+
for (const tone of THEME_COLOR_STATE_TONES) {
|
|
173
|
+
colorBadge[tone] = _buildBadgeColorTheme(tokens, {scheme, tone}, config)
|
|
176
174
|
}
|
|
175
|
+
|
|
176
|
+
return colorBadge
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
function _buildBadgeColorTheme(
|
|
@@ -195,15 +195,15 @@ function _buildBadgeColorTheme(
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
function buildButtonColorTheme(
|
|
198
|
-
options: {scheme: ThemeColorSchemeKey},
|
|
198
|
+
options: {scheme: ThemeColorSchemeKey; tone: ThemeColorCardToneKey},
|
|
199
199
|
config?: ThemeConfig,
|
|
200
200
|
): ThemeColorButton_v2 {
|
|
201
|
-
const {scheme} = options
|
|
201
|
+
const {scheme, tone: cardTone} = options
|
|
202
202
|
|
|
203
203
|
const modes: Partial<ThemeColorButton_v2> = {}
|
|
204
204
|
|
|
205
205
|
for (const mode of THEME_COLOR_BUTTON_MODES) {
|
|
206
|
-
modes[mode] = buildButtonTonesColorTheme({scheme, mode}, config)
|
|
206
|
+
modes[mode] = buildButtonTonesColorTheme({cardTone, scheme, mode}, config)
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
return modes as ThemeColorButton_v2
|
|
@@ -211,17 +211,18 @@ function buildButtonColorTheme(
|
|
|
211
211
|
|
|
212
212
|
function buildButtonTonesColorTheme(
|
|
213
213
|
options: {
|
|
214
|
+
cardTone: ThemeColorCardToneKey
|
|
214
215
|
scheme: ThemeColorSchemeKey
|
|
215
216
|
mode: ThemeColorButtonModeKey
|
|
216
217
|
},
|
|
217
218
|
config?: ThemeConfig,
|
|
218
219
|
): ThemeColorButtonMode_v2 {
|
|
219
|
-
const {mode, scheme} = options
|
|
220
|
+
const {cardTone, mode, scheme} = options
|
|
220
221
|
|
|
221
222
|
const tones: Partial<ThemeColorButtonMode_v2> = {}
|
|
222
223
|
|
|
223
224
|
for (const tone of THEME_COLOR_STATE_TONES) {
|
|
224
|
-
tones[tone] = buildButtonStatesColorTheme({mode, scheme, tone}, config)
|
|
225
|
+
tones[tone] = buildButtonStatesColorTheme({cardTone, mode, scheme, tone}, config)
|
|
225
226
|
}
|
|
226
227
|
|
|
227
228
|
return tones as ThemeColorButtonMode_v2
|
|
@@ -229,18 +230,19 @@ function buildButtonTonesColorTheme(
|
|
|
229
230
|
|
|
230
231
|
function buildButtonStatesColorTheme(
|
|
231
232
|
options: {
|
|
233
|
+
cardTone: ThemeColorCardToneKey
|
|
232
234
|
mode: ThemeColorButtonModeKey
|
|
233
235
|
scheme: ThemeColorSchemeKey
|
|
234
236
|
tone: ThemeColorStateToneKey
|
|
235
237
|
},
|
|
236
238
|
config?: ThemeConfig,
|
|
237
239
|
): ThemeColorButtonTone_v2 {
|
|
238
|
-
const {mode, scheme, tone} = options
|
|
240
|
+
const {cardTone, mode, scheme, tone} = options
|
|
239
241
|
|
|
240
242
|
const states: Partial<ThemeColorButtonTone_v2> = {}
|
|
241
243
|
|
|
242
244
|
for (const state of THEME_COLOR_STATES) {
|
|
243
|
-
states[state] = buildButtonStateColorTheme({mode, tone, scheme, state}, config)
|
|
245
|
+
states[state] = buildButtonStateColorTheme({cardTone, mode, tone, scheme, state}, config)
|
|
244
246
|
}
|
|
245
247
|
|
|
246
248
|
return states as ThemeColorButtonTone_v2
|
|
@@ -248,6 +250,7 @@ function buildButtonStatesColorTheme(
|
|
|
248
250
|
|
|
249
251
|
function buildButtonStateColorTheme(
|
|
250
252
|
options: {
|
|
253
|
+
cardTone: ThemeColorCardToneKey
|
|
251
254
|
mode: ThemeColorButtonModeKey
|
|
252
255
|
tone: ThemeColorStateToneKey
|
|
253
256
|
scheme: ThemeColorSchemeKey
|
|
@@ -255,9 +258,10 @@ function buildButtonStateColorTheme(
|
|
|
255
258
|
},
|
|
256
259
|
config?: ThemeConfig,
|
|
257
260
|
): ThemeColorState_v2 {
|
|
258
|
-
const {mode, tone, scheme, state} = options
|
|
261
|
+
const {cardTone, mode, tone, scheme, state} = options
|
|
262
|
+
const cardTokens = config?.color?.base?.[cardTone]
|
|
259
263
|
const tokens = config?.color?.button?.[mode]?.[tone]?.[state]
|
|
260
|
-
const hue = tokens?._hue || 'gray'
|
|
264
|
+
const hue = tokens?._hue || cardTokens?._hue || 'gray'
|
|
261
265
|
const blendMode = tokens?._blend || ['screen', 'multiply']
|
|
262
266
|
const context: ColorTokenContext = {hue, scheme}
|
|
263
267
|
|
|
@@ -318,25 +322,26 @@ function buildInputStatesColorTheme(
|
|
|
318
322
|
const {mode, scheme, tone} = options
|
|
319
323
|
|
|
320
324
|
return {
|
|
321
|
-
enabled: buildInputStateColorTheme({mode, scheme, state: 'enabled', tone}, config),
|
|
322
|
-
hovered: buildInputStateColorTheme({mode, scheme, state: 'hovered', tone}, config),
|
|
323
|
-
readOnly: buildInputStateColorTheme({mode, scheme, state: 'readOnly', tone}, config),
|
|
324
|
-
disabled: buildInputStateColorTheme({mode, scheme, state: 'disabled', tone}, config),
|
|
325
|
+
enabled: buildInputStateColorTheme({mode, scheme, state: 'enabled', cardTone: tone}, config),
|
|
326
|
+
hovered: buildInputStateColorTheme({mode, scheme, state: 'hovered', cardTone: tone}, config),
|
|
327
|
+
readOnly: buildInputStateColorTheme({mode, scheme, state: 'readOnly', cardTone: tone}, config),
|
|
328
|
+
disabled: buildInputStateColorTheme({mode, scheme, state: 'disabled', cardTone: tone}, config),
|
|
325
329
|
}
|
|
326
330
|
}
|
|
327
331
|
|
|
328
332
|
function buildInputStateColorTheme(
|
|
329
333
|
options: {
|
|
334
|
+
cardTone: ThemeColorCardToneKey
|
|
330
335
|
mode: 'default' | 'invalid'
|
|
331
336
|
scheme: ThemeColorSchemeKey
|
|
332
337
|
state: 'enabled' | 'hovered' | 'readOnly' | 'disabled'
|
|
333
|
-
tone: ThemeColorCardToneKey
|
|
334
338
|
},
|
|
335
339
|
config?: ThemeConfig,
|
|
336
340
|
): ThemeColorInputState_v2 {
|
|
337
|
-
const {
|
|
341
|
+
const {cardTone, mode, scheme, state} = options
|
|
342
|
+
const cardTokens = config?.color?.base?.[cardTone]
|
|
338
343
|
const tokens = config?.color?.input?.[mode]?.[state]
|
|
339
|
-
const hue = tokens?._hue ||
|
|
344
|
+
const hue = tokens?._hue || cardTokens?._hue || 'gray'
|
|
340
345
|
const blendMode = tokens?._blend || ['screen', 'multiply']
|
|
341
346
|
const context: ColorTokenContext = {hue, scheme}
|
|
342
347
|
|
|
@@ -355,15 +360,16 @@ function buildInputStateColorTheme(
|
|
|
355
360
|
function buildSelectableColorTheme(
|
|
356
361
|
options: {
|
|
357
362
|
scheme: ThemeColorSchemeKey
|
|
363
|
+
tone: ThemeColorCardToneKey
|
|
358
364
|
},
|
|
359
365
|
config?: ThemeConfig,
|
|
360
366
|
): ThemeColorButtonMode_v2 {
|
|
361
|
-
const {scheme} = options
|
|
367
|
+
const {scheme, tone: cardTone} = options
|
|
362
368
|
|
|
363
369
|
const tones: Partial<ThemeColorButtonMode_v2> = {}
|
|
364
370
|
|
|
365
371
|
for (const tone of THEME_COLOR_STATE_TONES) {
|
|
366
|
-
tones[tone] = buildSelectableStatesColorTheme({scheme, tone}, config)
|
|
372
|
+
tones[tone] = buildSelectableStatesColorTheme({cardTone, scheme, tone}, config)
|
|
367
373
|
}
|
|
368
374
|
|
|
369
375
|
return tones as ThemeColorButtonMode_v2
|
|
@@ -371,17 +377,18 @@ function buildSelectableColorTheme(
|
|
|
371
377
|
|
|
372
378
|
function buildSelectableStatesColorTheme(
|
|
373
379
|
options: {
|
|
380
|
+
cardTone: ThemeColorCardToneKey
|
|
374
381
|
scheme: ThemeColorSchemeKey
|
|
375
382
|
tone: ThemeColorStateToneKey
|
|
376
383
|
},
|
|
377
384
|
config?: ThemeConfig,
|
|
378
385
|
): ThemeColorButtonTone_v2 {
|
|
379
|
-
const {scheme, tone} = options
|
|
386
|
+
const {cardTone, scheme, tone} = options
|
|
380
387
|
|
|
381
388
|
const states: Partial<ThemeColorButtonTone_v2> = {}
|
|
382
389
|
|
|
383
390
|
for (const state of THEME_COLOR_STATES) {
|
|
384
|
-
states[state] = buildSelectableStateColorTheme({tone, scheme, state}, config)
|
|
391
|
+
states[state] = buildSelectableStateColorTheme({cardTone, tone, scheme, state}, config)
|
|
385
392
|
}
|
|
386
393
|
|
|
387
394
|
return states as ThemeColorButtonTone_v2
|
|
@@ -389,15 +396,18 @@ function buildSelectableStatesColorTheme(
|
|
|
389
396
|
|
|
390
397
|
function buildSelectableStateColorTheme(
|
|
391
398
|
options: {
|
|
399
|
+
cardTone: ThemeColorCardToneKey
|
|
392
400
|
scheme: ThemeColorSchemeKey
|
|
393
401
|
state: ThemeColorStateKey
|
|
394
402
|
tone: ThemeColorStateToneKey
|
|
395
403
|
},
|
|
396
404
|
config?: ThemeConfig,
|
|
397
405
|
): ThemeColorState_v2 {
|
|
398
|
-
const {scheme, state, tone} = options
|
|
406
|
+
const {cardTone, scheme, state, tone} = options
|
|
407
|
+
const cardTokens = config?.color?.base?.[cardTone]
|
|
399
408
|
const tokens = config?.color?.selectable?.[tone]?.[state]
|
|
400
|
-
|
|
409
|
+
|
|
410
|
+
const hue = tokens?._hue || cardTokens?._hue || 'gray'
|
|
401
411
|
const blendMode = tokens?._blend || ['screen', 'multiply']
|
|
402
412
|
const context: ColorTokenContext = {hue, scheme}
|
|
403
413
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import {COLOR_HUES} from '@sanity/color'
|
|
1
2
|
import {ThemeColorPalette, ThemeConfig} from '../config'
|
|
2
3
|
import {defaultColorPalette} from '../defaults/colorPalette'
|
|
3
4
|
import {
|
|
5
|
+
THEME_COLOR_STATE_TONES,
|
|
4
6
|
ThemeColorAvatar_v2,
|
|
5
7
|
ThemeColorBadgeTone_v2,
|
|
6
8
|
ThemeColorBadge_v2,
|
|
@@ -187,17 +189,13 @@ function renderThemeColorAvatar(
|
|
|
187
189
|
colorPalette: ThemeColorPalette
|
|
188
190
|
},
|
|
189
191
|
): ThemeColorAvatar_v2 {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
magenta: renderThemeColorAvatarColor(value.magenta, options),
|
|
195
|
-
red: renderThemeColorAvatarColor(value.red, options),
|
|
196
|
-
orange: renderThemeColorAvatarColor(value.orange, options),
|
|
197
|
-
yellow: renderThemeColorAvatarColor(value.yellow, options),
|
|
198
|
-
green: renderThemeColorAvatarColor(value.green, options),
|
|
199
|
-
cyan: renderThemeColorAvatarColor(value.cyan, options),
|
|
192
|
+
const colorAvatar = {} as ThemeColorAvatar_v2
|
|
193
|
+
|
|
194
|
+
for (const hue of COLOR_HUES) {
|
|
195
|
+
colorAvatar[hue] = renderThemeColorAvatarColor(value[hue], options)
|
|
200
196
|
}
|
|
197
|
+
|
|
198
|
+
return colorAvatar
|
|
201
199
|
}
|
|
202
200
|
|
|
203
201
|
function renderThemeColorAvatarColor(
|
|
@@ -240,13 +238,13 @@ function renderThemeColorBadge(
|
|
|
240
238
|
colorPalette: ThemeColorPalette
|
|
241
239
|
},
|
|
242
240
|
): ThemeColorBadge_v2 {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
caution: renderThemeColorBadgeColor(value.caution, options),
|
|
248
|
-
critical: renderThemeColorBadgeColor(value.critical, options),
|
|
241
|
+
const colorBadge = {} as ThemeColorBadge_v2
|
|
242
|
+
|
|
243
|
+
for (const tone of THEME_COLOR_STATE_TONES) {
|
|
244
|
+
colorBadge[tone] = renderThemeColorBadgeColor(value[tone], options)
|
|
249
245
|
}
|
|
246
|
+
|
|
247
|
+
return colorBadge
|
|
250
248
|
}
|
|
251
249
|
|
|
252
250
|
function renderThemeColorBadgeColor(
|
|
@@ -259,8 +257,6 @@ function renderThemeColorBadgeColor(
|
|
|
259
257
|
): ThemeColorBadgeTone_v2 {
|
|
260
258
|
const {baseBg, blendMode: rootBlendMode, colorPalette} = options
|
|
261
259
|
|
|
262
|
-
// const blendMode = value._blend || 'multiply'
|
|
263
|
-
|
|
264
260
|
const blendMode = rootBlendMode
|
|
265
261
|
|
|
266
262
|
const rootOptions: RenderColorValueOptions = {
|
|
@@ -308,13 +304,13 @@ function renderThemeColorButtonTones(
|
|
|
308
304
|
colorPalette: ThemeColorPalette
|
|
309
305
|
},
|
|
310
306
|
): ThemeColorButtonMode_v2 {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
caution: renderThemeColorButtonStates(value.caution, options),
|
|
316
|
-
critical: renderThemeColorButtonStates(value.critical, options),
|
|
307
|
+
const colorButtonMode = {} as ThemeColorButtonMode_v2
|
|
308
|
+
|
|
309
|
+
for (const tone of THEME_COLOR_STATE_TONES) {
|
|
310
|
+
colorButtonMode[tone] = renderThemeColorButtonStates(value[tone], options)
|
|
317
311
|
}
|
|
312
|
+
|
|
313
|
+
return colorButtonMode
|
|
318
314
|
}
|
|
319
315
|
|
|
320
316
|
function renderThemeColorButtonStates(
|
|
@@ -457,13 +453,13 @@ function renderThemeColorSelectable(
|
|
|
457
453
|
colorPalette: ThemeColorPalette
|
|
458
454
|
},
|
|
459
455
|
): ThemeColorSelectable_v2 {
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
caution: renderThemeColorSelectableStates(value.caution, options),
|
|
465
|
-
critical: renderThemeColorSelectableStates(value.critical, options),
|
|
456
|
+
const colorSelectable = {} as ThemeColorSelectable_v2
|
|
457
|
+
|
|
458
|
+
for (const tone of THEME_COLOR_STATE_TONES) {
|
|
459
|
+
colorSelectable[tone] = renderThemeColorSelectableStates(value[tone], options)
|
|
466
460
|
}
|
|
461
|
+
|
|
462
|
+
return colorSelectable
|
|
467
463
|
}
|
|
468
464
|
|
|
469
465
|
function renderThemeColorSelectableStates(
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {ColorHueKey} from '@sanity/color'
|
|
1
|
+
import {COLOR_HUES, ColorHueKey} from '@sanity/color'
|
|
2
2
|
import {
|
|
3
3
|
ColorConfigCardTone,
|
|
4
4
|
ColorConfigInputMode,
|
|
5
5
|
ColorConfigInputState,
|
|
6
6
|
ColorConfigStateTone,
|
|
7
|
+
ThemeColorAvatarTokens,
|
|
8
|
+
ThemeColorBadgeTokens,
|
|
7
9
|
ThemeColorBaseTokens,
|
|
8
10
|
ThemeColorButtonTokens,
|
|
9
11
|
ThemeColorInputStateTokens,
|
|
@@ -64,44 +66,22 @@ function resolveBaseColorTones(
|
|
|
64
66
|
return {
|
|
65
67
|
...spec,
|
|
66
68
|
_hue: hue,
|
|
67
|
-
avatar: {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
},
|
|
84
|
-
primary: {
|
|
85
|
-
_hue: inputTokens?.base?.primary?._hue || hue,
|
|
86
|
-
...spec.badge?.['*'],
|
|
87
|
-
...spec.badge?.primary,
|
|
88
|
-
},
|
|
89
|
-
positive: {
|
|
90
|
-
_hue: inputTokens?.base?.positive?._hue || hue,
|
|
91
|
-
...spec.badge?.['*'],
|
|
92
|
-
...spec.badge?.positive,
|
|
93
|
-
},
|
|
94
|
-
caution: {
|
|
95
|
-
_hue: inputTokens?.base?.caution?._hue || hue,
|
|
96
|
-
...spec.badge?.['*'],
|
|
97
|
-
...spec.badge?.caution,
|
|
98
|
-
},
|
|
99
|
-
critical: {
|
|
100
|
-
_hue: inputTokens?.base?.critical?._hue || hue,
|
|
101
|
-
...spec.badge?.['*'],
|
|
102
|
-
...spec.badge?.critical,
|
|
103
|
-
},
|
|
104
|
-
},
|
|
69
|
+
avatar: COLOR_HUES.reduce((acc, hue) => {
|
|
70
|
+
return {
|
|
71
|
+
...acc,
|
|
72
|
+
[hue]: merge({_hue: hue}, spec.avatar?.['*'], spec.avatar?.[hue]),
|
|
73
|
+
}
|
|
74
|
+
}, {} as ThemeColorAvatarTokens),
|
|
75
|
+
badge: THEME_COLOR_STATE_TONES.reduce((acc, tone) => {
|
|
76
|
+
return {
|
|
77
|
+
...acc,
|
|
78
|
+
[tone]: {
|
|
79
|
+
_hue: inputTokens?.base?.[tone]?._hue || hue,
|
|
80
|
+
...spec.badge?.['*'],
|
|
81
|
+
...spec.badge?.[tone],
|
|
82
|
+
},
|
|
83
|
+
}
|
|
84
|
+
}, {} as ThemeColorBadgeTokens),
|
|
105
85
|
}
|
|
106
86
|
}
|
|
107
87
|
|
|
@@ -162,44 +142,22 @@ function resolveButtonStateColorTokens(
|
|
|
162
142
|
return {
|
|
163
143
|
...spec,
|
|
164
144
|
_hue: hue,
|
|
165
|
-
avatar: {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
},
|
|
182
|
-
primary: {
|
|
183
|
-
_hue: inputTokens?.base?.primary?._hue,
|
|
184
|
-
...spec.badge?.['*'],
|
|
185
|
-
...spec.badge?.primary,
|
|
186
|
-
},
|
|
187
|
-
positive: {
|
|
188
|
-
_hue: inputTokens?.base?.positive?._hue,
|
|
189
|
-
...spec.badge?.['*'],
|
|
190
|
-
...spec.badge?.positive,
|
|
191
|
-
},
|
|
192
|
-
caution: {
|
|
193
|
-
_hue: inputTokens?.base?.caution?._hue,
|
|
194
|
-
...spec.badge?.['*'],
|
|
195
|
-
...spec.badge?.caution,
|
|
196
|
-
},
|
|
197
|
-
critical: {
|
|
198
|
-
_hue: inputTokens?.base?.critical?._hue,
|
|
199
|
-
...spec.badge?.['*'],
|
|
200
|
-
...spec.badge?.critical,
|
|
201
|
-
},
|
|
202
|
-
},
|
|
145
|
+
avatar: COLOR_HUES.reduce((acc, hue) => {
|
|
146
|
+
return {
|
|
147
|
+
...acc,
|
|
148
|
+
[hue]: merge({_hue: hue}, spec.avatar?.['*'], spec.avatar?.[hue]),
|
|
149
|
+
}
|
|
150
|
+
}, {} as ThemeColorAvatarTokens),
|
|
151
|
+
badge: THEME_COLOR_STATE_TONES.reduce((acc, tone) => {
|
|
152
|
+
return {
|
|
153
|
+
...acc,
|
|
154
|
+
[tone]: {
|
|
155
|
+
_hue: inputTokens?.base?.[tone]?._hue || hue,
|
|
156
|
+
...spec.badge?.['*'],
|
|
157
|
+
...spec.badge?.[tone],
|
|
158
|
+
},
|
|
159
|
+
}
|
|
160
|
+
}, {} as ThemeColorBadgeTokens),
|
|
203
161
|
}
|
|
204
162
|
}
|
|
205
163
|
|
|
@@ -289,43 +247,21 @@ function resolveSelectableStateColorTokens(
|
|
|
289
247
|
return {
|
|
290
248
|
...spec,
|
|
291
249
|
_hue: hue,
|
|
292
|
-
avatar: {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
},
|
|
309
|
-
primary: {
|
|
310
|
-
_hue: inputTokens?.base?.primary?._hue,
|
|
311
|
-
...spec.badge?.['*'],
|
|
312
|
-
...spec.badge?.primary,
|
|
313
|
-
},
|
|
314
|
-
positive: {
|
|
315
|
-
_hue: inputTokens?.base?.positive?._hue,
|
|
316
|
-
...spec.badge?.['*'],
|
|
317
|
-
...spec.badge?.positive,
|
|
318
|
-
},
|
|
319
|
-
caution: {
|
|
320
|
-
_hue: inputTokens?.base?.caution?._hue,
|
|
321
|
-
...spec.badge?.['*'],
|
|
322
|
-
...spec.badge?.caution,
|
|
323
|
-
},
|
|
324
|
-
critical: {
|
|
325
|
-
_hue: inputTokens?.base?.critical?._hue,
|
|
326
|
-
...spec.badge?.['*'],
|
|
327
|
-
...spec.badge?.critical,
|
|
328
|
-
},
|
|
329
|
-
},
|
|
250
|
+
avatar: COLOR_HUES.reduce((acc, hue) => {
|
|
251
|
+
return {
|
|
252
|
+
...acc,
|
|
253
|
+
[hue]: merge({_hue: hue}, spec.avatar?.['*'], spec.avatar?.[hue]),
|
|
254
|
+
}
|
|
255
|
+
}, {} as ThemeColorAvatarTokens),
|
|
256
|
+
badge: THEME_COLOR_STATE_TONES.reduce((acc, tone) => {
|
|
257
|
+
return {
|
|
258
|
+
...acc,
|
|
259
|
+
[tone]: {
|
|
260
|
+
_hue: inputTokens?.base?.[tone]?._hue || hue,
|
|
261
|
+
...spec.badge?.['*'],
|
|
262
|
+
...spec.badge?.[tone],
|
|
263
|
+
},
|
|
264
|
+
}
|
|
265
|
+
}, {} as ThemeColorBadgeTokens),
|
|
330
266
|
}
|
|
331
267
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {ColorHueKey} from '@sanity/color'
|
|
2
|
-
import {ThemeColorSyntax, ThemeColorButtonModeKey} from '../../../system'
|
|
2
|
+
import {ThemeColorSyntax, ThemeColorButtonModeKey, ThemeColorStateToneKey} from '../../../system'
|
|
3
3
|
import {
|
|
4
4
|
ColorBlendModeTokenValue,
|
|
5
5
|
ColorConfigCardTone,
|
|
@@ -32,15 +32,6 @@ export interface ThemeColorAvatarTokens {
|
|
|
32
32
|
'cyan'?: ThemeColorAvatarHueTokens
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
/** @public */
|
|
36
|
-
export interface ThemeColorBadgeTokens {
|
|
37
|
-
_hue?: ColorHueKey
|
|
38
|
-
bg?: ThemeColorTokenValue
|
|
39
|
-
fg?: ThemeColorTokenValue
|
|
40
|
-
dot?: ThemeColorTokenValue
|
|
41
|
-
icon?: ThemeColorTokenValue
|
|
42
|
-
}
|
|
43
|
-
|
|
44
35
|
/** @public */
|
|
45
36
|
export interface ThemeColorBaseTokens extends ThemeColorStateTokens {
|
|
46
37
|
focusRing?: ThemeColorTokenValue
|
|
@@ -64,14 +55,9 @@ export interface ThemeColorBadgeToneTokens {
|
|
|
64
55
|
}
|
|
65
56
|
|
|
66
57
|
/** @public */
|
|
67
|
-
export
|
|
68
|
-
'*'
|
|
69
|
-
|
|
70
|
-
'primary'?: ThemeColorBadgeToneTokens
|
|
71
|
-
'positive'?: ThemeColorBadgeToneTokens
|
|
72
|
-
'caution'?: ThemeColorBadgeToneTokens
|
|
73
|
-
'critical'?: ThemeColorBadgeToneTokens
|
|
74
|
-
}
|
|
58
|
+
export type ThemeColorBadgeTokens = Partial<
|
|
59
|
+
Record<'*' | ThemeColorStateToneKey, ThemeColorBadgeToneTokens>
|
|
60
|
+
>
|
|
75
61
|
|
|
76
62
|
/** @public */
|
|
77
63
|
export interface ThemeColorStateTokens {
|
|
@@ -74,6 +74,7 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
74
74
|
},
|
|
75
75
|
},
|
|
76
76
|
'primary': {_hue: 'blue'},
|
|
77
|
+
'suggest': {_hue: 'purple'},
|
|
77
78
|
'positive': {
|
|
78
79
|
_hue: 'green',
|
|
79
80
|
shadow: {outline: ['500/0.4', '500/0.4']},
|
|
@@ -133,7 +134,7 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
133
134
|
},
|
|
134
135
|
},
|
|
135
136
|
'hovered': {
|
|
136
|
-
bg: ['
|
|
137
|
+
bg: ['600', '300'],
|
|
137
138
|
border: ['700/0', '300/0'],
|
|
138
139
|
},
|
|
139
140
|
'pressed': {
|
|
@@ -260,11 +261,11 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
260
261
|
fg: ['700', '300'],
|
|
261
262
|
},
|
|
262
263
|
'pressed': {
|
|
263
|
-
bg: ['
|
|
264
|
+
bg: ['200', '800'],
|
|
264
265
|
fg: ['800', '200'],
|
|
265
266
|
},
|
|
266
267
|
'selected': {
|
|
267
|
-
bg: ['
|
|
268
|
+
bg: ['200', '800'],
|
|
268
269
|
fg: ['800', '200'],
|
|
269
270
|
},
|
|
270
271
|
'disabled': {
|
|
@@ -368,7 +369,8 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
368
369
|
},
|
|
369
370
|
'hovered': {
|
|
370
371
|
bg: ['50', '950'],
|
|
371
|
-
|
|
372
|
+
fg: ['800', '200'],
|
|
373
|
+
icon: ['800 70%', '300 70%'],
|
|
372
374
|
},
|
|
373
375
|
'pressed': {
|
|
374
376
|
bg: ['100', '900'],
|
|
@@ -427,7 +429,7 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
427
429
|
'*': {
|
|
428
430
|
_blend: ['multiply', 'screen'],
|
|
429
431
|
bg: ['white', 'black'],
|
|
430
|
-
border: ['200', '
|
|
432
|
+
border: ['200', '700'],
|
|
431
433
|
fg: ['black', '200'],
|
|
432
434
|
muted: {
|
|
433
435
|
bg: ['50', '950'],
|
|
@@ -443,6 +445,7 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
443
445
|
fg: ['800', '200'],
|
|
444
446
|
},
|
|
445
447
|
'disabled': {
|
|
448
|
+
bg: ['50', '950'],
|
|
446
449
|
fg: ['400', '600'],
|
|
447
450
|
border: ['100', '900'],
|
|
448
451
|
placeholder: ['200', '800 50%'],
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import {defaultThemeConfig} from './defaults/config'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
RootTheme,
|
|
4
|
+
RootTheme_v2,
|
|
5
|
+
Theme,
|
|
6
|
+
ThemeColor,
|
|
7
|
+
ThemeColorCardToneKey,
|
|
8
|
+
ThemeColorSchemeKey,
|
|
9
|
+
} from './system'
|
|
3
10
|
import {is_v2, v0_v2, v2_v0} from './versioning'
|
|
4
11
|
|
|
5
12
|
// cache[scheme][tone][rootTheme] = theme
|
|
@@ -22,7 +29,7 @@ export function getScopedTheme(
|
|
|
22
29
|
const v2 = is_v2(themeProp) ? themeProp : v0_v2(themeProp)
|
|
23
30
|
|
|
24
31
|
const colorScheme_v0 = v0.color[scheme] || v0.color.light
|
|
25
|
-
const color_v0 = colorScheme_v0[tone] || colorScheme_v0.default
|
|
32
|
+
const color_v0 = (colorScheme_v0 as Record<string, ThemeColor>)[tone] || colorScheme_v0.default
|
|
26
33
|
const layer_v0 = v0.layer || defaultThemeConfig.layer
|
|
27
34
|
|
|
28
35
|
const colorScheme_v2 = v2.color[scheme] || v2.color.light
|
|
@@ -10,7 +10,9 @@ export const THEME_COLOR_BLEND_MODES = ['multiply', 'screen'] as const
|
|
|
10
10
|
export const THEME_COLOR_CARD_TONES = [
|
|
11
11
|
'transparent',
|
|
12
12
|
'default',
|
|
13
|
-
'
|
|
13
|
+
'neutral',
|
|
14
|
+
'primary', // deprecated
|
|
15
|
+
'suggest',
|
|
14
16
|
'positive',
|
|
15
17
|
'caution',
|
|
16
18
|
'critical',
|
|
@@ -19,7 +21,9 @@ export const THEME_COLOR_CARD_TONES = [
|
|
|
19
21
|
/** @public */
|
|
20
22
|
export const THEME_COLOR_STATE_TONES = [
|
|
21
23
|
'default',
|
|
22
|
-
'
|
|
24
|
+
'neutral',
|
|
25
|
+
'primary', // deprecated
|
|
26
|
+
'suggest',
|
|
23
27
|
'positive',
|
|
24
28
|
'caution',
|
|
25
29
|
'critical',
|