@sanity/ui 1.8.2 → 2.0.0-alpha.2

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 (49) hide show
  1. package/dist/index.d.ts +42 -11
  2. package/dist/index.esm.js +335 -116
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.js +334 -115
  5. package/dist/index.js.map +1 -1
  6. package/package.json +34 -16
  7. package/src/components/autocomplete/autocomplete.tsx +2 -1
  8. package/src/components/dialog/dialog.tsx +3 -3
  9. package/src/components/hotkeys/hotkeys.tsx +2 -1
  10. package/src/components/menu/menuButton.tsx +2 -2
  11. package/src/components/menu/menuGroup.tsx +2 -2
  12. package/src/components/tab/tab.tsx +2 -1
  13. package/src/primitives/avatar/styles.ts +1 -1
  14. package/src/primitives/button/button.tsx +6 -7
  15. package/src/primitives/button/styles.ts +20 -3
  16. package/src/primitives/card/styles.ts +1 -1
  17. package/src/primitives/checkbox/checkbox.tsx +1 -0
  18. package/src/primitives/checkbox/styles.ts +47 -17
  19. package/src/primitives/kbd/kbd.tsx +6 -6
  20. package/src/primitives/popover/popoverCard.tsx +2 -2
  21. package/src/primitives/radio/radio.tsx +1 -0
  22. package/src/primitives/radio/styles.ts +17 -4
  23. package/src/primitives/select/select.tsx +3 -2
  24. package/src/primitives/select/styles.ts +2 -1
  25. package/src/primitives/switch/__workshop__/props.tsx +4 -4
  26. package/src/primitives/switch/styles.ts +19 -12
  27. package/src/primitives/text/styles.ts +1 -0
  28. package/src/primitives/textInput/textInput.tsx +2 -1
  29. package/src/primitives/tooltip/tooltip.tsx +2 -2
  30. package/src/primitives/types.ts +3 -2
  31. package/src/styles/colorVars/colorVarsStyle.ts +2 -0
  32. package/src/styles/focusRing/index.ts +3 -1
  33. package/src/styles/input/textInputStyle.ts +2 -1
  34. package/src/styles/radius/radiusStyle.ts +14 -4
  35. package/src/styles/radius/types.ts +3 -1
  36. package/src/theme/lib/theme/avatar.ts +3 -0
  37. package/src/theme/lib/theme/color/_generic/types.ts +1 -0
  38. package/src/theme/lib/theme/color/color.test.ts +1 -0
  39. package/src/theme/lib/theme/color/defaults.ts +8 -0
  40. package/src/theme/lib/theme/color/input/types.ts +1 -0
  41. package/src/theme/lib/theme/input.ts +11 -0
  42. package/src/theme/lib/theme/theme.ts +7 -1
  43. package/src/theme/studioTheme/color.ts +82 -70
  44. package/src/theme/studioTheme/fonts.ts +3 -3
  45. package/src/theme/studioTheme/theme.ts +17 -3
  46. package/src/theme/studioTheme/tints.ts +152 -0
  47. package/src/theme/types.ts +8 -0
  48. package/src/types/index.ts +1 -0
  49. package/src/types/radius.ts +4 -0
@@ -1,16 +1,17 @@
1
- import {black, ColorTints, hues, white} from '@sanity/color'
1
+ import {ColorTints, black, hues, white} from '@sanity/color'
2
2
  import {rgba} from '../lib/color-fns'
3
- import {createColorTheme} from '../lib/theme'
3
+ import {ThemeColorName, createColorTheme} from '../lib/theme'
4
4
  import {multiply, screen} from './helpers'
5
+ import {getColorHex} from './tints'
5
6
 
6
- const tones: {[key: string]: ColorTints} = {
7
+ export const tones: Record<ThemeColorName, ColorTints> = {
7
8
  default: hues.gray,
8
9
  transparent: hues.gray,
9
- primary: hues.blue,
10
- positive: hues.green,
10
+ primary: hues.gray,
11
+ positive: hues.cyan,
11
12
  caution: hues.yellow,
12
13
  critical: hues.red,
13
- }
14
+ } as const
14
15
 
