@sanity/ui 2.0.0-alpha.34 → 2.0.0-alpha.36
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 +4 -3
- package/dist/index.d.ts +29 -22
- package/dist/index.esm.js +397 -518
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +413 -534
- package/dist/index.js.map +1 -1
- package/dist/theme.cjs.mjs +10 -4
- package/dist/theme.d.ts +489 -201
- package/dist/theme.esm.js +2934 -2748
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +2943 -2751
- package/dist/theme.js.map +1 -1
- package/package.json +3 -3
- package/src/core/_compat.ts +7 -7
- package/src/core/components/dialog/dialog.tsx +5 -5
- package/src/core/components/dialog/styles.ts +4 -5
- package/src/core/components/hotkeys/hotkeys.tsx +4 -2
- package/src/core/components/menu/__workshop__/avatarMenu.tsx +50 -0
- package/src/core/components/menu/__workshop__/index.ts +5 -0
- package/src/core/components/menu/menuItem.tsx +7 -1
- package/src/core/components/skeleton/textSkeleton.tsx +12 -14
- package/src/core/components/tree/style.ts +14 -17
- package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +3 -3
- package/src/core/hooks/useMediaIndex/useMediaIndex.ts +2 -3
- package/src/core/primitives/_selectable/style.ts +18 -18
- package/src/core/primitives/avatar/avatar.tsx +3 -3
- package/src/core/primitives/avatar/avatarCounter.tsx +4 -4
- package/src/core/primitives/avatar/avatarStack.tsx +2 -2
- package/src/core/primitives/avatar/styles.ts +7 -8
- package/src/core/primitives/avatar/types.ts +2 -2
- package/src/core/primitives/badge/__workshop__/props.tsx +1 -1
- package/src/core/primitives/badge/__workshop__/tones.tsx +1 -1
- package/src/core/primitives/badge/badge.tsx +1 -1
- package/src/core/primitives/badge/styles.ts +5 -6
- package/src/core/primitives/button/button.tsx +3 -4
- package/src/core/primitives/button/styles.ts +22 -23
- package/src/core/primitives/card/__workshop__/selected.tsx +15 -15
- package/src/core/primitives/card/card.tsx +1 -1
- package/src/core/primitives/card/styles.ts +22 -22
- package/src/core/primitives/checkbox/styles.ts +21 -22
- package/src/core/primitives/code/styles.ts +4 -1
- package/src/core/primitives/container/styles.ts +2 -3
- package/src/core/primitives/heading/styles.ts +4 -2
- package/src/core/primitives/inline/styles.ts +6 -6
- package/src/core/primitives/kbd/kbd.tsx +7 -11
- package/src/core/primitives/label/styles.ts +4 -3
- package/src/core/primitives/popover/helpers.ts +3 -4
- package/src/core/primitives/popover/popover.tsx +8 -4
- package/src/core/primitives/popover/types.ts +1 -1
- package/src/core/primitives/radio/styles.ts +17 -19
- package/src/core/primitives/select/styles.ts +27 -32
- package/src/core/primitives/stack/styles.ts +2 -3
- package/src/core/primitives/switch/__workshop__/props.tsx +11 -31
- package/src/core/primitives/switch/styles.ts +18 -21
- package/src/core/primitives/text/__workshop__/colored.tsx +10 -10
- package/src/core/primitives/text/styles.ts +9 -4
- package/src/core/primitives/tooltip/tooltip.tsx +3 -3
- package/src/core/styles/border/borderStyle.ts +6 -11
- package/src/core/styles/box/boxStyle.ts +5 -9
- package/src/core/styles/card/_cardColorStyle.ts +99 -0
- package/src/core/styles/card/index.ts +1 -0
- package/src/core/styles/flex/flexItemStyle.ts +2 -3
- package/src/core/styles/flex/flexStyle.ts +6 -11
- package/src/core/styles/font/responsiveFont.ts +4 -4
- package/src/core/styles/font/textAlignStyle.ts +3 -3
- package/src/core/styles/grid/gridItemStyle.ts +7 -13
- package/src/core/styles/grid/gridStyle.ts +9 -17
- package/src/core/styles/helpers.ts +5 -3
- package/src/core/styles/input/responsiveInputPaddingStyle.ts +6 -6
- package/src/core/styles/input/textInputStyle.ts +36 -40
- package/src/core/styles/margin/marginsStyle.test.ts +2 -3
- package/src/core/styles/padding/paddingStyle.test.ts +2 -3
- package/src/core/styles/radius/radiusStyle.ts +2 -3
- package/src/core/styles/shadow/shadowStyle.ts +4 -5
- package/src/core/theme/__workshop__/build/Root.tsx +24 -20
- package/src/core/theme/__workshop__/build/story.tsx +22 -26
- package/src/core/theme/__workshop__/canvas.tsx +21 -40
- package/src/core/theme/theme.test.tsx +2 -35
- package/src/core/theme/themeColorProvider.tsx +2 -2
- package/src/core/theme/themeContext.ts +2 -2
- package/src/core/theme/themeProvider.tsx +25 -25
- package/src/core/theme/types.ts +3 -2
- package/src/core/theme/useRootTheme.ts +1 -9
- package/src/core/theme/useTheme.ts +8 -1
- package/src/core/types/card.ts +2 -2
- package/src/core/utils/arrow/arrow.tsx +3 -3
- package/src/core/utils/elementQuery/elementQuery.tsx +3 -3
- package/src/core/utils/virtualList/virtualList.tsx +2 -2
- package/src/theme/build/_deprecated/color/muted/createMuted.ts +2 -2
- package/src/theme/build/buildColorTheme.test.ts +14 -15
- package/src/theme/build/buildColorTheme.ts +239 -292
- package/src/theme/build/buildTheme.test.ts +9 -7
- package/src/theme/build/buildTheme.ts +12 -9
- package/src/theme/build/colorToken.ts +3 -1
- package/src/theme/build/lib/color-fns/contrastRatio.ts +1 -0
- package/src/theme/build/lib/isRecord.ts +3 -0
- package/src/theme/build/merge.ts +18 -13
- package/src/theme/build/renderColorTheme.ts +205 -213
- package/src/theme/build/renderColorValue.ts +15 -8
- package/src/theme/build/resolveColorTokens.ts +177 -198
- package/src/theme/build/theme.test.ts +27 -0
- package/src/theme/config/helpers.ts +16 -8
- package/src/theme/config/system.ts +46 -17
- package/src/theme/config/tokens/color/types.ts +55 -32
- package/src/theme/config/tokens/types.ts +11 -4
- package/src/theme/config/types.ts +5 -11
- package/src/theme/{build/defaults → defaults}/colorPalette.ts +1 -1
- package/src/theme/{build/defaults → defaults}/colorTokens.ts +189 -136
- package/src/theme/{build/defaults → defaults}/config.ts +14 -12
- package/src/theme/{build/defaults → defaults}/fonts.ts +6 -6
- package/src/theme/getScopedTheme.ts +81 -0
- package/src/theme/index.ts +9 -1
- package/src/theme/system/avatar.ts +1 -1
- package/src/theme/system/color/_constants.ts +11 -11
- package/src/theme/system/color/_system.ts +10 -71
- package/src/theme/system/color/avatar.ts +22 -10
- package/src/theme/system/color/badge.ts +18 -7
- package/src/theme/system/color/button.ts +17 -23
- package/src/theme/system/color/color.ts +34 -0
- package/src/theme/system/color/index.ts +3 -10
- package/src/theme/system/color/input.ts +13 -11
- package/src/theme/system/color/kbd.ts +3 -3
- package/src/theme/system/color/selectable.ts +13 -19
- package/src/theme/system/color/shadow.ts +7 -0
- package/src/theme/system/color/state.ts +37 -0
- package/src/theme/system/css.ts +9 -0
- package/src/theme/system/focusRing.ts +7 -0
- package/src/theme/system/index.ts +5 -1
- package/src/theme/system/input.ts +1 -1
- package/src/theme/system/layer.ts +1 -2
- package/src/theme/system/shadow.ts +1 -0
- package/src/theme/system/styles.ts +19 -0
- package/src/theme/system/theme.ts +128 -0
- package/src/theme/system/{color → v0/color}/_generic.ts +2 -1
- package/src/theme/system/v0/color/_system.ts +13 -0
- package/src/theme/system/{color → v0/color}/base.ts +2 -0
- package/src/theme/system/v0/color/button.ts +42 -0
- package/src/theme/system/{color → v0/color}/card.ts +2 -1
- package/src/theme/system/v0/color/color.ts +40 -0
- package/src/theme/system/v0/color/index.ts +11 -0
- package/src/theme/system/v0/color/input.ts +34 -0
- package/src/theme/system/{color/_deprecated → v0/color}/muted.ts +1 -1
- package/src/theme/system/v0/color/selectable.ts +31 -0
- package/src/theme/system/{color/_deprecated → v0/color}/solid.ts +1 -1
- package/src/theme/system/v0/color/spot.ts +13 -0
- package/src/theme/system/v0/index.ts +1 -0
- package/src/theme/versioning/getTheme_v2.ts +38 -0
- package/src/theme/versioning/index.ts +5 -0
- package/src/theme/versioning/is_v0.ts +6 -0
- package/src/theme/versioning/is_v2.ts +6 -0
- package/src/theme/versioning/themeColor_v0_v2.ts +217 -0
- package/src/theme/versioning/v0_v2.ts +72 -0
- package/src/theme/versioning/v2_v0.ts +126 -0
- package/src/core/styles/colorVars/colorVarsStyle.ts +0 -43
- package/src/core/styles/colorVars/index.ts +0 -1
- package/src/core/theme/defaults.ts +0 -7
- package/src/theme/system/_system.ts +0 -95
- package/src/theme/system/color/_deprecated/spot.ts +0 -13
- package/src/theme/themes/studio/config.ts +0 -69
- package/src/theme/themes/studio/fonts.ts +0 -219
- package/src/theme/themes/studio/index.ts +0 -1
- package/src/theme/themes/studio/studioTheme.test.ts +0 -27
- package/src/theme/themes/studio/studioTheme.ts +0 -8
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import {CSSObject} from '@sanity/ui/theme'
|
|
2
|
-
import {ThemeProps} from '../../styles'
|
|
3
2
|
import {BadgeStyleProps} from './types'
|
|
4
3
|
|
|
5
|
-
export function badgeStyle(props: BadgeStyleProps
|
|
6
|
-
const {$tone
|
|
7
|
-
const color = theme.sanity.color.badge?.[$tone] || theme.sanity.color.muted[$tone].enabled
|
|
4
|
+
export function badgeStyle(props: BadgeStyleProps): CSSObject {
|
|
5
|
+
const {$tone} = props
|
|
8
6
|
|
|
9
7
|
return {
|
|
10
|
-
'--card-bg-color': color
|
|
11
|
-
'--card-fg-color': color
|
|
8
|
+
'--card-bg-color': `var(--card-badge-${$tone}-bg-color)`,
|
|
9
|
+
'--card-fg-color': `var(--card-badge-${$tone}-fg-color)`,
|
|
12
10
|
|
|
13
11
|
backgroundColor: 'var(--card-bg-color)',
|
|
14
12
|
cursor: 'default',
|
|
15
13
|
|
|
16
14
|
'&:not([hidden])': {
|
|
17
15
|
display: 'inline-block',
|
|
16
|
+
verticalAlign: 'top',
|
|
18
17
|
},
|
|
19
18
|
}
|
|
20
19
|
}
|
|
@@ -4,7 +4,7 @@ import styled from 'styled-components'
|
|
|
4
4
|
import {useArrayProp} from '../../hooks'
|
|
5
5
|
import {ThemeProps} from '../../styles'
|
|
6
6
|
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
|
|
7
|
-
import {
|
|
7
|
+
import {useTheme_v2} from '../../theme'
|
|
8
8
|
import {ButtonMode, ButtonTextAlign, ButtonTone, ButtonWidth, FlexJustify} from '../../types'
|
|
9
9
|
import {Box} from '../box'
|
|
10
10
|
import {Flex} from '../flex'
|
|
@@ -91,6 +91,7 @@ export const Button = forwardRef(function Button(
|
|
|
91
91
|
width,
|
|
92
92
|
...restProps
|
|
93
93
|
} = props
|
|
94
|
+
const {button} = useTheme_v2()
|
|
94
95
|
|
|
95
96
|
const justify = useArrayProp(justifyProp)
|
|
96
97
|
const padding = useArrayProp(paddingProp)
|
|
@@ -103,8 +104,6 @@ export const Button = forwardRef(function Button(
|
|
|
103
104
|
const radius = useArrayProp(radiusProp)
|
|
104
105
|
const space = useArrayProp(spaceProp)
|
|
105
106
|
|
|
106
|
-
const theme = useTheme()
|
|
107
|
-
|
|
108
107
|
const boxProps = useMemo(
|
|
109
108
|
() => ({
|
|
110
109
|
// flex: 1,
|
|
@@ -156,7 +155,7 @@ export const Button = forwardRef(function Button(
|
|
|
156
155
|
align={textAlign}
|
|
157
156
|
size={fontSize}
|
|
158
157
|
textOverflow="ellipsis"
|
|
159
|
-
weight={
|
|
158
|
+
weight={button.textWeight}
|
|
160
159
|
>
|
|
161
160
|
{text}
|
|
162
161
|
</Text>
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {CSSObject} from '@sanity/ui/theme'
|
|
1
|
+
import {CSSObject, getTheme_v2} from '@sanity/ui/theme'
|
|
2
2
|
import {css} from 'styled-components'
|
|
3
3
|
import {ThemeProps} from '../../styles'
|
|
4
|
-
import {
|
|
4
|
+
import {_cardColorStyle} from '../../styles/card'
|
|
5
5
|
import {focusRingBorderStyle, focusRingStyle} from '../../styles/internal'
|
|
6
6
|
import {ButtonMode, ButtonTone, ButtonWidth} from '../../types'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @internal
|
|
10
10
|
*/
|
|
11
|
-
export function buttonBaseStyles(
|
|
12
|
-
$width,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const {
|
|
11
|
+
export function buttonBaseStyles(
|
|
12
|
+
props: {$width?: ButtonWidth} & ThemeProps,
|
|
13
|
+
): ReturnType<typeof css> {
|
|
14
|
+
const {$width} = props
|
|
15
|
+
const {style} = getTheme_v2(props.theme)
|
|
16
16
|
|
|
17
17
|
return css`
|
|
18
|
-
${
|
|
18
|
+
${style?.button};
|
|
19
19
|
|
|
20
20
|
-webkit-font-smoothing: inherit;
|
|
21
21
|
appearance: none;
|
|
@@ -66,26 +66,25 @@ function combineBoxShadow(...boxShadows: (string | undefined)[]): string {
|
|
|
66
66
|
export function buttonColorStyles(
|
|
67
67
|
props: {$mode: ButtonMode; $tone: ButtonTone} & ThemeProps,
|
|
68
68
|
): CSSObject[] {
|
|
69
|
-
const {$mode
|
|
70
|
-
const
|
|
69
|
+
const {$mode} = props
|
|
70
|
+
const {button, color: baseColor, style} = getTheme_v2(props.theme)
|
|
71
71
|
const shadow = props.$mode === 'ghost'
|
|
72
|
-
const
|
|
73
|
-
const mode = theme.sanity.color.button[$mode] || theme.sanity.color.button.default
|
|
72
|
+
const mode = baseColor.button[$mode] || baseColor.button.default
|
|
74
73
|
const color = mode[props.$tone] || mode.default
|
|
75
74
|
const border = {
|
|
76
|
-
width:
|
|
75
|
+
width: button.border.width,
|
|
77
76
|
color: 'var(--card-border-color)',
|
|
78
77
|
}
|
|
79
78
|
// const defaultBoxShadow = `inset 0px -1.5px 0px ${buttonTheme.border.width}px color-mix(in srgb, var(--card-border-color) 25%, var(--card-bg-color))`
|
|
80
79
|
const defaultBoxShadow = undefined
|
|
81
80
|
|
|
82
81
|
return [
|
|
83
|
-
|
|
82
|
+
_cardColorStyle(baseColor, color.enabled),
|
|
84
83
|
{
|
|
85
84
|
backgroundColor: 'var(--card-bg-color)',
|
|
86
85
|
color: 'var(--card-fg-color)',
|
|
87
86
|
boxShadow: focusRingBorderStyle(border),
|
|
88
|
-
'&:disabled, &[data-disabled="true"]':
|
|
87
|
+
'&:disabled, &[data-disabled="true"]': _cardColorStyle(baseColor, color.disabled),
|
|
89
88
|
"&:not([data-disabled='true'])": {
|
|
90
89
|
boxShadow: combineBoxShadow(
|
|
91
90
|
focusRingBorderStyle(border),
|
|
@@ -93,9 +92,9 @@ export function buttonColorStyles(
|
|
|
93
92
|
),
|
|
94
93
|
'&:focus': {
|
|
95
94
|
boxShadow: focusRingStyle({
|
|
96
|
-
base,
|
|
97
|
-
border: {width: 2, color:
|
|
98
|
-
focusRing:
|
|
95
|
+
base: baseColor,
|
|
96
|
+
border: {width: 2, color: baseColor.bg},
|
|
97
|
+
focusRing: button.focusRing,
|
|
99
98
|
}),
|
|
100
99
|
},
|
|
101
100
|
'&:focus:not(:focus-visible)': {
|
|
@@ -105,13 +104,13 @@ export function buttonColorStyles(
|
|
|
105
104
|
),
|
|
106
105
|
},
|
|
107
106
|
'@media (hover: hover)': {
|
|
108
|
-
'&:hover':
|
|
109
|
-
'&:active':
|
|
110
|
-
'&[data-hovered]':
|
|
107
|
+
'&:hover': _cardColorStyle(baseColor, color.hovered),
|
|
108
|
+
'&:active': _cardColorStyle(baseColor, color.pressed),
|
|
109
|
+
'&[data-hovered]': _cardColorStyle(baseColor, color.hovered),
|
|
111
110
|
},
|
|
112
|
-
'&[data-selected]':
|
|
111
|
+
'&[data-selected]': _cardColorStyle(baseColor, color.pressed),
|
|
113
112
|
},
|
|
114
113
|
},
|
|
115
|
-
|
|
114
|
+
style?.button?.root,
|
|
116
115
|
].filter(Boolean) as CSSObject[]
|
|
117
116
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {EditIcon, PublishIcon} from '@sanity/icons'
|
|
2
|
-
import {Box, Card, Container, Flex, Inline, Stack, Text, useRootTheme} from '@sanity/ui'
|
|
3
|
-
import {
|
|
2
|
+
import {Box, Card, Container, Flex, Inline, Stack, Text, ThemeProps, useRootTheme} from '@sanity/ui'
|
|
3
|
+
import {ThemeColorStateToneKey, getTheme_v2} from '@sanity/ui/theme'
|
|
4
4
|
import {useBoolean} from '@sanity/ui-workshop'
|
|
5
5
|
import styled, {css} from 'styled-components'
|
|
6
6
|
|
|
7
|
-
const TextWithTone = styled(Text)<{$tone:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
const tone =
|
|
7
|
+
const TextWithTone = styled(Text)<{$tone: ThemeColorStateToneKey}>((
|
|
8
|
+
props: {
|
|
9
|
+
$tone: ThemeColorStateToneKey
|
|
10
|
+
} & ThemeProps,
|
|
11
|
+
) => {
|
|
12
|
+
const {$tone} = props
|
|
13
|
+
const {color} = getTheme_v2(props.theme)
|
|
14
|
+
const tone = color.button.default[$tone]
|
|
15
15
|
|
|
16
16
|
return css`
|
|
17
17
|
&:not([data-selected]) {
|
|
18
|
-
--card-fg-color: ${tone
|
|
19
|
-
--card-muted-fg-color: ${tone
|
|
18
|
+
--card-fg-color: ${tone.enabled.bg};
|
|
19
|
+
--card-muted-fg-color: ${tone.enabled.bg};
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
[data-ui='Card']:disabled & {
|
|
@@ -63,7 +63,7 @@ export default function SelectedStory() {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
function Preview({selected}: {selected: boolean}) {
|
|
66
|
-
const
|
|
66
|
+
const rootTheme = useRootTheme()
|
|
67
67
|
|
|
68
68
|
return (
|
|
69
69
|
<Flex>
|
|
@@ -74,14 +74,14 @@ function Preview({selected}: {selected: boolean}) {
|
|
|
74
74
|
<TextWithTone
|
|
75
75
|
data-selected={selected ? '' : undefined}
|
|
76
76
|
muted
|
|
77
|
-
$tone={
|
|
77
|
+
$tone={rootTheme.tone === 'default' ? 'caution' : 'default'}
|
|
78
78
|
>
|
|
79
79
|
<EditIcon />
|
|
80
80
|
</TextWithTone>
|
|
81
81
|
<TextWithTone
|
|
82
82
|
data-selected={selected ? '' : undefined}
|
|
83
83
|
muted
|
|
84
|
-
$tone={
|
|
84
|
+
$tone={rootTheme.tone === 'default' ? 'positive' : 'default'}
|
|
85
85
|
>
|
|
86
86
|
<PublishIcon />
|
|
87
87
|
</TextWithTone>
|
|
@@ -80,7 +80,7 @@ export const Card = forwardRef(function Card(
|
|
|
80
80
|
const rootTheme = useRootTheme()
|
|
81
81
|
const tone = toneProp === 'inherit' ? rootTheme.tone : toneProp
|
|
82
82
|
|
|
83
|
-
//
|
|
83
|
+
// todo: Consider adding the wrapper approach for nested cards in which the tones are not changing, avoid unnecessary ThemeColorProvider
|
|
84
84
|
return (
|
|
85
85
|
<ThemeColorProvider scheme={scheme} tone={tone}>
|
|
86
86
|
<Root
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import {getTheme_v2} from '@sanity/ui/theme'
|
|
1
2
|
import {css} from 'styled-components'
|
|
2
3
|
import {ThemeProps} from '../../styles'
|
|
3
|
-
import {
|
|
4
|
+
import {_cardColorStyle} from '../../styles/card'
|
|
4
5
|
import {focusRingBorderStyle, focusRingStyle} from '../../styles/focusRing'
|
|
5
6
|
import {CardStyleProps} from './types'
|
|
6
7
|
|
|
@@ -11,8 +12,8 @@ export function cardStyle(
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export function cardBaseStyle(props: CardStyleProps & ThemeProps): ReturnType<typeof css> {
|
|
14
|
-
const {$checkered
|
|
15
|
-
const space = theme
|
|
15
|
+
const {$checkered} = props
|
|
16
|
+
const {space} = getTheme_v2(props.theme)
|
|
16
17
|
|
|
17
18
|
return css`
|
|
18
19
|
${$checkered &&
|
|
@@ -48,15 +49,14 @@ export function cardBaseStyle(props: CardStyleProps & ThemeProps): ReturnType<ty
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
export function cardColorStyle(props: CardStyleProps & ThemeProps): ReturnType<typeof css> {
|
|
51
|
-
const {$checkered, $focusRing
|
|
52
|
-
const {
|
|
53
|
-
const {
|
|
54
|
-
const border = {width: 0, color: 'var(--card-border-color)'}
|
|
52
|
+
const {$checkered, $focusRing} = props
|
|
53
|
+
const {card, color, style} = getTheme_v2(props.theme)
|
|
54
|
+
const border = {width: card.border.width, color: 'var(--card-border-color)'}
|
|
55
55
|
|
|
56
56
|
return css`
|
|
57
|
-
color-scheme: ${
|
|
57
|
+
color-scheme: ${color._dark ? 'dark' : 'light'};
|
|
58
58
|
|
|
59
|
-
${
|
|
59
|
+
${_cardColorStyle(color, color, $checkered)}
|
|
60
60
|
|
|
61
61
|
background-color: var(--card-bg-color);
|
|
62
62
|
color: var(--card-fg-color);
|
|
@@ -69,34 +69,34 @@ export function cardColorStyle(props: CardStyleProps & ThemeProps): ReturnType<t
|
|
|
69
69
|
box-shadow: var(--card-focus-ring-box-shadow);
|
|
70
70
|
|
|
71
71
|
&:disabled {
|
|
72
|
-
${
|
|
72
|
+
${_cardColorStyle(color, color.selectable.default.disabled, $checkered)}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
&:not(:disabled) {
|
|
76
76
|
&[data-pressed] {
|
|
77
|
-
${
|
|
77
|
+
${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
&[data-selected] {
|
|
81
|
-
${
|
|
81
|
+
${_cardColorStyle(color, color.selectable.default.selected, $checkered)}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
@media (hover: hover) {
|
|
85
85
|
&:not([data-pressed]):not([data-selected]) {
|
|
86
86
|
&[data-hovered],
|
|
87
87
|
&:hover {
|
|
88
|
-
${
|
|
88
|
+
${_cardColorStyle(color, color.selectable.default.hovered, $checkered)}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
&:active {
|
|
92
|
-
${
|
|
92
|
+
${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
&:focus {
|
|
98
98
|
--card-focus-ring-box-shadow: ${$focusRing
|
|
99
|
-
? focusRingStyle({base, border, focusRing})
|
|
99
|
+
? focusRingStyle({base: color, border, focusRing: card.focusRing})
|
|
100
100
|
: undefined};
|
|
101
101
|
}
|
|
102
102
|
|
|
@@ -112,34 +112,34 @@ export function cardColorStyle(props: CardStyleProps & ThemeProps): ReturnType<t
|
|
|
112
112
|
box-shadow: var(--card-focus-ring-box-shadow);
|
|
113
113
|
|
|
114
114
|
&[data-disabled] {
|
|
115
|
-
${
|
|
115
|
+
${_cardColorStyle(color, color.selectable.default.disabled, $checkered)}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
&:not([data-disabled]) {
|
|
119
119
|
&[data-pressed] {
|
|
120
|
-
${
|
|
120
|
+
${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
&[data-selected] {
|
|
124
|
-
${
|
|
124
|
+
${_cardColorStyle(color, color.selectable.default.selected, $checkered)}
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
@media (hover: hover) {
|
|
128
128
|
&:not([data-pressed]):not([data-selected]) {
|
|
129
129
|
&[data-hovered],
|
|
130
130
|
&:hover {
|
|
131
|
-
${
|
|
131
|
+
${_cardColorStyle(color, color.selectable.default.hovered, $checkered)}
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
&:active {
|
|
135
|
-
${
|
|
135
|
+
${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
&:focus {
|
|
141
141
|
--card-focus-ring-box-shadow: ${$focusRing
|
|
142
|
-
? focusRingStyle({base, border, focusRing})
|
|
142
|
+
? focusRingStyle({base: color, border, focusRing: card.focusRing})
|
|
143
143
|
: undefined};
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -149,6 +149,6 @@ export function cardColorStyle(props: CardStyleProps & ThemeProps): ReturnType<t
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
${
|
|
152
|
+
${style?.card?.root}
|
|
153
153
|
`
|
|
154
154
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {getTheme_v2} from '@sanity/ui/theme'
|
|
1
2
|
import {css} from 'styled-components'
|
|
2
3
|
import {rem, ThemeProps} from '../../styles'
|
|
3
4
|
import {focusRingBorderStyle, focusRingStyle} from '../../styles/internal'
|
|
@@ -10,9 +11,7 @@ export function checkboxBaseStyles(): ReturnType<typeof css> {
|
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export function inputElementStyles(props: ThemeProps): ReturnType<typeof css> {
|
|
13
|
-
const {
|
|
14
|
-
const color = theme.sanity.color.input
|
|
15
|
-
const {input, radius} = theme.sanity
|
|
14
|
+
const {color, input, radius} = getTheme_v2(props.theme)
|
|
16
15
|
const {focusRing} = input.checkbox
|
|
17
16
|
|
|
18
17
|
return css`
|
|
@@ -34,12 +33,12 @@ export function inputElementStyles(props: ThemeProps): ReturnType<typeof css> {
|
|
|
34
33
|
width: ${rem(input.checkbox.size)};
|
|
35
34
|
box-sizing: border-box;
|
|
36
35
|
box-shadow: ${focusRingBorderStyle({
|
|
37
|
-
color: color.default.enabled.border,
|
|
36
|
+
color: color.input.default.enabled.border,
|
|
38
37
|
width: input.border.width,
|
|
39
38
|
})};
|
|
40
39
|
border-radius: ${rem(radius[2])};
|
|
41
40
|
line-height: 1;
|
|
42
|
-
background-color: ${color.default.enabled.bg};
|
|
41
|
+
background-color: ${color.input.default.enabled.bg};
|
|
43
42
|
|
|
44
43
|
& > svg {
|
|
45
44
|
display: block;
|
|
@@ -56,12 +55,12 @@ export function inputElementStyles(props: ThemeProps): ReturnType<typeof css> {
|
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
&:checked + span {
|
|
59
|
-
background: ${color.default.enabled.fg};
|
|
58
|
+
background: ${color.input.default.enabled.fg};
|
|
60
59
|
box-shadow: ${focusRingBorderStyle({
|
|
61
|
-
color: color.default.enabled.fg,
|
|
60
|
+
color: color.input.default.enabled.fg,
|
|
62
61
|
width: input.border.width,
|
|
63
62
|
})};
|
|
64
|
-
color: ${color.default.enabled.bg};
|
|
63
|
+
color: ${color.input.default.enabled.bg};
|
|
65
64
|
}
|
|
66
65
|
|
|
67
66
|
/* focus */
|
|
@@ -75,47 +74,47 @@ export function inputElementStyles(props: ThemeProps): ReturnType<typeof css> {
|
|
|
75
74
|
}
|
|
76
75
|
|
|
77
76
|
&[data-error] + span {
|
|
78
|
-
background-color: ${color.invalid.enabled.border};
|
|
77
|
+
background-color: ${color.input.invalid.enabled.border};
|
|
79
78
|
box-shadow: ${focusRingBorderStyle({
|
|
80
79
|
width: input.border.width,
|
|
81
|
-
color: color.invalid.enabled.
|
|
80
|
+
color: color.input.invalid.enabled.muted.bg,
|
|
82
81
|
})};
|
|
83
|
-
color: ${color.default.disabled.fg};
|
|
82
|
+
color: ${color.input.default.disabled.fg};
|
|
84
83
|
}
|
|
85
84
|
&[data-error]&:checked + span {
|
|
86
|
-
background-color: ${color.invalid.enabled.
|
|
87
|
-
color: ${color.default.enabled.bg};
|
|
85
|
+
background-color: ${color.input.invalid.enabled.muted.bg};
|
|
86
|
+
color: ${color.input.default.enabled.bg};
|
|
88
87
|
}
|
|
89
88
|
&[data-error]&:checked&:not(:disabled):focus:focus-visible + span {
|
|
90
89
|
box-shadow: ${focusRingStyle({
|
|
91
|
-
border: {width: input.border.width, color: color.invalid.readOnly.
|
|
90
|
+
border: {width: input.border.width, color: color.input.invalid.readOnly.muted.bg},
|
|
92
91
|
focusRing: {width: 1, offset: 1},
|
|
93
92
|
})};
|
|
94
93
|
}
|
|
95
94
|
|
|
96
95
|
&:disabled + span {
|
|
97
|
-
background-color: ${color.default.disabled.bg};
|
|
96
|
+
background-color: ${color.input.default.disabled.bg};
|
|
98
97
|
box-shadow: ${focusRingBorderStyle({
|
|
99
98
|
width: input.border.width,
|
|
100
|
-
color: color.default.disabled.border,
|
|
99
|
+
color: color.input.default.disabled.border,
|
|
101
100
|
})};
|
|
102
|
-
color: ${color.default.disabled.fg};
|
|
101
|
+
color: ${color.input.default.disabled.fg};
|
|
103
102
|
}
|
|
104
103
|
&:disabled&:checked + span {
|
|
105
|
-
background-color: ${color.default.disabled.
|
|
104
|
+
background-color: ${color.input.default.disabled.muted.bg};
|
|
106
105
|
}
|
|
107
106
|
|
|
108
107
|
&[data-read-only] + span {
|
|
109
|
-
background-color: ${color.default.readOnly.bg};
|
|
108
|
+
background-color: ${color.input.default.readOnly.bg};
|
|
110
109
|
box-shadow: ${focusRingBorderStyle({
|
|
111
110
|
width: input.border.width,
|
|
112
|
-
color: color.default.readOnly.border,
|
|
111
|
+
color: color.input.default.readOnly.border,
|
|
113
112
|
})};
|
|
114
|
-
color: ${color.default.readOnly.fg};
|
|
113
|
+
color: ${color.input.default.readOnly.fg};
|
|
115
114
|
}
|
|
116
115
|
|
|
117
116
|
&[data-read-only]&:checked + span {
|
|
118
|
-
background-color: ${color.default.readOnly.
|
|
117
|
+
background-color: ${color.input.default.readOnly.muted.bg};
|
|
119
118
|
}
|
|
120
119
|
|
|
121
120
|
&:checked + span > svg:first-child {
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import {getTheme_v2} from '@sanity/ui/theme'
|
|
1
2
|
import {css, ExecutionContext} from 'styled-components'
|
|
2
3
|
|
|
3
4
|
function codeSyntaxHighlightingStyle({theme}: ExecutionContext) {
|
|
4
|
-
const
|
|
5
|
+
const {
|
|
6
|
+
color: {syntax: color},
|
|
7
|
+
} = getTheme_v2(theme)
|
|
5
8
|
|
|
6
9
|
return {
|
|
7
10
|
'&.atrule': {color: color.atrule},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {CSSObject} from '@sanity/ui/theme'
|
|
1
|
+
import {CSSObject, getTheme_v2} from '@sanity/ui/theme'
|
|
2
2
|
import {rem, _responsive, ThemeProps} from '../../styles'
|
|
3
3
|
import {ResponsiveWidthStyleProps} from './types'
|
|
4
4
|
|
|
@@ -14,8 +14,7 @@ export function containerBaseStyle(): CSSObject {
|
|
|
14
14
|
export function responsiveContainerWidthStyle(
|
|
15
15
|
props: ResponsiveWidthStyleProps & ThemeProps,
|
|
16
16
|
): CSSObject[] {
|
|
17
|
-
const {
|
|
18
|
-
const {container, media} = theme.sanity
|
|
17
|
+
const {container, media} = getTheme_v2(props.theme)
|
|
19
18
|
|
|
20
19
|
return _responsive(media, props.$width, (val) => ({
|
|
21
20
|
maxWidth: val === 'auto' ? 'none' : rem(container[val]),
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import {getTheme_v2} from '@sanity/ui/theme'
|
|
1
2
|
import {css} from 'styled-components'
|
|
2
3
|
import {ThemeProps} from '../../styles'
|
|
3
4
|
import {HeadingStyleProps} from './types'
|
|
4
5
|
|
|
5
6
|
export function headingBaseStyle(props: HeadingStyleProps & ThemeProps): ReturnType<typeof css> {
|
|
6
|
-
const {$accent, $muted
|
|
7
|
+
const {$accent, $muted} = props
|
|
8
|
+
const {font} = getTheme_v2(props.theme)
|
|
7
9
|
|
|
8
10
|
return css`
|
|
9
11
|
${$accent &&
|
|
@@ -17,7 +19,7 @@ export function headingBaseStyle(props: HeadingStyleProps & ThemeProps): ReturnT
|
|
|
17
19
|
`}
|
|
18
20
|
|
|
19
21
|
& code {
|
|
20
|
-
font-family: ${
|
|
22
|
+
font-family: ${font.code.family};
|
|
21
23
|
border-radius: 1px;
|
|
22
24
|
}
|
|
23
25
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {CSSObject} from '@sanity/ui/theme'
|
|
1
|
+
import {CSSObject, getTheme_v2} from '@sanity/ui/theme'
|
|
2
2
|
import {rem, _responsive, ThemeProps} from '../../styles'
|
|
3
3
|
import {ResponsiveInlineSpaceStyleProps} from './types'
|
|
4
4
|
|
|
@@ -18,14 +18,14 @@ export function inlineBaseStyle(): CSSObject {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export function inlineSpaceStyle(props: ResponsiveInlineSpaceStyleProps & ThemeProps): CSSObject[] {
|
|
21
|
-
const {
|
|
21
|
+
const {media, space} = getTheme_v2(props.theme)
|
|
22
22
|
|
|
23
|
-
return _responsive(
|
|
24
|
-
const
|
|
23
|
+
return _responsive(media, props.$space, (spaceIndex) => {
|
|
24
|
+
const _space = rem(spaceIndex === 0.5 ? space[1] / 2 : space[spaceIndex])
|
|
25
25
|
|
|
26
26
|
return {
|
|
27
|
-
margin: `-${
|
|
28
|
-
'& > div': {padding: `${
|
|
27
|
+
margin: `-${_space} 0 0 -${_space}`,
|
|
28
|
+
'& > div': {padding: `${_space} 0 0 ${_space}`},
|
|
29
29
|
}
|
|
30
30
|
})
|
|
31
31
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {forwardRef} from 'react'
|
|
2
2
|
import styled, {css} from 'styled-components'
|
|
3
3
|
import {useArrayProp} from '../../hooks'
|
|
4
|
-
import {ThemeProps} from '../../styles'
|
|
5
4
|
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
|
|
6
5
|
import {Radius} from '../../types'
|
|
7
6
|
import {Box} from '../box'
|
|
@@ -17,17 +16,14 @@ export interface KBDProps {
|
|
|
17
16
|
radius?: Radius | Radius[]
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
function kbdStyle(
|
|
21
|
-
const {theme} = props
|
|
22
|
-
const color = theme.sanity.color.kbd || theme.sanity.color.base
|
|
23
|
-
|
|
19
|
+
function kbdStyle() {
|
|
24
20
|
return css`
|
|
25
|
-
--card-
|
|
26
|
-
--
|
|
27
|
-
--
|
|
21
|
+
--card-bg-color: var(--card-kbd-bg-color);
|
|
22
|
+
--card-border-color: var(--card-kbd-border-color);
|
|
23
|
+
--card-fg-color: var(--card-kbd-fg-color);
|
|
28
24
|
|
|
29
|
-
box-shadow: inset 0 0 0 1px var(--
|
|
30
|
-
background: var(--
|
|
25
|
+
box-shadow: inset 0 0 0 1px var(--card-border-color);
|
|
26
|
+
background: var(--card-bg-color);
|
|
31
27
|
font: inherit;
|
|
32
28
|
|
|
33
29
|
&:not([hidden]) {
|
|
@@ -52,7 +48,7 @@ export const KBD = forwardRef(function KBD(
|
|
|
52
48
|
return (
|
|
53
49
|
<Root data-ui="KBD" {...restProps} $radius={useArrayProp(radius)} ref={ref}>
|
|
54
50
|
<Box as="span" padding={padding}>
|
|
55
|
-
<Text as="span" size={fontSize} weight="
|
|
51
|
+
<Text as="span" size={fontSize} weight="semibold">
|
|
56
52
|
{children}
|
|
57
53
|
</Text>
|
|
58
54
|
</Box>
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import {getTheme_v2} from '@sanity/ui/theme'
|
|
1
2
|
import {css} from 'styled-components'
|
|
2
3
|
import {ThemeProps} from '../../styles'
|
|
3
4
|
|
|
4
5
|
export function labelBaseStyle(
|
|
5
6
|
props: {$accent?: boolean; $muted: boolean} & ThemeProps,
|
|
6
7
|
): ReturnType<typeof css> {
|
|
7
|
-
const {$accent, $muted
|
|
8
|
-
const {
|
|
8
|
+
const {$accent, $muted} = props
|
|
9
|
+
const {font} = getTheme_v2(props.theme)
|
|
9
10
|
|
|
10
11
|
return css`
|
|
11
12
|
text-transform: uppercase;
|
|
@@ -21,7 +22,7 @@ export function labelBaseStyle(
|
|
|
21
22
|
`}
|
|
22
23
|
|
|
23
24
|
& code {
|
|
24
|
-
font-family: ${
|
|
25
|
+
font-family: ${font.code.family};
|
|
25
26
|
border-radius: 1px;
|
|
26
27
|
}
|
|
27
28
|
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import {Theme} from '@sanity/ui/theme'
|
|
2
1
|
import {DEFAULT_POPOVER_PADDING} from './constants'
|
|
3
2
|
import {PopoverWidth} from './types'
|
|
4
3
|
|
|
5
4
|
export function calcCurrentWidth(params: {
|
|
6
5
|
mediaIndex: number
|
|
7
|
-
|
|
6
|
+
container: number[]
|
|
8
7
|
width: PopoverWidth[]
|
|
9
8
|
}): number | undefined {
|
|
10
|
-
const {
|
|
9
|
+
const {container, mediaIndex, width} = params
|
|
11
10
|
|
|
12
11
|
const w = width[mediaIndex]
|
|
13
12
|
const currentWidth: PopoverWidth | undefined = w === undefined ? width[width.length - 1] : w
|
|
14
13
|
|
|
15
|
-
return typeof currentWidth === 'number' ?
|
|
14
|
+
return typeof currentWidth === 'number' ? container[currentWidth] : undefined
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
export function calcMaxWidth(params: {
|