@sanity/ui 1.8.3 → 2.0.0-alpha.10
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 -0
- package/dist/index.d.ts +339 -415
- package/dist/index.esm.js +5374 -2489
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +5375 -2487
- package/dist/index.js.map +1 -1
- package/package.json +21 -3
- package/src/components/autocomplete/autocomplete.tsx +2 -1
- package/src/components/dialog/constants.ts +4 -0
- package/src/components/dialog/dialog.tsx +89 -27
- package/src/components/dialog/styles.ts +3 -4
- package/src/components/hotkeys/hotkeys.tsx +2 -1
- package/src/components/menu/__workshop__/closableMenuButton.tsx +2 -2
- package/src/components/menu/menuButton.tsx +2 -2
- package/src/components/menu/menuDivider.ts +2 -1
- package/src/components/menu/menuGroup.tsx +24 -25
- package/src/components/menu/menuItem.tsx +31 -37
- package/src/components/skeleton/styles.ts +8 -7
- package/src/components/tab/tab.tsx +2 -1
- package/src/components/tree/style.ts +19 -20
- package/src/primitives/_selectable/style.ts +25 -23
- 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 +6 -8
- package/src/primitives/avatar/types.ts +14 -0
- package/src/primitives/badge/badge.tsx +5 -3
- package/src/primitives/badge/styles.ts +7 -8
- package/src/primitives/box/__workshop__/responsive.tsx +2 -2
- package/src/primitives/button/__workshop__/sanityUploadButton.tsx +1 -2
- package/src/primitives/button/button.tsx +8 -9
- package/src/primitives/button/styles.ts +100 -17
- package/src/primitives/card/__workshop__/selected.tsx +8 -9
- package/src/primitives/card/card.tsx +43 -7
- package/src/primitives/card/styles.ts +31 -24
- package/src/primitives/card/types.ts +3 -1
- package/src/primitives/checkbox/checkbox.tsx +1 -0
- package/src/primitives/checkbox/styles.ts +53 -23
- 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 +7 -6
- package/src/primitives/label/styles.ts +3 -2
- package/src/primitives/popover/popoverArrow.tsx +3 -2
- package/src/primitives/popover/popoverCard.tsx +8 -4
- package/src/primitives/radio/radio.tsx +1 -0
- package/src/primitives/radio/styles.ts +26 -13
- package/src/primitives/select/select.tsx +3 -2
- package/src/primitives/select/styles.ts +22 -24
- package/src/primitives/switch/__workshop__/props.tsx +4 -4
- package/src/primitives/switch/styles.ts +19 -12
- package/src/primitives/text/__workshop__/colored.tsx +10 -11
- package/src/primitives/text/styles.ts +10 -8
- package/src/primitives/textArea/textArea.tsx +8 -12
- package/src/primitives/textInput/textInput.tsx +15 -14
- package/src/primitives/tooltip/__workshop__/props.tsx +20 -3
- package/src/primitives/tooltip/tooltip.tsx +2 -2
- package/src/primitives/tooltip/tooltipArrow.tsx +3 -2
- package/src/primitives/types.ts +3 -2
- package/src/styles/border/borderStyle.ts +2 -1
- package/src/styles/colorVars/colorVarsStyle.ts +73 -30
- package/src/styles/focusRing/index.ts +8 -4
- package/src/styles/input/textInputStyle.ts +78 -94
- package/src/styles/margin/marginsStyle.test.ts +1 -2
- package/src/styles/padding/paddingStyle.test.ts +1 -2
- package/src/styles/radius/radiusStyle.ts +14 -4
- package/src/styles/radius/types.ts +3 -1
- 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/avatar.ts +3 -0
- package/src/theme/lib/theme/color/_legacy/createColorTheme.ts +7 -0
- package/src/theme/lib/theme/color/_legacy/index.ts +1 -0
- package/src/theme/lib/theme/color/_legacy/legacyColor.ts +3997 -0
- package/src/theme/lib/theme/color/cssVariables/cardVariables.ts +88 -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 +3 -12
- package/src/theme/lib/theme/color/types.ts +6 -37
- package/src/theme/lib/theme/input.ts +11 -0
- package/src/theme/lib/theme/theme.ts +7 -1
- package/src/theme/studioTheme/color.ts +6 -633
- package/src/theme/studioTheme/fonts.ts +3 -3
- package/src/theme/studioTheme/helpers.ts +15 -1
- package/src/theme/studioTheme/theme.ts +26 -6
- package/src/theme/themeColorProvider.tsx +2 -0
- package/src/theme/themeProvider.tsx +28 -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 +10 -4
- package/src/types/index.ts +1 -0
- package/src/types/radius.ts +4 -0
- 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 -29
- 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 -62
- package/src/theme/lib/theme/color/defaults.ts +0 -382
- 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 -27
- 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
|
@@ -1,57 +1,66 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {purple, green, yellow, orange, cyan, gray, red, blue, magenta} from '@sanity/color'
|
|
2
|
+
import {css} from 'styled-components'
|
|
3
|
+
import {ThemeColorSchemeKey} from '../../theme'
|
|
4
|
+
import {cssVars} from '../../theme/lib/theme/color/cssVariables/createCssVars'
|
|
2
5
|
|
|
3
|
-
function codeSyntaxHighlightingStyle(
|
|
4
|
-
const
|
|
6
|
+
function codeSyntaxHighlightingStyle(scheme: ThemeColorSchemeKey) {
|
|
7
|
+
const dark = scheme === 'dark'
|
|
8
|
+
const mainShade = dark ? 400 : 600
|
|
9
|
+
const secondaryShade = dark ? 600 : 400
|
|
5
10
|
|
|
6
11
|
return {
|
|
7
|
-
'&.atrule': {color:
|
|
8
|
-
'&.attr-name': {color:
|
|
9
|
-
'&.attr-value': {color:
|
|
10
|
-
'&.attribute': {color:
|
|
11
|
-
'&.boolean': {color:
|
|
12
|
-
'&.builtin': {color:
|
|
13
|
-
'&.cdata': {color:
|
|
14
|
-
'&.char': {color:
|
|
15
|
-
'&.class': {color:
|
|
16
|
-
'&.class-name': {color:
|
|
17
|
-
'&.comment': {color:
|
|
18
|
-
'&.constant': {color:
|
|
19
|
-
'&.deleted': {color:
|
|
20
|
-
'&.doctype': {color:
|
|
21
|
-
'&.entity': {color:
|
|
22
|
-
'&.function': {color:
|
|
23
|
-
'&.hexcode': {color:
|
|
24
|
-
'&.id': {color:
|
|
25
|
-
'&.important': {color:
|
|
26
|
-
'&.inserted': {color:
|
|
27
|
-
'&.keyword': {color:
|
|
28
|
-
'&.number': {color:
|
|
29
|
-
'&.operator': {color:
|
|
30
|
-
'&.prolog': {color:
|
|
31
|
-
'&.property': {color:
|
|
32
|
-
'&.pseudo-class': {color:
|
|
33
|
-
'&.pseudo-element': {color:
|
|
34
|
-
'&.punctuation': {color:
|
|
35
|
-
'&.regex': {color:
|
|
36
|
-
'&.selector': {color:
|
|
37
|
-
'&.string': {color:
|
|
38
|
-
'&.symbol': {color:
|
|
39
|
-
'&.tag': {color:
|
|
40
|
-
'&.unit': {color:
|
|
41
|
-
'&.url': {color:
|
|
42
|
-
'&.variable': {color:
|
|
12
|
+
'&.atrule': {color: purple[mainShade].hex},
|
|
13
|
+
'&.attr-name': {color: green[mainShade].hex},
|
|
14
|
+
'&.attr-value': {color: yellow[mainShade].hex},
|
|
15
|
+
'&.attribute': {color: yellow[mainShade].hex},
|
|
16
|
+
'&.boolean': {color: purple[mainShade].hex},
|
|
17
|
+
'&.builtin': {color: purple[mainShade].hex},
|
|
18
|
+
'&.cdata': {color: yellow[mainShade].hex},
|
|
19
|
+
'&.char': {color: yellow[mainShade].hex},
|
|
20
|
+
'&.class': {color: orange[mainShade].hex},
|
|
21
|
+
'&.class-name': {color: cyan[mainShade].hex},
|
|
22
|
+
'&.comment': {color: gray[secondaryShade].hex},
|
|
23
|
+
'&.constant': {color: purple[mainShade].hex},
|
|
24
|
+
'&.deleted': {color: red[mainShade].hex},
|
|
25
|
+
'&.doctype': {color: gray[secondaryShade].hex},
|
|
26
|
+
'&.entity': {color: red[mainShade].hex},
|
|
27
|
+
'&.function': {color: green[mainShade].hex},
|
|
28
|
+
'&.hexcode': {color: blue[mainShade].hex},
|
|
29
|
+
'&.id': {color: purple[mainShade].hex},
|
|
30
|
+
'&.important': {color: purple[mainShade].hex},
|
|
31
|
+
'&.inserted': {color: yellow[mainShade].hex},
|
|
32
|
+
'&.keyword': {color: magenta[mainShade].hex},
|
|
33
|
+
'&.number': {color: purple[mainShade].hex},
|
|
34
|
+
'&.operator': {color: magenta[mainShade].hex},
|
|
35
|
+
'&.prolog': {color: gray[secondaryShade].hex},
|
|
36
|
+
'&.property': {color: blue[mainShade].hex},
|
|
37
|
+
'&.pseudo-class': {color: yellow[mainShade].hex},
|
|
38
|
+
'&.pseudo-element': {color: yellow[mainShade].hex},
|
|
39
|
+
'&.punctuation': {color: gray[mainShade].hex},
|
|
40
|
+
'&.regex': {color: blue[mainShade].hex},
|
|
41
|
+
'&.selector': {color: red[mainShade].hex},
|
|
42
|
+
'&.string': {color: yellow[mainShade].hex},
|
|
43
|
+
'&.symbol': {color: purple[mainShade].hex},
|
|
44
|
+
'&.tag': {color: red[mainShade].hex},
|
|
45
|
+
'&.unit': {color: orange[mainShade].hex},
|
|
46
|
+
'&.url': {color: red[mainShade].hex},
|
|
47
|
+
'&.variable': {color: red[mainShade].hex},
|
|
43
48
|
}
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
export
|
|
51
|
+
export interface CodeBaseStyleProps {
|
|
52
|
+
$scheme: ThemeColorSchemeKey
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function codeBaseStyle(props: CodeBaseStyleProps): ReturnType<typeof css> {
|
|
47
56
|
return css`
|
|
48
|
-
color:
|
|
57
|
+
color: ${cssVars.default['text-code']};
|
|
49
58
|
|
|
50
59
|
& code {
|
|
51
60
|
font-family: inherit;
|
|
52
61
|
|
|
53
62
|
&.refractor .token {
|
|
54
|
-
${codeSyntaxHighlightingStyle}
|
|
63
|
+
${codeSyntaxHighlightingStyle(props.$scheme)}
|
|
55
64
|
}
|
|
56
65
|
}
|
|
57
66
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {css} from 'styled-components'
|
|
2
2
|
import {ThemeProps} from '../../styles'
|
|
3
|
+
import {cssVars} from '../../theme'
|
|
3
4
|
import {HeadingStyleProps} from './types'
|
|
4
5
|
|
|
5
6
|
export function headingBaseStyle(props: HeadingStyleProps & ThemeProps): ReturnType<typeof css> {
|
|
@@ -8,12 +9,12 @@ export function headingBaseStyle(props: HeadingStyleProps & ThemeProps): ReturnT
|
|
|
8
9
|
return css`
|
|
9
10
|
${$accent &&
|
|
10
11
|
css`
|
|
11
|
-
color:
|
|
12
|
+
color: ${cssVars.default['text-accent']}};
|
|
12
13
|
`}
|
|
13
14
|
|
|
14
15
|
${$muted &&
|
|
15
16
|
css`
|
|
16
|
-
color:
|
|
17
|
+
color: ${cssVars.mutable['muted-fg-color']};
|
|
17
18
|
`}
|
|
18
19
|
|
|
19
20
|
& code {
|
|
@@ -24,7 +25,7 @@ export function headingBaseStyle(props: HeadingStyleProps & ThemeProps): ReturnT
|
|
|
24
25
|
& a {
|
|
25
26
|
text-decoration: none;
|
|
26
27
|
border-radius: 1px;
|
|
27
|
-
color:
|
|
28
|
+
color: ${cssVars.default['text-link']};
|
|
28
29
|
outline: none;
|
|
29
30
|
|
|
30
31
|
@media (hover: hover) {
|
|
@@ -35,8 +36,8 @@ export function headingBaseStyle(props: HeadingStyleProps & ThemeProps): ReturnT
|
|
|
35
36
|
|
|
36
37
|
&:focus {
|
|
37
38
|
box-shadow:
|
|
38
|
-
0 0 0 1px
|
|
39
|
-
0 0 0 3px
|
|
39
|
+
0 0 0 1px ${cssVars.mutable['bg-color']},
|
|
40
|
+
0 0 0 3px ${cssVars.positive['border-accent']};
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
&:focus:not(:focus-visible) {
|
|
@@ -2,8 +2,10 @@ import {forwardRef} from 'react'
|
|
|
2
2
|
import styled, {css} from 'styled-components'
|
|
3
3
|
import {useArrayProp} from '../../hooks'
|
|
4
4
|
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
|
|
5
|
+
import {cssVars} from '../../theme'
|
|
6
|
+
import {Radius} from '../../types'
|
|
5
7
|
import {Box} from '../box'
|
|
6
|
-
import {
|
|
8
|
+
import {Text} from '../text'
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* @public
|
|
@@ -12,14 +14,13 @@ export interface KBDProps {
|
|
|
12
14
|
as?: React.ElementType | keyof JSX.IntrinsicElements
|
|
13
15
|
fontSize?: number | number[]
|
|
14
16
|
padding?: number | number[]
|
|
15
|
-
radius?:
|
|
17
|
+
radius?: Radius | Radius[]
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
function kbdStyle() {
|
|
19
21
|
return css`
|
|
20
|
-
background:
|
|
22
|
+
background: ${cssVars.default['bg-tint']};
|
|
21
23
|
font: inherit;
|
|
22
|
-
box-shadow: inset 0 0 0 1px var(--card-hairline-hard-color);
|
|
23
24
|
|
|
24
25
|
&:not([hidden]) {
|
|
25
26
|
display: inline-block;
|
|
@@ -41,9 +42,9 @@ export const KBD = forwardRef(function KBD(
|
|
|
41
42
|
return (
|
|
42
43
|
<Root data-ui="KBD" {...restProps} $radius={useArrayProp(radius)} ref={ref}>
|
|
43
44
|
<Box as="span" padding={padding}>
|
|
44
|
-
<
|
|
45
|
+
<Text as="span" muted size={fontSize} weight="medium">
|
|
45
46
|
{children}
|
|
46
|
-
</
|
|
47
|
+
</Text>
|
|
47
48
|
</Box>
|
|
48
49
|
</Root>
|
|
49
50
|
)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {css} from 'styled-components'
|
|
2
2
|
import {ThemeProps} from '../../styles'
|
|
3
|
+
import {cssVars} from '../../theme'
|
|
3
4
|
|
|
4
5
|
export function labelBaseStyle(
|
|
5
6
|
props: {$accent?: boolean; $muted: boolean} & ThemeProps,
|
|
@@ -12,12 +13,12 @@ export function labelBaseStyle(
|
|
|
12
13
|
|
|
13
14
|
${$accent &&
|
|
14
15
|
css`
|
|
15
|
-
color:
|
|
16
|
+
color: ${cssVars.default['text-accent']}};
|
|
16
17
|
`}
|
|
17
18
|
|
|
18
19
|
${$muted &&
|
|
19
20
|
css`
|
|
20
|
-
color:
|
|
21
|
+
color: ${cssVars.mutable['muted-fg-color']};
|
|
21
22
|
`}
|
|
22
23
|
|
|
23
24
|
& code {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {forwardRef} from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
|
+
import {cssVars} from '../../theme'
|
|
3
4
|
import {DEFAULT_POPOVER_ARROW_HEIGHT, DEFAULT_POPOVER_ARROW_WIDTH} from './constants'
|
|
4
5
|
|
|
5
6
|
const Root = styled.div`
|
|
@@ -48,11 +49,11 @@ const Root = styled.div`
|
|
|
48
49
|
`
|
|
49
50
|
|
|
50
51
|
const BorderPath = styled.path`
|
|
51
|
-
fill:
|
|
52
|
+
fill: ${cssVars.default['base-shadow-outline-color']};
|
|
52
53
|
`
|
|
53
54
|
|
|
54
55
|
const ShapePath = styled.path`
|
|
55
|
-
fill:
|
|
56
|
+
fill: ${cssVars.mutable['bg-color']};
|
|
56
57
|
`
|
|
57
58
|
|
|
58
59
|
export const PopoverArrow = forwardRef(function PopoverArrow(
|
|
@@ -3,7 +3,8 @@ import React, {CSSProperties, forwardRef, memo, useMemo} from 'react'
|
|
|
3
3
|
import styled from 'styled-components'
|
|
4
4
|
import {FLOATING_STATIC_SIDES} from '../../constants'
|
|
5
5
|
import {ThemeColorSchemeKey} from '../../theme'
|
|
6
|
-
import {
|
|
6
|
+
import {useToneContext} from '../../theme/toneContext/useToneContext'
|
|
7
|
+
import {BoxOverflow, CardTone, Placement, PopoverMargins, Radius} from '../../types'
|
|
7
8
|
import {useLayer} from '../../utils'
|
|
8
9
|
import {Card} from '../card'
|
|
9
10
|
import {Flex} from '../flex'
|
|
@@ -34,7 +35,7 @@ export const PopoverCard = memo(
|
|
|
34
35
|
overflow?: BoxOverflow
|
|
35
36
|
padding?: number | number[]
|
|
36
37
|
placement?: Placement
|
|
37
|
-
radius?:
|
|
38
|
+
radius?: Radius | Radius[]
|
|
38
39
|
scheme?: ThemeColorSchemeKey
|
|
39
40
|
shadow?: number | number[]
|
|
40
41
|
strategy: Strategy
|
|
@@ -66,8 +67,8 @@ export const PopoverCard = memo(
|
|
|
66
67
|
y: yProp,
|
|
67
68
|
...restProps
|
|
68
69
|
} = props
|
|
69
|
-
|
|
70
70
|
const {zIndex} = useLayer()
|
|
71
|
+
const toneContext = useToneContext()
|
|
71
72
|
|
|
72
73
|
// Get margins: [top, right, bottom, left]
|
|
73
74
|
const margins: PopoverMargins = useMemo(
|
|
@@ -110,14 +111,17 @@ export const PopoverCard = memo(
|
|
|
110
111
|
<Root
|
|
111
112
|
data-ui="Popover"
|
|
112
113
|
{...restProps}
|
|
114
|
+
data-tone={tone}
|
|
113
115
|
data-placement={placement}
|
|
114
116
|
radius={radius}
|
|
115
117
|
ref={ref}
|
|
116
118
|
scheme={scheme}
|
|
117
119
|
shadow={shadow}
|
|
118
120
|
sizing="border"
|
|
121
|
+
// The popover creates a new html element, so it's out of context of the css variables generated in the cards.
|
|
122
|
+
updateCssVars
|
|
123
|
+
tone={tone === 'inherit' ? toneContext.tone : tone}
|
|
119
124
|
style={rootStyle}
|
|
120
|
-
tone={tone}
|
|
121
125
|
>
|
|
122
126
|
<Flex data-ui="Popover__wrapper" direction="column" flex={1} overflow={overflow}>
|
|
123
127
|
<Flex direction="column" flex={1} padding={padding}>
|
|
@@ -29,6 +29,7 @@ export const Radio = forwardRef(function Radio(
|
|
|
29
29
|
<Root className={className} data-ui="Radio" style={style}>
|
|
30
30
|
<Input
|
|
31
31
|
data-read-only={!disabled && readOnly ? '' : undefined}
|
|
32
|
+
data-error={customValidity ? '' : undefined}
|
|
32
33
|
{...restProps}
|
|
33
34
|
disabled={disabled || readOnly}
|
|
34
35
|
readOnly={readOnly}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {css} from 'styled-components'
|
|
2
2
|
import {rem, ThemeProps} from '../../styles'
|
|
3
3
|
import {focusRingBorderStyle, focusRingStyle} from '../../styles/internal'
|
|
4
|
+
import {cssVars} from '../../theme/lib/theme/color/cssVariables/createCssVars'
|
|
4
5
|
|
|
5
6
|
export function radioBaseStyle(): ReturnType<typeof css> {
|
|
6
7
|
return css`
|
|
@@ -18,8 +19,8 @@ export function radioBaseStyle(): ReturnType<typeof css> {
|
|
|
18
19
|
|
|
19
20
|
export function inputElementStyle(props: ThemeProps): ReturnType<typeof css> {
|
|
20
21
|
const {theme} = props
|
|
21
|
-
const {
|
|
22
|
-
const
|
|
22
|
+
const {input} = theme.sanity
|
|
23
|
+
const {focusRing} = input.radio
|
|
23
24
|
const dist = (input.radio.size - input.radio.markSize) / 2
|
|
24
25
|
|
|
25
26
|
return css`
|
|
@@ -44,9 +45,9 @@ export function inputElementStyle(props: ThemeProps): ReturnType<typeof css> {
|
|
|
44
45
|
height: ${rem(input.radio.size)};
|
|
45
46
|
width: ${rem(input.radio.size)};
|
|
46
47
|
border-radius: ${rem(input.radio.size / 2)};
|
|
47
|
-
background: ${
|
|
48
|
+
background: ${cssVars.default['bg-base']};
|
|
48
49
|
box-shadow: ${focusRingBorderStyle({
|
|
49
|
-
color:
|
|
50
|
+
color: cssVars.default['border-base'],
|
|
50
51
|
width: input.border.width,
|
|
51
52
|
})};
|
|
52
53
|
|
|
@@ -58,7 +59,7 @@ export function inputElementStyle(props: ThemeProps): ReturnType<typeof css> {
|
|
|
58
59
|
height: ${rem(input.radio.markSize)};
|
|
59
60
|
width: ${rem(input.radio.markSize)};
|
|
60
61
|
border-radius: ${rem(input.radio.markSize / 2)};
|
|
61
|
-
background: ${
|
|
62
|
+
background: ${cssVars.default['text-secondary']};
|
|
62
63
|
opacity: 0;
|
|
63
64
|
}
|
|
64
65
|
}
|
|
@@ -66,14 +67,14 @@ export function inputElementStyle(props: ThemeProps): ReturnType<typeof css> {
|
|
|
66
67
|
/* focused */
|
|
67
68
|
&:not(:disabled):focus + span {
|
|
68
69
|
box-shadow: ${focusRingStyle({
|
|
69
|
-
border: {width: input.border.width, color:
|
|
70
|
+
border: {width: input.border.width, color: cssVars.default['border-base']},
|
|
70
71
|
focusRing,
|
|
71
72
|
})};
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
&:not(:disabled):focus:not(:focus-visible) + span {
|
|
75
76
|
box-shadow: ${focusRingBorderStyle({
|
|
76
|
-
color:
|
|
77
|
+
color: cssVars.default['border-base'],
|
|
77
78
|
width: input.border.width,
|
|
78
79
|
})};
|
|
79
80
|
}
|
|
@@ -82,23 +83,35 @@ export function inputElementStyle(props: ThemeProps): ReturnType<typeof css> {
|
|
|
82
83
|
opacity: 1;
|
|
83
84
|
}
|
|
84
85
|
|
|
86
|
+
/* customValidity */
|
|
87
|
+
&[data-error] + span {
|
|
88
|
+
background-color: ${cssVars.critical['border-base']};
|
|
89
|
+
box-shadow: ${focusRingBorderStyle({
|
|
90
|
+
width: input.border.width,
|
|
91
|
+
color: cssVars.critical['text-secondary'],
|
|
92
|
+
})};
|
|
93
|
+
&::after {
|
|
94
|
+
background: ${cssVars.critical['text-secondary']};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
85
98
|
/* read only */
|
|
86
99
|
&[data-read-only] + span {
|
|
87
|
-
box-shadow: 0 0 0 1px ${
|
|
88
|
-
background: ${
|
|
100
|
+
box-shadow: 0 0 0 1px ${cssVars.default['border-base']};
|
|
101
|
+
background: ${cssVars.default['bg-tint']};
|
|
89
102
|
|
|
90
103
|
&::after {
|
|
91
|
-
background: ${
|
|
104
|
+
background: ${cssVars.default['border-base']};
|
|
92
105
|
}
|
|
93
106
|
}
|
|
94
107
|
|
|
95
108
|
/* disabled */
|
|
96
109
|
&:not([data-read-only]):disabled + span {
|
|
97
|
-
box-shadow: 0 0 0 1px ${
|
|
98
|
-
background: ${
|
|
110
|
+
box-shadow: 0 0 0 1px ${cssVars.default['border-base']};
|
|
111
|
+
background: ${cssVars.default['bg-tint']};
|
|
99
112
|
|
|
100
113
|
&::after {
|
|
101
|
-
background: ${
|
|
114
|
+
background: ${cssVars.default['border-base']};
|
|
102
115
|
}
|
|
103
116
|
}
|
|
104
117
|
`
|
|
@@ -2,6 +2,7 @@ import {SelectIcon} from '@sanity/icons'
|
|
|
2
2
|
import {forwardRef} from 'react'
|
|
3
3
|
import styled from 'styled-components'
|
|
4
4
|
import {useForwardedRef, useCustomValidity, useArrayProp} from '../../hooks'
|
|
5
|
+
import {Radius} from '../../types'
|
|
5
6
|
import {Box} from '../box'
|
|
6
7
|
import {Text} from '../text'
|
|
7
8
|
import {selectStyle} from './styles'
|
|
@@ -12,7 +13,7 @@ import {selectStyle} from './styles'
|
|
|
12
13
|
export interface SelectProps {
|
|
13
14
|
fontSize?: number | number[]
|
|
14
15
|
padding?: number | number[]
|
|
15
|
-
radius?:
|
|
16
|
+
radius?: Radius | Radius[]
|
|
16
17
|
space?: number | number[]
|
|
17
18
|
customValidity?: string
|
|
18
19
|
}
|
|
@@ -22,7 +23,7 @@ const Root = styled.div(selectStyle.root)
|
|
|
22
23
|
const Input = styled.select<{
|
|
23
24
|
$fontSize: number[]
|
|
24
25
|
$padding: number[]
|
|
25
|
-
$radius:
|
|
26
|
+
$radius: Radius[]
|
|
26
27
|
$space: number[]
|
|
27
28
|
}>(selectStyle.input)
|
|
28
29
|
|
|
@@ -8,12 +8,13 @@ import {
|
|
|
8
8
|
ResponsiveRadiusStyleProps,
|
|
9
9
|
} from '../../styles/internal'
|
|
10
10
|
import {ThemeFontSize} from '../../theme'
|
|
11
|
+
import {mutableCardVariables} from '../../theme/lib/theme/color/cssVariables/cardVariables'
|
|
12
|
+
import {cssVars} from '../../theme/lib/theme/color/cssVariables/createCssVars'
|
|
11
13
|
import {CSSObject} from '../../types/styled'
|
|
12
14
|
|
|
13
15
|
function rootStyle(): ReturnType<typeof css> {
|
|
14
16
|
return css`
|
|
15
17
|
position: relative;
|
|
16
|
-
width: -webkit-fill-available;
|
|
17
18
|
width: stretch;
|
|
18
19
|
|
|
19
20
|
&:not([hidden]) {
|
|
@@ -44,25 +45,25 @@ function inputBaseStyle(props: ThemeProps): ReturnType<typeof css> {
|
|
|
44
45
|
|
|
45
46
|
function inputColorStyle(props: ThemeProps) {
|
|
46
47
|
const {theme} = props
|
|
47
|
-
const {
|
|
48
|
-
const
|
|
48
|
+
const {input} = theme.sanity
|
|
49
|
+
const {focusRing} = input.select
|
|
49
50
|
|
|
50
51
|
return css`
|
|
51
52
|
/* enabled */
|
|
52
|
-
background-color: ${
|
|
53
|
-
color: ${
|
|
53
|
+
background-color: ${cssVars.default['bg-base']};
|
|
54
|
+
color: ${cssVars.default['text-primary']};
|
|
54
55
|
box-shadow: ${focusRingBorderStyle({
|
|
55
|
-
color:
|
|
56
|
+
color: cssVars.default['border-base'],
|
|
56
57
|
width: input.border.width,
|
|
57
58
|
})};
|
|
58
59
|
|
|
59
60
|
/* hovered */
|
|
60
61
|
@media (hover: hover) {
|
|
61
62
|
&:not(:disabled):hover {
|
|
62
|
-
background-color: ${
|
|
63
|
-
color: ${
|
|
63
|
+
background-color: ${cssVars.default['bg-base-hover']};
|
|
64
|
+
color: ${cssVars.default['text-primary']};
|
|
64
65
|
box-shadow: ${focusRingBorderStyle({
|
|
65
|
-
color:
|
|
66
|
+
color: cssVars.default['border-base-hover'],
|
|
66
67
|
width: input.border.width,
|
|
67
68
|
})};
|
|
68
69
|
}
|
|
@@ -71,27 +72,27 @@ function inputColorStyle(props: ThemeProps) {
|
|
|
71
72
|
/* focused */
|
|
72
73
|
&:not(:disabled):focus {
|
|
73
74
|
box-shadow: ${focusRingStyle({
|
|
74
|
-
border: {width: input.border.width, color:
|
|
75
|
+
border: {width: input.border.width, color: cssVars.default['border-base']},
|
|
75
76
|
focusRing,
|
|
76
77
|
})};
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
/* read-only */
|
|
80
81
|
&[data-read-only] {
|
|
81
|
-
background-color: ${
|
|
82
|
-
color: ${
|
|
82
|
+
background-color: ${cssVars.default['bg-tint']};
|
|
83
|
+
color: ${cssVars.default['text-primary']};
|
|
83
84
|
box-shadow: ${focusRingBorderStyle({
|
|
84
|
-
color:
|
|
85
|
+
color: cssVars.default['border-base'],
|
|
85
86
|
width: input.border.width,
|
|
86
87
|
})};
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
/* disabled */
|
|
90
91
|
&:not([data-read-only]):disabled {
|
|
91
|
-
background-color: ${
|
|
92
|
-
color: ${
|
|
92
|
+
background-color: ${cssVars.default['bg-tint']};
|
|
93
|
+
color: ${cssVars.default['text-primary']};
|
|
93
94
|
box-shadow: ${focusRingBorderStyle({
|
|
94
|
-
color:
|
|
95
|
+
color: cssVars.default['border-base'],
|
|
95
96
|
width: input.border.width,
|
|
96
97
|
})};
|
|
97
98
|
}
|
|
@@ -130,10 +131,7 @@ function inputStyle(): Array<
|
|
|
130
131
|
]
|
|
131
132
|
}
|
|
132
133
|
|
|
133
|
-
function iconBoxStyle(
|
|
134
|
-
const {theme} = props
|
|
135
|
-
const color = theme.sanity.color.input
|
|
136
|
-
|
|
134
|
+
function iconBoxStyle(): ReturnType<typeof css> {
|
|
137
135
|
return css`
|
|
138
136
|
pointer-events: none;
|
|
139
137
|
position: absolute;
|
|
@@ -141,23 +139,23 @@ function iconBoxStyle(props: ThemeProps): ReturnType<typeof css> {
|
|
|
141
139
|
right: 0;
|
|
142
140
|
|
|
143
141
|
/* enabled */
|
|
144
|
-
|
|
142
|
+
${mutableCardVariables['fg-color']}: ${cssVars.default['text-primary']};
|
|
145
143
|
|
|
146
144
|
/* hover */
|
|
147
145
|
@media (hover: hover) {
|
|
148
146
|
select:not(disabled):not(:read-only):hover + && {
|
|
149
|
-
|
|
147
|
+
${mutableCardVariables['fg-color']}: ${cssVars.default['text-primary']};
|
|
150
148
|
}
|
|
151
149
|
}
|
|
152
150
|
|
|
153
151
|
/* disabled */
|
|
154
152
|
select:disabled + && {
|
|
155
|
-
|
|
153
|
+
${mutableCardVariables['fg-color']}: ${cssVars.default['text-primary']};
|
|
156
154
|
}
|
|
157
155
|
|
|
158
156
|
/* read-only */
|
|
159
157
|
select[data-read-only] + && {
|
|
160
|
-
|
|
158
|
+
${mutableCardVariables['fg-color']}: ${cssVars.default['text-primary']};
|
|
161
159
|
}
|
|
162
160
|
`
|
|
163
161
|
}
|
|
@@ -8,8 +8,8 @@ export default function PropsStory() {
|
|
|
8
8
|
const indeterminate = useBoolean('Indeterminate', false)
|
|
9
9
|
const readOnly = useBoolean('Read only', false)
|
|
10
10
|
const theme = useTheme()
|
|
11
|
-
const focusRingOffset = useNumber('Focus ring offset', theme.sanity.focusRing.offset)
|
|
12
|
-
const focusRingWidth = useNumber('Focus ring width', theme.sanity.focusRing.width)
|
|
11
|
+
const focusRingOffset = useNumber('Focus ring offset', theme.sanity.input.switch.focusRing.offset)
|
|
12
|
+
const focusRingWidth = useNumber('Focus ring width', theme.sanity.input.switch.focusRing.width)
|
|
13
13
|
const handleChange = useCallback(() => undefined, [])
|
|
14
14
|
|
|
15
15
|
const customTheme = useMemo(
|
|
@@ -18,8 +18,8 @@ export default function PropsStory() {
|
|
|
18
18
|
sanity: {
|
|
19
19
|
...theme.sanity,
|
|
20
20
|
focusRing: {
|
|
21
|
-
offset: focusRingOffset || theme.sanity.focusRing.offset,
|
|
22
|
-
width: focusRingWidth || theme.sanity.focusRing.width,
|
|
21
|
+
offset: focusRingOffset || theme.sanity.input.switch.focusRing.offset,
|
|
22
|
+
width: focusRingWidth || theme.sanity.input.switch.focusRing.width,
|
|
23
23
|
},
|
|
24
24
|
},
|
|
25
25
|
}),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {css} from 'styled-components'
|
|
2
2
|
import {rem, ThemeProps} from '../../styles'
|
|
3
3
|
import {focusRingStyle} from '../../styles/internal'
|
|
4
|
+
import {cssVars} from '../../theme/lib/theme/color/cssVariables/createCssVars'
|
|
4
5
|
|
|
5
6
|
/* Root */
|
|
6
7
|
export function switchBaseStyles(): ReturnType<typeof css> {
|
|
@@ -36,12 +37,12 @@ export function switchInputStyles(): ReturnType<typeof css> {
|
|
|
36
37
|
/* Representation */
|
|
37
38
|
export function switchRepresentationStyles(props: ThemeProps): ReturnType<typeof css> {
|
|
38
39
|
const {theme} = props
|
|
39
|
-
const {
|
|
40
|
-
const
|
|
40
|
+
const {input} = theme.sanity
|
|
41
|
+
const {focusRing} = input.switch
|
|
41
42
|
|
|
42
43
|
return css`
|
|
43
|
-
--switch-bg-color: ${
|
|
44
|
-
--switch-fg-color: ${
|
|
44
|
+
--switch-bg-color: ${cssVars.default['border-base']};
|
|
45
|
+
--switch-fg-color: ${cssVars.default['bg-base']};
|
|
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: ${
|
|
82
|
+
--switch-bg-color: ${cssVars.positive['border-accent']};
|
|
83
|
+
--switch-fg-color: ${cssVars.positive['bg-base']};
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
@media (hover: hover) {
|
|
86
87
|
input:not(:disabled):hover + && {
|
|
87
|
-
--switch-bg-color: ${
|
|
88
|
-
--switch-fg-color: ${
|
|
88
|
+
--switch-bg-color: ${cssVars.default['border-base']};
|
|
89
|
+
--switch-fg-color: ${cssVars.default['bg-base']};
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
input:not(:disabled):checked:hover + && {
|
|
92
|
-
--switch-bg-color: ${
|
|
93
|
-
--switch-fg-color: ${
|
|
93
|
+
--switch-bg-color: ${cssVars.positive['border-accent']};
|
|
94
|
+
--switch-fg-color: ${cssVars.positive['bg-base']};
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
input:not([data-read-only]):disabled + && {
|
|
98
|
-
--switch-bg-color: ${
|
|
99
|
-
--switch-fg-color: ${
|
|
99
|
+
--switch-bg-color: ${cssVars.default['border-base']};
|
|
100
|
+
--switch-fg-color: ${cssVars.default['bg-tint']};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
input[data-read-only]:disabled + && {
|
|
104
|
+
--switch-bg-color: ${cssVars.default['border-base']};
|
|
105
|
+
--switch-fg-color: ${cssVars.default['bg-tint']};
|
|
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`
|