@sanity/ui 2.0.0-beta.1 → 2.0.0-beta.3
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 +180 -239
- package/dist/index.esm.js +105 -84
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +113 -297
- 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 +169 -97
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +169 -97
- package/dist/theme.js.map +1 -1
- package/package.json +1 -1
- package/src/core/__workshop__/constants.ts +3 -2
- package/src/core/_compat.ts +236 -87
- package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +6 -3
- package/src/core/primitives/avatar/__workshop__/asButton.tsx +1 -1
- package/src/core/primitives/avatar/__workshop__/stack.tsx +1 -1
- package/src/core/primitives/avatar/avatar.tsx +14 -4
- package/src/core/primitives/avatar/avatarCounter.tsx +16 -5
- package/src/core/primitives/avatar/avatarStack.tsx +2 -2
- package/src/core/primitives/kbd/kbd.tsx +2 -0
- package/src/core/primitives/tooltip/tooltip.tsx +1 -1
- 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/avatar.ts +1 -1
- 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/defaults/config.ts +1 -0
- package/src/theme/defaults/fonts.ts +13 -5
- 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
|
@@ -17,9 +17,10 @@ import {
|
|
|
17
17
|
import {ThemeColorSpotKey, ThemeColorToneKey, ThemeFontWeightKey} from '@sanity/ui/theme'
|
|
18
18
|
|
|
19
19
|
export const WORKSHOP_AVATAR_SIZE_OPTIONS: {[key: string]: AvatarSize} = {
|
|
20
|
-
'0
|
|
21
|
-
'1': 1,
|
|
20
|
+
'0': 0,
|
|
21
|
+
'1 (default)': 1,
|
|
22
22
|
'2': 2,
|
|
23
|
+
'3': 3,
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export const WORKSHOP_BADGE_MODE_OPTIONS: {[key: string]: BadgeMode} = {
|
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()
|
|
@@ -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
|
),
|
|
@@ -3,7 +3,7 @@ import {useSelect} from '@sanity/ui-workshop'
|
|
|
3
3
|
import {WORKSHOP_AVATAR_SIZE_OPTIONS} from '../../../__workshop__/constants'
|
|
4
4
|
|
|
5
5
|
export default function AsButtonStory() {
|
|
6
|
-
const size = useSelect('Size', WORKSHOP_AVATAR_SIZE_OPTIONS,
|
|
6
|
+
const size = useSelect('Size', WORKSHOP_AVATAR_SIZE_OPTIONS, 1, 'Props')
|
|
7
7
|
|
|
8
8
|
return (
|
|
9
9
|
<Flex align="center" height="fill" justify="center">
|
|
@@ -3,7 +3,7 @@ import {useSelect} from '@sanity/ui-workshop'
|
|
|
3
3
|
import {WORKSHOP_AVATAR_SIZE_OPTIONS} from '../../../__workshop__/constants'
|
|
4
4
|
|
|
5
5
|
export default function StackStory() {
|
|
6
|
-
const size = useSelect('Size', WORKSHOP_AVATAR_SIZE_OPTIONS,
|
|
6
|
+
const size = useSelect('Size', WORKSHOP_AVATAR_SIZE_OPTIONS, 1, 'Props')
|
|
7
7
|
|
|
8
8
|
return (
|
|
9
9
|
<Flex align="center" height="fill" justify="center">
|
|
@@ -69,12 +69,12 @@ export const Avatar = forwardRef(function Avatar(
|
|
|
69
69
|
arrowPosition: arrowPositionProp,
|
|
70
70
|
animateArrowFrom,
|
|
71
71
|
status = 'online',
|
|
72
|
-
size: sizeProp =
|
|
72
|
+
size: sizeProp = 1,
|
|
73
73
|
...restProps
|
|
74
74
|
} = props
|
|
75
|
+
const {avatar} = useTheme_v2()
|
|
75
76
|
const as = ReactIs.isValidElementType(asProp) ? asProp : 'div'
|
|
76
77
|
const size = useArrayProp(sizeProp)
|
|
77
|
-
const {avatar} = useTheme_v2()
|
|
78
78
|
|
|
79
79
|
// @todo: remove this
|
|
80
80
|
const avatarSize = avatar.sizes[size[0]] || avatar.sizes[0]
|
|
@@ -111,7 +111,17 @@ export const Avatar = forwardRef(function Avatar(
|
|
|
111
111
|
}
|
|
112
112
|
}, [onImageLoadError])
|
|
113
113
|
|
|
114
|
-
const initialsSize = useMemo(
|
|
114
|
+
const initialsSize = useMemo(
|
|
115
|
+
() =>
|
|
116
|
+
size.map((s) => {
|
|
117
|
+
if (s === 1) return 1
|
|
118
|
+
if (s === 2) return 3
|
|
119
|
+
if (s === 3) return 5
|
|
120
|
+
|
|
121
|
+
return 0
|
|
122
|
+
}),
|
|
123
|
+
[size],
|
|
124
|
+
)
|
|
115
125
|
|
|
116
126
|
return (
|
|
117
127
|
<Root
|
|
@@ -175,7 +185,7 @@ export const Avatar = forwardRef(function Avatar(
|
|
|
175
185
|
{(imageFailed || !src) && initials && (
|
|
176
186
|
<>
|
|
177
187
|
<Initials>
|
|
178
|
-
<InitialsLabel forwardedAs="span" size={initialsSize}>
|
|
188
|
+
<InitialsLabel forwardedAs="span" size={initialsSize} weight="medium">
|
|
179
189
|
{initials}
|
|
180
190
|
</InitialsLabel>
|
|
181
191
|
</Initials>
|
|
@@ -5,7 +5,7 @@ import {EMPTY_RECORD} from '../../constants'
|
|
|
5
5
|
import {useArrayProp} from '../../hooks'
|
|
6
6
|
import {rem, _responsive, ThemeProps} from '../../styles'
|
|
7
7
|
import {AvatarSize} from '../../types'
|
|
8
|
-
import {
|
|
8
|
+
import {Label} from '../label'
|
|
9
9
|
|
|
10
10
|
function _responsiveAvatarCounterSizeStyle(props: {$size: AvatarSize[]} & ThemeProps) {
|
|
11
11
|
const {avatar, media} = getTheme_v2(props.theme)
|
|
@@ -67,15 +67,26 @@ export const AvatarCounter = forwardRef(function AvatarCounter(
|
|
|
67
67
|
props: AvatarCounterProps,
|
|
68
68
|
ref: React.Ref<HTMLDivElement>,
|
|
69
69
|
) {
|
|
70
|
-
const {count, size: sizeProp =
|
|
70
|
+
const {count, size: sizeProp = 1} = props
|
|
71
71
|
const size = useArrayProp(sizeProp)
|
|
72
|
-
|
|
72
|
+
|
|
73
|
+
const fontSize = useMemo(
|
|
74
|
+
() =>
|
|
75
|
+
size.map((s) => {
|
|
76
|
+
if (s === 1) return 1
|
|
77
|
+
if (s === 2) return 3
|
|
78
|
+
if (s === 3) return 5
|
|
79
|
+
|
|
80
|
+
return 0
|
|
81
|
+
}),
|
|
82
|
+
[size],
|
|
83
|
+
)
|
|
73
84
|
|
|
74
85
|
return (
|
|
75
86
|
<Root $size={size} data-ui="AvatarCounter" ref={ref}>
|
|
76
|
-
<
|
|
87
|
+
<Label as="span" size={fontSize} weight="medium">
|
|
77
88
|
{count}
|
|
78
|
-
</
|
|
89
|
+
</Label>
|
|
79
90
|
</Root>
|
|
80
91
|
)
|
|
81
92
|
})
|
|
@@ -63,7 +63,7 @@ export const AvatarStack = forwardRef(function AvatarStack(
|
|
|
63
63
|
const {
|
|
64
64
|
children: childrenProp,
|
|
65
65
|
maxLength: maxLengthProp = 4,
|
|
66
|
-
size: sizeProp =
|
|
66
|
+
size: sizeProp = 1,
|
|
67
67
|
...restProps
|
|
68
68
|
} = props
|
|
69
69
|
const children = childrenToElementArray(childrenProp).filter(
|
|
@@ -81,7 +81,7 @@ export const AvatarStack = forwardRef(function AvatarStack(
|
|
|
81
81
|
<Root data-ui="AvatarStack" {...restProps} ref={ref} $size={size}>
|
|
82
82
|
{len === 0 && (
|
|
83
83
|
<div>
|
|
84
|
-
<AvatarCounter count={len} />
|
|
84
|
+
<AvatarCounter count={len} size={size} />
|
|
85
85
|
</div>
|
|
86
86
|
)}
|
|
87
87
|
|
|
@@ -105,7 +105,7 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
105
105
|
disabled,
|
|
106
106
|
fallbackPlacements: fallbackPlacementsProp = props.fallbackPlacements ??
|
|
107
107
|
DEFAULT_FALLBACK_PLACEMENTS[props.placement ?? 'bottom'],
|
|
108
|
-
padding =
|
|
108
|
+
padding = 2,
|
|
109
109
|
placement: placementProp = 'bottom',
|
|
110
110
|
portal: portalProp,
|
|
111
111
|
radius = 2,
|
|
@@ -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
|
}
|