15
16
  const NEUTRAL_TONES = ['default', 'transparent']
16
17
 
@@ -22,9 +23,9 @@ export const color = createColorTheme({
22
23
 
23
24
  return {
24
25
  fg: dark ? white.hex : black.hex,
25
- bg: dark ? black.hex : white.hex,
26
- border: tints[dark ? 800 : 200].hex,
27
- focusRing: hues.blue[dark ? 500 : 500].hex,
26
+ bg: getColorHex(tones['default'], dark, 'default', 'bg_base'),
27
+ border: getColorHex(tones['default'], dark, 'default', 'border_base'),
28
+ focusRing: getColorHex(tones['positive'], dark, 'positive', 'border_accent'),
28
29
  shadow: {
29
30
  outline: rgba(tints[500].hex, 0.4),
30
31
  umbra: dark ? rgba(tints[950].hex, 0.4) : rgba(tints[500].hex, 0.2),
@@ -65,9 +66,9 @@ export const color = createColorTheme({
65
66
 
66
67
  return {
67
68
  fg: tints[dark ? 100 : 900].hex,
68
- bg: tints[dark ? 950 : 50].hex,
69
- border: tints[dark ? 800 : 200].hex,
70
- focusRing: tints[500].hex,
69
+ bg: getColorHex(tints, dark, name, 'bg_base'),
70
+ border: getColorHex(tints, dark, name, 'border_base'),
71
+ focusRing: getColorHex(tints, dark, name, 'border_accent'),
71
72
  shadow: {
72
73
  outline: rgba(tints[500].hex, 0.4),
73
74
  umbra: dark ? rgba(tints[900].hex, 0.4) : rgba(tints[500].hex, 0.2),
@@ -92,14 +93,15 @@ export const color = createColorTheme({
92
93
  if (state === 'disabled') {
93
94
  tints = defaultTints
94
95
 
95
- const bg = mix(base.bg, tints[dark ? 800 : 200].hex)
96
+ const bg = getColorHex(tones.default, dark, 'default', 'bg_tint')
96
97
  const skeletonFrom = mix2(bg, tints[dark ? 200 : 800].hex)
97
98
 
98
99
  return {
99
100
  bg,
100
101
  bg2: mix2(bg, tints[dark ? 50 : 950].hex),
101
- border: mix(base.bg, tints[dark ? 800 : 200].hex),
102
- fg: mix(base.bg, dark ? black.hex : white.hex),
102
+ border: getColorHex(tones.default, dark, 'default', 'bg_base'),
103
+ fg: getColorHex(tones.default, dark, 'default', 'text_inactive'),
104
+ iconColor: getColorHex(tones.default, dark, 'default', 'border_base'),
103
105
  muted: {
104
106
  fg: mix(base.bg, tints[dark ? 950 : 50].hex),
105
107
  },
@@ -121,14 +123,15 @@ export const color = createColorTheme({
121
123
  }
122
124
 
123
125
  if (state === 'hovered') {
124
- const bg = mix(base.bg, tints[dark ? 300 : 600].hex)
126
+ const bg = getColorHex(tints, dark, tone, 'bg_accent_hover')
125
127
  const skeletonFrom = mix2(bg, tints[dark ? 200 : 800].hex)
126
128
 
127
129
  return {
128
130
  bg,
129
131
  bg2: mix2(bg, tints[dark ? 50 : 950].hex),
130
- border: mix(base.bg, tints[dark ? 300 : 600].hex),
131
- fg: mix(base.bg, dark ? black.hex : white.hex),
132
+ border: bg,
133
+ fg: getColorHex(tints, dark, 'default', 'bg_base'),
134
+ iconColor: getColorHex(tints, dark, 'default', 'icon_inverted'),
132
135
  muted: {
133
136
  fg: mix(base.bg, tints[dark ? 800 : 200].hex),
134
137
  },
@@ -150,14 +153,15 @@ export const color = createColorTheme({
150
153
  }
151
154
 
152
155
  if (state === 'pressed') {
153
- const bg = mix(base.bg, tints[dark ? 200 : 800].hex)
154
- const skeletonFrom = mix2(bg, tints[dark ? 200 : 800].hex)
156
+ const bg = getColorHex(tints, dark, tone, 'bg_accent_active')
157
+ const skeletonFrom = mix2(bg, tints[dark ? 200 : 600].hex)
155
158
 
156
159
  return {
157
- bg: mix(base.bg, tints[dark ? 200 : 800].hex),
160
+ bg: bg,
158
161
  bg2: mix2(bg, tints[dark ? 50 : 950].hex),
159
- border: mix(base.bg, tints[dark ? 200 : 800].hex),
160
- fg: mix(base.bg, dark ? black.hex : white.hex),
162
+ border: bg,
163
+ fg: getColorHex(tints, dark, 'default', 'bg_base'),
164
+ iconColor: getColorHex(tints, dark, 'default', 'icon_inverted'),
161
165
  muted: {
162
166
  fg: mix(base.bg, tints[dark ? 800 : 200].hex),
163
167
  },
@@ -189,8 +193,9 @@ export const color = createColorTheme({
189
193
  return {
190
194
  bg,
191
195
  bg2: mix2(bg, tints[dark ? 50 : 950].hex),
192
- border: mix(base.bg, tints[dark ? 200 : 800].hex),
193
- fg: mix(base.bg, dark ? black.hex : white.hex),
196
+ border: bg,
197
+ fg: getColorHex(tints, dark, 'default', 'bg_base'),
198
+ iconColor: getColorHex(tints, dark, 'default', 'icon_inverted'),
194
199
  muted: {
195
200
  fg: mix(base.bg, tints[dark ? 800 : 200].hex),
196
201
  },
@@ -212,14 +217,15 @@ export const color = createColorTheme({
212
217
  }
213
218
 
214
219
  // state: "enabled" | unknown
215
- const bg = mix(base.bg, tints[dark ? 400 : 500].hex)
220
+ const bg = getColorHex(tints, dark, tone, 'bg_accent')
216
221
  const skeletonFrom = mix2(bg, tints[dark ? 200 : 800].hex)
217
222
 
218
223
  return {
219
224
  bg,
220
225
  bg2: mix2(bg, tints[dark ? 50 : 950].hex),
221
- border: mix(base.bg, tints[dark ? 400 : 500].hex),
222
- fg: mix(base.bg, dark ? black.hex : white.hex),
226
+ border: bg,
227
+ fg: getColorHex(tints, dark, 'default', 'bg_base'),
228
+ iconColor: getColorHex(tints, dark, 'default', 'icon_inverted'),
223
229
  muted: {
224
230
  fg: mix(base.bg, tints[dark ? 900 : 100].hex),
225
231
  },
@@ -256,20 +262,21 @@ export const color = createColorTheme({
256
262
  return {
257
263
  bg,
258
264
  bg2: mix(bg, tints[dark ? 950 : 50].hex),
259
- border: mix(bg, tints[dark ? 950 : 50].hex),
260
- fg: mix(bg, tints[dark ? 800 : 200].hex),
265
+ border: getColorHex(tones.default, dark, 'default', 'border_base'),
266
+ fg: getColorHex(tones.default, dark, 'default', 'text_inactive'),
267
+ iconColor: getColorHex(tones.default, dark, 'default', 'border_base'),
261
268
  muted: {
262
- fg: mix(bg, tints[dark ? 900 : 100].hex),
269
+ fg: getColorHex(tones.default, dark, 'default', 'text_inactive'),
263
270
  },
264
271
  accent: {
265
- fg: mix(bg, tints[dark ? 900 : 100].hex),
272
+ fg: getColorHex(tints, dark, tone, 'text_secondary'),
266
273
  },
267
274
  link: {
268
- fg: mix(bg, tints[dark ? 900 : 100].hex),
275
+ fg: getColorHex(tints, dark, tone, 'text_secondary'),
269
276
  },
270
277
  code: {
271
278
  bg,
272
- fg: mix(bg, tints[dark ? 900 : 100].hex),
279
+ fg: getColorHex(tints, dark, tone, 'text_secondary'),
273
280
  },
274
281
  skeleton: {
275
282
  from: rgba(skeletonFrom, 0.5),
@@ -279,20 +286,17 @@ export const color = createColorTheme({
279
286
  }
280
287
 
281
288
  if (state === 'hovered') {
282
- // if (isNeutral) {
283
- // tints = tones.primary
284
- // }
285
-
286
- const bg = mix(base.bg, tints[dark ? 950 : 50].hex)
289
+ const bg = getColorHex(tints, dark, name, 'bg_base_hover')
287
290
  const skeletonFrom = mix(bg, tints[dark ? 900 : 100].hex)
288
291
 
289
292
  return {
290
293
  bg,
291
294
  bg2: mix(bg, tints[dark ? 950 : 50].hex),
292
295
  border: mix(bg, tints[dark ? 900 : 100].hex),
293
- fg: mix(base.bg, tints[dark ? 200 : 800].hex),
296
+ fg: getColorHex(tints, dark, tone, 'text_primary'),
297
+ iconColor: getColorHex(tints, dark, name, 'icon_default'),
294
298
  muted: {
295
- fg: mix(base.bg, tints[dark ? 400 : 600].hex),
299
+ fg: getColorHex(tints, dark, tone, 'text_secondary'),
296
300
  },
297
301
  accent: {
298
302
  fg: mix(base.bg, hues.red[dark ? 400 : 500].hex),
@@ -302,7 +306,7 @@ export const color = createColorTheme({
302
306
  },
303
307
  code: {
304
308
  bg: mix(bg, tints[dark ? 950 : 50].hex),
305
- fg: mix(base.bg, tints[dark ? 400 : 600].hex),
309
+ fg: getColorHex(tints, dark, tone, 'text_secondary'),
306
310
  },
307
311
  skeleton: {
308
312
  from: skeletonFrom,
@@ -316,16 +320,17 @@ export const color = createColorTheme({
316
320
  tints = tones.primary
317
321
  }
318
322
 
319
- const bg = mix(base.bg, tints[dark ? 900 : 100].hex)
320
- const skeletonFrom = mix(bg, tints[dark ? 900 : 100].hex)
323
+ const bg = getColorHex(tints, dark, name, 'bg_base_active')
324
+ const skeletonFrom = mix(bg, getColorHex(tints, dark, name, 'bg_base_active'))
321
325
 
322
326
  return {
323
327
  bg,
324
328
  bg2: mix(bg, tints[dark ? 950 : 50].hex),
325
- border: mix(bg, tints[dark ? 900 : 100].hex),
326
- fg: mix(base.bg, tints[dark ? 200 : 800].hex),
329
+ border: getColorHex(tints, dark, name, 'border_base'),
330
+ fg: getColorHex(tints, dark, tone, 'text_primary'),
331
+ iconColor: getColorHex(tints, dark, name, 'icon_default'),
327
332
  muted: {
328
- fg: mix(base.bg, tints[dark ? 400 : 600].hex),
333
+ fg: getColorHex(tints, dark, tone, 'text_secondary'),
329
334
  },
330
335
  accent: {
331
336
  fg: mix(bg, hues.red[dark ? 400 : 500].hex),
@@ -335,7 +340,7 @@ export const color = createColorTheme({
335
340
  },
336
341
  code: {
337
342
  bg: mix(bg, tints[dark ? 950 : 50].hex),
338
- fg: mix(base.bg, tints[dark ? 400 : 600].hex),
343
+ fg: getColorHex(tints, dark, tone, 'text_secondary'),
339
344
  },
340
345
  skeleton: {
341
346
  from: skeletonFrom,
@@ -355,10 +360,11 @@ export const color = createColorTheme({
355
360
  return {
356
361
  bg,
357
362
  bg2: mix(bg, tints[dark ? 950 : 50].hex),
358
- border: mix(bg, tints[dark ? 900 : 100].hex),
359
- fg: mix(base.bg, tints[dark ? 200 : 800].hex),
363
+ border: getColorHex(tints, dark, name, 'border_base'),
364
+ fg: getColorHex(tints, dark, tone, 'text_primary'),
365
+ iconColor: getColorHex(tints, dark, name, 'icon_default'),
360
366
  muted: {
361
- fg: mix(base.bg, tints[dark ? 400 : 600].hex),
367
+ fg: getColorHex(tints, dark, tone, 'text_secondary'),
362
368
  },
363
369
  accent: {
364
370
  fg: mix(bg, hues.red[dark ? 400 : 500].hex),
@@ -368,7 +374,7 @@ export const color = createColorTheme({
368
374
  },
369
375
  code: {
370
376
  bg: mix(bg, tints[dark ? 950 : 50].hex),
371
- fg: mix(base.bg, tints[dark ? 400 : 600].hex),
377
+ fg: getColorHex(tints, dark, tone, 'text_secondary'),
372
378
  },
373
379
  skeleton: {
374
380
  from: skeletonFrom,
@@ -383,10 +389,11 @@ export const color = createColorTheme({
383
389
  return {
384
390
  bg,
385
391
  bg2: mix(bg, tints[dark ? 950 : 50].hex),
386
- border: mix(bg, tints[dark ? 900 : 100].hex),
387
- fg: mix(base.bg, tints[dark ? 300 : 700].hex),
392
+ border: mix(bg, getColorHex(tints, dark, name, 'bg_base')),
393
+ fg: getColorHex(tints, dark, tone, 'text_primary'),
394
+ iconColor: getColorHex(tints, dark, name, 'icon_default'),
388
395
  muted: {
389
- fg: mix(base.bg, tints[dark ? 400 : 600].hex),
396
+ fg: getColorHex(tints, dark, tone, 'text_secondary'),
390
397
  },
391
398
  accent: {
392
399
  fg: mix(base.bg, hues.red[dark ? 400 : 500].hex),
@@ -396,7 +403,7 @@ export const color = createColorTheme({
396
403
  },
397
404
  code: {
398
405
  bg: mix(base.bg, tints[dark ? 950 : 50].hex),
399
- fg: mix(base.bg, tints[dark ? 400 : 600].hex),
406
+ fg: getColorHex(tints, dark, tone, 'text_secondary'),
400
407
  },
401
408
  skeleton: {
402
409
  from: skeletonFrom,
@@ -433,12 +440,11 @@ export const color = createColorTheme({
433
440
 
434
441
  if (mode === 'ghost') {
435
442
  return {
436
- ...solid,
443
+ ...muted,
437
444
  enabled: {
438
445
  ...muted.enabled,
439
446
  border: base.border,
440
447
  },
441
- disabled: muted.disabled,
442
448
  }
443
449
  }
444
450
 
@@ -481,6 +487,7 @@ export const color = createColorTheme({
481
487
  bg,
482
488
  bg2: mix(bg, tints[dark ? 950 : 50].hex),
483
489
  fg: base.fg,
490
+ iconColor: getColorHex(tints, dark, name, 'icon_default'),
484
491
  border: base.border,
485
492
  muted: {
486
493
  fg: mix(base.bg, tints[dark ? 400 : 600].hex),
@@ -510,44 +517,49 @@ export const color = createColorTheme({
510
517
 
511
518
  return {
512
519
  bg: mix(base.bg, tints[dark ? 950 : 50].hex),
520
+ bg2: getColorHex(tints, dark, 'critical', 'text_secondary'),
513
521
  fg: mix(base.bg, tints[dark ? 400 : 600].hex),
514
- border: mix(base.bg, tints[dark ? 800 : 200].hex),
515
- placeholder: mix(base.bg, tints[dark ? 600 : 400].hex),
522
+ border: getColorHex(tints, dark, 'critical', 'border_base'),
523
+ placeholder: getColorHex(tones.default, !dark, 'default', 'text_secondary'),
516
524
  }
517
525
  }
518
526
 
519
527
  if (state === 'hovered') {
520
528
  return {
521
529
  bg: base.bg,
530
+ bg2: getColorHex(tones.default, dark, 'default', 'text_secondary'),
522
531
  fg: base.fg,
523
532
  border: mix(base.bg, hues.gray[dark ? 700 : 300].hex),
524
- placeholder: mix(base.bg, hues.gray[dark ? 600 : 400].hex),
533
+ placeholder: getColorHex(tones.default, !dark, 'default', 'text_secondary'),
525
534
  }
526
535
  }
527
536
 
528
537
  if (state === 'disabled') {
529
538
  return {
530
- bg: mix(base.bg, hues.gray[dark ? 950 : 50].hex),
531
- fg: mix(base.bg, hues.gray[dark ? 700 : 300].hex),
532
- border: mix(base.bg, hues.gray[dark ? 900 : 100].hex),
533
- placeholder: mix(base.bg, hues.gray[dark ? 800 : 200].hex),
539
+ bg: getColorHex(tones.default, dark, 'default', 'bg_tint'),
540
+ bg2: getColorHex(tones.default, dark, 'default', 'border_base'),
541
+ fg: getColorHex(tones.default, dark, 'default', 'text_secondary'),
542
+ border: getColorHex(tones.default, dark, 'default', 'border_base'),
543
+ placeholder: getColorHex(tones.default, !dark, 'default', 'text_secondary'),
534
544
  }
535
545
  }
536
546
 
537
547
  if (state === 'readOnly') {
538
548
  return {
539
- bg: mix(base.bg, hues.gray[dark ? 950 : 50].hex),
540
- fg: mix(base.bg, hues.gray[dark ? 200 : 800].hex),
541
- border: mix(base.bg, hues.gray[dark ? 800 : 200].hex),
542
- placeholder: mix(base.bg, hues.gray[dark ? 600 : 400].hex),
549
+ bg: getColorHex(tones.default, dark, 'default', 'bg_tint'),
550
+ bg2: getColorHex(tones.default, dark, 'default', 'border_base'),
551
+ fg: getColorHex(tones.default, dark, 'default', 'text_secondary'),
552
+ border: getColorHex(tones.default, dark, 'default', 'border_base'),
553
+ placeholder: getColorHex(tones.default, !dark, 'default', 'text_secondary'),
543
554
  }
544
555
  }
545
556
 
546
557
  return {
547
558
  bg: base.bg,
559
+ bg2: getColorHex(tones.default, dark, 'default', 'text_secondary'),
548
560
  fg: base.fg,
549
561
  border: base.border,
550
- placeholder: mix(base.bg, hues.gray[dark ? 600 : 400].hex),
562
+ placeholder: getColorHex(tones.default, !dark, 'default', 'text_secondary'),
551
563
  }
552
564
  },
553
565
 
@@ -54,7 +54,7 @@ export const fonts: ThemeFonts = {
54
54
  },
55
55
  heading: {
56
56
  family:
57
- '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Helvetica, Arial, system-ui, sans-serif',
57
+ 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Helvetica, Arial, system-ui, sans-serif',
58
58
  weights: {
59
59
  regular: 700,
60
60
  medium: 800,
@@ -114,7 +114,7 @@ export const fonts: ThemeFonts = {
114
114
  },
115
115
  label: {
116
116
  family:
117
- '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", system-ui, sans-serif',
117
+ 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", system-ui, sans-serif',
118
118
  weights: {
119
119
  regular: 600,
120
120
  medium: 700,
@@ -166,7 +166,7 @@ export const fonts: ThemeFonts = {
166
166
  },
167
167
  text: {
168
168
  family:
169
- '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Helvetica, Arial, system-ui, sans-serif',
169
+ 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Helvetica, Arial, system-ui, sans-serif',
170
170
  weights: {
171
171
  regular: 400,
172
172
  medium: 500,
@@ -12,9 +12,14 @@ export const studioTheme: RootTheme = {
12
12
  {distance: -6, size: 35},
13
13
  {distance: -9, size: 55},
14
14
  ],
15
+ focusRing: {offset: 1, width: 1},
15
16
  },
16
17
  button: {
17
18
  textWeight: 'medium',
19
+ focusRing: {offset: -1, width: 2},
20
+ },
21
+ card: {
22
+ focusRing: {offset: -1, width: 1},
18
23
  },
19
24
  color,
20
25
  container: [320, 640, 960, 1280, 1600, 1920],
@@ -37,21 +42,30 @@ export const studioTheme: RootTheme = {
37
42
  input: {
38
43
  checkbox: {
39
44
  size: 17,
45
+ focusRing: {offset: -1, width: 1},
40
46
  },
41
47
  radio: {
42
48
  size: 17,
43
49
  markSize: 9,
50
+ focusRing: {offset: -1, width: 1},
44
51
  },
45
52
  switch: {
46
- width: 33,
47
- height: 17,
48
- padding: 4,
53
+ width: 21,
54
+ height: 13,
55
+ padding: 2,
49
56
  transitionDurationMs: 150,
50
57
  transitionTimingFunction: 'ease-out',
58
+ focusRing: {offset: 1, width: 1},
51
59
  },
52
60
  border: {
53
61
  width: 1,
54
62
  },
63
+ select: {
64
+ focusRing: {offset: -1, width: 1},
65
+ },
66
+ text: {
67
+ focusRing: {offset: -1, width: 1},
68
+ },
55
69
  },
56
70
  // styles: {
57
71
  // button: {
@@ -0,0 +1,152 @@
1
+ /**
2
+ * This file creates a translation between the tints and the studio colors
3
+ * Providing readable names, and allowing to mix colors and tints in the same ThemeColor.
4
+ * e.g. for positive theme: `{"bg_base": "white", "bg_base_hover": "gray/50", "bg_base_active": "cyan/50"}
5
+ * This is not possible in the previous configuration, as each ThemeColor uses only one tint.
6
+ */
7
+ import {ColorTintKey, ColorTints, ColorValue, black, hues, white} from '@sanity/color'
8
+ import {ThemeColorName, ThemeColorSchemeKey} from '../lib/theme'
9
+
10
+ export const colorKeys = [
11
+ 'text_primary',
12
+ 'text_secondary',
13
+ 'text_inactive',
14
+ 'bg_base',
15
+ 'bg_base_hover',
16
+ 'bg_base_active',
17
+ 'bg_accent',
18
+ 'bg_accent_hover',
19
+ 'bg_accent_active',
20
+ 'bg_tint',
21
+ 'icon_default',
22
+ 'icon_inverted',
23
+ 'border_base',
24
+ 'border_accent',
25
+ 'border_accent_inverted',
26
+ ] as const
27
+
28
+ export type ColorKey = (typeof colorKeys)[number]
29
+
30
+ type ColorTintsDictionary = Record<ColorKey, ColorTintKey | ColorValue>
31
+ const defaultTints: Record<ThemeColorSchemeKey, ColorTintsDictionary> = {
32
+ light: {
33
+ text_primary: '900',
34
+ text_secondary: '600',
35
+ text_inactive: '500',
36
+ bg_base: white,
37
+ bg_base_hover: '50',
38
+ bg_base_active: '100',
39
+ bg_accent: '500',
40
+ bg_accent_hover: '600',
41
+ bg_accent_active: '700',
42
+ bg_tint: '50',
43
+ icon_default: '500',
44
+ icon_inverted: white,
45
+ border_base: '100',
46
+ border_accent: '500',
47
+ border_accent_inverted: white,
48
+ },
49
+ dark: {
50
+ text_primary: '50',
51
+ text_secondary: '300',
52
+ text_inactive: '400',
53
+ bg_base: black,
54
+ bg_base_hover: '900',
55
+ bg_base_active: '800',
56
+ bg_accent: '500',
57
+ bg_accent_hover: '400',
58
+ bg_accent_active: '300',
59
+ bg_tint: '900',
60
+ icon_default: '300',
61
+ icon_inverted: hues.gray[900],
62
+ border_base: '800',
63
+ border_accent: '300',
64
+ border_accent_inverted: hues.gray[900],
65
+ },
66
+ }
67
+
68
+ export const colorTints: Record<
69
+ ThemeColorSchemeKey,
70
+ Record<ThemeColorName, ColorTintsDictionary>
71
+ > = {
72
+ light: {
73
+ default: {
74
+ ...defaultTints.light,
75
+ bg_accent: '900',
76
+ bg_accent_hover: '950',
77
+ bg_accent_active: black,
78
+ border_accent: '600',
79
+ },
80
+ primary: {
81
+ ...defaultTints.light,
82
+ bg_accent: '900',
83
+ bg_accent_hover: '950',
84
+ bg_accent_active: black,
85
+ border_accent: '600',
86
+ },
87
+ positive: {
88
+ ...defaultTints.light,
89
+ bg_base_hover: hues.gray[50],
90
+ bg_base_active: '50',
91
+ bg_accent: '400',
92
+ bg_accent_hover: '500',
93
+ bg_accent_active: '600',
94
+ border_accent: '400',
95
+ },
96
+ transparent: defaultTints.light,
97
+ caution: defaultTints.light,
98
+ critical: defaultTints.light,
99
+ },
100
+ dark: {
101
+ default: {
102
+ ...defaultTints.dark,
103
+ text_primary: white,
104
+ bg_accent: white,
105
+ bg_accent_hover: '50',
106
+ bg_accent_active: '100',
107
+ },
108
+ primary: {
109
+ ...defaultTints.dark,
110
+ text_primary: white,
111
+ bg_accent: white,
112
+ bg_accent_hover: '50',
113
+ bg_accent_active: '100',
114
+ },
115
+ positive: {
116
+ ...defaultTints.dark,
117
+ bg_base_hover: hues.gray[900],
118
+ bg_base_active: '900',
119
+ bg_accent: '400',
120
+ bg_accent_hover: '300',
121
+ bg_accent_active: '200',
122
+ border_accent: '400',
123
+ },
124
+ transparent: defaultTints.dark,
125
+ caution: defaultTints.dark,
126
+ critical: defaultTints.dark,
127
+ },
128
+ }
129
+
130
+ export const getColorValue = (
131
+ tints: ColorTints,
132
+ dark: boolean,
133
+ tone: ThemeColorName,
134
+ key: ColorKey,
135
+ ): ColorValue => {
136
+ const value = colorTints[dark ? 'dark' : 'light'][tone][key]
137
+
138
+ if (typeof value === 'string') {
139
+ return tints[value]
140
+ }
141
+
142
+ return value
143
+ }
144
+
145
+ export const getColorHex = (
146
+ tints: ColorTints,
147
+ dark: boolean,
148
+ tone: ThemeColorName,
149
+ key: ColorKey,
150
+ ): string => {
151
+ return getColorValue(tints, dark, tone, key).hex
152
+ }
@@ -37,3 +37,11 @@ export interface ThemeContextValue {
37
37
  theme: RootTheme
38
38
  tone: ThemeColorName
39
39
  }
40
+
41
+ /**
42
+ * @public
43
+ */
44
+ export interface FocusRing {
45
+ offset: number
46
+ width: number
47
+ }
@@ -9,6 +9,7 @@ export * from './grid'
9
9
  export * from './gridItem'
10
10
  export * from './placement'
11
11
  export * from './popover'
12
+ export * from './radius'
12
13
  export * from './selectable'
13
14
  export * from './styled'
14
15
  export * from './text'
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @public
3
+ */
4
+ export type Radius = number | 'full'