@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.
- package/dist/index.cjs.mjs +3 -1
- package/dist/index.d.ts +294 -407
- package/dist/index.esm.js +971 -2333
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +972 -2332
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/dialog/dialog.tsx +3 -3
- package/src/components/dialog/styles.ts +3 -4
- package/src/components/menu/__workshop__/closableMenuButton.tsx +2 -2
- package/src/components/menu/menuDivider.ts +2 -1
- package/src/components/menu/menuGroup.tsx +22 -23
- package/src/components/menu/menuItem.tsx +30 -36
- package/src/components/skeleton/styles.ts +8 -7
- package/src/components/tree/style.ts +19 -20
- package/src/primitives/_selectable/style.ts +25 -22
- package/src/primitives/avatar/avatar.tsx +8 -3
- package/src/primitives/avatar/avatarCounter.tsx +5 -4
- package/src/primitives/avatar/spotColors.ts +53 -0
- package/src/primitives/avatar/styles.ts +5 -7
- package/src/primitives/avatar/types.ts +14 -0
- package/src/primitives/badge/badge.tsx +4 -2
- package/src/primitives/badge/styles.ts +7 -8
- package/src/primitives/box/__workshop__/responsive.tsx +2 -2
- package/src/primitives/button/button.tsx +2 -2
- package/src/primitives/button/styles.ts +82 -16
- package/src/primitives/card/__workshop__/selected.tsx +8 -9
- package/src/primitives/card/card.tsx +43 -7
- package/src/primitives/card/styles.ts +30 -22
- package/src/primitives/card/types.ts +3 -1
- package/src/primitives/checkbox/styles.ts +20 -20
- package/src/primitives/code/code.tsx +15 -3
- package/src/primitives/code/styles.ts +51 -42
- package/src/primitives/heading/styles.ts +6 -5
- package/src/primitives/kbd/kbd.tsx +2 -1
- package/src/primitives/label/styles.ts +3 -2
- package/src/primitives/popover/popoverArrow.tsx +3 -2
- package/src/primitives/popover/popoverCard.tsx +6 -2
- package/src/primitives/radio/styles.ts +15 -15
- package/src/primitives/select/styles.ts +20 -22
- package/src/primitives/switch/styles.ts +13 -13
- package/src/primitives/text/__workshop__/colored.tsx +10 -11
- package/src/primitives/text/styles.ts +10 -9
- package/src/primitives/textArea/textArea.tsx +7 -11
- package/src/primitives/textInput/textInput.tsx +12 -12
- package/src/primitives/tooltip/__workshop__/props.tsx +20 -3
- package/src/primitives/tooltip/tooltipArrow.tsx +3 -2
- package/src/styles/border/borderStyle.ts +2 -1
- package/src/styles/colorVars/colorVarsStyle.ts +73 -32
- package/src/styles/focusRing/index.ts +6 -4
- package/src/styles/input/textInputStyle.ts +76 -93
- package/src/styles/margin/marginsStyle.test.ts +1 -2
- package/src/styles/padding/paddingStyle.test.ts +1 -2
- package/src/styles/shadow/shadowStyle.ts +5 -5
- package/src/theme/__workshop__/color.tsx +2 -2
- package/src/theme/__workshop__/index.ts +0 -5
- 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/color/cssVariables/cardVariables.ts +92 -0
- package/src/theme/lib/theme/color/cssVariables/createCssVars.ts +31 -0
- package/src/theme/lib/theme/color/cssVariables/cssVars.test.ts +262 -0
- package/src/theme/lib/theme/color/cssVariables/index.ts +1 -0
- package/src/theme/lib/theme/color/cssVariables/tints.ts +312 -0
- package/src/theme/lib/theme/color/cssVariables/tones.ts +67 -0
- package/src/theme/lib/theme/color/cssVariables/utils.test.ts +15 -0
- package/src/theme/lib/theme/color/cssVariables/utils.ts +9 -0
- package/src/theme/lib/theme/color/index.ts +2 -12
- package/src/theme/lib/theme/color/types.ts +6 -37
- package/src/theme/studioTheme/color.ts +2 -641
- package/src/theme/studioTheme/helpers.ts +15 -1
- package/src/theme/studioTheme/theme.ts +9 -3
- package/src/theme/themeColorProvider.tsx +2 -0
- package/src/theme/themeProvider.tsx +27 -8
- package/src/theme/toneContext/toneContext.ts +12 -0
- package/src/theme/toneContext/toneProvider.tsx +31 -0
- package/src/theme/toneContext/types.ts +10 -0
- package/src/theme/toneContext/useToneContext.tsx +26 -0
- package/src/theme/types.ts +2 -4
- package/src/utils/elementQuery/__workshop__/customMedia.tsx +4 -3
- package/src/theme/__workshop__/canvas.tsx +0 -395
- package/src/theme/lib/theme/color/_generic/index.ts +0 -1
- package/src/theme/lib/theme/color/_generic/types.ts +0 -30
- package/src/theme/lib/theme/color/base/index.ts +0 -1
- package/src/theme/lib/theme/color/base/types.ts +0 -19
- package/src/theme/lib/theme/color/button/createButtonModes.ts +0 -20
- package/src/theme/lib/theme/color/button/createButtonTones.ts +0 -52
- package/src/theme/lib/theme/color/button/index.ts +0 -1
- package/src/theme/lib/theme/color/button/types.ts +0 -44
- package/src/theme/lib/theme/color/card/createCardStates.ts +0 -58
- package/src/theme/lib/theme/color/card/index.ts +0 -1
- package/src/theme/lib/theme/color/card/types.ts +0 -18
- package/src/theme/lib/theme/color/color.test.ts +0 -63
- package/src/theme/lib/theme/color/defaults.ts +0 -390
- package/src/theme/lib/theme/color/factory.ts +0 -138
- package/src/theme/lib/theme/color/input/createInputModes.ts +0 -84
- package/src/theme/lib/theme/color/input/index.ts +0 -1
- package/src/theme/lib/theme/color/input/types.ts +0 -28
- package/src/theme/lib/theme/color/muted/createMuted.ts +0 -56
- package/src/theme/lib/theme/color/muted/index.ts +0 -1
- package/src/theme/lib/theme/color/muted/types.ts +0 -24
- package/src/theme/lib/theme/color/selectable/createSelectableTones.ts +0 -73
- package/src/theme/lib/theme/color/selectable/index.ts +0 -1
- package/src/theme/lib/theme/color/selectable/types.ts +0 -29
- package/src/theme/lib/theme/color/solid/createSolidTones.ts +0 -56
- package/src/theme/lib/theme/color/solid/index.ts +0 -1
- package/src/theme/lib/theme/color/solid/types.ts +0 -24
- package/src/theme/lib/theme/color/spot/createSpot.ts +0 -21
- package/src/theme/lib/theme/color/spot/index.ts +0 -1
- package/src/theme/lib/theme/color/spot/types.ts +0 -28
- package/src/theme/lib/theme/color/syntax/index.ts +0 -1
- package/src/theme/lib/theme/color/syntax/types.ts +0 -41
- package/src/theme/studioTheme/tints.ts +0 -152
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
textInputFontSizeStyle,
|
|
14
14
|
textInputRepresentationStyle,
|
|
15
15
|
} from '../../styles/internal'
|
|
16
|
-
import {
|
|
16
|
+
import {ThemeColorToneKey, ThemeFontWeightKey} from '../../theme'
|
|
17
17
|
import {ResponsiveRadiusProps} from '../types'
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -25,6 +25,7 @@ export interface TextAreaProps extends ResponsiveRadiusProps {
|
|
|
25
25
|
fontSize?: number | number[]
|
|
26
26
|
padding?: number | number[]
|
|
27
27
|
weight?: ThemeFontWeightKey
|
|
28
|
+
tone?: ThemeColorToneKey
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
const Root = styled.span(textInputRootStyle)
|
|
@@ -62,13 +63,12 @@ export const TextArea = forwardRef(function TextArea(
|
|
|
62
63
|
padding = 3,
|
|
63
64
|
radius = 2,
|
|
64
65
|
weight,
|
|
66
|
+
tone = 'default',
|
|
65
67
|
...restProps
|
|
66
68
|
} = props
|
|
67
69
|
|
|
68
70
|
const ref = useForwardedRef(forwardedRef)
|
|
69
71
|
|
|
70
|
-
const rootTheme = useRootTheme()
|
|
71
|
-
|
|
72
72
|
useCustomValidity(ref, customValidity)
|
|
73
73
|
|
|
74
74
|
return (
|
|
@@ -76,25 +76,21 @@ export const TextArea = forwardRef(function TextArea(
|
|
|
76
76
|
<InputRoot>
|
|
77
77
|
<Input
|
|
78
78
|
data-as="textarea"
|
|
79
|
-
data-
|
|
80
|
-
data-tone={rootTheme.tone}
|
|
79
|
+
data-tone={tone}
|
|
81
80
|
{...restProps}
|
|
82
81
|
$fontSize={useArrayProp(fontSize)}
|
|
83
82
|
$padding={useArrayProp(padding)}
|
|
84
|
-
$scheme={rootTheme.scheme}
|
|
85
83
|
$space={useArrayProp(0)}
|
|
86
|
-
$tone={
|
|
84
|
+
$tone={tone}
|
|
87
85
|
$weight={weight}
|
|
88
86
|
disabled={disabled}
|
|
89
87
|
ref={ref}
|
|
90
88
|
/>
|
|
91
89
|
<Presentation
|
|
92
90
|
$radius={useArrayProp(radius)}
|
|
93
|
-
$
|
|
94
|
-
$tone={rootTheme.tone}
|
|
91
|
+
$tone={tone}
|
|
95
92
|
data-border={border ? '' : undefined}
|
|
96
|
-
data-
|
|
97
|
-
data-tone={rootTheme.tone}
|
|
93
|
+
data-tone={tone}
|
|
98
94
|
/>
|
|
99
95
|
</InputRoot>
|
|
100
96
|
</Root>
|
|
@@ -16,7 +16,8 @@ import {
|
|
|
16
16
|
textInputRepresentationStyle,
|
|
17
17
|
textInputRootStyle,
|
|
18
18
|
} from '../../styles/internal'
|
|
19
|
-
import {
|
|
19
|
+
import {ThemeColorToneKey, ThemeFontWeightKey} from '../../theme'
|
|
20
|
+
import {useToneContext} from '../../theme/toneContext/useToneContext'
|
|
20
21
|
import {Radius} from '../../types'
|
|
21
22
|
import {Box} from '../box'
|
|
22
23
|
import {Button, ButtonProps} from '../button'
|
|
@@ -70,6 +71,7 @@ export interface TextInputProps {
|
|
|
70
71
|
suffix?: React.ReactNode
|
|
71
72
|
type?: TextInputType
|
|
72
73
|
weight?: ThemeFontWeightKey
|
|
74
|
+
tone?: ThemeColorToneKey
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
const CLEAR_BUTTON_BOX_STYLE: React.CSSProperties = {zIndex: 2}
|
|
@@ -163,12 +165,14 @@ export const TextInput = forwardRef(function TextInput(
|
|
|
163
165
|
customValidity,
|
|
164
166
|
type = 'text',
|
|
165
167
|
weight,
|
|
168
|
+
tone: toneProp = 'default',
|
|
166
169
|
...restProps
|
|
167
170
|
} = props
|
|
168
171
|
|
|
169
172
|
const ref = useForwardedRef(forwardedRef)
|
|
170
173
|
|
|
171
|
-
const
|
|
174
|
+
const toneContext = useToneContext()
|
|
175
|
+
const tone = toneProp === 'default' ? toneContext.tone : toneProp
|
|
172
176
|
|
|
173
177
|
const fontSize = useArrayProp(fontSizeProp)
|
|
174
178
|
const padding = useArrayProp(paddingProp)
|
|
@@ -221,11 +225,9 @@ export const TextInput = forwardRef(function TextInput(
|
|
|
221
225
|
$hasPrefix={$hasPrefix}
|
|
222
226
|
$hasSuffix={$hasSuffix}
|
|
223
227
|
$radius={radius}
|
|
224
|
-
$
|
|
225
|
-
$tone={rootTheme.tone}
|
|
228
|
+
$tone={tone}
|
|
226
229
|
data-border={border ? '' : undefined}
|
|
227
|
-
data-
|
|
228
|
-
data-tone={rootTheme.tone}
|
|
230
|
+
data-tone={tone}
|
|
229
231
|
>
|
|
230
232
|
{icon && (
|
|
231
233
|
<LeftBox padding={padding}>
|
|
@@ -253,10 +255,10 @@ export const TextInput = forwardRef(function TextInput(
|
|
|
253
255
|
iconRight,
|
|
254
256
|
padding,
|
|
255
257
|
radius,
|
|
256
|
-
rootTheme,
|
|
257
258
|
$hasClearButton,
|
|
258
259
|
$hasPrefix,
|
|
259
260
|
$hasSuffix,
|
|
261
|
+
tone,
|
|
260
262
|
],
|
|
261
263
|
)
|
|
262
264
|
|
|
@@ -339,22 +341,20 @@ export const TextInput = forwardRef(function TextInput(
|
|
|
339
341
|
)
|
|
340
342
|
|
|
341
343
|
return (
|
|
342
|
-
<Root data-ui="TextInput" tone={
|
|
344
|
+
<Root data-ui="TextInput" tone={tone}>
|
|
343
345
|
{prefixNode}
|
|
344
346
|
|
|
345
347
|
<InputRoot>
|
|
346
348
|
<Input
|
|
347
349
|
data-as="input"
|
|
348
|
-
data-
|
|
349
|
-
data-tone={rootTheme.tone}
|
|
350
|
+
data-tone={tone}
|
|
350
351
|
{...restProps}
|
|
351
352
|
$fontSize={fontSize}
|
|
352
353
|
$iconLeft={$hasIcon}
|
|
353
354
|
$iconRight={$hasIconRight || $hasClearButton}
|
|
354
355
|
$padding={padding}
|
|
355
|
-
$scheme={rootTheme.scheme}
|
|
356
356
|
$space={space}
|
|
357
|
-
$tone={
|
|
357
|
+
$tone={tone}
|
|
358
358
|
$weight={weight}
|
|
359
359
|
disabled={disabled}
|
|
360
360
|
readOnly={readOnly}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Button,
|
|
3
|
+
Card,
|
|
4
|
+
Flex,
|
|
5
|
+
Text,
|
|
6
|
+
Tooltip,
|
|
7
|
+
TooltipDelayGroupProvider,
|
|
8
|
+
Stack,
|
|
9
|
+
cssVars,
|
|
10
|
+
} from '@sanity/ui'
|
|
2
11
|
import {useBoolean, useSelect, useText, useNumber} from '@sanity/ui-workshop'
|
|
3
12
|
import {
|
|
4
13
|
WORKSHOP_PLACEMENT_OPTIONS,
|
|
@@ -28,7 +37,11 @@ export default function PropsStory() {
|
|
|
28
37
|
>
|
|
29
38
|
<Stack
|
|
30
39
|
padding={4}
|
|
31
|
-
style={{
|
|
40
|
+
style={{
|
|
41
|
+
outline: `1px solid ${cssVars.default['border-base']}`,
|
|
42
|
+
width: '100%',
|
|
43
|
+
maxWidth: '640px',
|
|
44
|
+
}}
|
|
32
45
|
space={4}
|
|
33
46
|
>
|
|
34
47
|
<Text align="center" size={3}>
|
|
@@ -52,7 +65,11 @@ export default function PropsStory() {
|
|
|
52
65
|
</Stack>
|
|
53
66
|
<Stack
|
|
54
67
|
padding={4}
|
|
55
|
-
style={{
|
|
68
|
+
style={{
|
|
69
|
+
outline: `1px solid ${cssVars.default['border-base']}`,
|
|
70
|
+
width: '100%',
|
|
71
|
+
maxWidth: '640px',
|
|
72
|
+
}}
|
|
56
73
|
space={4}
|
|
57
74
|
>
|
|
58
75
|
<Text align="center" size={3}>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {forwardRef} from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
|
+
import {cssVars} from '../../theme'
|
|
3
4
|
|
|
4
5
|
const Root = styled.div`
|
|
5
6
|
position: absolute;
|
|
@@ -63,11 +64,11 @@ const Root = styled.div`
|
|
|
63
64
|
`
|
|
64
65
|
|
|
65
66
|
const Border = styled.path`
|
|
66
|
-
fill:
|
|
67
|
+
fill: ${cssVars.default['base-shadow-outline-color']};
|
|
67
68
|
`
|
|
68
69
|
|
|
69
70
|
const Shape = styled.path`
|
|
70
|
-
fill:
|
|
71
|
+
fill: ${cssVars.mutable['bg-color']};
|
|
71
72
|
`
|
|
72
73
|
|
|
73
74
|
interface TooltipArrowProps {}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import {cssVars} from '../../theme'
|
|
1
2
|
import {CSSObject} from '../../types/styled'
|
|
2
3
|
import {_responsive} from '../helpers'
|
|
3
4
|
import {ThemeProps} from '../types'
|
|
4
5
|
import {ResponsiveBorderStyleProps} from './types'
|
|
5
6
|
|
|
6
|
-
const BORDER_VALUE =
|
|
7
|
+
const BORDER_VALUE = `1px solid ${cssVars.default['border-base']}`
|
|
7
8
|
|
|
8
9
|
export function responsiveBorderStyle(): Array<
|
|
9
10
|
(props: ResponsiveBorderStyleProps & ThemeProps) => CSSObject[]
|
|
@@ -1,43 +1,84 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {ThemeColorToneKey, cssVars} from '../../theme'
|
|
2
|
+
import {mutableCardVariables} from '../../theme/lib/theme/color/cssVariables/cardVariables'
|
|
3
|
+
import {getToneCssVar} from '../../theme/lib/theme/color/cssVariables/tones'
|
|
2
4
|
import {CSSObject} from '../../types/styled'
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* @internal
|
|
8
|
+
* Card overrides in disabled states
|
|
6
9
|
*/
|
|
7
|
-
export function
|
|
8
|
-
base: ThemeColorBase,
|
|
9
|
-
color: ThemeColorGenericState,
|
|
10
|
-
checkered = false,
|
|
11
|
-
): CSSObject {
|
|
10
|
+
export function _colorVarStyleDisabled(checkered = false): CSSObject {
|
|
12
11
|
return {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
'--card-shadow-penumbra-color': base.shadow.penumbra,
|
|
18
|
-
'--card-shadow-ambient-color': base.shadow.ambient,
|
|
19
|
-
'--card-focus-ring-color': base.focusRing,
|
|
20
|
-
'--card-icon-color': color.iconColor,
|
|
12
|
+
[getToneCssVar('default', 'text-link')]: cssVars.default['text-secondary'],
|
|
13
|
+
[getToneCssVar('default', 'text-accent')]: cssVars.default['text-secondary'],
|
|
14
|
+
[getToneCssVar('default', 'text-code')]: cssVars.default['text-secondary'],
|
|
15
|
+
[getToneCssVar('default', 'text-primary')]: cssVars.default['text-secondary'],
|
|
21
16
|
|
|
22
|
-
|
|
23
|
-
'
|
|
24
|
-
'
|
|
25
|
-
'
|
|
26
|
-
|
|
17
|
+
[mutableCardVariables['fg-color']]: cssVars.primary['text-secondary'],
|
|
18
|
+
[mutableCardVariables['muted-fg-color']]: cssVars.primary['text-secondary'],
|
|
19
|
+
[mutableCardVariables['icon-color']]: cssVars.primary['border-base'],
|
|
20
|
+
[mutableCardVariables['accent-color']]: cssVars.primary['base-bg-card'],
|
|
21
|
+
[mutableCardVariables['bg-color']]: cssVars.primary['bg-tint'],
|
|
22
|
+
[mutableCardVariables['bg-image']]: checkered
|
|
23
|
+
? `repeating-conic-gradient(${cssVars.default['base-bg-card']} 0% 25%, ${cssVars.default['bg-tint']} 0% 50%)`
|
|
27
24
|
: undefined,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @internal
|
|
30
|
+
* Card overrides in selected states
|
|
31
|
+
*/
|
|
32
|
+
export function _colorVarStyleSelected(): CSSObject {
|
|
33
|
+
return {
|
|
34
|
+
[mutableCardVariables['bg-color']]: cssVars.default['bg-accent'],
|
|
35
|
+
[mutableCardVariables['fg-color']]: cssVars.default['bg-base'],
|
|
36
|
+
[mutableCardVariables['muted-fg-color']]: cssVars.default['base-bg-card'],
|
|
37
|
+
[mutableCardVariables['accent-color']]: cssVars.default['base-bg-card'],
|
|
38
|
+
[mutableCardVariables['icon-color']]: cssVars.primary['bg-base'],
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @internal
|
|
44
|
+
* Card overrides in hover
|
|
45
|
+
*/
|
|
46
|
+
export function _colorVarStyleHover(): CSSObject {
|
|
47
|
+
return {
|
|
48
|
+
[mutableCardVariables['bg-color']]: cssVars.default['bg-base-hover'],
|
|
49
|
+
[getToneCssVar('default', 'bg-tint')]: cssVars.default['bg-base-active'],
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @internal
|
|
55
|
+
* Card overrides in active / pressed states
|
|
56
|
+
*/
|
|
57
|
+
export function _colorVarStyleActive(): CSSObject {
|
|
58
|
+
return {
|
|
59
|
+
[mutableCardVariables['bg-color']]: cssVars.default['bg-base-active'],
|
|
60
|
+
}
|
|
61
|
+
}
|
|
37
62
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
63
|
+
/**
|
|
64
|
+
* @internal
|
|
65
|
+
* Selectable needs to redefine bg-color and fg-color
|
|
66
|
+
*/
|
|
67
|
+
export function _selectableVarStyle(tone: ThemeColorToneKey): CSSObject {
|
|
68
|
+
return {
|
|
69
|
+
[mutableCardVariables['bg-color']]: 'inherit',
|
|
70
|
+
[mutableCardVariables['fg-color']]:
|
|
71
|
+
tone === 'default' ? cssVars.default['text-primary'] : cssVars.default['text-secondary'],
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @internal
|
|
77
|
+
* Selectable overrides in disabled states, same as card but with different bg-color
|
|
78
|
+
*/
|
|
79
|
+
export function _selectableVarStyleDisabled(): CSSObject {
|
|
80
|
+
return {
|
|
81
|
+
..._colorVarStyleDisabled(),
|
|
82
|
+
[mutableCardVariables['bg-color']]: undefined,
|
|
42
83
|
}
|
|
43
84
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {FocusRing} from '../../theme'
|
|
1
|
+
import {FocusRing, cssVars} from '../../theme'
|
|
2
2
|
|
|
3
3
|
export function focusRingBorderStyle(border: {color: string; width: number}): string {
|
|
4
4
|
return `inset 0 0 0 ${border.width}px ${border.color}`
|
|
@@ -12,13 +12,15 @@ export function focusRingStyle(opts: {
|
|
|
12
12
|
const {base, border, focusRing} = opts
|
|
13
13
|
const focusRingOutsetWidth = focusRing.offset + focusRing.width
|
|
14
14
|
const focusRingInsetWidth = 0 - focusRing.offset
|
|
15
|
-
const bgColor = base ? base.bg : '
|
|
15
|
+
const bgColor = base ? base.bg : cssVars.mutable['bg-color']
|
|
16
16
|
|
|
17
17
|
return [
|
|
18
|
-
focusRingInsetWidth > 0 &&
|
|
18
|
+
focusRingInsetWidth > 0 &&
|
|
19
|
+
`inset 0 0 0 ${focusRingInsetWidth}px ${cssVars.positive['border-accent']}`,
|
|
19
20
|
border && focusRingBorderStyle(border),
|
|
20
21
|
focusRingInsetWidth < 0 && `0 0 0 ${0 - focusRingInsetWidth}px ${bgColor}`,
|
|
21
|
-
focusRingOutsetWidth > 0 &&
|
|
22
|
+
focusRingOutsetWidth > 0 &&
|
|
23
|
+
`0 0 0 ${focusRingOutsetWidth}px ${cssVars.positive['border-accent']}`,
|
|
22
24
|
]
|
|
23
25
|
.filter(Boolean)
|
|
24
26
|
.join(',')
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {css} from 'styled-components'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import {ThemeColorToneKey, ThemeFontWeightKey} from '../../theme'
|
|
3
|
+
import {mutableCardVariables} from '../../theme/lib/theme/color/cssVariables/cardVariables'
|
|
4
|
+
import {cssVars} from '../../theme/lib/theme/color/cssVariables/createCssVars'
|
|
4
5
|
import {CSSObject} from '../../types/styled'
|
|
5
6
|
import {focusRingBorderStyle, focusRingStyle} from '../focusRing'
|
|
6
7
|
import {rem, _responsive} from '../helpers'
|
|
@@ -11,8 +12,7 @@ import {ThemeProps} from '../types'
|
|
|
11
12
|
*/
|
|
12
13
|
export interface TextInputInputStyleProps {
|
|
13
14
|
$fontSize: number[]
|
|
14
|
-
$
|
|
15
|
-
$tone: CardTone
|
|
15
|
+
$tone: ThemeColorToneKey
|
|
16
16
|
$weight?: ThemeFontWeightKey
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -22,8 +22,7 @@ export interface TextInputInputStyleProps {
|
|
|
22
22
|
export interface TextInputRepresentationStyleProps {
|
|
23
23
|
$hasPrefix?: boolean
|
|
24
24
|
$hasSuffix?: boolean
|
|
25
|
-
$
|
|
26
|
-
$tone: CardTone
|
|
25
|
+
$tone: ThemeColorToneKey
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
const ROOT_STYLE = css`
|
|
@@ -41,9 +40,8 @@ export function textInputRootStyle(): ReturnType<typeof css> {
|
|
|
41
40
|
export function textInputBaseStyle(
|
|
42
41
|
props: TextInputInputStyleProps & ThemeProps,
|
|
43
42
|
): ReturnType<typeof css> {
|
|
44
|
-
const {theme, $
|
|
43
|
+
const {theme, $tone, $weight} = props
|
|
45
44
|
const font = theme.sanity.fonts.text
|
|
46
|
-
const color = theme.sanity.color.input
|
|
47
45
|
|
|
48
46
|
return css`
|
|
49
47
|
appearance: none;
|
|
@@ -81,33 +79,31 @@ export function textInputBaseStyle(
|
|
|
81
79
|
color: var(--input-placeholder-color);
|
|
82
80
|
}
|
|
83
81
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
--input-placeholder-color: ${color.default.enabled.placeholder};
|
|
82
|
+
--input-fg-color: ${cssVars[$tone]['text-primary']};
|
|
83
|
+
--input-placeholder-color: ${cssVars[$tone]['text-inactive']};
|
|
87
84
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
85
|
+
/* enabled */
|
|
86
|
+
&:not(:invalid):not(:disabled):not(:read-only) {
|
|
87
|
+
--input-fg-color: ${cssVars[$tone]['text-primary']};
|
|
88
|
+
--input-placeholder-color: ${cssVars[$tone]['text-inactive']};
|
|
89
|
+
}
|
|
93
90
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
/* disabled */
|
|
92
|
+
&:not(:invalid):disabled {
|
|
93
|
+
--input-fg-color: ${cssVars[$tone]['text-primary']};
|
|
94
|
+
--input-placeholder-color: ${cssVars[$tone]['text-inactive']};
|
|
95
|
+
}
|
|
99
96
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
97
|
+
/* invalid */
|
|
98
|
+
&:invalid {
|
|
99
|
+
--input-fg-color: ${cssVars.critical['text-primary']};
|
|
100
|
+
--input-placeholder-color: ${cssVars.critical['text-inactive']};
|
|
101
|
+
}
|
|
105
102
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
103
|
+
/* readOnly */
|
|
104
|
+
&:read-only {
|
|
105
|
+
--input-fg-color: ${cssVars[$tone]['text-primary']};
|
|
106
|
+
--input-placeholder-color: ${cssVars[$tone]['text-inactive']};
|
|
111
107
|
}
|
|
112
108
|
`
|
|
113
109
|
}
|
|
@@ -129,10 +125,9 @@ export function textInputFontSizeStyle(props: TextInputInputStyleProps & ThemePr
|
|
|
129
125
|
export function textInputRepresentationStyle(
|
|
130
126
|
props: TextInputRepresentationStyleProps & ThemeProps,
|
|
131
127
|
): ReturnType<typeof css> {
|
|
132
|
-
const {$hasPrefix, $hasSuffix, $
|
|
128
|
+
const {$hasPrefix, $hasSuffix, $tone, theme} = props
|
|
133
129
|
const {input} = theme.sanity
|
|
134
130
|
const {focusRing} = input.text
|
|
135
|
-
const color = theme.sanity.color.input
|
|
136
131
|
|
|
137
132
|
return css`
|
|
138
133
|
--input-box-shadow: none;
|
|
@@ -146,7 +141,7 @@ export function textInputRepresentationStyle(
|
|
|
146
141
|
pointer-events: none;
|
|
147
142
|
z-index: 0;
|
|
148
143
|
|
|
149
|
-
background-color:
|
|
144
|
+
background-color: ${cssVars.mutable['bg-color']};
|
|
150
145
|
box-shadow: var(--input-box-shadow);
|
|
151
146
|
|
|
152
147
|
border-top-left-radius: ${$hasPrefix ? 0 : undefined};
|
|
@@ -154,78 +149,66 @@ export function textInputRepresentationStyle(
|
|
|
154
149
|
border-top-right-radius: ${$hasSuffix ? 0 : undefined};
|
|
155
150
|
border-bottom-right-radius: ${$hasSuffix ? 0 : undefined};
|
|
156
151
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
152
|
+
${mutableCardVariables['bg-color']}: ${cssVars[$tone]['bg-base']};
|
|
153
|
+
${mutableCardVariables['fg-color']}: ${cssVars[$tone]['text-primary']};
|
|
154
|
+
|
|
155
|
+
/* enabled */
|
|
156
|
+
&[data-border] {
|
|
157
|
+
--input-box-shadow: ${focusRingBorderStyle({
|
|
158
|
+
color: cssVars[$tone]['border-base'],
|
|
159
|
+
width: input.border.width,
|
|
160
|
+
})};
|
|
161
|
+
}
|
|
160
162
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
+
/* invalid */
|
|
164
|
+
*:not(:disabled):invalid + & {
|
|
165
|
+
${mutableCardVariables['bg-color']}: ${cssVars.critical['bg-tint']};
|
|
166
|
+
${mutableCardVariables['fg-color']}: ${cssVars.critical['text-primary']};
|
|
167
|
+
|
|
168
|
+
&[data-border] {
|
|
163
169
|
--input-box-shadow: ${focusRingBorderStyle({
|
|
164
|
-
color:
|
|
170
|
+
color: cssVars.critical['border-base'],
|
|
165
171
|
width: input.border.width,
|
|
166
172
|
})};
|
|
167
173
|
}
|
|
174
|
+
}
|
|
168
175
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
--
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
color: color.invalid.enabled.border,
|
|
177
|
-
width: input.border.width,
|
|
178
|
-
})};
|
|
179
|
-
}
|
|
176
|
+
/* focused */
|
|
177
|
+
*:not(:disabled):focus + & {
|
|
178
|
+
&[data-border] {
|
|
179
|
+
--input-box-shadow: ${focusRingStyle({
|
|
180
|
+
border: {color: cssVars[$tone]['border-base'], width: input.border.width},
|
|
181
|
+
focusRing,
|
|
182
|
+
})};
|
|
180
183
|
}
|
|
181
184
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
&[data-border] {
|
|
185
|
-
--input-box-shadow: ${focusRingStyle({
|
|
186
|
-
border: {color: color.default.enabled.border, width: input.border.width},
|
|
187
|
-
focusRing,
|
|
188
|
-
})};
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
&:not([data-border]) {
|
|
192
|
-
--input-box-shadow: ${focusRingStyle({focusRing})};
|
|
193
|
-
}
|
|
185
|
+
&:not([data-border]) {
|
|
186
|
+
--input-box-shadow: ${focusRingStyle({focusRing})};
|
|
194
187
|
}
|
|
188
|
+
}
|
|
195
189
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
&[data-border] {
|
|
202
|
-
--input-box-shadow: ${focusRingBorderStyle({
|
|
203
|
-
color: color.default.disabled.border,
|
|
204
|
-
width: input.border.width,
|
|
205
|
-
})};
|
|
206
|
-
}
|
|
207
|
-
}
|
|
190
|
+
/* disabled */
|
|
191
|
+
*:disabled + & {
|
|
192
|
+
${mutableCardVariables['bg-color']}: ${cssVars.default['bg-tint']} !important;
|
|
193
|
+
${mutableCardVariables['fg-color']}: ${cssVars.default['text-primary']} !important;
|
|
194
|
+
}
|
|
208
195
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
196
|
+
/* readOnly */
|
|
197
|
+
*:read-only + & {
|
|
198
|
+
${mutableCardVariables['bg-color']}: ${cssVars.default['bg-tint']} !important;
|
|
199
|
+
${mutableCardVariables['fg-color']}: ${cssVars.default['text-primary']} !important;
|
|
200
|
+
}
|
|
214
201
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
--input-box-shadow: ${focusRingBorderStyle({
|
|
224
|
-
color: color.default.hovered.border,
|
|
225
|
-
width: input.border.width,
|
|
226
|
-
})};
|
|
227
|
-
}
|
|
202
|
+
/* hovered */
|
|
203
|
+
@media (hover: hover) {
|
|
204
|
+
|
|
205
|
+
*:not(:disabled):not(:read-only):not(:invalid):not(:focus):hover + &[data-border] {
|
|
206
|
+
--input-box-shadow: ${focusRingBorderStyle({
|
|
207
|
+
color: cssVars.default['border-base-hover'],
|
|
208
|
+
width: input.border.width,
|
|
209
|
+
})};
|
|
228
210
|
}
|
|
229
211
|
}
|
|
212
|
+
}
|
|
230
213
|
`
|
|
231
214
|
}
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
import {studioTheme, Theme} from '../../theme'
|
|
4
4
|
import {responsiveMarginStyle} from './marginStyle'
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
const theme: Theme = {sanity: {...restTheme, color: color.light.default}}
|
|
6
|
+
const theme: Theme = {sanity: studioTheme}
|
|
8
7
|
|
|
9
8
|
describe('styles/margin', () => {
|
|
10
9
|
it('should 1', () => {
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
import {studioTheme, Theme} from '../../theme'
|
|
4
4
|
import {responsivePaddingStyle} from './paddingStyle'
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
const theme: Theme = {sanity: {...restTheme, color: color.light.default}}
|
|
6
|
+
const theme: Theme = {sanity: studioTheme}
|
|
8
7
|
|
|
9
8
|
describe('styles/padding', () => {
|
|
10
9
|
it('should 1', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {EMPTY_RECORD} from '../../constants'
|
|
2
|
-
import {BoxShadow, ThemeShadow} from '../../theme'
|
|
2
|
+
import {BoxShadow, ThemeShadow, cssVars} from '../../theme'
|
|
3
3
|
import {CSSObject} from '../../types/styled'
|
|
4
4
|
import {rem, _responsive} from '../helpers'
|
|
5
5
|
import {ThemeProps} from '../types'
|
|
@@ -12,10 +12,10 @@ function toBoxShadow(shadow: BoxShadow, color: string) {
|
|
|
12
12
|
function shadowStyle(shadow: ThemeShadow | null): CSSObject {
|
|
13
13
|
if (!shadow) return EMPTY_RECORD
|
|
14
14
|
|
|
15
|
-
const outline = `0 0 0 ${rem(1)}
|
|
16
|
-
const umbra = toBoxShadow(shadow.umbra, '
|
|
17
|
-
const penumbra = toBoxShadow(shadow.penumbra, '
|
|
18
|
-
const ambient = toBoxShadow(shadow.ambient, '
|
|
15
|
+
const outline = `0 0 0 ${rem(1)} ${cssVars.default['base-shadow-outline-color']}`
|
|
16
|
+
const umbra = toBoxShadow(shadow.umbra, cssVars.default['base-shadow-umbra-color'])
|
|
17
|
+
const penumbra = toBoxShadow(shadow.penumbra, cssVars.default['base-shadow-penumbra-color'])
|
|
18
|
+
const ambient = toBoxShadow(shadow.ambient, cssVars.default['base-shadow-ambient-color'])
|
|
19
19
|
|
|
20
20
|
return {boxShadow: `${outline}, ${umbra}, ${penumbra}, ${ambient}`}
|
|
21
21
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import {Box, Card, Tree, TreeItem, useRootTheme} from '@sanity/ui'
|
|
2
|
+
import {Box, Card, Tree, TreeItem, cssVars, useRootTheme} from '@sanity/ui'
|
|
3
3
|
|
|
4
4
|
export default function ColorStory() {
|
|
5
5
|
const {theme} = useRootTheme()
|
|
@@ -48,7 +48,7 @@ function ColorPreview({name, value}: {name: string; value: string}) {
|
|
|
48
48
|
radius={2}
|
|
49
49
|
style={{
|
|
50
50
|
backgroundColor: value,
|
|
51
|
-
boxShadow:
|
|
51
|
+
boxShadow: `inset 0 0 0 1px ${cssVars.default['base-shadow-outline-color']}`,
|
|
52
52
|
display: 'inline-block',
|
|
53
53
|
height: 17,
|
|
54
54
|
width: 25,
|