@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.
- package/dist/index.d.ts +42 -11
- package/dist/index.esm.js +335 -116
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +334 -115
- package/dist/index.js.map +1 -1
- package/package.json +34 -16
- package/src/components/autocomplete/autocomplete.tsx +2 -1
- package/src/components/dialog/dialog.tsx +3 -3
- package/src/components/hotkeys/hotkeys.tsx +2 -1
- package/src/components/menu/menuButton.tsx +2 -2
- package/src/components/menu/menuGroup.tsx +2 -2
- package/src/components/tab/tab.tsx +2 -1
- package/src/primitives/avatar/styles.ts +1 -1
- package/src/primitives/button/button.tsx +6 -7
- package/src/primitives/button/styles.ts +20 -3
- package/src/primitives/card/styles.ts +1 -1
- package/src/primitives/checkbox/checkbox.tsx +1 -0
- package/src/primitives/checkbox/styles.ts +47 -17
- package/src/primitives/kbd/kbd.tsx +6 -6
- package/src/primitives/popover/popoverCard.tsx +2 -2
- package/src/primitives/radio/radio.tsx +1 -0
- package/src/primitives/radio/styles.ts +17 -4
- package/src/primitives/select/select.tsx +3 -2
- package/src/primitives/select/styles.ts +2 -1
- package/src/primitives/switch/__workshop__/props.tsx +4 -4
- package/src/primitives/switch/styles.ts +19 -12
- package/src/primitives/text/styles.ts +1 -0
- package/src/primitives/textInput/textInput.tsx +2 -1
- package/src/primitives/tooltip/tooltip.tsx +2 -2
- package/src/primitives/types.ts +3 -2
- package/src/styles/colorVars/colorVarsStyle.ts +2 -0
- package/src/styles/focusRing/index.ts +3 -1
- package/src/styles/input/textInputStyle.ts +2 -1
- package/src/styles/radius/radiusStyle.ts +14 -4
- package/src/styles/radius/types.ts +3 -1
- package/src/theme/lib/theme/avatar.ts +3 -0
- package/src/theme/lib/theme/color/_generic/types.ts +1 -0
- package/src/theme/lib/theme/color/color.test.ts +1 -0
- package/src/theme/lib/theme/color/defaults.ts +8 -0
- package/src/theme/lib/theme/color/input/types.ts +1 -0
- package/src/theme/lib/theme/input.ts +11 -0
- package/src/theme/lib/theme/theme.ts +7 -1
- package/src/theme/studioTheme/color.ts +82 -70
- package/src/theme/studioTheme/fonts.ts +3 -3
- package/src/theme/studioTheme/theme.ts +17 -3
- package/src/theme/studioTheme/tints.ts +152 -0
- package/src/theme/types.ts +8 -0
- package/src/types/index.ts +1 -0
- package/src/types/radius.ts +4 -0
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
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:
|
|
7
|
+
export const tones: Record<ThemeColorName, ColorTints> = {
|
|
7
8
|
default: hues.gray,
|
|
8
9
|
transparent: hues.gray,
|
|
9
|
-
primary: hues.
|
|
10
|
-
positive: hues.
|
|
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
|
|
26
|
-
border:
|
|
27
|
-
focusRing:
|
|
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
|
|
69
|
-
border: tints
|
|
70
|
-
focusRing: tints
|
|
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 =
|
|
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:
|
|
102
|
-
fg:
|
|
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 =
|
|
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:
|
|
131
|
-
fg:
|
|
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 =
|
|
154
|
-
const skeletonFrom = mix2(bg, tints[dark ? 200 :
|
|
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:
|
|
160
|
+
bg: bg,
|
|
158
161
|
bg2: mix2(bg, tints[dark ? 50 : 950].hex),
|
|
159
|
-
border:
|
|
160
|
-
fg:
|
|
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:
|
|
193
|
-
fg:
|
|
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 =
|
|
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:
|
|
222
|
-
fg:
|
|
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:
|
|
260
|
-
fg:
|
|
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:
|
|
269
|
+
fg: getColorHex(tones.default, dark, 'default', 'text_inactive'),
|
|
263
270
|
},
|
|
264
271
|
accent: {
|
|
265
|
-
fg:
|
|
272
|
+
fg: getColorHex(tints, dark, tone, 'text_secondary'),
|
|
266
273
|
},
|
|
267
274
|
link: {
|
|
268
|
-
fg:
|
|
275
|
+
fg: getColorHex(tints, dark, tone, 'text_secondary'),
|
|
269
276
|
},
|
|
270
277
|
code: {
|
|
271
278
|
bg,
|
|
272
|
-
fg:
|
|
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
|
-
|
|
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:
|
|
296
|
+
fg: getColorHex(tints, dark, tone, 'text_primary'),
|
|
297
|
+
iconColor: getColorHex(tints, dark, name, 'icon_default'),
|
|
294
298
|
muted: {
|
|
295
|
-
fg:
|
|
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:
|
|
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 =
|
|
320
|
-
const skeletonFrom = mix(bg, tints
|
|
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:
|
|
326
|
-
fg:
|
|
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:
|
|
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:
|
|
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:
|
|
359
|
-
fg:
|
|
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:
|
|
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:
|
|
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
|
|
387
|
-
fg:
|
|
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:
|
|
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:
|
|
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
|
-
...
|
|
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:
|
|
515
|
-
placeholder:
|
|
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:
|
|
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:
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
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:
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
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:
|
|
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:
|
|
47
|
-
height:
|
|
48
|
-
padding:
|
|
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
|
+
}
|
package/src/theme/types.ts
CHANGED
package/src/types/index.ts
CHANGED