@sanity/ui 2.0.0-alpha.5 → 2.0.0-alpha.7

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 (115) hide show
  1. package/dist/index.cjs.mjs +3 -1
  2. package/dist/index.d.ts +294 -407
  3. package/dist/index.esm.js +971 -2333
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/index.js +972 -2332
  6. package/dist/index.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/components/dialog/dialog.tsx +3 -3
  9. package/src/components/dialog/styles.ts +3 -4
  10. package/src/components/menu/__workshop__/closableMenuButton.tsx +2 -2
  11. package/src/components/menu/menuDivider.ts +2 -1
  12. package/src/components/menu/menuGroup.tsx +22 -23
  13. package/src/components/menu/menuItem.tsx +30 -36
  14. package/src/components/skeleton/styles.ts +8 -7
  15. package/src/components/tree/style.ts +19 -20
  16. package/src/primitives/_selectable/style.ts +25 -22
  17. package/src/primitives/avatar/avatar.tsx +8 -3
  18. package/src/primitives/avatar/avatarCounter.tsx +5 -4
  19. package/src/primitives/avatar/spotColors.ts +53 -0
  20. package/src/primitives/avatar/styles.ts +5 -7
  21. package/src/primitives/avatar/types.ts +14 -0
  22. package/src/primitives/badge/badge.tsx +4 -2
  23. package/src/primitives/badge/styles.ts +7 -8
  24. package/src/primitives/box/__workshop__/responsive.tsx +2 -2
  25. package/src/primitives/button/button.tsx +2 -2
  26. package/src/primitives/button/styles.ts +82 -16
  27. package/src/primitives/card/__workshop__/selected.tsx +8 -9
  28. package/src/primitives/card/card.tsx +43 -7
  29. package/src/primitives/card/styles.ts +30 -22
  30. package/src/primitives/card/types.ts +3 -1
  31. package/src/primitives/checkbox/styles.ts +20 -20
  32. package/src/primitives/code/code.tsx +15 -3
  33. package/src/primitives/code/styles.ts +51 -42
  34. package/src/primitives/heading/styles.ts +6 -5
  35. package/src/primitives/kbd/kbd.tsx +2 -1
  36. package/src/primitives/label/styles.ts +3 -2
  37. package/src/primitives/popover/popoverArrow.tsx +3 -2
  38. package/src/primitives/popover/popoverCard.tsx +6 -2
  39. package/src/primitives/radio/styles.ts +15 -15
  40. package/src/primitives/select/styles.ts +20 -22
  41. package/src/primitives/switch/styles.ts +13 -13
  42. package/src/primitives/text/__workshop__/colored.tsx +10 -11
  43. package/src/primitives/text/styles.ts +10 -9
  44. package/src/primitives/textArea/textArea.tsx +7 -11
  45. package/src/primitives/textInput/textInput.tsx +12 -12
  46. package/src/primitives/tooltip/__workshop__/props.tsx +20 -3
  47. package/src/primitives/tooltip/tooltipArrow.tsx +3 -2
  48. package/src/styles/border/borderStyle.ts +2 -1
  49. package/src/styles/colorVars/colorVarsStyle.ts +73 -32
  50. package/src/styles/focusRing/index.ts +6 -4
  51. package/src/styles/input/textInputStyle.ts +76 -93
  52. package/src/styles/margin/marginsStyle.test.ts +1 -2
  53. package/src/styles/padding/paddingStyle.test.ts +1 -2
  54. package/src/styles/shadow/shadowStyle.ts +5 -5
  55. package/src/theme/__workshop__/color.tsx +2 -2
  56. package/src/theme/__workshop__/index.ts +0 -5
  57. package/src/theme/lib/color-fns/blend/multiply.ts +2 -2
  58. package/src/theme/lib/color-fns/blend/screen.ts +2 -2
  59. package/src/theme/lib/color-fns/convert.ts +15 -1
  60. package/src/theme/lib/color-fns/parse.ts +7 -3
  61. package/src/theme/lib/color-fns/types.ts +11 -0
  62. package/src/theme/lib/theme/color/cssVariables/cardVariables.ts +92 -0
  63. package/src/theme/lib/theme/color/cssVariables/createCssVars.ts +31 -0
  64. package/src/theme/lib/theme/color/cssVariables/cssVars.test.ts +262 -0
  65. package/src/theme/lib/theme/color/cssVariables/index.ts +1 -0
  66. package/src/theme/lib/theme/color/cssVariables/tints.ts +312 -0
  67. package/src/theme/lib/theme/color/cssVariables/tones.ts +67 -0
  68. package/src/theme/lib/theme/color/cssVariables/utils.test.ts +15 -0
  69. package/src/theme/lib/theme/color/cssVariables/utils.ts +9 -0
  70. package/src/theme/lib/theme/color/index.ts +2 -12
  71. package/src/theme/lib/theme/color/types.ts +6 -37
  72. package/src/theme/studioTheme/color.ts +2 -641
  73. package/src/theme/studioTheme/helpers.ts +15 -1
  74. package/src/theme/studioTheme/theme.ts +9 -3
  75. package/src/theme/themeColorProvider.tsx +2 -0
  76. package/src/theme/themeProvider.tsx +27 -8
  77. package/src/theme/toneContext/toneContext.ts +12 -0
  78. package/src/theme/toneContext/toneProvider.tsx +31 -0
  79. package/src/theme/toneContext/types.ts +10 -0
  80. package/src/theme/toneContext/useToneContext.tsx +26 -0
  81. package/src/theme/types.ts +2 -4
  82. package/src/utils/elementQuery/__workshop__/customMedia.tsx +4 -3
  83. package/src/theme/__workshop__/canvas.tsx +0 -395
  84. package/src/theme/lib/theme/color/_generic/index.ts +0 -1
  85. package/src/theme/lib/theme/color/_generic/types.ts +0 -30
  86. package/src/theme/lib/theme/color/base/index.ts +0 -1
  87. package/src/theme/lib/theme/color/base/types.ts +0 -19
  88. package/src/theme/lib/theme/color/button/createButtonModes.ts +0 -20
  89. package/src/theme/lib/theme/color/button/createButtonTones.ts +0 -52
  90. package/src/theme/lib/theme/color/button/index.ts +0 -1
  91. package/src/theme/lib/theme/color/button/types.ts +0 -44
  92. package/src/theme/lib/theme/color/card/createCardStates.ts +0 -58
  93. package/src/theme/lib/theme/color/card/index.ts +0 -1
  94. package/src/theme/lib/theme/color/card/types.ts +0 -18
  95. package/src/theme/lib/theme/color/color.test.ts +0 -63
  96. package/src/theme/lib/theme/color/defaults.ts +0 -390
  97. package/src/theme/lib/theme/color/factory.ts +0 -138
  98. package/src/theme/lib/theme/color/input/createInputModes.ts +0 -84
  99. package/src/theme/lib/theme/color/input/index.ts +0 -1
  100. package/src/theme/lib/theme/color/input/types.ts +0 -28
  101. package/src/theme/lib/theme/color/muted/createMuted.ts +0 -56
  102. package/src/theme/lib/theme/color/muted/index.ts +0 -1
  103. package/src/theme/lib/theme/color/muted/types.ts +0 -24
  104. package/src/theme/lib/theme/color/selectable/createSelectableTones.ts +0 -73
  105. package/src/theme/lib/theme/color/selectable/index.ts +0 -1
  106. package/src/theme/lib/theme/color/selectable/types.ts +0 -29
  107. package/src/theme/lib/theme/color/solid/createSolidTones.ts +0 -56
  108. package/src/theme/lib/theme/color/solid/index.ts +0 -1
  109. package/src/theme/lib/theme/color/solid/types.ts +0 -24
  110. package/src/theme/lib/theme/color/spot/createSpot.ts +0 -21
  111. package/src/theme/lib/theme/color/spot/index.ts +0 -1
  112. package/src/theme/lib/theme/color/spot/types.ts +0 -28
  113. package/src/theme/lib/theme/color/syntax/index.ts +0 -1
  114. package/src/theme/lib/theme/color/syntax/types.ts +0 -41
  115. package/src/theme/studioTheme/tints.ts +0 -152
