@sanity/ui 1.8.2 → 2.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +42 -11
- package/dist/index.esm.js +335 -116
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +334 -115
- package/dist/index.js.map +1 -1
- package/package.json +34 -16
- package/src/components/autocomplete/autocomplete.tsx +2 -1
- package/src/components/dialog/dialog.tsx +3 -3
- package/src/components/hotkeys/hotkeys.tsx +2 -1
- package/src/components/menu/menuButton.tsx +2 -2
- package/src/components/menu/menuGroup.tsx +2 -2
- package/src/components/tab/tab.tsx +2 -1
- package/src/primitives/avatar/styles.ts +1 -1
- package/src/primitives/button/button.tsx +6 -7
- package/src/primitives/button/styles.ts +20 -3
- package/src/primitives/card/styles.ts +1 -1
- package/src/primitives/checkbox/checkbox.tsx +1 -0
- package/src/primitives/checkbox/styles.ts +47 -17
- package/src/primitives/kbd/kbd.tsx +6 -6
- package/src/primitives/popover/popoverCard.tsx +2 -2
- package/src/primitives/radio/radio.tsx +1 -0
- package/src/primitives/radio/styles.ts +17 -4
- package/src/primitives/select/select.tsx +3 -2
- package/src/primitives/select/styles.ts +2 -1
- package/src/primitives/switch/__workshop__/props.tsx +4 -4
- package/src/primitives/switch/styles.ts +19 -12
- package/src/primitives/text/styles.ts +1 -0
- package/src/primitives/textInput/textInput.tsx +2 -1
- package/src/primitives/tooltip/tooltip.tsx +2 -2
- package/src/primitives/types.ts +3 -2
- package/src/styles/colorVars/colorVarsStyle.ts +2 -0
- package/src/styles/focusRing/index.ts +3 -1
- package/src/styles/input/textInputStyle.ts +2 -1
- package/src/styles/radius/radiusStyle.ts +14 -4
- package/src/styles/radius/types.ts +3 -1
- package/src/theme/lib/theme/avatar.ts +3 -0
- package/src/theme/lib/theme/color/_generic/types.ts +1 -0
- package/src/theme/lib/theme/color/color.test.ts +1 -0
- package/src/theme/lib/theme/color/defaults.ts +8 -0
- package/src/theme/lib/theme/color/input/types.ts +1 -0
- package/src/theme/lib/theme/input.ts +11 -0
- package/src/theme/lib/theme/theme.ts +7 -1
- package/src/theme/studioTheme/color.ts +82 -70
- package/src/theme/studioTheme/fonts.ts +3 -3
- package/src/theme/studioTheme/theme.ts +17 -3
- package/src/theme/studioTheme/tints.ts +152 -0
- package/src/theme/types.ts +8 -0
- package/src/types/index.ts +1 -0
- package/src/types/radius.ts +4 -0
|
@@ -36,12 +36,13 @@ export function switchInputStyles(): ReturnType<typeof css> {
|
|
|
36
36
|
/* Representation */
|
|
37
37
|
export function switchRepresentationStyles(props: ThemeProps): ReturnType<typeof css> {
|
|
38
38
|
const {theme} = props
|
|
39
|
-
const {
|
|
40
|
-
const
|
|
39
|
+
const {input} = theme.sanity
|
|
40
|
+
const {focusRing} = input.switch
|
|
41
|
+
const color = theme.sanity.color.input
|
|
41
42
|
|
|
42
43
|
return css`
|
|
43
|
-
--switch-bg-color: ${color.default.enabled.
|
|
44
|
-
--switch-fg-color: ${color.default.enabled.
|
|
44
|
+
--switch-bg-color: ${color.default.enabled.border};
|
|
45
|
+
--switch-fg-color: ${color.default.enabled.bg};
|
|
45
46
|
--switch-box-shadow: none;
|
|
46
47
|
|
|
47
48
|
&:not([hidden]) {
|
|
@@ -78,25 +79,30 @@ export function switchRepresentationStyles(props: ThemeProps): ReturnType<typeof
|
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
input:checked + && {
|
|
81
|
-
--switch-bg-color:
|
|
82
|
-
--switch-fg-color: ${color.
|
|
82
|
+
--switch-bg-color: var(--card-focus-ring-color);
|
|
83
|
+
--switch-fg-color: ${color.default.enabled.bg};
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
@media (hover: hover) {
|
|
86
87
|
input:not(:disabled):hover + && {
|
|
87
|
-
--switch-bg-color: ${color.default.hovered.
|
|
88
|
-
--switch-fg-color: ${color.default.hovered.
|
|
88
|
+
--switch-bg-color: ${color.default.hovered.border};
|
|
89
|
+
--switch-fg-color: ${color.default.hovered.bg};
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
input:not(:disabled):checked:hover + && {
|
|
92
|
-
--switch-bg-color:
|
|
93
|
-
--switch-fg-color: ${color.
|
|
93
|
+
--switch-bg-color: var(--card-focus-ring-color);
|
|
94
|
+
--switch-fg-color: ${color.default.enabled.bg};
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
input:not([data-read-only]):disabled + && {
|
|
98
|
-
--switch-bg-color: ${color.default.disabled.
|
|
99
|
-
--switch-fg-color: ${color.default.disabled.
|
|
99
|
+
--switch-bg-color: ${color.default.disabled.border};
|
|
100
|
+
--switch-fg-color: ${color.default.disabled.bg};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
input[data-read-only]:disabled + && {
|
|
104
|
+
--switch-bg-color: ${color.default.readOnly.border};
|
|
105
|
+
--switch-fg-color: ${color.default.readOnly.bg};
|
|
100
106
|
}
|
|
101
107
|
`
|
|
102
108
|
}
|
|
@@ -149,6 +155,7 @@ export function switchThumbStyles(
|
|
|
149
155
|
transition-timing-function: ${input.switch.transitionTimingFunction};
|
|
150
156
|
background: var(--switch-fg-color);
|
|
151
157
|
transform: translate3d(0, 0, 0);
|
|
158
|
+
box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.1);
|
|
152
159
|
|
|
153
160
|
${checked &&
|
|
154
161
|
css`
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
textInputRootStyle,
|
|
18
18
|
} from '../../styles/internal'
|
|
19
19
|
import {ThemeFontWeightKey, useRootTheme} from '../../theme'
|
|
20
|
+
import {Radius} from '../../types'
|
|
20
21
|
import {Box} from '../box'
|
|
21
22
|
import {Button, ButtonProps} from '../button'
|
|
22
23
|
import {Card} from '../card'
|
|
@@ -64,7 +65,7 @@ export interface TextInputProps {
|
|
|
64
65
|
onClear?: () => void
|
|
65
66
|
padding?: number | number[]
|
|
66
67
|
prefix?: React.ReactNode
|
|
67
|
-
radius?:
|
|
68
|
+
radius?: Radius | Radius[]
|
|
68
69
|
space?: number | number[]
|
|
69
70
|
suffix?: React.ReactNode
|
|
70
71
|
type?: TextInputType
|
|
@@ -81,7 +81,7 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
81
81
|
disabled,
|
|
82
82
|
fallbackPlacements: fallbackPlacementsProp = props.fallbackPlacements ??
|
|
83
83
|
DEFAULT_FALLBACK_PLACEMENTS[props.placement ?? 'bottom'],
|
|
84
|
-
padding,
|
|
84
|
+
padding = 3,
|
|
85
85
|
placement: placementProp = 'bottom',
|
|
86
86
|
portal,
|
|
87
87
|
scheme,
|
|
@@ -303,7 +303,7 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
303
303
|
data-ui="Tooltip__card"
|
|
304
304
|
data-placement={placement}
|
|
305
305
|
padding={padding}
|
|
306
|
-
radius={
|
|
306
|
+
radius={3}
|
|
307
307
|
scheme={scheme}
|
|
308
308
|
shadow={shadow}
|
|
309
309
|
>
|
package/src/primitives/types.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
GridItemRow,
|
|
18
18
|
GridItemRowEnd,
|
|
19
19
|
GridItemRowStart,
|
|
20
|
+
Radius,
|
|
20
21
|
} from '../types'
|
|
21
22
|
|
|
22
23
|
/**
|
|
@@ -113,7 +114,7 @@ export interface ResponsivePaddingProps {
|
|
|
113
114
|
* @public
|
|
114
115
|
*/
|
|
115
116
|
export interface ResponsiveRadiusProps {
|
|
116
|
-
radius?:
|
|
117
|
+
radius?: Radius | Radius[]
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
/**
|
|
@@ -131,7 +132,7 @@ export interface ResponsiveWidthProps {
|
|
|
131
132
|
}
|
|
132
133
|
|
|
133
134
|
/**
|
|
134
|
-
* @
|
|
135
|
+
* @public
|
|
135
136
|
*/
|
|
136
137
|
export type Delay =
|
|
137
138
|
| number
|
|
@@ -17,9 +17,11 @@ export function _colorVarsStyle(
|
|
|
17
17
|
'--card-shadow-penumbra-color': base.shadow.penumbra,
|
|
18
18
|
'--card-shadow-ambient-color': base.shadow.ambient,
|
|
19
19
|
'--card-focus-ring-color': base.focusRing,
|
|
20
|
+
'--card-icon-color': color.iconColor,
|
|
20
21
|
|
|
21
22
|
// Card
|
|
22
23
|
'--card-bg-color': color.bg,
|
|
24
|
+
'--card-bg2-color': color.bg2,
|
|
23
25
|
'--card-bg-image': checkered
|
|
24
26
|
? `repeating-conic-gradient(${color.bg} 0% 25%, ${color.bg2 || color.bg} 0% 50%)`
|
|
25
27
|
: undefined,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {FocusRing} from '../../theme'
|
|
2
|
+
|
|
1
3
|
export function focusRingBorderStyle(border: {color: string; width: number}): string {
|
|
2
4
|
return `inset 0 0 0 ${border.width}px ${border.color}`
|
|
3
5
|
}
|
|
@@ -5,7 +7,7 @@ export function focusRingBorderStyle(border: {color: string; width: number}): st
|
|
|
5
7
|
export function focusRingStyle(opts: {
|
|
6
8
|
base?: {bg: string}
|
|
7
9
|
border?: {color: string; width: number}
|
|
8
|
-
focusRing:
|
|
10
|
+
focusRing: FocusRing
|
|
9
11
|
}): string {
|
|
10
12
|
const {base, border, focusRing} = opts
|
|
11
13
|
const focusRingOutsetWidth = focusRing.offset + focusRing.width
|
|
@@ -130,7 +130,8 @@ export function textInputRepresentationStyle(
|
|
|
130
130
|
props: TextInputRepresentationStyleProps & ThemeProps,
|
|
131
131
|
): ReturnType<typeof css> {
|
|
132
132
|
const {$hasPrefix, $hasSuffix, $scheme, $tone, theme} = props
|
|
133
|
-
const {
|
|
133
|
+
const {input} = theme.sanity
|
|
134
|
+
const {focusRing} = input.text
|
|
134
135
|
const color = theme.sanity.color.input
|
|
135
136
|
|
|
136
137
|
return css`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {CSSObject} from '../../types/styled'
|
|
2
|
-
import {
|
|
2
|
+
import {_responsive, rem} from '../helpers'
|
|
3
3
|
import {ThemeProps} from '../types'
|
|
4
4
|
import {ResponsiveRadiusStyleProps} from './types'
|
|
5
5
|
|
|
@@ -7,7 +7,17 @@ export function responsiveRadiusStyle(props: ResponsiveRadiusStyleProps & ThemeP
|
|
|
7
7
|
const {theme} = props
|
|
8
8
|
const {media, radius} = theme.sanity
|
|
9
9
|
|
|
10
|
-
return _responsive(media, props.$radius, (
|
|
11
|
-
borderRadius:
|
|
12
|
-
|
|
10
|
+
return _responsive(media, props.$radius, (value) => {
|
|
11
|
+
let borderRadius: string | 0 = 0
|
|
12
|
+
|
|
13
|
+
if (typeof value === 'number') {
|
|
14
|
+
borderRadius = rem(radius[value])
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (value === 'full') {
|
|
18
|
+
borderRadius = '9999px'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return {borderRadius}
|
|
22
|
+
})
|
|
13
23
|
}
|
|
@@ -158,6 +158,7 @@ export const defaultOpts: ThemeColorBuilderOpts = {
|
|
|
158
158
|
bg2: dark ? color.light : color.dark,
|
|
159
159
|
border: dark ? color.lighter : color.darker,
|
|
160
160
|
fg: dark ? color.darkest : color.lightest,
|
|
161
|
+
iconColor: dark ? color.darkest : color.lightest,
|
|
161
162
|
muted: {
|
|
162
163
|
fg: black,
|
|
163
164
|
},
|
|
@@ -180,6 +181,7 @@ export const defaultOpts: ThemeColorBuilderOpts = {
|
|
|
180
181
|
bg2: color.base,
|
|
181
182
|
border: dark ? color.light : color.dark,
|
|
182
183
|
fg: dark ? color.darkest : color.lightest,
|
|
184
|
+
iconColor: dark ? color.darkest : color.lightest,
|
|
183
185
|
muted: {
|
|
184
186
|
fg: black,
|
|
185
187
|
},
|
|
@@ -206,6 +208,7 @@ export const defaultOpts: ThemeColorBuilderOpts = {
|
|
|
206
208
|
bg2: dark ? color.darker : color.lighter,
|
|
207
209
|
border: dark ? color.lighter : color.darker,
|
|
208
210
|
fg: dark ? color.lightest : color.darkest,
|
|
211
|
+
iconColor: dark ? color.lightest : color.darkest,
|
|
209
212
|
muted: {
|
|
210
213
|
fg: black,
|
|
211
214
|
},
|
|
@@ -228,6 +231,7 @@ export const defaultOpts: ThemeColorBuilderOpts = {
|
|
|
228
231
|
bg2: dark ? color.darkest : color.lightest,
|
|
229
232
|
border: dark ? color.darker : color.lighter,
|
|
230
233
|
fg: dark ? color.lighter : color.darker,
|
|
234
|
+
iconColor: dark ? color.lighter : color.darker,
|
|
231
235
|
muted: {
|
|
232
236
|
fg: black,
|
|
233
237
|
},
|
|
@@ -253,6 +257,7 @@ export const defaultOpts: ThemeColorBuilderOpts = {
|
|
|
253
257
|
bg: 'transparent',
|
|
254
258
|
bg2: 'transparent',
|
|
255
259
|
fg: muted.enabled.fg,
|
|
260
|
+
iconColor: muted.enabled.fg,
|
|
256
261
|
border: 'transparent',
|
|
257
262
|
muted: {
|
|
258
263
|
fg: black,
|
|
@@ -273,6 +278,7 @@ export const defaultOpts: ThemeColorBuilderOpts = {
|
|
|
273
278
|
bg: muted.enabled.bg,
|
|
274
279
|
bg2: muted.enabled.bg,
|
|
275
280
|
fg: muted.hovered.fg,
|
|
281
|
+
iconColor: muted.hovered.fg,
|
|
276
282
|
border: 'transparent',
|
|
277
283
|
muted: {
|
|
278
284
|
fg: black,
|
|
@@ -306,6 +312,7 @@ export const defaultOpts: ThemeColorBuilderOpts = {
|
|
|
306
312
|
bg: black,
|
|
307
313
|
bg2: black,
|
|
308
314
|
fg: black,
|
|
315
|
+
iconColor: black,
|
|
309
316
|
border: black,
|
|
310
317
|
muted: {
|
|
311
318
|
fg: black,
|
|
@@ -327,6 +334,7 @@ export const defaultOpts: ThemeColorBuilderOpts = {
|
|
|
327
334
|
input: () => {
|
|
328
335
|
return {
|
|
329
336
|
bg: black,
|
|
337
|
+
bg2: black,
|
|
330
338
|
fg: black,
|
|
331
339
|
border: black,
|
|
332
340
|
placeholder: black,
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
import {FocusRing} from '../../types'
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @public
|
|
3
5
|
*/
|
|
4
6
|
export interface ThemeInput {
|
|
5
7
|
checkbox: {
|
|
6
8
|
size: number
|
|
9
|
+
focusRing: FocusRing
|
|
7
10
|
}
|
|
8
11
|
radio: {
|
|
9
12
|
size: number
|
|
10
13
|
markSize: number
|
|
14
|
+
focusRing: FocusRing
|
|
11
15
|
}
|
|
12
16
|
switch: {
|
|
13
17
|
width: number
|
|
@@ -15,8 +19,15 @@ export interface ThemeInput {
|
|
|
15
19
|
padding: number
|
|
16
20
|
transitionDurationMs: number
|
|
17
21
|
transitionTimingFunction: string
|
|
22
|
+
focusRing: FocusRing
|
|
18
23
|
}
|
|
19
24
|
border: {
|
|
20
25
|
width: number
|
|
21
26
|
}
|
|
27
|
+
select: {
|
|
28
|
+
focusRing: FocusRing
|
|
29
|
+
}
|
|
30
|
+
text: {
|
|
31
|
+
focusRing: FocusRing
|
|
32
|
+
}
|
|
22
33
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {FocusRing} from '../../types'
|
|
1
2
|
import {ThemeAvatar} from './avatar'
|
|
2
3
|
import {ThemeColorSchemes} from './color'
|
|
3
4
|
import {ThemeFonts, ThemeFontWeightKey} from './fonts'
|
|
@@ -15,14 +16,20 @@ export interface BaseTheme<
|
|
|
15
16
|
avatar: ThemeAvatar
|
|
16
17
|
button: {
|
|
17
18
|
textWeight: ThemeFontWeightKey
|
|
19
|
+
focusRing: FocusRing
|
|
20
|
+
}
|
|
21
|
+
card: {
|
|
22
|
+
focusRing: FocusRing
|
|
18
23
|
}
|
|
19
24
|
color: ThemeColorSchemes
|
|
20
25
|
container: number[]
|
|
26
|
+
/** @deprecated Use component-specific `focusRing` values instead */
|
|
21
27
|
focusRing: {
|
|
22
28
|
offset: number
|
|
23
29
|
width: number
|
|
24
30
|
}
|
|
25
31
|
fonts: ThemeFonts
|
|
32
|
+
input: ThemeInput
|
|
26
33
|
/**
|
|
27
34
|
* THIS API MAY BE UNSTABLE. DO NOT USE IN PRODUCTION.
|
|
28
35
|
* @beta
|
|
@@ -32,6 +39,5 @@ export interface BaseTheme<
|
|
|
32
39
|
radius: number[]
|
|
33
40
|
shadows: Array<ThemeShadow | null>
|
|
34
41
|
space: number[]
|
|
35
|
-
input: ThemeInput
|
|
36
42
|
styles?: Styles
|
|
37
43
|
}
|