@sanity/ui 2.0.0-alpha.2 → 2.0.0-alpha.21
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.cjs.mjs +28 -0
- package/dist/index.d.ts +476 -12
- package/dist/index.esm.js +1326 -524
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1353 -523
- package/dist/index.js.map +1 -1
- package/package.json +6 -8
- package/src/components/autocomplete/autocomplete.tsx +6 -0
- package/src/components/dialog/constants.ts +4 -0
- package/src/components/dialog/dialog.tsx +79 -15
- package/src/components/hotkeys/hotkeys.tsx +2 -0
- package/src/components/menu/menu.tsx +2 -0
- package/src/components/menu/menuButton.tsx +2 -0
- package/src/components/menu/menuGroup.tsx +22 -23
- package/src/components/menu/menuItem.tsx +29 -35
- package/src/components/tab/tab.tsx +4 -1
- package/src/components/toast/toast.tsx +4 -0
- package/src/primitives/_selectable/style.ts +2 -1
- package/src/primitives/avatar/avatar.tsx +16 -9
- package/src/primitives/avatar/avatarCounter.tsx +3 -3
- package/src/primitives/avatar/styles.ts +1 -1
- package/src/primitives/badge/badge.tsx +7 -3
- package/src/primitives/box/box.tsx +3 -0
- package/src/primitives/button/__workshop__/sanityUploadButton.tsx +2 -1
- package/src/primitives/button/button.tsx +7 -3
- package/src/primitives/button/styles.ts +9 -2
- package/src/primitives/card/card.tsx +4 -0
- package/src/primitives/card/styles.ts +2 -0
- package/src/primitives/checkbox/checkbox.tsx +2 -0
- package/src/primitives/code/code.tsx +1 -0
- package/src/primitives/container/container.tsx +2 -0
- package/src/primitives/flex/flex.tsx +2 -0
- package/src/primitives/grid/grid.tsx +2 -0
- package/src/primitives/heading/heading.tsx +2 -0
- package/src/primitives/inline/inline.tsx +3 -0
- package/src/primitives/kbd/kbd.tsx +2 -0
- package/src/primitives/label/label.tsx +2 -0
- package/src/primitives/popover/popover.tsx +6 -1
- package/src/primitives/radio/radio.tsx +2 -0
- package/src/primitives/select/select.tsx +2 -0
- package/src/primitives/select/styles.ts +2 -0
- package/src/primitives/spinner/spinner.tsx +2 -0
- package/src/primitives/stack/stack.tsx +2 -0
- package/src/primitives/switch/switch.tsx +4 -0
- package/src/primitives/text/text.tsx +3 -0
- package/src/primitives/textArea/textArea.tsx +4 -1
- package/src/primitives/textInput/textInput.tsx +10 -1
- package/src/primitives/tooltip/__workshop__/customPortal.tsx +99 -0
- package/src/primitives/tooltip/__workshop__/index.ts +15 -0
- package/src/primitives/tooltip/__workshop__/overflowingBoundary.tsx +73 -0
- package/src/primitives/tooltip/__workshop__/resizableBoundary.tsx +85 -0
- package/src/primitives/tooltip/constants.ts +1 -0
- package/src/primitives/tooltip/tooltip.test.tsx +192 -0
- package/src/primitives/tooltip/tooltip.tsx +109 -33
- package/src/primitives/types.ts +4 -0
- package/src/styles/input/textInputStyle.ts +11 -6
- package/src/theme/_internal/__workshop__/build/story.tsx +288 -0
- package/src/theme/_internal/__workshop__/build/theme.ts +3 -0
- package/src/theme/_internal/__workshop__/index.ts +14 -0
- package/src/theme/_internal/build/buildTheme.test.ts +78 -0
- package/src/theme/_internal/build/buildTheme.ts +16 -0
- package/src/theme/_internal/build/colorTheme/buildColorTheme.test.ts +185 -0
- package/src/theme/_internal/build/colorTheme/buildColorTheme.ts +164 -0
- package/src/theme/_internal/build/colorTheme/renderColorTheme.ts +242 -0
- package/src/theme/_internal/build/colorTheme/resolveColorTokens.ts +121 -0
- package/src/theme/_internal/build/defaults/colorPalette.ts +8 -0
- package/src/theme/_internal/build/defaults/colorTokens.ts +147 -0
- package/src/theme/_internal/build/helpers.ts +65 -0
- package/src/theme/_internal/build/index.ts +1 -0
- package/src/theme/_internal/config/helpers.ts +47 -0
- package/src/theme/_internal/config/index.ts +3 -0
- package/src/theme/_internal/config/token/index.ts +2 -0
- package/src/theme/_internal/config/token/parseTokenKey.test.ts +72 -0
- package/src/theme/_internal/config/token/parseTokenKey.ts +88 -0
- package/src/theme/_internal/config/token/parseTokenValue.test.ts +45 -0
- package/src/theme/_internal/config/token/parseTokenValue.ts +123 -0
- package/src/theme/_internal/config/types.ts +137 -0
- package/src/theme/_internal/constants.ts +48 -0
- package/src/theme/_internal/helpers.ts +19 -0
- package/src/theme/_internal/index.ts +5 -0
- package/src/theme/_internal/types.ts +91 -0
- package/src/theme/index.ts +1 -0
- package/src/theme/lib/color-fns/blend/multiply.ts +2 -2
- package/src/theme/lib/color-fns/blend/screen.ts +2 -2
- package/src/theme/lib/color-fns/convert.ts +15 -1
- package/src/theme/lib/color-fns/parse.ts +7 -3
- package/src/theme/lib/color-fns/types.ts +11 -0
- package/src/theme/lib/theme/avatar.ts +2 -0
- package/src/theme/lib/theme/color/_legacy/createColorTheme.ts +7 -0
- package/src/theme/lib/theme/color/_legacy/index.ts +1 -0
- package/src/theme/lib/theme/color/_legacy/legacyColor.ts +3997 -0
- package/src/theme/studioTheme/color.ts +98 -82
- package/src/theme/studioTheme/helpers.ts +15 -1
- package/src/theme/studioTheme/theme.ts +5 -5
- package/src/theme/studioTheme/tints.ts +244 -84
- package/src/types/button.ts +5 -0
|
@@ -1,67 +1,201 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This file creates a translation between the tints and the studio colors
|
|
3
3
|
* Providing readable names, and allowing to mix colors and tints in the same ThemeColor.
|
|
4
|
-
* e.g. for positive theme: `{"bg_base": "white", "
|
|
4
|
+
* e.g. for positive theme: `{"bg_base": "white", ""bg-base-hover"": "gray/50", ""bg-base-active"": "cyan/50"}
|
|
5
5
|
* This is not possible in the previous configuration, as each ThemeColor uses only one tint.
|
|
6
6
|
*/
|
|
7
|
-
import {ColorTintKey, ColorTints,
|
|
7
|
+
import {ColorTintKey, ColorTints, ColorTint, black, hues, white} from '@sanity/color'
|
|
8
|
+
import {rgba} from '../lib/color-fns'
|
|
8
9
|
import {ThemeColorName, ThemeColorSchemeKey} from '../lib/theme'
|
|
9
10
|
|
|
10
11
|
export const colorKeys = [
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
-
'
|
|
21
|
-
'
|
|
22
|
-
'
|
|
23
|
-
'
|
|
24
|
-
'
|
|
25
|
-
'
|
|
12
|
+
'text-primary',
|
|
13
|
+
'text-secondary',
|
|
14
|
+
'text-inactive',
|
|
15
|
+
// TODO: Can this be replaced by other of the text colors? It's used by the code html element if it's inside a text
|
|
16
|
+
'text-code',
|
|
17
|
+
'text-muted',
|
|
18
|
+
'text-link',
|
|
19
|
+
'text-accent',
|
|
20
|
+
'bg-base',
|
|
21
|
+
'bg-base-hover',
|
|
22
|
+
'bg-base-active',
|
|
23
|
+
'bg-accent',
|
|
24
|
+
'bg-accent-hover',
|
|
25
|
+
'bg-accent-active',
|
|
26
|
+
'bg-tint',
|
|
27
|
+
// TODO: Can we replace this with bg_tint? It's used by the code html element if it's inside a text
|
|
28
|
+
'bg-tint-code',
|
|
29
|
+
|
|
30
|
+
'icon-default',
|
|
31
|
+
'icon-inverted',
|
|
32
|
+
'border-base',
|
|
33
|
+
'border-base-hover',
|
|
34
|
+
'border-accent',
|
|
35
|
+
'border-accent-inverted',
|
|
36
|
+
|
|
37
|
+
// Colors starting with -base won't be affected by the mix function
|
|
38
|
+
'base-bg-card', // This is used by the card when a tone is defined, it will also override the bg-base in the rest of the components.
|
|
39
|
+
'base-bg-raw', // This is the same color as bg-base, but it won't be overridden by the card bg color, used in selectable items.
|
|
40
|
+
|
|
41
|
+
'base-shadow-outline-color',
|
|
42
|
+
'base-shadow-umbra-color',
|
|
43
|
+
'base-shadow-penumbra-color',
|
|
44
|
+
'base-shadow-ambient-color',
|
|
45
|
+
'base-text-color', // Color used by the buttons for default mode text
|
|
46
|
+
|
|
47
|
+
'skeleton-from',
|
|
48
|
+
'skeleton-to',
|
|
26
49
|
] as const
|
|
27
50
|
|
|
28
51
|
export type ColorKey = (typeof colorKeys)[number]
|
|
29
52
|
|
|
30
|
-
type
|
|
53
|
+
type ColorWithOpacity = {
|
|
54
|
+
type: 'colorWithOpacity'
|
|
55
|
+
tint: ColorTintKey
|
|
56
|
+
/**
|
|
57
|
+
* Number between 0 and 1
|
|
58
|
+
*/
|
|
59
|
+
opacity: number
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
type DefaultColor = {
|
|
63
|
+
type: 'colorTint'
|
|
64
|
+
value: ColorTint
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
type ColorTintsDictionary = Record<ColorKey, ColorTintKey | DefaultColor | ColorWithOpacity>
|
|
31
68
|
const defaultTints: Record<ThemeColorSchemeKey, ColorTintsDictionary> = {
|
|
32
69
|
light: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
70
|
+
'text-primary': '900',
|
|
71
|
+
'text-secondary': '600',
|
|
72
|
+
'text-inactive': '500',
|
|
73
|
+
'text-code': '600',
|
|
74
|
+
'text-muted': '600',
|
|
75
|
+
'text-link': {
|
|
76
|
+
type: 'colorTint',
|
|
77
|
+
value: hues.blue['600'],
|
|
78
|
+
},
|
|
79
|
+
'text-accent': {
|
|
80
|
+
type: 'colorTint',
|
|
81
|
+
value: hues.red['500'],
|
|
82
|
+
},
|
|
83
|
+
'bg-base': {
|
|
84
|
+
type: 'colorTint',
|
|
85
|
+
value: white,
|
|
86
|
+
},
|
|
87
|
+
'bg-base-hover': '50',
|
|
88
|
+
'bg-base-active': '100',
|
|
89
|
+
'bg-accent': '500',
|
|
90
|
+
'bg-accent-hover': '600',
|
|
91
|
+
'bg-accent-active': '700',
|
|
92
|
+
'bg-tint': '50',
|
|
93
|
+
'bg-tint-code': '50',
|
|
94
|
+
'icon-default': '500',
|
|
95
|
+
'icon-inverted': {
|
|
96
|
+
type: 'colorTint',
|
|
97
|
+
value: white,
|
|
98
|
+
},
|
|
99
|
+
'border-base': '100',
|
|
100
|
+
'border-base-hover': '200',
|
|
101
|
+
'border-accent': '500',
|
|
102
|
+
'border-accent-inverted': {
|
|
103
|
+
type: 'colorTint',
|
|
104
|
+
value: white,
|
|
105
|
+
},
|
|
106
|
+
'base-bg-card': '50',
|
|
107
|
+
'base-bg-raw': {
|
|
108
|
+
type: 'colorTint',
|
|
109
|
+
value: white,
|
|
110
|
+
},
|
|
111
|
+
'base-text-color': {type: 'colorTint', value: white},
|
|
112
|
+
'base-shadow-outline-color': {
|
|
113
|
+
type: 'colorWithOpacity',
|
|
114
|
+
tint: '500',
|
|
115
|
+
opacity: 0.2,
|
|
116
|
+
},
|
|
117
|
+
'base-shadow-umbra-color': {
|
|
118
|
+
type: 'colorWithOpacity',
|
|
119
|
+
tint: '500',
|
|
120
|
+
opacity: 0.1,
|
|
121
|
+
},
|
|
122
|
+
'base-shadow-penumbra-color': {
|
|
123
|
+
type: 'colorWithOpacity',
|
|
124
|
+
tint: '500',
|
|
125
|
+
opacity: 0.07,
|
|
126
|
+
},
|
|
127
|
+
'base-shadow-ambient-color': {
|
|
128
|
+
type: 'colorWithOpacity',
|
|
129
|
+
tint: '500',
|
|
130
|
+
opacity: 0.06,
|
|
131
|
+
},
|
|
132
|
+
'skeleton-from': '100',
|
|
133
|
+
'skeleton-to': {
|
|
134
|
+
type: 'colorWithOpacity',
|
|
135
|
+
tint: '50',
|
|
136
|
+
opacity: 0.5,
|
|
137
|
+
},
|
|
48
138
|
},
|
|
49
139
|
dark: {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
140
|
+
'text-primary': '50',
|
|
141
|
+
'text-secondary': '300',
|
|
142
|
+
'text-inactive': '400',
|
|
143
|
+
'text-code': '400',
|
|
144
|
+
'text-muted': '400',
|
|
145
|
+
'text-link': {
|
|
146
|
+
type: 'colorTint',
|
|
147
|
+
value: hues.blue['400'],
|
|
148
|
+
},
|
|
149
|
+
'text-accent': {
|
|
150
|
+
type: 'colorTint',
|
|
151
|
+
value: hues.red['400'],
|
|
152
|
+
},
|
|
153
|
+
'bg-base': {type: 'colorTint', value: black},
|
|
154
|
+
'bg-base-hover': '900',
|
|
155
|
+
'bg-base-active': '800',
|
|
156
|
+
'bg-accent': '500',
|
|
157
|
+
'bg-accent-hover': '400',
|
|
158
|
+
'bg-accent-active': '300',
|
|
159
|
+
'bg-tint': '900',
|
|
160
|
+
'bg-tint-code': '950',
|
|
161
|
+
'icon-default': '300',
|
|
162
|
+
'icon-inverted': {type: 'colorTint', value: hues.gray[900]},
|
|
163
|
+
'border-base': '800',
|
|
164
|
+
'border-base-hover': '700',
|
|
165
|
+
'border-accent': '300',
|
|
166
|
+
'border-accent-inverted': {type: 'colorTint', value: hues.gray[900]},
|
|
167
|
+
'base-bg-card': '950',
|
|
168
|
+
'base-text-color': {type: 'colorTint', value: black},
|
|
169
|
+
'base-shadow-outline-color': {
|
|
170
|
+
type: 'colorWithOpacity',
|
|
171
|
+
tint: '500',
|
|
172
|
+
opacity: 0.4,
|
|
173
|
+
},
|
|
174
|
+
'base-shadow-umbra-color': {
|
|
175
|
+
type: 'colorWithOpacity',
|
|
176
|
+
tint: '900',
|
|
177
|
+
opacity: 0.4,
|
|
178
|
+
},
|
|
179
|
+
'base-shadow-penumbra-color': {
|
|
180
|
+
type: 'colorWithOpacity',
|
|
181
|
+
tint: '900',
|
|
182
|
+
opacity: 0.28,
|
|
183
|
+
},
|
|
184
|
+
'base-shadow-ambient-color': {
|
|
185
|
+
type: 'colorWithOpacity',
|
|
186
|
+
tint: '900',
|
|
187
|
+
opacity: 0.24,
|
|
188
|
+
},
|
|
189
|
+
'base-bg-raw': {
|
|
190
|
+
type: 'colorTint',
|
|
191
|
+
value: black,
|
|
192
|
+
},
|
|
193
|
+
'skeleton-from': '900',
|
|
194
|
+
'skeleton-to': {
|
|
195
|
+
type: 'colorWithOpacity',
|
|
196
|
+
tint: '50',
|
|
197
|
+
opacity: 0.5,
|
|
198
|
+
},
|
|
65
199
|
},
|
|
66
200
|
}
|
|
67
201
|
|
|
@@ -72,81 +206,107 @@ export const colorTints: Record<
|
|
|
72
206
|
light: {
|
|
73
207
|
default: {
|
|
74
208
|
...defaultTints.light,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
209
|
+
'base-bg-card': {type: 'colorTint', value: white},
|
|
210
|
+
'bg-accent': '900',
|
|
211
|
+
'bg-accent-hover': '950',
|
|
212
|
+
'bg-accent-active': {type: 'colorTint', value: black},
|
|
213
|
+
'border-accent': '600',
|
|
79
214
|
},
|
|
80
215
|
primary: {
|
|
81
216
|
...defaultTints.light,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
217
|
+
'bg-accent': '900',
|
|
218
|
+
'bg-accent-hover': '950',
|
|
219
|
+
'bg-accent-active': {type: 'colorTint', value: black},
|
|
220
|
+
'border-accent': '600',
|
|
86
221
|
},
|
|
87
222
|
positive: {
|
|
88
223
|
...defaultTints.light,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
224
|
+
'bg-base-hover': {type: 'colorTint', value: hues.gray[50]},
|
|
225
|
+
'bg-base-active': '50',
|
|
226
|
+
'bg-accent': '400',
|
|
227
|
+
'bg-accent-hover': '500',
|
|
228
|
+
'bg-accent-active': '600',
|
|
229
|
+
'border-accent': '400',
|
|
95
230
|
},
|
|
96
231
|
transparent: defaultTints.light,
|
|
97
232
|
caution: defaultTints.light,
|
|
98
|
-
critical: defaultTints.light,
|
|
233
|
+
critical: {...defaultTints.light, 'text-inactive': '300'},
|
|
99
234
|
},
|
|
100
235
|
dark: {
|
|
101
236
|
default: {
|
|
102
237
|
...defaultTints.dark,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
238
|
+
'base-bg-card': {type: 'colorTint', value: black},
|
|
239
|
+
'text-primary': {type: 'colorTint', value: white},
|
|
240
|
+
'bg-accent': {type: 'colorTint', value: white},
|
|
241
|
+
'bg-accent-hover': '50',
|
|
242
|
+
'bg-accent-active': '100',
|
|
243
|
+
'base-shadow-umbra-color': {
|
|
244
|
+
type: 'colorWithOpacity',
|
|
245
|
+
tint: '950',
|
|
246
|
+
opacity: 0.4,
|
|
247
|
+
},
|
|
248
|
+
'base-shadow-penumbra-color': {
|
|
249
|
+
type: 'colorWithOpacity',
|
|
250
|
+
tint: '950',
|
|
251
|
+
opacity: 0.28,
|
|
252
|
+
},
|
|
253
|
+
'base-shadow-ambient-color': {
|
|
254
|
+
type: 'colorWithOpacity',
|
|
255
|
+
tint: '950',
|
|
256
|
+
opacity: 0.24,
|
|
257
|
+
},
|
|
107
258
|
},
|
|
108
259
|
primary: {
|
|
109
260
|
...defaultTints.dark,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
261
|
+
'text-primary': {type: 'colorTint', value: white},
|
|
262
|
+
'bg-accent': {type: 'colorTint', value: white},
|
|
263
|
+
'bg-accent-hover': '50',
|
|
264
|
+
'bg-accent-active': '100',
|
|
114
265
|
},
|
|
115
266
|
positive: {
|
|
116
267
|
...defaultTints.dark,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
268
|
+
'bg-base-hover': {type: 'colorTint', value: hues.gray[900]},
|
|
269
|
+
'bg-base-active': '900',
|
|
270
|
+
'bg-accent': '400',
|
|
271
|
+
'bg-accent-hover': '300',
|
|
272
|
+
'bg-accent-active': '200',
|
|
273
|
+
'border-accent': '400',
|
|
123
274
|
},
|
|
124
275
|
transparent: defaultTints.dark,
|
|
125
276
|
caution: defaultTints.dark,
|
|
126
|
-
critical: defaultTints.dark,
|
|
277
|
+
critical: {...defaultTints.dark, 'text-inactive': '700'},
|
|
127
278
|
},
|
|
128
279
|
}
|
|
129
280
|
|
|
130
281
|
export const getColorValue = (
|
|
131
282
|
tints: ColorTints,
|
|
132
|
-
|
|
283
|
+
scheme: ThemeColorSchemeKey,
|
|
133
284
|
tone: ThemeColorName,
|
|
134
285
|
key: ColorKey,
|
|
135
|
-
):
|
|
136
|
-
const value = colorTints[
|
|
286
|
+
): ColorTint => {
|
|
287
|
+
const value = colorTints[scheme][tone][key]
|
|
137
288
|
|
|
138
289
|
if (typeof value === 'string') {
|
|
139
290
|
return tints[value]
|
|
140
291
|
}
|
|
141
292
|
|
|
142
|
-
|
|
293
|
+
if (value.type === 'colorWithOpacity') {
|
|
294
|
+
const base = tints[value.tint]
|
|
295
|
+
|
|
296
|
+
return {
|
|
297
|
+
hex: rgba(base.hex, value.opacity),
|
|
298
|
+
title: `${base.title} ${Math.round(value.opacity * 100)}%`,
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return value.value
|
|
143
303
|
}
|
|
144
304
|
|
|
145
305
|
export const getColorHex = (
|
|
146
306
|
tints: ColorTints,
|
|
147
|
-
|
|
307
|
+
scheme: ThemeColorSchemeKey,
|
|
148
308
|
tone: ThemeColorName,
|
|
149
309
|
key: ColorKey,
|
|
150
310
|
): string => {
|
|
151
|
-
return getColorValue(tints,
|
|
311
|
+
return getColorValue(tints, scheme, tone, key).hex
|
|
152
312
|
}
|
package/src/types/button.ts
CHANGED