@sanity/ui 2.0.0-alpha.34 → 2.0.0-alpha.36

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.
Files changed (163) hide show
  1. package/dist/index.cjs.mjs +4 -3
  2. package/dist/index.d.ts +29 -22
  3. package/dist/index.esm.js +397 -518
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/index.js +413 -534
  6. package/dist/index.js.map +1 -1
  7. package/dist/theme.cjs.mjs +10 -4
  8. package/dist/theme.d.ts +489 -201
  9. package/dist/theme.esm.js +2934 -2748
  10. package/dist/theme.esm.js.map +1 -1
  11. package/dist/theme.js +2943 -2751
  12. package/dist/theme.js.map +1 -1
  13. package/package.json +3 -3
  14. package/src/core/_compat.ts +7 -7
  15. package/src/core/components/dialog/dialog.tsx +5 -5
  16. package/src/core/components/dialog/styles.ts +4 -5
  17. package/src/core/components/hotkeys/hotkeys.tsx +4 -2
  18. package/src/core/components/menu/__workshop__/avatarMenu.tsx +50 -0
  19. package/src/core/components/menu/__workshop__/index.ts +5 -0
  20. package/src/core/components/menu/menuItem.tsx +7 -1
  21. package/src/core/components/skeleton/textSkeleton.tsx +12 -14
  22. package/src/core/components/tree/style.ts +14 -17
  23. package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +3 -3
  24. package/src/core/hooks/useMediaIndex/useMediaIndex.ts +2 -3
  25. package/src/core/primitives/_selectable/style.ts +18 -18
  26. package/src/core/primitives/avatar/avatar.tsx +3 -3
  27. package/src/core/primitives/avatar/avatarCounter.tsx +4 -4
  28. package/src/core/primitives/avatar/avatarStack.tsx +2 -2
  29. package/src/core/primitives/avatar/styles.ts +7 -8
  30. package/src/core/primitives/avatar/types.ts +2 -2
  31. package/src/core/primitives/badge/__workshop__/props.tsx +1 -1
  32. package/src/core/primitives/badge/__workshop__/tones.tsx +1 -1
  33. package/src/core/primitives/badge/badge.tsx +1 -1
  34. package/src/core/primitives/badge/styles.ts +5 -6
  35. package/src/core/primitives/button/button.tsx +3 -4
  36. package/src/core/primitives/button/styles.ts +22 -23
  37. package/src/core/primitives/card/__workshop__/selected.tsx +15 -15
  38. package/src/core/primitives/card/card.tsx +1 -1
  39. package/src/core/primitives/card/styles.ts +22 -22
  40. package/src/core/primitives/checkbox/styles.ts +21 -22
  41. package/src/core/primitives/code/styles.ts +4 -1
  42. package/src/core/primitives/container/styles.ts +2 -3
  43. package/src/core/primitives/heading/styles.ts +4 -2
  44. package/src/core/primitives/inline/styles.ts +6 -6
  45. package/src/core/primitives/kbd/kbd.tsx +7 -11
  46. package/src/core/primitives/label/styles.ts +4 -3
  47. package/src/core/primitives/popover/helpers.ts +3 -4
  48. package/src/core/primitives/popover/popover.tsx +8 -4
  49. package/src/core/primitives/popover/types.ts +1 -1
  50. package/src/core/primitives/radio/styles.ts +17 -19
  51. package/src/core/primitives/select/styles.ts +27 -32
  52. package/src/core/primitives/stack/styles.ts +2 -3
  53. package/src/core/primitives/switch/__workshop__/props.tsx +11 -31
  54. package/src/core/primitives/switch/styles.ts +18 -21
  55. package/src/core/primitives/text/__workshop__/colored.tsx +10 -10
  56. package/src/core/primitives/text/styles.ts +9 -4
  57. package/src/core/primitives/tooltip/tooltip.tsx +3 -3
  58. package/src/core/styles/border/borderStyle.ts +6 -11
  59. package/src/core/styles/box/boxStyle.ts +5 -9
  60. package/src/core/styles/card/_cardColorStyle.ts +99 -0
  61. package/src/core/styles/card/index.ts +1 -0
  62. package/src/core/styles/flex/flexItemStyle.ts +2 -3
  63. package/src/core/styles/flex/flexStyle.ts +6 -11
  64. package/src/core/styles/font/responsiveFont.ts +4 -4
  65. package/src/core/styles/font/textAlignStyle.ts +3 -3
  66. package/src/core/styles/grid/gridItemStyle.ts +7 -13
  67. package/src/core/styles/grid/gridStyle.ts +9 -17
  68. package/src/core/styles/helpers.ts +5 -3
  69. package/src/core/styles/input/responsiveInputPaddingStyle.ts +6 -6
  70. package/src/core/styles/input/textInputStyle.ts +36 -40
  71. package/src/core/styles/margin/marginsStyle.test.ts +2 -3
  72. package/src/core/styles/padding/paddingStyle.test.ts +2 -3
  73. package/src/core/styles/radius/radiusStyle.ts +2 -3
  74. package/src/core/styles/shadow/shadowStyle.ts +4 -5
  75. package/src/core/theme/__workshop__/build/Root.tsx +24 -20
  76. package/src/core/theme/__workshop__/build/story.tsx +22 -26
  77. package/src/core/theme/__workshop__/canvas.tsx +21 -40
  78. package/src/core/theme/theme.test.tsx +2 -35
  79. package/src/core/theme/themeColorProvider.tsx +2 -2
  80. package/src/core/theme/themeContext.ts +2 -2
  81. package/src/core/theme/themeProvider.tsx +25 -25
  82. package/src/core/theme/types.ts +3 -2
  83. package/src/core/theme/useRootTheme.ts +1 -9
  84. package/src/core/theme/useTheme.ts +8 -1
  85. package/src/core/types/card.ts +2 -2
  86. package/src/core/utils/arrow/arrow.tsx +3 -3
  87. package/src/core/utils/elementQuery/elementQuery.tsx +3 -3
  88. package/src/core/utils/virtualList/virtualList.tsx +2 -2
  89. package/src/theme/build/_deprecated/color/muted/createMuted.ts +2 -2
  90. package/src/theme/build/buildColorTheme.test.ts +14 -15
  91. package/src/theme/build/buildColorTheme.ts +239 -292
  92. package/src/theme/build/buildTheme.test.ts +9 -7
  93. package/src/theme/build/buildTheme.ts +12 -9
  94. package/src/theme/build/colorToken.ts +3 -1
  95. package/src/theme/build/lib/color-fns/contrastRatio.ts +1 -0
  96. package/src/theme/build/lib/isRecord.ts +3 -0
  97. package/src/theme/build/merge.ts +18 -13
  98. package/src/theme/build/renderColorTheme.ts +205 -213
  99. package/src/theme/build/renderColorValue.ts +15 -8
  100. package/src/theme/build/resolveColorTokens.ts +177 -198
  101. package/src/theme/build/theme.test.ts +27 -0
  102. package/src/theme/config/helpers.ts +16 -8
  103. package/src/theme/config/system.ts +46 -17
  104. package/src/theme/config/tokens/color/types.ts +55 -32
  105. package/src/theme/config/tokens/types.ts +11 -4
  106. package/src/theme/config/types.ts +5 -11
  107. package/src/theme/{build/defaults → defaults}/colorPalette.ts +1 -1
  108. package/src/theme/{build/defaults → defaults}/colorTokens.ts +189 -136
  109. package/src/theme/{build/defaults → defaults}/config.ts +14 -12
  110. package/src/theme/{build/defaults → defaults}/fonts.ts +6 -6
  111. package/src/theme/getScopedTheme.ts +81 -0
  112. package/src/theme/index.ts +9 -1
  113. package/src/theme/system/avatar.ts +1 -1
  114. package/src/theme/system/color/_constants.ts +11 -11
  115. package/src/theme/system/color/_system.ts +10 -71
  116. package/src/theme/system/color/avatar.ts +22 -10
  117. package/src/theme/system/color/badge.ts +18 -7
  118. package/src/theme/system/color/button.ts +17 -23
  119. package/src/theme/system/color/color.ts +34 -0
  120. package/src/theme/system/color/index.ts +3 -10
  121. package/src/theme/system/color/input.ts +13 -11
  122. package/src/theme/system/color/kbd.ts +3 -3
  123. package/src/theme/system/color/selectable.ts +13 -19
  124. package/src/theme/system/color/shadow.ts +7 -0
  125. package/src/theme/system/color/state.ts +37 -0
  126. package/src/theme/system/css.ts +9 -0
  127. package/src/theme/system/focusRing.ts +7 -0
  128. package/src/theme/system/index.ts +5 -1
  129. package/src/theme/system/input.ts +1 -1
  130. package/src/theme/system/layer.ts +1 -2
  131. package/src/theme/system/shadow.ts +1 -0
  132. package/src/theme/system/styles.ts +19 -0
  133. package/src/theme/system/theme.ts +128 -0
  134. package/src/theme/system/{color → v0/color}/_generic.ts +2 -1
  135. package/src/theme/system/v0/color/_system.ts +13 -0
  136. package/src/theme/system/{color → v0/color}/base.ts +2 -0
  137. package/src/theme/system/v0/color/button.ts +42 -0
  138. package/src/theme/system/{color → v0/color}/card.ts +2 -1
  139. package/src/theme/system/v0/color/color.ts +40 -0
  140. package/src/theme/system/v0/color/index.ts +11 -0
  141. package/src/theme/system/v0/color/input.ts +34 -0
  142. package/src/theme/system/{color/_deprecated → v0/color}/muted.ts +1 -1
  143. package/src/theme/system/v0/color/selectable.ts +31 -0
  144. package/src/theme/system/{color/_deprecated → v0/color}/solid.ts +1 -1
  145. package/src/theme/system/v0/color/spot.ts +13 -0
  146. package/src/theme/system/v0/index.ts +1 -0
  147. package/src/theme/versioning/getTheme_v2.ts +38 -0
  148. package/src/theme/versioning/index.ts +5 -0
  149. package/src/theme/versioning/is_v0.ts +6 -0
  150. package/src/theme/versioning/is_v2.ts +6 -0
  151. package/src/theme/versioning/themeColor_v0_v2.ts +217 -0
  152. package/src/theme/versioning/v0_v2.ts +72 -0
  153. package/src/theme/versioning/v2_v0.ts +126 -0
  154. package/src/core/styles/colorVars/colorVarsStyle.ts +0 -43
  155. package/src/core/styles/colorVars/index.ts +0 -1
  156. package/src/core/theme/defaults.ts +0 -7
  157. package/src/theme/system/_system.ts +0 -95
  158. package/src/theme/system/color/_deprecated/spot.ts +0 -13
  159. package/src/theme/themes/studio/config.ts +0 -69
  160. package/src/theme/themes/studio/fonts.ts +0 -219
  161. package/src/theme/themes/studio/index.ts +0 -1
  162. package/src/theme/themes/studio/studioTheme.test.ts +0 -27
  163. package/src/theme/themes/studio/studioTheme.ts +0 -8
