@sanity/ui 2.0.0-beta.9 → 2.0.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/LICENSE +1 -1
- package/dist/index.esm.js +53 -30
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +53 -30
- package/dist/index.js.map +1 -1
- package/dist/theme.d.ts +12 -1
- package/dist/theme.esm.js +99 -78
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +99 -78
- package/dist/theme.js.map +1 -1
- package/package.json +2 -2
- package/src/core/__workshop__/fontsPlugin.tsx +48 -8
- package/src/core/components/dialog/dialog.tsx +1 -1
- package/src/core/components/dialog/styles.ts +2 -2
- package/src/core/components/toast/toast.tsx +17 -2
- package/src/core/components/toast/toastProvider.tsx +20 -3
- package/src/core/constants.ts +22 -3
- package/src/core/primitives/button/button.tsx +10 -12
- package/src/core/primitives/heading/styles.ts +4 -0
- package/src/core/primitives/popover/popoverCard.tsx +7 -2
- package/src/core/primitives/switch/styles.ts +5 -0
- package/src/core/primitives/textInput/__workshop__/plain.tsx +1 -1
- package/src/core/primitives/textInput/__workshop__/states.tsx +10 -2
- package/src/core/primitives/tooltip/tooltipCard.tsx +9 -3
- package/src/core/styles/input/textInputStyle.ts +33 -2
- package/src/core/theme/__workshop__/debug/story.tsx +65 -28
- package/src/theme/build/buildColorTheme.test.ts +2 -2
- package/src/theme/defaults/colorTokens.ts +90 -72
- package/src/theme/defaults/config.ts +1 -1
- package/src/theme/getScopedTheme.ts +1 -0
- package/src/theme/system/color/state.ts +6 -0
- package/src/theme/system/theme.ts +9 -1
- package/src/theme/system/v0/color/color.ts +0 -1
- package/src/theme/versioning/getTheme_v2.ts +2 -1
- package/src/theme/versioning/v2_v0.ts +1 -0
|
@@ -14,7 +14,7 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
14
14
|
fg: ['white', 'black'],
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
|
-
backdrop: ['gray/200/0.
|
|
17
|
+
backdrop: ['gray/200/0.5', 'black/0.5'],
|
|
18
18
|
badge: {
|
|
19
19
|
'*': {
|
|
20
20
|
bg: ['100', '900'],
|
|
@@ -35,10 +35,11 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
35
35
|
border: ['200', '800'],
|
|
36
36
|
code: {
|
|
37
37
|
bg: ['50', '950'],
|
|
38
|
-
fg: ['600', '
|
|
38
|
+
fg: ['600', '400'],
|
|
39
39
|
},
|
|
40
40
|
fg: ['800', '200'],
|
|
41
41
|
focusRing: ['blue/500', 'blue/500'],
|
|
42
|
+
icon: ['600', '400'],
|
|
42
43
|
kbd: {
|
|
43
44
|
bg: ['white', 'black'],
|
|
44
45
|
fg: ['600', '400'],
|
|
@@ -49,7 +50,7 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
49
50
|
},
|
|
50
51
|
muted: {
|
|
51
52
|
bg: ['50', '950'],
|
|
52
|
-
fg: ['700
|
|
53
|
+
fg: ['700 75%', '300 75%'],
|
|
53
54
|
},
|
|
54
55
|
shadow: {
|
|
55
56
|
outline: ['500/0.3', '500/0.4'],
|
|
@@ -64,14 +65,10 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
64
65
|
},
|
|
65
66
|
transparent: {
|
|
66
67
|
bg: ['50', 'black'],
|
|
67
|
-
fg: ['600', '400'],
|
|
68
|
-
muted: {
|
|
69
|
-
fg: ['600', '400'],
|
|
70
|
-
},
|
|
71
68
|
},
|
|
72
69
|
default: {
|
|
73
70
|
bg: ['white', '950'],
|
|
74
|
-
fg: ['
|
|
71
|
+
fg: ['800', '200'],
|
|
75
72
|
muted: {
|
|
76
73
|
fg: ['600', '400'],
|
|
77
74
|
},
|
|
@@ -95,6 +92,13 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
95
92
|
accent: {
|
|
96
93
|
fg: ['purple/300', 'purple/700'],
|
|
97
94
|
},
|
|
95
|
+
avatar: {
|
|
96
|
+
'*': {
|
|
97
|
+
_blend: ['multiply', 'screen'],
|
|
98
|
+
bg: ['white', 'black'],
|
|
99
|
+
fg: ['black', 'white'],
|
|
100
|
+
},
|
|
101
|
+
},
|
|
98
102
|
badge: {
|
|
99
103
|
'*': {
|
|
100
104
|
bg: ['900', '100'],
|
|
@@ -110,18 +114,18 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
110
114
|
fg: ['200', '600'],
|
|
111
115
|
},
|
|
112
116
|
fg: ['white', 'black'],
|
|
113
|
-
icon: ['
|
|
117
|
+
icon: ['100 70%', '900 70%'],
|
|
114
118
|
kbd: {
|
|
115
119
|
bg: ['black', 'white'],
|
|
116
|
-
fg: ['200', '
|
|
120
|
+
fg: ['200', '600'],
|
|
117
121
|
border: ['800', '200'],
|
|
118
122
|
},
|
|
119
123
|
link: {
|
|
120
|
-
fg: ['blue/200', 'blue/
|
|
124
|
+
fg: ['blue/200', 'blue/600'],
|
|
121
125
|
},
|
|
122
126
|
muted: {
|
|
123
127
|
bg: ['950', '50'],
|
|
124
|
-
fg: ['100 70%', '
|
|
128
|
+
fg: ['100 70%', '900 70%'],
|
|
125
129
|
},
|
|
126
130
|
skeleton: {
|
|
127
131
|
from: ['900', '100'],
|
|
@@ -140,6 +144,9 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
140
144
|
},
|
|
141
145
|
disabled: {
|
|
142
146
|
_hue: 'gray',
|
|
147
|
+
accent: {
|
|
148
|
+
fg: ['100 70%', '900 70%'],
|
|
149
|
+
},
|
|
143
150
|
badge: {
|
|
144
151
|
'*': {
|
|
145
152
|
bg: ['gray/700', 'gray/300'],
|
|
@@ -149,12 +156,14 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
149
156
|
},
|
|
150
157
|
},
|
|
151
158
|
bg: ['200', '800'],
|
|
152
|
-
icon: ['white', 'black'],
|
|
153
159
|
kbd: {
|
|
154
160
|
bg: ['black', 'white'],
|
|
155
161
|
fg: ['white', 'black'],
|
|
156
162
|
border: ['700', '300'],
|
|
157
163
|
},
|
|
164
|
+
link: {
|
|
165
|
+
fg: ['100 70%', '900 70%'],
|
|
166
|
+
},
|
|
158
167
|
},
|
|
159
168
|
},
|
|
160
169
|
default: {
|
|
@@ -198,7 +207,7 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
198
207
|
fg: ['700 60%', '400 60%'],
|
|
199
208
|
},
|
|
200
209
|
fg: ['600', '400'],
|
|
201
|
-
icon: ['
|
|
210
|
+
icon: ['700 60%', '300 60%'],
|
|
202
211
|
kbd: {
|
|
203
212
|
bg: ['white', 'black'],
|
|
204
213
|
fg: ['600', '400'],
|
|
@@ -291,14 +300,14 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
291
300
|
bg: ['white', 'black'],
|
|
292
301
|
border: ['white/0', 'black/0'],
|
|
293
302
|
code: {
|
|
294
|
-
bg: ['
|
|
295
|
-
fg: ['
|
|
303
|
+
bg: ['50', '950'],
|
|
304
|
+
fg: ['700 75%', '300 75%'],
|
|
296
305
|
},
|
|
297
306
|
fg: ['700', '300'],
|
|
298
|
-
icon: ['700
|
|
307
|
+
icon: ['700 75%', '300 75%'],
|
|
299
308
|
kbd: {
|
|
300
309
|
bg: ['white', 'black'],
|
|
301
|
-
fg: ['
|
|
310
|
+
fg: ['700', '300'],
|
|
302
311
|
border: ['200', '800'],
|
|
303
312
|
},
|
|
304
313
|
link: {
|
|
@@ -306,7 +315,7 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
306
315
|
},
|
|
307
316
|
muted: {
|
|
308
317
|
bg: ['100', '950'],
|
|
309
|
-
fg: ['700
|
|
318
|
+
fg: ['700 75%', '300 75%'],
|
|
310
319
|
},
|
|
311
320
|
skeleton: {
|
|
312
321
|
from: ['100', '900'],
|
|
@@ -315,7 +324,6 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
315
324
|
},
|
|
316
325
|
hovered: {
|
|
317
326
|
bg: ['50', '950'],
|
|
318
|
-
fg: ['700', '300'],
|
|
319
327
|
icon: ['700 70%', '400 70%'],
|
|
320
328
|
},
|
|
321
329
|
pressed: {
|
|
@@ -330,6 +338,9 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
330
338
|
},
|
|
331
339
|
disabled: {
|
|
332
340
|
_hue: 'gray',
|
|
341
|
+
accent: {
|
|
342
|
+
fg: ['200', '800'],
|
|
343
|
+
},
|
|
333
344
|
badge: {
|
|
334
345
|
'*': {
|
|
335
346
|
_hue: 'gray',
|
|
@@ -339,13 +350,12 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
339
350
|
icon: ['gray/200', 'gray/800'],
|
|
340
351
|
},
|
|
341
352
|
},
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
fg: ['200', '800'],
|
|
345
|
-
},
|
|
346
|
-
accent: {
|
|
353
|
+
code: {
|
|
354
|
+
bg: ['50', '950'],
|
|
347
355
|
fg: ['200', '800'],
|
|
348
356
|
},
|
|
357
|
+
fg: ['200', '800'],
|
|
358
|
+
icon: ['200', '800'],
|
|
349
359
|
kbd: {
|
|
350
360
|
bg: ['white', 'black'],
|
|
351
361
|
fg: ['200', '800'],
|
|
@@ -354,8 +364,7 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
354
364
|
link: {
|
|
355
365
|
fg: ['200', '800'],
|
|
356
366
|
},
|
|
357
|
-
|
|
358
|
-
bg: ['50', '950'],
|
|
367
|
+
muted: {
|
|
359
368
|
fg: ['200', '800'],
|
|
360
369
|
},
|
|
361
370
|
},
|
|
@@ -398,15 +407,8 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
398
407
|
'*': {
|
|
399
408
|
'*': {
|
|
400
409
|
_blend: ['multiply', 'screen'],
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
icon: ['700 70%', '300 70%'],
|
|
404
|
-
avatar: {
|
|
405
|
-
'*': {
|
|
406
|
-
_blend: ['screen', 'multiply'],
|
|
407
|
-
bg: ['500', '400'],
|
|
408
|
-
fg: ['white', 'black'],
|
|
409
|
-
},
|
|
410
|
+
accent: {
|
|
411
|
+
fg: ['purple/700 70%', 'purple/300 70%'],
|
|
410
412
|
},
|
|
411
413
|
badge: {
|
|
412
414
|
'*': {
|
|
@@ -416,25 +418,25 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
416
418
|
icon: ['500', '500'],
|
|
417
419
|
},
|
|
418
420
|
},
|
|
421
|
+
bg: ['white', 'black'],
|
|
419
422
|
border: ['200', '800'],
|
|
420
|
-
|
|
423
|
+
code: {
|
|
421
424
|
bg: ['50', '950'],
|
|
422
|
-
fg: ['
|
|
423
|
-
},
|
|
424
|
-
accent: {
|
|
425
|
-
fg: ['purple/600', 'purple/400'],
|
|
425
|
+
fg: ['600', '400'],
|
|
426
426
|
},
|
|
427
|
+
fg: ['700', '300'],
|
|
428
|
+
icon: ['700 75%', '300 75%'],
|
|
427
429
|
kbd: {
|
|
428
430
|
bg: ['white', 'black'],
|
|
429
431
|
fg: ['600', '400'],
|
|
430
432
|
border: ['200', '800'],
|
|
431
433
|
},
|
|
432
434
|
link: {
|
|
433
|
-
fg: ['blue/700', 'blue/300'],
|
|
435
|
+
fg: ['blue/700 70%', 'blue/300 70%'],
|
|
434
436
|
},
|
|
435
|
-
|
|
436
|
-
bg: ['
|
|
437
|
-
fg: ['700', '300'],
|
|
437
|
+
muted: {
|
|
438
|
+
bg: ['100', '950'],
|
|
439
|
+
fg: ['700 75%', '300 75%'],
|
|
438
440
|
},
|
|
439
441
|
skeleton: {
|
|
440
442
|
from: ['100', '900'],
|
|
@@ -449,9 +451,9 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
449
451
|
},
|
|
450
452
|
selected: {
|
|
451
453
|
_blend: ['screen', 'multiply'],
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
454
|
+
accent: {
|
|
455
|
+
fg: ['purple/300', 'purple/700'],
|
|
456
|
+
},
|
|
455
457
|
avatar: {
|
|
456
458
|
'*': {
|
|
457
459
|
_blend: ['multiply', 'screen'],
|
|
@@ -461,31 +463,31 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
461
463
|
},
|
|
462
464
|
badge: {
|
|
463
465
|
'*': {
|
|
464
|
-
bg: ['
|
|
465
|
-
fg: ['
|
|
466
|
-
dot: ['
|
|
467
|
-
icon: ['
|
|
466
|
+
bg: ['900', '100'],
|
|
467
|
+
fg: ['400', '600'],
|
|
468
|
+
dot: ['500', '500'],
|
|
469
|
+
icon: ['500', '500'],
|
|
468
470
|
},
|
|
469
471
|
},
|
|
472
|
+
bg: ['500', '400'],
|
|
470
473
|
border: ['500 20%', '400 20%'],
|
|
471
|
-
|
|
472
|
-
bg: ['
|
|
473
|
-
fg: ['200', '
|
|
474
|
-
},
|
|
475
|
-
accent: {
|
|
476
|
-
fg: ['purple/200', 'purple/800'],
|
|
474
|
+
code: {
|
|
475
|
+
bg: ['500 20%', '400 20%'],
|
|
476
|
+
fg: ['200', '600'],
|
|
477
477
|
},
|
|
478
|
+
fg: ['white', 'black'],
|
|
479
|
+
icon: ['100 70%', '900 70%'],
|
|
478
480
|
kbd: {
|
|
479
|
-
bg: ['black
|
|
480
|
-
fg: ['
|
|
481
|
-
border: ['
|
|
481
|
+
bg: ['black', 'white'],
|
|
482
|
+
fg: ['200', '600'],
|
|
483
|
+
border: ['800', '200'],
|
|
482
484
|
},
|
|
483
485
|
link: {
|
|
484
|
-
fg: ['blue/200', 'blue/
|
|
486
|
+
fg: ['blue/200', 'blue/600'],
|
|
485
487
|
},
|
|
486
|
-
|
|
487
|
-
bg: ['
|
|
488
|
-
fg: ['
|
|
488
|
+
muted: {
|
|
489
|
+
bg: ['950', '50'],
|
|
490
|
+
fg: ['100 70%', '900 70%'],
|
|
489
491
|
},
|
|
490
492
|
skeleton: {
|
|
491
493
|
from: ['900', '100'],
|
|
@@ -493,19 +495,35 @@ export const defaultColorTokens: ThemeColorTokens = {
|
|
|
493
495
|
},
|
|
494
496
|
},
|
|
495
497
|
disabled: {
|
|
498
|
+
_hue: 'gray',
|
|
499
|
+
accent: {
|
|
500
|
+
fg: ['200', '800'],
|
|
501
|
+
},
|
|
502
|
+
badge: {
|
|
503
|
+
'*': {
|
|
504
|
+
_hue: 'gray',
|
|
505
|
+
bg: ['50', '950'],
|
|
506
|
+
fg: ['gray/200', 'gray/800'],
|
|
507
|
+
dot: ['gray/200', 'gray/800'],
|
|
508
|
+
icon: ['gray/200', 'gray/800'],
|
|
509
|
+
},
|
|
510
|
+
},
|
|
511
|
+
border: ['100', '900'],
|
|
512
|
+
code: {
|
|
513
|
+
bg: ['50', '950'],
|
|
514
|
+
fg: ['200', '800'],
|
|
515
|
+
},
|
|
496
516
|
fg: ['200', '800'],
|
|
497
517
|
icon: ['200', '800'],
|
|
498
|
-
|
|
518
|
+
kbd: {
|
|
519
|
+
bg: ['white', 'black'],
|
|
499
520
|
fg: ['200', '800'],
|
|
500
|
-
|
|
501
|
-
accent: {
|
|
502
|
-
fg: ['purple/200', 'purple/800'],
|
|
521
|
+
border: ['100', '900'],
|
|
503
522
|
},
|
|
504
523
|
link: {
|
|
505
|
-
fg: ['
|
|
524
|
+
fg: ['200', '800'],
|
|
506
525
|
},
|
|
507
|
-
|
|
508
|
-
bg: ['50', '950'],
|
|
526
|
+
muted: {
|
|
509
527
|
fg: ['200', '800'],
|
|
510
528
|
},
|
|
511
529
|
},
|
|
@@ -24,7 +24,7 @@ export const defaultThemeConfig: Omit<RootTheme_v2, 'color' | 'font'> = {
|
|
|
24
24
|
focusRing: {offset: -1, width: 1},
|
|
25
25
|
shadow: {outline: OUTLINE_WIDTH},
|
|
26
26
|
},
|
|
27
|
-
container: [
|
|
27
|
+
container: [320, 640, 960, 1280, 1600, 1920],
|
|
28
28
|
media: [360, 600, 900, 1200, 1800, 2400],
|
|
29
29
|
layer: {
|
|
30
30
|
dialog: {zOffset: 600},
|
|
@@ -12,7 +12,13 @@ export interface ThemeColorState_v2 {
|
|
|
12
12
|
accent: {
|
|
13
13
|
fg: string
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* @internal This may be removed in a future release
|
|
17
|
+
* */
|
|
15
18
|
avatar: ThemeColorAvatar_v2
|
|
19
|
+
/**
|
|
20
|
+
* @internal This may be removed in a future release
|
|
21
|
+
* */
|
|
16
22
|
badge: ThemeColorBadge_v2
|
|
17
23
|
bg: string
|
|
18
24
|
border: string
|
|
@@ -114,7 +114,15 @@ export type RootTheme = BaseTheme
|
|
|
114
114
|
/**
|
|
115
115
|
* @public
|
|
116
116
|
*/
|
|
117
|
-
export type Theme_v2 = Omit<RootTheme_v2, 'color'> & {
|
|
117
|
+
export type Theme_v2 = Omit<RootTheme_v2, 'color'> & {
|
|
118
|
+
color: ThemeColorCard_v2
|
|
119
|
+
/**
|
|
120
|
+
* Indicates whether the theme is resolved or raw, it's necessary to avoid issues
|
|
121
|
+
* with sanity V2 components accessing a v1 <ThemeProvider>.
|
|
122
|
+
* See https://github.com/sanity-io/ui/pull/1203 for more info.
|
|
123
|
+
*/
|
|
124
|
+
_resolved: boolean
|
|
125
|
+
}
|
|
118
126
|
|
|
119
127
|
/**
|
|
120
128
|
* @public
|
|
@@ -6,7 +6,7 @@ const cache = new WeakMap<Theme, Theme_v2>()
|
|
|
6
6
|
|
|
7
7
|
/** @public */
|
|
8
8
|
export function getTheme_v2(theme: Theme): Theme_v2 {
|
|
9
|
-
if (theme.sanity.v2) return theme.sanity.v2
|
|
9
|
+
if (theme.sanity.v2?._resolved) return theme.sanity.v2
|
|
10
10
|
|
|
11
11
|
const cached_v2 = cache.get(theme)
|
|
12
12
|
|
|
@@ -14,6 +14,7 @@ export function getTheme_v2(theme: Theme): Theme_v2 {
|
|
|
14
14
|
|
|
15
15
|
const v2: Theme_v2 = {
|
|
16
16
|
_version: 2,
|
|
17
|
+
_resolved: true,
|
|
17
18
|
avatar: {
|
|
18
19
|
...defaultThemeConfig.avatar,
|
|
19
20
|
...theme.sanity.avatar,
|
|
@@ -91,6 +91,7 @@ function themeColor_v2_v0(color_v2: ThemeColorCard_v2): ThemeColor {
|
|
|
91
91
|
...color_v2.button.default,
|
|
92
92
|
transparent: color_v2.button.default.default,
|
|
93
93
|
},
|
|
94
|
+
selectable: color_v2.selectable,
|
|
94
95
|
spot: {
|
|
95
96
|
gray: color_v2.avatar.gray.bg,
|
|
96
97
|
blue: color_v2.avatar.blue.bg,
|