@sanity/ui 2.0.0-beta.2 → 2.0.0-beta.4
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 +10 -36
- package/dist/index.d.ts +179 -238
- package/dist/index.esm.js +18 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +26 -218
- package/dist/index.js.map +1 -1
- package/dist/theme.cjs.mjs +1 -1
- package/dist/theme.d.ts +75 -111
- package/dist/theme.esm.js +154 -92
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +154 -92
- package/dist/theme.js.map +1 -1
- package/package.json +1 -1
- package/src/core/_compat.ts +236 -87
- package/src/core/components/menu/__workshop__/selectedItem.tsx +7 -2
- package/src/core/components/menu/menuButton.tsx +12 -1
- package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +6 -3
- package/src/core/primitives/kbd/kbd.tsx +2 -0
- package/src/core/styles/margin/marginsStyle.test.ts +2 -2
- package/src/core/styles/padding/paddingStyle.test.ts +2 -2
- package/src/core/theme/__workshop__/build/Root.tsx +20 -3
- package/src/core/theme/__workshop__/build/story.tsx +16 -10
- package/src/core/theme/__workshop__/canvas.tsx +7 -7
- package/src/core/theme/__workshop__/debug/story.tsx +159 -0
- package/src/core/theme/__workshop__/index.ts +5 -0
- package/src/core/theme/theme.test.tsx +2 -2
- package/src/core/types/button.ts +1 -2
- package/src/theme/build/_deprecated/color/factory.ts +3 -3
- package/src/theme/build/buildColorTheme.ts +16 -16
- package/src/theme/build/colorToken/colorToken.ts +19 -0
- package/src/theme/build/colorToken/compileColorToken.ts +17 -0
- package/src/theme/build/colorToken/index.ts +2 -0
- package/src/theme/build/colorToken/types.ts +6 -0
- package/src/theme/build/renderColorTheme.ts +14 -15
- package/src/theme/build/renderColorValue.ts +1 -1
- package/src/theme/config/system.ts +9 -9
- package/src/theme/config/tokens/color/types.ts +12 -1
- package/src/theme/config/tokens/parseTokenKey.ts +1 -0
- package/src/theme/config/tokens/parseTokenValue.ts +1 -0
- package/src/theme/defaults/colorTokens.ts +127 -66
- package/src/theme/index.ts +0 -7
- package/src/theme/system/color/_constants.ts +5 -2
- package/src/theme/system/color/_system.ts +2 -1
- package/src/theme/system/color/avatar.ts +2 -12
- package/src/theme/system/color/button.ts +4 -20
- package/src/theme/system/color/input.ts +3 -11
- package/src/theme/system/color/selectable.ts +3 -14
- package/src/theme/system/shadow.ts +0 -6
- package/src/theme/system/styles.ts +0 -6
- package/src/theme/system/theme.ts +2 -0
- package/src/theme/system/v0/avatar.ts +1 -1
- package/src/theme/system/v0/color/button.ts +4 -4
- package/src/theme/system/v0/color/card.ts +2 -2
- package/src/theme/system/v0/color/input.ts +3 -3
- package/src/theme/system/v0/color/muted.ts +2 -2
- package/src/theme/system/v0/color/solid.ts +2 -2
- package/src/theme/versioning/themeColor_v0_v2.ts +2 -2
- package/src/theme/versioning/v2_v0.ts +2 -2
- package/src/theme/build/colorToken.ts +0 -39
package/package.json
CHANGED
package/src/core/_compat.ts
CHANGED
|
@@ -1,73 +1,23 @@
|
|
|
1
|
-
// re-export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
COLOR_CONFIG_STATE_TONES,
|
|
8
|
-
THEME_COLOR_CARD_TONES,
|
|
9
|
-
THEME_COLOR_BLEND_MODES,
|
|
10
|
-
THEME_COLOR_BUTTON_MODES,
|
|
11
|
-
THEME_COLOR_STATES,
|
|
12
|
-
THEME_COLOR_STATE_TONES,
|
|
13
|
-
buildTheme,
|
|
14
|
-
createColorTheme,
|
|
15
|
-
hexToRgb,
|
|
16
|
-
hslToRgb,
|
|
17
|
-
isColorBlendModeValue,
|
|
18
|
-
isColorButtonMode,
|
|
19
|
-
isColorConfigBaseKey,
|
|
20
|
-
isColorConfigBaseTone,
|
|
21
|
-
isColorConfigBlendKey,
|
|
22
|
-
isColorConfigStateKey,
|
|
23
|
-
isColorConfigStateTone,
|
|
24
|
-
isColorHueKey,
|
|
25
|
-
isColorOpacityValue,
|
|
26
|
-
isColorTintKey,
|
|
27
|
-
isColorTokenValue,
|
|
28
|
-
isColorValue,
|
|
29
|
-
multiply,
|
|
30
|
-
parseColor,
|
|
31
|
-
parseTokenKey,
|
|
32
|
-
parseTokenValue,
|
|
33
|
-
rgbToHex,
|
|
34
|
-
rgbToHsl,
|
|
35
|
-
rgba,
|
|
36
|
-
rgbaToRGBA,
|
|
37
|
-
screen,
|
|
38
|
-
defaultTheme as studioTheme,
|
|
39
|
-
type BaseTheme,
|
|
40
|
-
type BoxShadow,
|
|
41
|
-
type CSSObject,
|
|
42
|
-
type ColorBlendModeTokenValue,
|
|
43
|
-
type ColorConfigCardKey,
|
|
44
|
-
type ColorConfigCardTone,
|
|
45
|
-
type ColorConfigBlendKey,
|
|
46
|
-
type ColorConfigOpacityValue,
|
|
47
|
-
type ColorConfigStateKey,
|
|
48
|
-
type ColorConfigStateTone,
|
|
49
|
-
type ColorConfigValue,
|
|
50
|
-
type HSL,
|
|
1
|
+
// This file re-exports API members which existed in the `@sanity/ui` export in v1.
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type BaseTheme as _BaseTheme,
|
|
5
|
+
type ThemeBoxShadow,
|
|
6
|
+
type HSL as _HSL,
|
|
51
7
|
type PartialThemeColorBuilderOpts,
|
|
52
|
-
type RGB,
|
|
53
|
-
type
|
|
54
|
-
type
|
|
55
|
-
type Theme,
|
|
8
|
+
type RGB as _RGB,
|
|
9
|
+
type RootTheme as _RootTheme,
|
|
10
|
+
type ThemeStyles,
|
|
11
|
+
type Theme as _Theme,
|
|
56
12
|
type ThemeAvatar,
|
|
57
13
|
type ThemeColor,
|
|
58
14
|
type ThemeColorBase,
|
|
59
|
-
type ThemeColorBaseTokens,
|
|
60
|
-
type ThemeColorCardToneKey,
|
|
61
|
-
type ThemeColorBlendModeKey,
|
|
62
15
|
type ThemeColorBuilderOpts,
|
|
63
16
|
type ThemeColorButton,
|
|
64
|
-
type ThemeColorButtonModeKey,
|
|
65
|
-
type ThemeColorButtonState,
|
|
17
|
+
type ThemeColorButtonModeKey as _ThemeColorButtonModeKey,
|
|
66
18
|
type ThemeColorButtonStates,
|
|
67
|
-
type ThemeColorButtonTokens,
|
|
68
19
|
type ThemeColorButtonTones,
|
|
69
20
|
type ThemeColorCard,
|
|
70
|
-
type ThemeColorCardState,
|
|
71
21
|
type ThemeColorGenericState,
|
|
72
22
|
type ThemeColorInput,
|
|
73
23
|
type ThemeColorInputState,
|
|
@@ -76,40 +26,239 @@ export {
|
|
|
76
26
|
type ThemeColorMutedTone,
|
|
77
27
|
type ThemeColorName,
|
|
78
28
|
type ThemeColorScheme,
|
|
79
|
-
type ThemeColorSchemeKey,
|
|
29
|
+
type ThemeColorSchemeKey as _ThemeColorSchemeKey,
|
|
80
30
|
type ThemeColorSchemes,
|
|
81
31
|
type ThemeColorSelectable,
|
|
32
|
+
type ThemeColorSelectableStates,
|
|
33
|
+
type ThemeColorSolid,
|
|
34
|
+
type ThemeColorSolidTone,
|
|
35
|
+
type ThemeColorSpot,
|
|
36
|
+
type ThemeColorSpotKey,
|
|
37
|
+
type ThemeColorSyntax as _ThemeColorSyntax,
|
|
38
|
+
type ThemeColorToneKey,
|
|
39
|
+
type ThemeFont as _ThemeFont,
|
|
40
|
+
type ThemeFontKey as _ThemeFontKey,
|
|
41
|
+
type ThemeFontSize as _ThemeFontSize,
|
|
42
|
+
type ThemeFontWeight as _ThemeFontWeight,
|
|
43
|
+
type ThemeFontWeightKey as _ThemeFontWeightKey,
|
|
44
|
+
type ThemeFonts as _ThemeFonts,
|
|
45
|
+
type ThemeInput,
|
|
46
|
+
type ThemeLayer as _ThemeLayer,
|
|
47
|
+
type ThemeShadow as _ThemeShadow,
|
|
48
|
+
type ThemeColorButtonState,
|
|
49
|
+
type ThemeColorCardState,
|
|
82
50
|
type ThemeColorSelectableState,
|
|
51
|
+
buildTheme,
|
|
52
|
+
} from '@sanity/ui/theme'
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @public
|
|
56
|
+
* @deprecated Use `BaseTheme` from `@sanity/ui/theme` instead.
|
|
57
|
+
*/
|
|
58
|
+
export type BaseTheme = _BaseTheme
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @public
|
|
62
|
+
* @deprecated Use `ThemeBoxShadow` from `@sanity/ui/theme` instead.
|
|
63
|
+
*/
|
|
64
|
+
export type BoxShadow = ThemeBoxShadow
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @public
|
|
68
|
+
* @deprecated Use `HSL` from `@sanity/ui/theme` instead.
|
|
69
|
+
*/
|
|
70
|
+
export type HSL = _HSL
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @public
|
|
74
|
+
* @deprecated Use `RGB` from `@sanity/ui/theme` instead.
|
|
75
|
+
*/
|
|
76
|
+
export type RGB = _RGB
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @public
|
|
80
|
+
* @deprecated Use `RootTheme` from `@sanity/ui/theme` instead.
|
|
81
|
+
*/
|
|
82
|
+
export type RootTheme = _RootTheme
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @public
|
|
86
|
+
* @deprecated Use `ThemeStyles` from `@sanity/ui/theme` instead.
|
|
87
|
+
*/
|
|
88
|
+
export type Styles = ThemeStyles
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @public
|
|
92
|
+
* @deprecated Use `Theme` from `@sanity/ui/theme` instead.
|
|
93
|
+
*/
|
|
94
|
+
export type Theme = _Theme
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @public
|
|
98
|
+
* @deprecated Use `ThemeColorButtonModeKey` from `@sanity/ui/theme` instead.
|
|
99
|
+
*/
|
|
100
|
+
export type ThemeColorButtonModeKey = _ThemeColorButtonModeKey
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @public
|
|
104
|
+
* @deprecated Use `ThemeColorSchemeKey` from `@sanity/ui/theme` instead.
|
|
105
|
+
*/
|
|
106
|
+
export type ThemeColorSchemeKey = _ThemeColorSchemeKey
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @public
|
|
110
|
+
* @deprecated Use `ThemeColorSyntax` from `@sanity/ui/theme` instead.
|
|
111
|
+
*/
|
|
112
|
+
export type ThemeColorSyntax = _ThemeColorSyntax
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @public
|
|
116
|
+
* @deprecated Use `ThemeFont` from `@sanity/ui/theme` instead.
|
|
117
|
+
*/
|
|
118
|
+
export type ThemeFont = _ThemeFont
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @public
|
|
122
|
+
* @deprecated Use `ThemeFontKey` from `@sanity/ui/theme` instead.
|
|
123
|
+
*/
|
|
124
|
+
export type ThemeFontKey = _ThemeFontKey
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @public
|
|
128
|
+
* @deprecated Use `ThemeFontSize` from `@sanity/ui/theme` instead.
|
|
129
|
+
*/
|
|
130
|
+
export type ThemeFontSize = _ThemeFontSize
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @public
|
|
134
|
+
* @deprecated Use `ThemeFontWeight` from `@sanity/ui/theme` instead.
|
|
135
|
+
*/
|
|
136
|
+
export type ThemeFontWeight = _ThemeFontWeight
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @public
|
|
140
|
+
* @deprecated Use `ThemeFontWeightKey` from `@sanity/ui/theme` instead.
|
|
141
|
+
*/
|
|
142
|
+
export type ThemeFontWeightKey = _ThemeFontWeightKey
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @public
|
|
146
|
+
* @deprecated Use `ThemeFonts` from `@sanity/ui/theme` instead.
|
|
147
|
+
*/
|
|
148
|
+
export type ThemeFonts = _ThemeFonts
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* @public
|
|
152
|
+
* @deprecated Use `ThemeLayer` from `@sanity/ui/theme` instead.
|
|
153
|
+
*/
|
|
154
|
+
export type ThemeLayer = _ThemeLayer
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* @public
|
|
158
|
+
* @deprecated Use `ThemeShadow` from `@sanity/ui/theme` instead.
|
|
159
|
+
*/
|
|
160
|
+
export type ThemeShadow = _ThemeShadow
|
|
161
|
+
|
|
162
|
+
export {
|
|
163
|
+
type PartialThemeColorBuilderOpts,
|
|
164
|
+
type ThemeAvatar,
|
|
165
|
+
type ThemeColor,
|
|
166
|
+
type ThemeColorBase,
|
|
167
|
+
type ThemeColorBuilderOpts,
|
|
168
|
+
type ThemeColorButton,
|
|
169
|
+
type ThemeColorButtonStates,
|
|
170
|
+
type ThemeColorButtonTones,
|
|
171
|
+
type ThemeColorCard,
|
|
172
|
+
type ThemeColorGenericState,
|
|
173
|
+
type ThemeColorInput,
|
|
174
|
+
type ThemeColorInputState,
|
|
175
|
+
type ThemeColorInputStates,
|
|
176
|
+
type ThemeColorMuted,
|
|
177
|
+
type ThemeColorMutedTone,
|
|
178
|
+
type ThemeColorName,
|
|
179
|
+
type ThemeColorScheme,
|
|
180
|
+
type ThemeColorSchemes,
|
|
181
|
+
type ThemeColorSelectable,
|
|
83
182
|
type ThemeColorSelectableStates,
|
|
84
183
|
type ThemeColorSolid,
|
|
85
184
|
type ThemeColorSolidTone,
|
|
86
185
|
type ThemeColorSpot,
|
|
87
186
|
type ThemeColorSpotKey,
|
|
88
|
-
type ThemeColorStateKey,
|
|
89
|
-
type ThemeColorStateTokens,
|
|
90
|
-
type ThemeColorStateToneKey,
|
|
91
|
-
type ThemeColorStatesTokens,
|
|
92
|
-
type ThemeColorSyntax,
|
|
93
|
-
type ThemeColorTokenValue,
|
|
94
|
-
type ThemeColorTokens,
|
|
95
187
|
type ThemeColorToneKey,
|
|
96
|
-
type ThemeConfig,
|
|
97
|
-
type ThemeFocusRing,
|
|
98
|
-
type ThemeFont,
|
|
99
|
-
type ThemeFontKey,
|
|
100
|
-
type ThemeFontSize,
|
|
101
|
-
type ThemeFontWeight,
|
|
102
|
-
type ThemeFontWeightKey,
|
|
103
|
-
type ThemeFonts,
|
|
104
188
|
type ThemeInput,
|
|
105
|
-
type
|
|
106
|
-
type
|
|
107
|
-
type
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
189
|
+
type ThemeColorButtonState,
|
|
190
|
+
type ThemeColorCardState,
|
|
191
|
+
type ThemeColorSelectableState,
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
import {
|
|
195
|
+
createColorTheme as _createColorTheme,
|
|
196
|
+
hexToRgb as _hexToRgb,
|
|
197
|
+
hslToRgb as _hslToRgb,
|
|
198
|
+
multiply as _multiply,
|
|
199
|
+
parseColor as _parseColor,
|
|
200
|
+
rgbToHex as _rgbToHex,
|
|
201
|
+
rgbToHsl as _rgbToHsl,
|
|
202
|
+
rgba as _rgba,
|
|
203
|
+
screen as _screen,
|
|
115
204
|
} from '@sanity/ui/theme'
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* @public
|
|
208
|
+
* @deprecated Use `createColorTheme` from `@sanity/ui/theme` instead.
|
|
209
|
+
*/
|
|
210
|
+
export const createColorTheme = _createColorTheme
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* @public
|
|
214
|
+
* @deprecated Use `hexToRgb` from `@sanity/ui/theme` instead.
|
|
215
|
+
*/
|
|
216
|
+
export const hexToRgb = _hexToRgb
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* @public
|
|
220
|
+
* @deprecated Use `hslToRgb` from `@sanity/ui/theme` instead.
|
|
221
|
+
*/
|
|
222
|
+
export const hslToRgb = _hslToRgb
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* @public
|
|
226
|
+
* @deprecated Use `multiply` from `@sanity/ui/theme` instead.
|
|
227
|
+
*/
|
|
228
|
+
export const multiply = _multiply
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* @public
|
|
232
|
+
* @deprecated Use `parseColor` from `@sanity/ui/theme` instead.
|
|
233
|
+
*/
|
|
234
|
+
export const parseColor = _parseColor
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* @public
|
|
238
|
+
* @deprecated Use `rgbToHex` from `@sanity/ui/theme` instead.
|
|
239
|
+
*/
|
|
240
|
+
export const rgbToHex = _rgbToHex
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* @public
|
|
244
|
+
* @deprecated Use `rgbToHsl` from `@sanity/ui/theme` instead.
|
|
245
|
+
*/
|
|
246
|
+
export const rgbToHsl = _rgbToHsl
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* @public
|
|
250
|
+
* @deprecated Use `rgba` from `@sanity/ui/theme` instead.
|
|
251
|
+
*/
|
|
252
|
+
export const rgba = _rgba
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* @public
|
|
256
|
+
* @deprecated Use `screen` from `@sanity/ui/theme` instead.
|
|
257
|
+
*/
|
|
258
|
+
export const screen = _screen
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* @public
|
|
262
|
+
* @deprecated Use `buildTheme` from `@sanity/ui/theme` instead.
|
|
263
|
+
*/
|
|
264
|
+
export const studioTheme = buildTheme()
|
|
@@ -16,8 +16,10 @@ const POPOVER_PROPS: MenuButtonProps['popover'] = {
|
|
|
16
16
|
matchReferenceWidth: true,
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
const INITIAL_INDEX = 1
|
|
20
|
+
|
|
19
21
|
export default function SelectedItemStory() {
|
|
20
|
-
const [selectedIndex, setSelectedIndex] = useState(
|
|
22
|
+
const [selectedIndex, setSelectedIndex] = useState(INITIAL_INDEX)
|
|
21
23
|
|
|
22
24
|
return (
|
|
23
25
|
<Box padding={[4, 5, 6]}>
|
|
@@ -26,12 +28,13 @@ export default function SelectedItemStory() {
|
|
|
26
28
|
|
|
27
29
|
<MenuButton
|
|
28
30
|
button={<Button text="Open menu" />}
|
|
29
|
-
id="
|
|
31
|
+
id="menu-button"
|
|
30
32
|
menu={
|
|
31
33
|
<Menu>
|
|
32
34
|
<MenuItem
|
|
33
35
|
icon={SearchIcon}
|
|
34
36
|
iconRight={selectedIndex === 0 ? CheckmarkIcon : undefined}
|
|
37
|
+
id="menu-item-1"
|
|
35
38
|
onClick={() => setSelectedIndex(0)}
|
|
36
39
|
pressed={selectedIndex === 0}
|
|
37
40
|
selected={selectedIndex === 0}
|
|
@@ -40,6 +43,7 @@ export default function SelectedItemStory() {
|
|
|
40
43
|
<MenuItem
|
|
41
44
|
icon={ClockIcon}
|
|
42
45
|
iconRight={selectedIndex === 1 ? CheckmarkIcon : undefined}
|
|
46
|
+
id="menu-item-2"
|
|
43
47
|
onClick={() => setSelectedIndex(1)}
|
|
44
48
|
pressed={selectedIndex === 1}
|
|
45
49
|
selected={selectedIndex === 1}
|
|
@@ -49,6 +53,7 @@ export default function SelectedItemStory() {
|
|
|
49
53
|
<MenuItem
|
|
50
54
|
icon={ExpandIcon}
|
|
51
55
|
iconRight={selectedIndex === 2 ? CheckmarkIcon : undefined}
|
|
56
|
+
id="menu-item-3"
|
|
52
57
|
onClick={() => setSelectedIndex(2)}
|
|
53
58
|
pressed={selectedIndex === 2}
|
|
54
59
|
selected={selectedIndex === 2}
|
|
@@ -99,6 +99,16 @@ export const MenuButton = forwardRef(function MenuButton(
|
|
|
99
99
|
setShouldFocus(null)
|
|
100
100
|
}, [])
|
|
101
101
|
|
|
102
|
+
// Prevent mouse event propagation when the menu is open.
|
|
103
|
+
// This is to ensure that `handleBlur` isn't triggered when clicking the menu button whilst open,
|
|
104
|
+
// which can lead to `setOpen` being triggered multiple times (once by `handleBlur`, and again by `handleButtonClick`).
|
|
105
|
+
const handleMouseDown = useCallback(
|
|
106
|
+
(event: PointerEvent) => {
|
|
107
|
+
if (open) event.preventDefault()
|
|
108
|
+
},
|
|
109
|
+
[open],
|
|
110
|
+
)
|
|
111
|
+
|
|
102
112
|
const handleButtonKeyDown = useCallback((event: React.KeyboardEvent<HTMLButtonElement>) => {
|
|
103
113
|
// On `ArrowDown`, `Enter` and `Space`
|
|
104
114
|
// - Opens menu and moves focus to first menuitem
|
|
@@ -231,13 +241,14 @@ export const MenuButton = forwardRef(function MenuButton(
|
|
|
231
241
|
id,
|
|
232
242
|
onClick: handleButtonClick,
|
|
233
243
|
onKeyDown: handleButtonKeyDown,
|
|
244
|
+
onMouseDown: handleMouseDown,
|
|
234
245
|
'aria-haspopup': true,
|
|
235
246
|
'aria-expanded': open,
|
|
236
247
|
ref: setButtonRef,
|
|
237
248
|
selected: open,
|
|
238
249
|
})
|
|
239
250
|
: null,
|
|
240
|
-
[buttonProp, handleButtonClick, handleButtonKeyDown, id, open, setButtonRef],
|
|
251
|
+
[buttonProp, handleButtonClick, handleButtonKeyDown, handleMouseDown, id, open, setButtonRef],
|
|
241
252
|
)
|
|
242
253
|
|
|
243
254
|
const popoverProps: MenuButtonProps['popover'] = useMemo(
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/** @jest-environment node */
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import {buildTheme} from '@sanity/ui/theme'
|
|
3
4
|
import {renderToString, renderToStaticMarkup} from 'react-dom/server'
|
|
4
5
|
import {ThemeProvider} from '../../theme'
|
|
5
6
|
import {useMediaIndex} from './useMediaIndex'
|
|
6
7
|
|
|
8
|
+
const theme = buildTheme()
|
|
9
|
+
|
|
7
10
|
function Log() {
|
|
8
11
|
const mediaIndex = useMediaIndex()
|
|
9
12
|
|
|
@@ -14,7 +17,7 @@ describe('useMediaIndex', () => {
|
|
|
14
17
|
it(`SSR to static markup returns 0`, () => {
|
|
15
18
|
expect(
|
|
16
19
|
renderToStaticMarkup(
|
|
17
|
-
<ThemeProvider theme={
|
|
20
|
+
<ThemeProvider theme={theme}>
|
|
18
21
|
<Log />
|
|
19
22
|
</ThemeProvider>,
|
|
20
23
|
),
|
|
@@ -23,7 +26,7 @@ describe('useMediaIndex', () => {
|
|
|
23
26
|
it(`SSR to markup for hydration doesn't throw`, () => {
|
|
24
27
|
expect(
|
|
25
28
|
renderToString(
|
|
26
|
-
<ThemeProvider theme={
|
|
29
|
+
<ThemeProvider theme={theme}>
|
|
27
30
|
<Log />
|
|
28
31
|
</ThemeProvider>,
|
|
29
32
|
),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** @jest-environment jsdom */
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {buildTheme, getScopedTheme} from '@sanity/ui/theme'
|
|
4
4
|
import {responsiveMarginStyle} from './marginStyle'
|
|
5
5
|
|
|
6
|
-
const theme = getScopedTheme(
|
|
6
|
+
const theme = getScopedTheme(buildTheme(), 'light', 'default')
|
|
7
7
|
|
|
8
8
|
describe('styles/margin', () => {
|
|
9
9
|
it('should 1', () => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** @jest-environment jsdom */
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {buildTheme, getScopedTheme} from '@sanity/ui/theme'
|
|
4
4
|
import {responsivePaddingStyle} from './paddingStyle'
|
|
5
5
|
|
|
6
|
-
const theme = getScopedTheme(
|
|
6
|
+
const theme = getScopedTheme(buildTheme(), 'light', 'default')
|
|
7
7
|
|
|
8
8
|
describe('styles/padding', () => {
|
|
9
9
|
it('should 1', () => {
|
|
@@ -159,6 +159,7 @@ export const Root = styled.div((props) => {
|
|
|
159
159
|
--link-fg: var(--card-enabled-link-fg);
|
|
160
160
|
--code-bg: var(--card-enabled-code-bg);
|
|
161
161
|
--code-fg: var(--card-enabled-code-fg);
|
|
162
|
+
--kbd-bg: var(--card-enabled-kbd-bg);
|
|
162
163
|
--skeleton-from: var(--card-enabled-skeleton-from);
|
|
163
164
|
--skeleton-to: var(--card-enabled-skeleton-to);
|
|
164
165
|
|
|
@@ -322,15 +323,15 @@ export const Root = styled.div((props) => {
|
|
|
322
323
|
color: var(--icon);
|
|
323
324
|
}
|
|
324
325
|
|
|
325
|
-
.muted
|
|
326
|
+
.muted {
|
|
326
327
|
color: var(--muted-fg);
|
|
327
328
|
}
|
|
328
329
|
|
|
329
|
-
.accent
|
|
330
|
+
.accent {
|
|
330
331
|
color: var(--accent-fg);
|
|
331
332
|
}
|
|
332
333
|
|
|
333
|
-
.link
|
|
334
|
+
.link {
|
|
334
335
|
color: var(--link-fg);
|
|
335
336
|
}
|
|
336
337
|
|
|
@@ -339,6 +340,22 @@ export const Root = styled.div((props) => {
|
|
|
339
340
|
color: var(--code-fg);
|
|
340
341
|
}
|
|
341
342
|
|
|
343
|
+
.kbd {
|
|
344
|
+
background-color: var(--kbd-bg);
|
|
345
|
+
color: var(--kbd-fg);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
.badge {
|
|
349
|
+
background-color: var(--badge-bg);
|
|
350
|
+
color: var(--badge-fg);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
.badge--default {
|
|
354
|
+
--badge-bg: var(--badge-default-bg);
|
|
355
|
+
--badge-fg: var(--badge-default-fg);
|
|
356
|
+
--badge-border: var(--badge-default-border);
|
|
357
|
+
}
|
|
358
|
+
|
|
342
359
|
.skeleton-from {
|
|
343
360
|
color: var(--skeleton-from);
|
|
344
361
|
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
ThemeColorButtonTone_v2,
|
|
5
5
|
ThemeColorCard_v2,
|
|
6
|
-
|
|
6
|
+
ThemeColorInputMode_v2,
|
|
7
7
|
ThemeColorState_v2,
|
|
8
8
|
} from '@sanity/ui/theme'
|
|
9
9
|
import {
|
|
10
|
-
THEME_COLOR_CARD_TONES,
|
|
11
10
|
THEME_COLOR_BUTTON_MODES,
|
|
11
|
+
THEME_COLOR_CARD_TONES,
|
|
12
12
|
THEME_COLOR_INPUT_MODES,
|
|
13
13
|
THEME_COLOR_STATE_TONES,
|
|
14
14
|
ThemeColorCardToneKey,
|
|
15
15
|
ThemeColorInputModeKey,
|
|
16
16
|
} from '@sanity/ui/theme'
|
|
17
|
-
import {
|
|
17
|
+
import {buildTheme} from '@sanity/ui/theme'
|
|
18
18
|
import {ReactElement} from 'react'
|
|
19
19
|
import {rem} from '../../../styles'
|
|
20
20
|
import {useTheme_v2} from '../../useTheme'
|
|
21
21
|
import {getCSSProps} from './helpers'
|
|
22
22
|
import {Root} from './Root'
|
|
23
23
|
|
|
24
|
-
const theme =
|
|
24
|
+
const theme = buildTheme()
|
|
25
25
|
|
|
26
26
|
export default function BuildStory(): ReactElement {
|
|
27
27
|
return (
|
|
@@ -268,7 +268,7 @@ function StatePreview(props: {theme: ThemeColorState_v2}) {
|
|
|
268
268
|
)
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
function ButtonPreview(props: {theme:
|
|
271
|
+
function ButtonPreview(props: {theme: ThemeColorButtonTone_v2}) {
|
|
272
272
|
const {theme: button} = props
|
|
273
273
|
|
|
274
274
|
return (
|
|
@@ -289,18 +289,24 @@ function ButtonPreview(props: {theme: ThemeColorButtonStates_v2}) {
|
|
|
289
289
|
<div className="icon" style={{flex: 'none'}}>
|
|
290
290
|
©
|
|
291
291
|
</div>
|
|
292
|
-
<div className="muted
|
|
292
|
+
<div className="muted" style={{flex: 'none'}}>
|
|
293
293
|
m
|
|
294
294
|
</div>
|
|
295
|
-
<div className="accent
|
|
295
|
+
<div className="accent" style={{flex: 'none'}}>
|
|
296
296
|
a
|
|
297
297
|
</div>
|
|
298
|
-
<div className="link
|
|
298
|
+
<div className="link" style={{flex: 'none'}}>
|
|
299
299
|
l
|
|
300
300
|
</div>
|
|
301
301
|
<div className="code" style={{flex: 'none'}}>
|
|
302
302
|
c
|
|
303
303
|
</div>
|
|
304
|
+
<div className="kbd" style={{flex: 'none'}}>
|
|
305
|
+
k
|
|
306
|
+
</div>
|
|
307
|
+
<div className="badge badge--default" style={{flex: 'none'}}>
|
|
308
|
+
b
|
|
309
|
+
</div>
|
|
304
310
|
<div style={{flex: 'none'}}>
|
|
305
311
|
<CheckeredBackground />
|
|
306
312
|
</div>
|
|
@@ -424,7 +430,7 @@ function Skeleton() {
|
|
|
424
430
|
)
|
|
425
431
|
}
|
|
426
432
|
|
|
427
|
-
function InputPreview(props: {mode: ThemeColorInputModeKey; theme:
|
|
433
|
+
function InputPreview(props: {mode: ThemeColorInputModeKey; theme: ThemeColorInputMode_v2}) {
|
|
428
434
|
const {mode, theme: input} = props
|
|
429
435
|
|
|
430
436
|
return (
|
|
@@ -10,14 +10,14 @@ import {
|
|
|
10
10
|
useRootTheme,
|
|
11
11
|
} from '@sanity/ui'
|
|
12
12
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
ThemeColorButtonMode_v2,
|
|
14
|
+
ThemeColorButtonTone_v2,
|
|
15
15
|
ThemeColorButton_v2,
|
|
16
|
+
ThemeColorCard_v2,
|
|
16
17
|
ThemeColorScheme_v2,
|
|
17
|
-
|
|
18
|
+
ThemeColorSelectableTone_v2,
|
|
18
19
|
ThemeColorSelectable_v2,
|
|
19
20
|
ThemeColorState_v2,
|
|
20
|
-
ThemeColorCard_v2,
|
|
21
21
|
getContrastRatio,
|
|
22
22
|
mix,
|
|
23
23
|
parseColor,
|
|
@@ -202,7 +202,7 @@ function ColorButton(props: {color: ThemeColorButton_v2}) {
|
|
|
202
202
|
)
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
function ColorButtonMode(props: {color:
|
|
205
|
+
function ColorButtonMode(props: {color: ThemeColorButtonMode_v2}) {
|
|
206
206
|
const {color} = props
|
|
207
207
|
|
|
208
208
|
return (
|
|
@@ -243,7 +243,7 @@ function ColorButtonMode(props: {color: ThemeColorButtonTones_v2}) {
|
|
|
243
243
|
)
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
-
function ColorGenericStates(props: {color:
|
|
246
|
+
function ColorGenericStates(props: {color: ThemeColorButtonTone_v2}) {
|
|
247
247
|
const {color} = props
|
|
248
248
|
|
|
249
249
|
return (
|
|
@@ -335,7 +335,7 @@ function ColorSelectable(props: {color: ThemeColorSelectable_v2}) {
|
|
|
335
335
|
)
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
-
function ColorSelectableTone(props: {color:
|
|
338
|
+
function ColorSelectableTone(props: {color: ThemeColorSelectableTone_v2}) {
|
|
339
339
|
const {color} = props
|
|
340
340
|
|
|
341
341
|
return (
|