@@ -1,8 +1,5 @@
1
- import {ColorTints, black, hues, white} from '@sanity/color'
2
- import {rgba} from '../lib/color-fns'
3
- import {ThemeColorName, createColorTheme} from '../lib/theme'
4
- import {multiply, screen} from './helpers'
5
- import {getColorHex} from './tints'
1
+ import {ColorTints, hues} from '@sanity/color'
2
+ import {ThemeColorName} from '../lib/theme'
6
3
 
7
4
  export const tones: Record<ThemeColorName, ColorTints> = {
8
5
  default: hues.gray,
@@ -12,639 +9,3 @@ export const tones: Record<ThemeColorName, ColorTints> = {
12
9
  caution: hues.yellow,
13
10
  critical: hues.red,
14
11
  } as const
15
-
16
- const NEUTRAL_TONES = ['default', 'transparent']
17
-
18
- export const color = createColorTheme({
19
- base: ({dark, name}) => {
20
- if (name === 'default') {
21
- const tints = hues.gray
22
- const skeletonFrom = dark ? tints[900].hex : tints[100].hex
23
-
24
- return {
25
- fg: dark ? white.hex : black.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'),
29
- shadow: {
30
- outline: rgba(tints[500].hex, 0.4),
31
- umbra: dark ? rgba(tints[950].hex, 0.4) : rgba(tints[500].hex, 0.2),
32
- penumbra: dark ? rgba(tints[950].hex, 0.28) : rgba(tints[500].hex, 0.14),
33
- ambient: dark ? rgba(tints[950].hex, 0.24) : rgba(tints[500].hex, 0.12),
34
- },
35
- skeleton: {
36
- from: skeletonFrom,
37
- to: rgba(skeletonFrom, 0.5),
38
- },
39
- }
40
- }
41
-
42
- if (name === 'transparent') {
43
- const tints = tones.default
44
- const skeletonFrom = tints[dark ? 800 : 200].hex
45
-
46
- return {
47
- fg: tints[dark ? 100 : 900].hex,
48
- bg: tints[dark ? 950 : 50].hex,
49
- border: tints[dark ? 800 : 300].hex,
50
- focusRing: hues.blue[500].hex,
51
- shadow: {
52
- outline: rgba(tints[500].hex, 0.4),
53
- umbra: dark ? rgba(tints[900].hex, 0.4) : rgba(tints[500].hex, 0.2),
54
- penumbra: dark ? rgba(tints[900].hex, 0.28) : rgba(tints[500].hex, 0.14),
55
- ambient: dark ? rgba(tints[900].hex, 0.24) : rgba(tints[500].hex, 0.12),
56
- },
57
- skeleton: {
58
- from: skeletonFrom,
59
- to: rgba(skeletonFrom, 0.5),
60
- },
61
- }
62
- }
63
-
64
- const tints = tones[name] || tones.default
65
- const skeletonFrom = tints[dark ? 800 : 200].hex
66
-
67
- return {
68
- fg: tints[dark ? 100 : 900].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'),
72
- shadow: {
73
- outline: rgba(tints[500].hex, 0.4),
74
- umbra: dark ? rgba(tints[900].hex, 0.4) : rgba(tints[500].hex, 0.2),
75
- penumbra: dark ? rgba(tints[900].hex, 0.28) : rgba(tints[500].hex, 0.14),
76
- ambient: dark ? rgba(tints[900].hex, 0.24) : rgba(tints[500].hex, 0.12),
77
- },
78
- skeleton: {
79
- from: skeletonFrom,
80
- to: rgba(skeletonFrom, 0.5),
81
- },
82
- }
83
- },
84
-
85
- solid: ({base, dark, name, state, tone}) => {
86
- const mix = dark ? screen : multiply
87
- const mix2 = dark ? multiply : screen
88
- const defaultTints = tones[name] || tones.default
89
- const isNeutral = NEUTRAL_TONES.includes(name) && NEUTRAL_TONES.includes(tone)
90
-
91
- let tints = tones[tone === 'default' ? name : tone] || defaultTints
92
-
93
- if (state === 'disabled') {
94
- tints = defaultTints
95
-
96
- const bg = getColorHex(tones.default, dark, 'default', 'bg_tint')
97
- const skeletonFrom = mix2(bg, tints[dark ? 200 : 800].hex)
98
-
99
- return {
100
- bg,
101
- bg2: mix2(bg, tints[dark ? 50 : 950].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'),
105
- muted: {
106
- fg: mix(base.bg, tints[dark ? 950 : 50].hex),
107
- },
108
- accent: {
109
- fg: mix(base.bg, tints[dark ? 950 : 50].hex),
110
- },
111
- link: {
112
- fg: mix(base.bg, tints[dark ? 950 : 50].hex),
113
- },
114
- code: {
115
- bg,
116
- fg: mix(base.bg, tints[dark ? 950 : 50].hex),
117
- },
118
- skeleton: {
119
- from: skeletonFrom,
120
- to: rgba(skeletonFrom, 0.5),
121
- },
122
- }
123
- }
124
-
125
- if (state === 'hovered') {
126
- const bg = getColorHex(tints, dark, tone, 'bg_accent_hover')
127
- const skeletonFrom = mix2(bg, tints[dark ? 200 : 800].hex)
128
-
129
- return {
130
- bg,
131
- bg2: mix2(bg, tints[dark ? 50 : 950].hex),
132
- border: bg,
133
- fg: getColorHex(tints, dark, 'default', 'bg_base'),
134
- iconColor: getColorHex(tints, dark, 'default', 'icon_inverted'),
135
- muted: {
136
- fg: mix(base.bg, tints[dark ? 800 : 200].hex),
137
- },
138
- accent: {
139
- fg: mix2(bg, hues.red[dark ? 800 : 200].hex),
140
- },
141
- link: {
142
- fg: mix2(bg, hues.blue[dark ? 800 : 200].hex),
143
- },
144
- code: {
145
- bg: mix(bg, tints[dark ? 950 : 50].hex),
146
- fg: mix(base.bg, tints[dark ? 800 : 200].hex),
147
- },
148
- skeleton: {
149
- from: skeletonFrom,
150
- to: rgba(skeletonFrom, 0.5),
151
- },
152
- }
153
- }
154
-
155
- if (state === 'pressed') {
156
- const bg = getColorHex(tints, dark, tone, 'bg_accent_active')
157
- const skeletonFrom = mix2(bg, tints[dark ? 200 : 600].hex)
158
-
159
- return {
160
- bg: bg,
161
- bg2: mix2(bg, tints[dark ? 50 : 950].hex),
162
- border: bg,
163
- fg: getColorHex(tints, dark, 'default', 'bg_base'),
164
- iconColor: getColorHex(tints, dark, 'default', 'icon_inverted'),
165
- muted: {
166
- fg: mix(base.bg, tints[dark ? 800 : 200].hex),
167
- },
168
- accent: {
169
- fg: mix2(bg, hues.red[dark ? 800 : 200].hex),
170
- },
171
- link: {
172
- fg: mix2(bg, hues.blue[dark ? 800 : 200].hex),
173
- },
174
- code: {
175
- bg: mix(bg, tints[dark ? 950 : 50].hex),
176
- fg: mix(base.bg, tints[dark ? 800 : 200].hex),
177
- },
178
- skeleton: {
179
- from: skeletonFrom,
180
- to: rgba(skeletonFrom, 0.5),
181
- },
182
- }
183
- }
184
-
185
- if (state === 'selected') {
186
- if (isNeutral) {
187
- tints = tones.primary
188
- }
189
-
190
- const bg = mix(base.bg, tints[dark ? 200 : 800].hex)
191
- const skeletonFrom = mix2(bg, tints[dark ? 200 : 800].hex)
192
-
193
- return {
194
- bg,
195
- bg2: mix2(bg, tints[dark ? 50 : 950].hex),
196
- border: bg,
197
- fg: getColorHex(tints, dark, 'default', 'bg_base'),
198
- iconColor: getColorHex(tints, dark, 'default', 'icon_inverted'),
199
- muted: {
200
- fg: mix(base.bg, tints[dark ? 800 : 200].hex),
201
- },
202
- accent: {
203
- fg: mix2(bg, hues.red[dark ? 800 : 200].hex),
204
- },
205
- link: {
206
- fg: mix2(bg, hues.blue[dark ? 800 : 200].hex),
207
- },
208
- code: {
209
- bg: mix(bg, tints[dark ? 950 : 50].hex),
210
- fg: mix(base.bg, tints[dark ? 800 : 200].hex),
211
- },
212
- skeleton: {
213
- from: skeletonFrom,
214
- to: rgba(skeletonFrom, 0.5),
215
- },
216
- }
217
- }
218
-
219
- // state: "enabled" | unknown
220
- const bg = getColorHex(tints, dark, tone, 'bg_accent')
221
- const skeletonFrom = mix2(bg, tints[dark ? 200 : 800].hex)
222
-
223
- return {
224
- bg,
225
- bg2: mix2(bg, tints[dark ? 50 : 950].hex),
226
- border: bg,
227
- fg: getColorHex(tints, dark, 'default', 'bg_base'),
228
- iconColor: getColorHex(tints, dark, 'default', 'icon_inverted'),
229
- muted: {
230
- fg: mix(base.bg, tints[dark ? 900 : 100].hex),
231
- },
232
- accent: {
233
- fg: mix2(bg, hues.red[dark ? 900 : 100].hex),
234
- },
235
- link: {
236
- fg: mix2(bg, hues.blue[dark ? 900 : 100].hex),
237
- },
238
- code: {
239
- bg: mix(bg, tints[dark ? 950 : 50].hex),
240
- fg: mix(base.bg, tints[dark ? 900 : 100].hex),
241
- },
242
- skeleton: {
243
- from: skeletonFrom,
244
- to: rgba(skeletonFrom, 0.5),
245
- },
246
- }
247
- },
248
-
249
- muted: ({base, dark, name, state, tone}) => {
250
- const mix = dark ? screen : multiply
251
- const defaultTints = tones[name] || tones.default
252
- const isNeutral = NEUTRAL_TONES.includes(name) && NEUTRAL_TONES.includes(tone)
253
-
254
- let tints = tones[tone === 'default' ? name : tone] || defaultTints
255
-
256
- if (state === 'disabled') {
257
- tints = defaultTints
258
-
259
- const bg = base.bg
260
- const skeletonFrom = mix(bg, tints[dark ? 900 : 100].hex)
261
-
262
- return {
263
- bg,
264
- bg2: mix(bg, tints[dark ? 950 : 50].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'),
268
- muted: {
269
- fg: getColorHex(tones.default, dark, 'default', 'text_inactive'),
270
- },
271
- accent: {
272
- fg: getColorHex(tints, dark, tone, 'text_secondary'),
273
- },
274
- link: {
275
- fg: getColorHex(tints, dark, tone, 'text_secondary'),
276
- },
277
- code: {
278
- bg,
279
- fg: getColorHex(tints, dark, tone, 'text_secondary'),
280
- },
281
- skeleton: {
282
- from: rgba(skeletonFrom, 0.5),
283
- to: rgba(skeletonFrom, 0.25),
284
- },
285
- }
286
- }
287
-
288
- if (state === 'hovered') {
289
- const bg = getColorHex(tints, dark, name, 'bg_base_hover')
290
- const skeletonFrom = mix(bg, tints[dark ? 900 : 100].hex)
291
-
292
- return {
293
- bg,
294
- bg2: mix(bg, tints[dark ? 950 : 50].hex),
295
- border: mix(bg, tints[dark ? 900 : 100].hex),
296
- fg: getColorHex(tints, dark, tone, 'text_primary'),
297
- iconColor: getColorHex(tints, dark, name, 'icon_default'),
298
- muted: {
299
- fg: getColorHex(tints, dark, tone, 'text_secondary'),
300
- },
301
- accent: {
302
- fg: mix(base.bg, hues.red[dark ? 400 : 500].hex),
303
- },
304
- link: {
305
- fg: mix(base.bg, hues.blue[dark ? 400 : 600].hex),
306
- },
307
- code: {
308
- bg: mix(bg, tints[dark ? 950 : 50].hex),
309
- fg: getColorHex(tints, dark, tone, 'text_secondary'),
310
- },
311
- skeleton: {
312
- from: skeletonFrom,
313
- to: rgba(skeletonFrom, 0.5),
314
- },
315
- }
316
- }
317
-
318
- if (state === 'pressed') {
319
- if (isNeutral) {
320
- tints = tones.primary
321
- }
322
-
323
- const bg = getColorHex(tints, dark, name, 'bg_base_active')
324
- const skeletonFrom = mix(bg, getColorHex(tints, dark, name, 'bg_base_active'))
325
-
326
- return {
327
- bg,
328
- bg2: mix(bg, tints[dark ? 950 : 50].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'),
332
- muted: {
333
- fg: getColorHex(tints, dark, tone, 'text_secondary'),
334
- },
335
- accent: {
336
- fg: mix(bg, hues.red[dark ? 400 : 500].hex),
337
- },
338
- link: {
339
- fg: mix(bg, hues.blue[dark ? 400 : 600].hex),
340
- },
341
- code: {
342
- bg: mix(bg, tints[dark ? 950 : 50].hex),
343
- fg: getColorHex(tints, dark, tone, 'text_secondary'),
344
- },
345
- skeleton: {
346
- from: skeletonFrom,
347
- to: rgba(skeletonFrom, 0.5),
348
- },
349
- }
350
- }
351
-
352
- if (state === 'selected') {
353
- if (isNeutral) {
354
- tints = tones.primary
355
- }
356
-
357
- const bg = mix(base.bg, tints[dark ? 900 : 100].hex)
358
- const skeletonFrom = mix(bg, tints[dark ? 900 : 100].hex)
359
-
360
- return {
361
- bg,
362
- bg2: mix(bg, tints[dark ? 950 : 50].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'),
366
- muted: {
367
- fg: getColorHex(tints, dark, tone, 'text_secondary'),
368
- },
369
- accent: {
370
- fg: mix(bg, hues.red[dark ? 400 : 500].hex),
371
- },
372
- link: {
373
- fg: mix(bg, hues.blue[dark ? 400 : 600].hex),
374
- },
375
- code: {
376
- bg: mix(bg, tints[dark ? 950 : 50].hex),
377
- fg: getColorHex(tints, dark, tone, 'text_secondary'),
378
- },
379
- skeleton: {
380
- from: skeletonFrom,
381
- to: rgba(skeletonFrom, 0.5),
382
- },
383
- }
384
- }
385
-
386
- const bg = base.bg
387
- const skeletonFrom = mix(bg, tints[dark ? 900 : 100].hex)
388
-
389
- return {
390
- bg,
391
- bg2: mix(bg, tints[dark ? 950 : 50].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'),
395
- muted: {
396
- fg: getColorHex(tints, dark, tone, 'text_secondary'),
397
- },
398
- accent: {
399
- fg: mix(base.bg, hues.red[dark ? 400 : 500].hex),
400
- },
401
- link: {
402
- fg: mix(base.bg, hues.blue[dark ? 400 : 600].hex),
403
- },
404
- code: {
405
- bg: mix(base.bg, tints[dark ? 950 : 50].hex),
406
- fg: getColorHex(tints, dark, tone, 'text_secondary'),
407
- },
408
- skeleton: {
409
- from: skeletonFrom,
410
- to: rgba(skeletonFrom, 0.5),
411
- },
412
- }
413
- },
414
-
415
- button: ({base, mode, muted, solid}) => {
416
- if (mode === 'bleed') {
417
- return {
418
- enabled: {
419
- ...muted.enabled,
420
- border: muted.enabled.bg,
421
- },
422
- hovered: {
423
- ...muted.hovered,
424
- border: muted.hovered.bg,
425
- },
426
- pressed: {
427
- ...muted.pressed,
428
- border: muted.pressed.bg,
429
- },
430
- selected: {
431
- ...muted.selected,
432
- border: muted.selected.bg,
433
- },
434
- disabled: {
435
- ...muted.disabled,
436
- border: muted.disabled.bg,
437
- },
438
- }
439
- }
440
-
441
- if (mode === 'ghost') {
442
- return {
443
- ...muted,
444
- enabled: {
445
- ...muted.enabled,
446
- border: base.border,
447
- },
448
- }
449
- }
450
-
451
- return solid
452
- },
453
-
454
- card: ({base, dark, muted, name, solid, state}) => {
455
- if (state === 'hovered') {
456
- return muted[name].hovered
457
- }
458
-
459
- if (state === 'disabled') {
460
- return muted[name].disabled
461
- }
462
-
463
- const isNeutral = NEUTRAL_TONES.includes(name)
464
- const tints = tones[name] || tones.default
465
- const mix = dark ? screen : multiply
466
-
467
- if (state === 'pressed') {
468
- if (isNeutral) {
469
- return muted.primary.pressed
470
- }
471
-
472
- return muted[name].pressed
473
- }
474
-
475
- if (state === 'selected') {
476
- if (isNeutral) {
477
- return solid.primary.enabled
478
- }
479
-
480
- return solid[name].enabled
481
- }
482
-
483
- const bg = base.bg
484
- const skeletonFrom = mix(base.bg, tints[dark ? 900 : 100].hex)
485
-
486
- return {
487
- bg,
488
- bg2: mix(bg, tints[dark ? 950 : 50].hex),
489
- fg: base.fg,
490
- iconColor: getColorHex(tints, dark, name, 'icon_default'),
491
- border: base.border,
492
- muted: {
493
- fg: mix(base.bg, tints[dark ? 400 : 600].hex),
494
- },
495
- accent: {
496
- fg: mix(base.bg, hues.red[dark ? 400 : 500].hex),
497
- },
498
- link: {
499
- fg: mix(base.bg, hues.blue[dark ? 400 : 600].hex),
500
- },
501
- code: {
502
- bg: mix(base.bg, tints[dark ? 950 : 50].hex),
503
- fg: tints[dark ? 400 : 600].hex,
504
- },
505
- skeleton: {
506
- from: skeletonFrom,
507
- to: rgba(skeletonFrom, 0.5),
508
- },
509
- }
510
- },
511
-
512
- input: ({base, dark, mode, state}) => {
513
- const mix = dark ? screen : multiply
514
-
515
- if (mode === 'invalid') {
516
- const tints = tones.critical
517
-
518
- return {
519
- bg: mix(base.bg, tints[dark ? 950 : 50].hex),
520
- bg2: getColorHex(tints, dark, 'critical', 'text_secondary'),
521
- fg: mix(base.bg, tints[dark ? 400 : 600].hex),
522
- border: getColorHex(tints, dark, 'critical', 'border_base'),
523
- placeholder: getColorHex(tones.default, !dark, 'default', 'text_secondary'),
524
- }
525
- }
526
-
527
- if (state === 'hovered') {
528
- return {
529
- bg: base.bg,
530
- bg2: getColorHex(tones.default, dark, 'default', 'text_secondary'),
531
- fg: base.fg,
532
- border: mix(base.bg, hues.gray[dark ? 700 : 300].hex),
533
- placeholder: getColorHex(tones.default, !dark, 'default', 'text_secondary'),
534
- }
535
- }
536
-
537
- if (state === 'disabled') {
538
- return {
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'),
544
- }
545
- }
546
-
547
- if (state === 'readOnly') {
548
- return {
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'),
554
- }
555
- }
556
-
557
- return {
558
- bg: base.bg,
559
- bg2: getColorHex(tones.default, dark, 'default', 'text_secondary'),
560
- fg: base.fg,
561
- border: base.border,
562
- placeholder: getColorHex(tones.default, !dark, 'default', 'text_secondary'),
563
- }
564
- },
565
-
566
- selectable: ({base, muted, tone, solid, state}) => {
567
- if (state === 'enabled') {
568
- return {
569
- ...muted[tone].enabled,
570
- bg: base.bg,
571
- }
572
- }
573
-
574
- if (state === 'pressed') {
575
- if (tone === 'default') {
576
- return muted.primary.pressed
577
- }
578
-
579
- return muted[tone].pressed
580
- }
581
-
582
- if (state === 'selected') {
583
- if (tone === 'default') {
584
- return solid.primary.enabled
585
- }
586
-
587
- return solid[tone].enabled
588
- }
589
-
590
- if (state === 'disabled') {
591
- return {
592
- ...muted[tone].disabled,
593
- bg: base.bg,
594
- }
595
- }
596
-
597
- return muted[tone][state]
598
- },
599
-
600
- spot: ({base, dark, key}) => {
601
- const mix = dark ? screen : multiply
602
-
603
- return mix(base.bg, hues[key][dark ? 400 : 500].hex)
604
- },
605
-
606
- syntax: ({base, dark}) => {
607
- const mix = dark ? screen : multiply
608
- const mainShade = dark ? 400 : 600
609
- const secondaryShade = dark ? 600 : 400
610
-
611
- return {
612
- atrule: mix(base.bg, hues.purple[mainShade].hex),
613
- attrName: mix(base.bg, hues.green[mainShade].hex),
614
- attrValue: mix(base.bg, hues.yellow[mainShade].hex),
615
- attribute: mix(base.bg, hues.yellow[mainShade].hex),
616
- boolean: mix(base.bg, hues.purple[mainShade].hex),
617
- builtin: mix(base.bg, hues.purple[mainShade].hex),
618
- cdata: mix(base.bg, hues.yellow[mainShade].hex),
619
- char: mix(base.bg, hues.yellow[mainShade].hex),
620
- class: mix(base.bg, hues.orange[mainShade].hex),
621
- className: mix(base.bg, hues.cyan[mainShade].hex),
622
- comment: mix(base.bg, hues.gray[secondaryShade].hex),
623
- constant: mix(base.bg, hues.purple[mainShade].hex),
624
- deleted: mix(base.bg, hues.red[mainShade].hex),
625
- doctype: mix(base.bg, hues.gray[secondaryShade].hex),
626
- entity: mix(base.bg, hues.red[mainShade].hex),
627
- function: mix(base.bg, hues.green[mainShade].hex),
628
- hexcode: mix(base.bg, hues.blue[mainShade].hex),
629
- id: mix(base.bg, hues.purple[mainShade].hex),
630
- important: mix(base.bg, hues.purple[mainShade].hex),
631
- inserted: mix(base.bg, hues.yellow[mainShade].hex),
632
- keyword: mix(base.bg, hues.magenta[mainShade].hex),
633
- number: mix(base.bg, hues.purple[mainShade].hex),
634
- operator: mix(base.bg, hues.magenta[mainShade].hex),
635
- prolog: mix(base.bg, hues.gray[secondaryShade].hex),
636
- property: mix(base.bg, hues.blue[mainShade].hex),
637
- pseudoClass: mix(base.bg, hues.yellow[mainShade].hex),
638
- pseudoElement: mix(base.bg, hues.yellow[mainShade].hex),
639
- punctuation: mix(base.bg, hues.gray[mainShade].hex),
640
- regex: mix(base.bg, hues.blue[mainShade].hex),
641
- selector: mix(base.bg, hues.red[mainShade].hex),
642
- string: mix(base.bg, hues.yellow[mainShade].hex),
643
- symbol: mix(base.bg, hues.purple[mainShade].hex),
644
- tag: mix(base.bg, hues.red[mainShade].hex),
645
- unit: mix(base.bg, hues.orange[mainShade].hex),
646
- url: mix(base.bg, hues.red[mainShade].hex),
647
- variable: mix(base.bg, hues.red[mainShade].hex),
648
- }
649
- },
650
- })
@@ -1,10 +1,20 @@
1
- import {parseColor, rgbToHex, screen as _screen, multiply as _multiply} from '../lib/color-fns'
1
+ import {
2
+ parseColor,
3
+ rgbToHex,
4
+ screen as _screen,
5
+ multiply as _multiply,
6
+ rgba,
7
+ } from '../lib/color-fns'
2
8
 
3
9
  export function multiply(bg: string, fg: string): string {
4
10
  const b = parseColor(bg)
5
11
  const s = parseColor(fg)
6
12
  const hex = rgbToHex(_multiply(b, s))
7
13
 
14
+ if (s.a) {
15
+ return rgba(hex, s.a)
16
+ }
17
+
8
18
  return hex
9
19
  }
10
20
 
@@ -13,5 +23,9 @@ export function screen(bg: string, fg: string): string {
13
23
  const s = parseColor(fg)
14
24
  const hex = rgbToHex(_screen(b, s))
15
25
 
26
+ if (s.a) {
27
+ return rgba(hex, s.a)
28
+ }
29
+
16
30
  return hex
17
31
  }
@@ -1,5 +1,5 @@
1
1
  import {RootTheme} from '../types'
2
- import {color} from './color'
2
+ import {tones} from './color'
3
3
  import {fonts} from './fonts'
4
4
 
5
5
  /**
@@ -21,7 +21,13 @@ export const studioTheme: RootTheme = {
21
21
  card: {
22
22
  focusRing: {offset: -1, width: 1},
23
23
  },
24
- color,
24
+ color: {
25
+ tones: tones,
26
+
27
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
28
+ // @ts-ignore This is necessary until workshop is updated.
29
+ base: {bg: '#fffff'},
30
+ },
25
31
  container: [320, 640, 960, 1280, 1600, 1920],
26
32
  focusRing: {
27
33
  offset: 1,
@@ -33,7 +39,7 @@ export const studioTheme: RootTheme = {
33
39
  shadows: [
34
40
  null,
35
41
  {umbra: [0, 0, 0, 0], penumbra: [0, 0, 0, 0], ambient: [0, 0, 0, 0]},
36
- {umbra: [0, 3, 5, -1], penumbra: [0, 6, 10, 0], ambient: [0, 1, 18, 0]},
42
+ {umbra: [0, 3, 5, -2], penumbra: [0, 6, 10, 0], ambient: [0, 1, 18, 1]},
37
43
  {umbra: [0, 7, 8, -4], penumbra: [0, 12, 17, 2], ambient: [0, 5, 22, 4]},
38
44
  {umbra: [0, 9, 11, -5], penumbra: [0, 18, 28, 2], ambient: [0, 7, 34, 6]},
39
45
  {umbra: [0, 11, 15, -7], penumbra: [0, 24, 38, 3], ambient: [0, 9, 46, 8]},