@@ -1,36 +1,54 @@
1
- import {ThemeColorTokens} from '../../config'
1
+ import {ThemeColorTokens} from '../config'
2
2
 
3
3
  export const defaultColorTokens: ThemeColorTokens = {
4
- avatar: {
5
- '*': {
6
- _blend: ['screen', 'multiply'],
7
- _hue: 'gray',
8
- bg: ['500', '400'],
9
- fg: ['white', 'black'],
10
- },
11
- blue: {_hue: 'blue'},
12
- purple: {_hue: 'purple'},
13
- magenta: {_hue: 'magenta'},
14
- red: {_hue: 'red'},
15
- orange: {_hue: 'orange'},
16
- yellow: {_hue: 'yellow', bg: ['600', '400']},
17
- green: {_hue: 'green', bg: ['600', '400']},
18
- cyan: {_hue: 'cyan', bg: ['600', '400']},
19
- },
20
- badge: {
21
- '*': {
22
- _blend: ['multiply', 'screen'],
23
- bg: ['100', '900'],
24
- fg: ['800', '200'],
25
- },
26
- },
27
4
  base: {
28
5
  '*': {
29
6
  _blend: ['multiply', 'screen'],
7
+ avatar: {
8
+ '*': {
9
+ _blend: ['screen', 'multiply'],
10
+ bg: ['500', '400'],
11
+ fg: ['white', 'black'],
12
+ },
13
+ yellow: {bg: ['600', '400']},
14
+ green: {bg: ['600', '400']},
15
+ cyan: {bg: ['600', '400']},
16
+ },
17
+ backdrop: ['gray/200/0.2', 'black/0.5'],
18
+ badge: {
19
+ '*': {
20
+ bg: ['100', '900'],
21
+ fg: ['600', '400'],
22
+ },
23
+ positive: {
24
+ bg: ['200/0.6', '900'],
25
+ fg: ['700', '500'],
26
+ },
27
+ caution: {
28
+ bg: ['200/0.7', '900'],
29
+ fg: ['700', '500'],
30
+ },
31
+ },
30
32
  bg: ['50', '950'],
33
+ border: ['200', '800'],
34
+ code: {
35
+ bg: ['50', '950'],
36
+ fg: ['600', '400'],
37
+ },
31
38
  fg: ['800', '200'],
32
- border: ['200', '900'],
33
39
  focusRing: ['blue/500', 'blue/500'],
40
+ kbd: {
41
+ bg: ['white', 'black'],
42
+ fg: ['600', '400'],
43
+ border: ['200', '800'],
44
+ },
45
+ link: {
46
+ fg: ['blue/600', 'blue/400'],
47
+ },
48
+ muted: {
49
+ bg: ['50', '950'],
50
+ fg: ['600', '400'],
51
+ },
34
52
  shadow: {
35
53
  outline: ['500/0.3', '500/0.4'],
36
54
  umbra: ['gray/500/0.1', 'black/0.2'],
@@ -55,12 +73,21 @@ export const defaultColorTokens: ThemeColorTokens = {
55
73
  },
56
74
  positive: {
57
75
  _hue: 'green',
76
+ shadow: {
77
+ outline: ['600/0.3', '500/0.25'],
78
+ },
58
79
  },
59
80
  caution: {
60
81
  _hue: 'yellow',
82
+ shadow: {
83
+ outline: ['600/0.3', '500/0.25'],
84
+ },
61
85
  },
62
86
  critical: {
63
87
  _hue: 'red',
88
+ shadow: {
89
+ outline: ['500/0.3', '500/0.3'],
90
+ },
64
91
  },
65
92
  },
66
93
  button: {
@@ -68,22 +95,33 @@ export const defaultColorTokens: ThemeColorTokens = {
68
95
  '*': {
69
96
  '*': {
70
97
  _blend: ['screen', 'multiply'],
98
+ accent: {
99
+ fg: ['purple/200', 'purple/700'],
100
+ },
101
+ badge: {
102
+ '*': {
103
+ dot: ['300', '700'],
104
+ icon: ['600', '400'],
105
+ },
106
+ },
71
107
  bg: ['500', '400'],
72
- bg2: ['900', '50'],
73
- fg: ['white', 'black'],
74
- icon: ['200', '900'],
75
108
  border: ['500/0', '400/0'],
76
- muted: {
109
+ code: {
110
+ bg: ['500/0.2', '400/0.2'],
77
111
  fg: ['200', '700'],
78
112
  },
79
- accent: {
80
- fg: ['purple/200', 'purple/700'],
113
+ fg: ['white', 'black'],
114
+ icon: ['200', '800'],
115
+ kbd: {
116
+ bg: ['900', '50'],
117
+ fg: ['white', 'black'],
118
+ border: ['800', '200'],
81
119
  },
82
120
  link: {
83
121
  fg: ['blue/200', 'blue/700'],
84
122
  },
85
- code: {
86
- bg: ['500/0.2', '400/0.2'],
123
+ muted: {
124
+ bg: ['900', '50'],
87
125
  fg: ['200', '700'],
88
126
  },
89
127
  skeleton: {
@@ -103,7 +141,7 @@ export const defaultColorTokens: ThemeColorTokens = {
103
141
  },
104
142
  disabled: {
105
143
  _hue: 'gray',
106
- bg: ['200', '900'],
144
+ bg: ['200', '800'],
107
145
  icon: ['white', 'black'],
108
146
  },
109
147
  },
@@ -155,19 +193,19 @@ export const defaultColorTokens: ThemeColorTokens = {
155
193
  '*': {
156
194
  _blend: ['multiply', 'screen'],
157
195
  bg: ['50', '950'],
158
- bg2: ['100', '950'],
159
196
  fg: ['700', '400'],
160
197
  icon: ['600', '500'],
161
- border: ['200', '900'],
162
- muted: {
163
- fg: ['700/0.6', '400/0.6'],
164
- },
198
+ border: ['100', '900'],
165
199
  accent: {
166
200
  fg: ['purple/700/0.6', 'purple/400/0.8'],
167
201
  },
168
202
  link: {
169
203
  fg: ['blue/700/0.6', 'blue/400/0.8'],
170
204
  },
205
+ muted: {
206
+ bg: ['100', '950'],
207
+ fg: ['700/0.6', '400/0.6'],
208
+ },
171
209
  code: {
172
210
  bg: ['500/0.1', '400/0.1'],
173
211
  fg: ['700/0.6', '400/0.6'],
@@ -176,24 +214,30 @@ export const defaultColorTokens: ThemeColorTokens = {
176
214
  from: ['100', '900'],
177
215
  to: ['100/0.5', '900/0.5'],
178
216
  },
217
+ badge: {
218
+ '*': {
219
+ dot: ['300', '700'],
220
+ icon: ['600', '400'],
221
+ },
222
+ },
179
223
  },
180
224
  hovered: {
181
225
  bg: ['100', '900'],
182
- fg: ['700', '400'],
226
+ fg: ['700', '300'],
183
227
  },
184
228
  pressed: {
185
229
  bg: ['100', '900'],
186
- fg: ['800', '300'],
230
+ fg: ['800', '200'],
187
231
  },
188
232
  selected: {
189
233
  bg: ['100', '900'],
190
- fg: ['800', '300'],
234
+ fg: ['800', '200'],
191
235
  },
192
236
  disabled: {
193
237
  _hue: 'gray',
194
- fg: ['200', '900'],
195
- icon: ['200', '900'],
196
- border: ['100', '950'],
238
+ fg: ['200', '800'],
239
+ icon: ['200', '800'],
240
+ border: ['100', '900'],
197
241
  muted: {
198
242
  fg: ['200/0.6', '900/0.6'],
199
243
  },
@@ -209,9 +253,14 @@ export const defaultColorTokens: ThemeColorTokens = {
209
253
  },
210
254
  },
211
255
  },
212
- critical: {
256
+ positive: {
257
+ '*': {
258
+ border: ['600/0.2', '800'],
259
+ },
260
+ },
261
+ caution: {
213
262
  '*': {
214
- border: ['500/0.2', '900'],
263
+ border: ['600/0.2', '800'],
215
264
  },
216
265
  },
217
266
  },
@@ -220,18 +269,18 @@ export const defaultColorTokens: ThemeColorTokens = {
220
269
  '*': {
221
270
  _blend: ['multiply', 'screen'],
222
271
  bg: ['white', 'black'],
223
- bg2: ['100', '950'],
224
- fg: ['700', '400'],
225
- icon: ['600', '500'],
272
+ fg: ['700', '300'],
273
+ icon: ['700/0.7', '300/0.7'],
226
274
  border: ['white/0', 'black/0'],
227
275
  muted: {
228
- fg: ['600', '300'],
276
+ bg: ['100', '950'],
277
+ fg: ['700/0.7', '300/0.7'],
229
278
  },
230
279
  accent: {
231
- fg: ['purple/600', 'purple/300'],
280
+ fg: ['purple/700/0.7', 'purple/300/0.7'],
232
281
  },
233
282
  link: {
234
- fg: ['blue/600', 'blue/300'],
283
+ fg: ['blue/700/0.7', 'blue/300/0.7'],
235
284
  },
236
285
  code: {
237
286
  bg: ['100', '950'],
@@ -241,22 +290,31 @@ export const defaultColorTokens: ThemeColorTokens = {
241
290
  from: ['100', '900'],
242
291
  to: ['100/0.5', '900/0.5'],
243
292
  },
293
+ badge: {
294
+ '*': {
295
+ dot: ['300', '700'],
296
+ icon: ['600', '400'],
297
+ },
298
+ },
244
299
  },
245
300
  hovered: {
246
301
  bg: ['50', '950'],
247
- fg: ['700', '400'],
302
+ fg: ['700', '300'],
303
+ icon: ['700/0.7', '400/0.7'],
248
304
  },
249
305
  pressed: {
250
306
  bg: ['100', '900'],
251
- fg: ['800', '300'],
307
+ fg: ['800', '200'],
308
+ icon: ['800/0.7', '200/0.7'],
252
309
  },
253
310
  selected: {
254
311
  bg: ['100', '900'],
255
- fg: ['800', '300'],
312
+ fg: ['800', '200'],
313
+ icon: ['800/0.7', '200/0.7'],
256
314
  },
257
315
  disabled: {
258
316
  _hue: 'gray',
259
- fg: ['200', '900'],
317
+ fg: ['200', '800'],
260
318
  muted: {
261
319
  fg: ['200/0.6', '900/0.6'],
262
320
  },
@@ -274,73 +332,16 @@ export const defaultColorTokens: ThemeColorTokens = {
274
332
  },
275
333
  },
276
334
  },
277
- card: {
278
- '*': {
279
- _blend: ['multiply', 'screen'],
280
- bg: ['white', 'black'],
281
- bg2: ['100', '950'],
282
- fg: ['black', 'white'],
283
- icon: ['500', '400'],
284
- border: ['200', '900'],
285
- muted: {
286
- fg: ['gray/600', 'gray/400'],
287
- },
288
- accent: {
289
- fg: ['purple/600', 'purple/300'],
290
- },
291
- link: {
292
- fg: ['blue/700', 'blue/300'],
293
- },
294
- code: {
295
- bg: ['100', '950'],
296
- fg: ['gray/600', 'gray/400'],
297
- },
298
- skeleton: {
299
- from: ['100', '900'],
300
- to: ['100/0.5', '900/0.5'],
301
- },
302
- },
303
- hovered: {
304
- bg: ['100', '950'],
305
- },
306
- pressed: {
307
- bg: ['100', '900'],
308
- },
309
- selected: {
310
- _blend: ['screen', 'multiply'],
311
- bg: ['500', '400'],
312
- border: ['800', '200'],
313
- bg2: ['950', '50'],
314
- fg: ['white', 'black'],
315
- },
316
- disabled: {
317
- _hue: 'gray',
318
- fg: ['200', '900'],
319
- icon: ['200', '800'],
320
- border: ['100', '900/0.5'],
321
- muted: {
322
- fg: ['200/0.5', '800/0.5'],
323
- },
324
- accent: {
325
- fg: ['200/0.6', '800/0.6'],
326
- },
327
- link: {
328
- fg: ['200/0.6', '800/0.6'],
329
- },
330
- code: {
331
- bg: ['100/0.6', '950/0.6'],
332
- fg: ['200/0.6', '800/0.6'],
333
- },
334
- },
335
- },
336
335
  input: {
337
336
  '*': {
338
337
  '*': {
339
338
  _blend: ['multiply', 'screen'],
340
339
  bg: ['white', 'black'],
341
- bg2: ['50', '950'],
340
+ border: ['200', '800'],
342
341
  fg: ['black', '200'],
343
- border: ['200', '900'],
342
+ muted: {
343
+ bg: ['50', '950'],
344
+ },
344
345
  placeholder: ['400', '600/0.5'],
345
346
  },
346
347
 
@@ -366,38 +367,57 @@ export const defaultColorTokens: ThemeColorTokens = {
366
367
  },
367
368
  },
368
369
  },
369
- kbd: {
370
- _blend: ['multiply', 'screen'],
371
- bg: ['white', 'black'],
372
- fg: ['600', '400'],
373
- border: ['200', '900'],
374
- },
375
370
  selectable: {
376
371
  '*': {
377
372
  '*': {
378
373
  _blend: ['multiply', 'screen'],
379
374
  bg: ['white', 'black'],
380
- bg2: ['50', '950'],
381
- fg: ['900', '200'],
382
- icon: ['600', '400'],
383
- border: ['200', '900'],
375
+ fg: ['800', '200'],
376
+ icon: ['700/0.7', '300/0.7'],
377
+ avatar: {
378
+ '*': {
379
+ _blend: ['screen', 'multiply'],
380
+ bg: ['500', '400'],
381
+ fg: ['white', 'black'],
382
+ },
383
+ // yellow: {bg: ['600', '400']},
384
+ // green: {bg: ['600', '400']},
385
+ // cyan: {bg: ['600', '400']},
386
+ },
387
+ border: ['200', '800'],
384
388
  muted: {
385
- fg: ['700', '400'],
389
+ bg: ['50', '950'],
390
+ fg: ['700', '300'],
386
391
  },
387
392
  accent: {
388
393
  fg: ['purple/600', 'purple/400'],
389
394
  },
390
395
  link: {
391
- fg: ['blue/700', 'blue/400'],
396
+ fg: ['blue/700', 'blue/300'],
392
397
  },
393
398
  code: {
394
399
  bg: ['100', '950'],
395
- fg: ['700', '400'],
400
+ fg: ['700', '300'],
396
401
  },
397
402
  skeleton: {
398
403
  from: ['100', '900'],
399
404
  to: ['100/0.5', '900/0.5'],
400
405
  },
406
+ badge: {
407
+ '*': {
408
+ // _blend: ['multiply', 'screen'],
409
+ bg: ['100', '900'],
410
+ fg: ['600', '200'],
411
+ dot: ['300', '700'],
412
+ icon: ['600', '400'],
413
+ },
414
+ },
415
+ kbd: {
416
+ // _blend: ['multiply', 'screen'],
417
+ bg: ['white', 'black'],
418
+ fg: ['600', '400'],
419
+ border: ['200', '800'],
420
+ },
401
421
  },
402
422
  hovered: {
403
423
  bg: ['50', '950'],
@@ -408,18 +428,42 @@ export const defaultColorTokens: ThemeColorTokens = {
408
428
  selected: {
409
429
  _blend: ['screen', 'multiply'],
410
430
  bg: ['500', '400'],
411
- bg2: ['900', '50'],
412
431
  fg: ['white', 'black'],
413
- icon: ['200', '900'],
432
+ icon: ['200', '800'],
433
+ avatar: {
434
+ '*': {
435
+ _blend: ['multiply', 'screen'],
436
+ bg: ['white', 'black'],
437
+ fg: ['black', 'white'],
438
+ },
439
+ // magenta: {_hue: 'green'},
440
+ // yellow: {bg: ['600', '400']},
441
+ // green: {bg: ['600', '400']},
442
+ // cyan: {bg: ['600', '400']},
443
+ },
444
+ badge: {
445
+ '*': {
446
+ // _blend: ['multiply', 'screen'],
447
+ // _blend: ['screen', 'multiply'],
448
+ bg: ['700', '300'],
449
+ fg: ['white', 'black'],
450
+ },
451
+ },
414
452
  border: ['500/0.2', '400/0.2'],
415
453
  muted: {
416
- fg: ['200', '700'],
454
+ bg: ['900', '50'],
455
+ fg: ['200', '800'],
417
456
  },
418
457
  accent: {
419
- fg: ['purple/200', 'purple/700'],
458
+ fg: ['purple/200', 'purple/800'],
459
+ },
460
+ kbd: {
461
+ bg: ['black/0', 'white/0'],
462
+ fg: ['white', 'black'],
463
+ border: ['gray/700', 'gray/300'],
420
464
  },
421
465
  link: {
422
- fg: ['blue/200', 'blue/700'],
466
+ fg: ['blue/200', 'blue/800'],
423
467
  },
424
468
  code: {
425
469
  bg: ['500/0.2', '400/0.2'],
@@ -429,6 +473,15 @@ export const defaultColorTokens: ThemeColorTokens = {
429
473
  from: ['900', '100'],
430
474
  to: ['900/0.5', '100/0.5'],
431
475
  },
476
+ // badge: {
477
+ // '*': {
478
+ // _blend: ['multiply', 'screen'],
479
+ // bg: ['900', '100'],
480
+ // fg: ['white', 'black'],
481
+ // dot: ['700', '300'],
482
+ // icon: ['400', '600'],
483
+ // },
484
+ // },
432
485
  },
433
486
  disabled: {
434
487
  fg: ['200', '800'],
@@ -1,21 +1,22 @@
1
- import {RootTheme} from '../../system'
1
+ import {RootTheme_v2} from '../system'
2
2
 
3
3
  const BORDER_WIDTH = 1
4
4
  const OUTLINE_WIDTH = 0.5
5
5
 
6
- export const defaultThemeConfig: Omit<RootTheme, 'color' | 'fonts'> = {
6
+ export const defaultThemeConfig: Omit<RootTheme_v2, 'color' | 'font'> = {
7
+ _version: 2,
7
8
  avatar: {
8
9
  sizes: [
9
- {distance: -3, size: 25},
10
- {distance: -6, size: 35},
11
- {distance: -9, size: 55},
10
+ {distance: -4, size: 25},
11
+ {distance: -8, size: 33},
12
+ {distance: -12, size: 49},
12
13
  ],
13
14
  focusRing: {offset: 1, width: 1},
14
15
  },
15
16
  button: {
16
17
  textWeight: 'medium',
17
18
  border: {width: BORDER_WIDTH},
18
- focusRing: {offset: -1, width: 2},
19
+ focusRing: {offset: -1, width: 1},
19
20
  },
20
21
  card: {
21
22
  border: {width: BORDER_WIDTH},
@@ -23,13 +24,14 @@ export const defaultThemeConfig: Omit<RootTheme, 'color' | 'fonts'> = {
23
24
  shadow: {outline: OUTLINE_WIDTH},
24
25
  },
25
26
  container: [480, 640, 960, 1280, 1600, 1920],
26
- focusRing: {
27
- offset: 1,
28
- width: 2,
29
- },
30
27
  media: [360, 600, 900, 1200, 1800, 2400],
28
+ layer: {
29
+ dialog: {zOffset: 600},
30
+ popover: {zOffset: 400},
31
+ tooltip: {zOffset: 200},
32
+ },
31
33
  radius: [0, 1, 3, 6, 9, 12, 21],
32
- shadows: [
34
+ shadow: [
33
35
  null,
34
36
  {umbra: [0, 0, 0, 0], penumbra: [0, 0, 0, 0], ambient: [0, 0, 0, 0]},
35
37
  {umbra: [0, 3, 5, -2], penumbra: [0, 6, 10, 0], ambient: [0, 1, 18, 1]},
@@ -66,7 +68,7 @@ export const defaultThemeConfig: Omit<RootTheme, 'color' | 'fonts'> = {
66
68
  focusRing: {offset: -1, width: 1},
67
69
  },
68
70
  },
69
- styles: {
71
+ style: {
70
72
  button: {
71
73
  root: {
72
74
  transition: 'background-color 100ms,border-color 100ms,color 100ms',
@@ -1,4 +1,4 @@
1
- import {ThemeFonts} from '../../system'
1
+ import {ThemeFonts} from '../system'
2
2
 
3
3
  export const defaultThemeFonts: ThemeFonts = {
4
4
  code: {
@@ -193,15 +193,15 @@ export const defaultThemeFonts: ThemeFonts = {
193
193
  {
194
194
  ascenderHeight: 6,
195
195
  descenderHeight: 6,
196
- fontSize: 16,
196
+ fontSize: 15,
197
197
  iconSize: 25,
198
198
  lineHeight: 23,
199
199
  letterSpacing: 0,
200
200
  },
201
201
  {
202
- ascenderHeight: 7.5,
203
- descenderHeight: 6.5,
204
- fontSize: 19,
202
+ ascenderHeight: 7,
203
+ descenderHeight: 7,
204
+ fontSize: 18,
205
205
  iconSize: 29,
206
206
  lineHeight: 27,
207
207
  letterSpacing: 0,
@@ -209,7 +209,7 @@ export const defaultThemeFonts: ThemeFonts = {
209
209
  {
210
210
  ascenderHeight: 8.5,
211
211
  descenderHeight: 7.5,
212
- fontSize: 22,
212
+ fontSize: 21,
213
213
  iconSize: 33,
214
214
  lineHeight: 31,
215
215
  letterSpacing: 0,
@@ -0,0 +1,81 @@
1
+ import {defaultThemeConfig} from './defaults/config'
2
+ import {RootTheme, RootTheme_v2, Theme, ThemeColorCardToneKey, ThemeColorSchemeKey} from './system'
3
+ import {is_v2, v0_v2, v2_v0} from './versioning'
4
+
5
+ // cache[scheme][tone][rootTheme] = theme
6
+ const cache = new Map<
7
+ ThemeColorSchemeKey,
8
+ Map<ThemeColorCardToneKey, WeakMap<RootTheme | RootTheme_v2, Theme>>
9
+ >()
10
+
11
+ /** @internal */
12
+ export function getScopedTheme(
13
+ themeProp: RootTheme | RootTheme_v2,
14
+ scheme: ThemeColorSchemeKey,
15
+ tone: ThemeColorCardToneKey,
16
+ ): Theme {
17
+ const cachedTheme = _getCachedTheme(themeProp, scheme, tone)
18
+
19
+ if (cachedTheme) return cachedTheme
20
+
21
+ const v0 = is_v2(themeProp) ? v2_v0(themeProp) : themeProp
22
+ const v2 = is_v2(themeProp) ? themeProp : v0_v2(themeProp)
23
+
24
+ const colorScheme_v0 = v0.color[scheme] || v0.color.light
25
+ const color_v0 = colorScheme_v0[tone] || colorScheme_v0.default
26
+ const layer_v0 = v0.layer || defaultThemeConfig.layer
27
+
28
+ const colorScheme_v2 = v2.color[scheme] || v2.color.light
29
+ const color_v2 = colorScheme_v2[tone] || colorScheme_v2.default
30
+ const layer_v2 = v2.layer || defaultThemeConfig.layer
31
+
32
+ const theme: Theme = {
33
+ sanity: {
34
+ ...v0,
35
+ color: color_v0,
36
+ layer: layer_v0,
37
+ v2: {
38
+ ...v2,
39
+ color: color_v2,
40
+ layer: layer_v2,
41
+ },
42
+ },
43
+ }
44
+
45
+ _setCachedTheme(themeProp, scheme, tone, theme)
46
+
47
+ return theme
48
+ }
49
+
50
+ function _getCachedTheme(
51
+ rootTheme: RootTheme | RootTheme_v2,
52
+ scheme: ThemeColorSchemeKey,
53
+ tone: ThemeColorCardToneKey,
54
+ ) {
55
+ const schemeCache = cache.get(scheme)
56
+
57
+ if (!schemeCache) return undefined
58
+
59
+ const toneCache = schemeCache.get(tone)
60
+
61
+ if (!toneCache) return undefined
62
+
63
+ return toneCache.get(rootTheme)
64
+ }
65
+
66
+ function _setCachedTheme(
67
+ rootTheme: RootTheme | RootTheme_v2,
68
+ scheme: ThemeColorSchemeKey,
69
+ tone: ThemeColorCardToneKey,
70
+ theme: Theme,
71
+ ) {
72
+ if (!cache.has(scheme)) cache.set(scheme, new Map())
73
+
74
+ const schemeCache = cache.get(scheme)!
75
+
76
+ if (!schemeCache.has(tone)) schemeCache.set(tone, new WeakMap())
77
+
78
+ const toneCache = schemeCache.get(tone)!
79
+
80
+ toneCache.set(rootTheme, theme)
81
+ }
@@ -1,4 +1,12 @@
1
+ import {buildTheme} from './build'
2
+
1
3
  export * from './build'
2
4
  export * from './config'
3
- export * from './themes/studio'
5
+ export * from './getScopedTheme'
4
6
  export * from './system'
7
+ export * from './versioning'
8
+
9
+ /**
10
+ * @public
11
+ */
12
+ export const defaultTheme = buildTheme()