@sanity/ui 1.0.0-next.3 → 1.0.0
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/LICENSE +1 -1
- package/README.md +2 -2
- package/dist/{types/src/index.d.ts → index.d.ts} +4450 -4398
- package/dist/{sanity-ui.esm.js → index.esm.js} +888 -2678
- package/dist/index.esm.js.map +1 -0
- package/dist/{sanity-ui.js → index.js} +882 -2688
- package/dist/index.js.map +1 -0
- package/package.json +112 -23
- package/src/components/autocomplete/__workshop__/example.tsx +1 -1
- package/src/components/autocomplete/__workshop__/index.ts +36 -32
- package/src/components/autocomplete/autocomplete.styles.tsx +22 -28
- package/src/components/autocomplete/autocomplete.tsx +1 -2
- package/src/components/autocomplete/constants.ts +3 -8
- package/src/components/breadcrumbs/__workshop__/index.ts +11 -7
- package/src/components/breadcrumbs/breadcrumbs.styles.ts +13 -18
- package/src/components/dialog/__workshop__/index.ts +13 -9
- package/src/components/dialog/dialog.tsx +53 -67
- package/src/components/hotkeys/__workshop__/index.ts +11 -3
- package/src/components/hotkeys/hotkeys.tsx +12 -16
- package/src/components/menu/__workshop__/index.ts +71 -67
- package/src/components/menu/menu.tsx +5 -7
- package/src/components/menu/menuButton.tsx +16 -14
- package/src/components/menu/menuDivider.ts +8 -10
- package/src/components/skeleton/__workshop__/index.ts +8 -4
- package/src/components/skeleton/skeleton.tsx +4 -6
- package/src/components/skeleton/styles.ts +13 -9
- package/src/components/skeleton/textSkeleton.tsx +12 -14
- package/src/components/tab/__workshop__/index.ts +11 -3
- package/src/components/toast/__workshop__/index.ts +16 -4
- package/src/components/toast/toast.tsx +6 -11
- package/src/components/toast/toastProvider.tsx +18 -22
- package/src/components/tree/__workshop__/basic.perf.ts +1 -14
- package/src/components/tree/__workshop__/basic.tsx +1 -1
- package/src/components/tree/__workshop__/index.ts +12 -8
- package/src/components/tree/style.ts +78 -76
- package/src/components/tree/treeItem.tsx +7 -12
- package/src/hooks/useElementRect/__workshop__/index.ts +11 -3
- package/src/hooks/useMediaIndex/__workshop__/index.ts +11 -3
- package/src/primitives/_selectable/selectable.tsx +4 -7
- package/src/primitives/_selectable/style.ts +85 -82
- package/src/primitives/avatar/__workshop__/index.ts +16 -12
- package/src/primitives/avatar/avatar.tsx +9 -12
- package/src/primitives/avatar/avatarCounter.tsx +22 -24
- package/src/primitives/avatar/avatarStack.tsx +16 -14
- package/src/primitives/avatar/styles.ts +1 -1
- package/src/primitives/badge/__workshop__/index.ts +16 -12
- package/src/primitives/badge/__workshop__/tones.tsx +1 -1
- package/src/primitives/badge/badge.tsx +6 -5
- package/src/primitives/box/__workshop__/index.ts +16 -4
- package/src/primitives/box/box.tsx +21 -49
- package/src/primitives/button/__workshop__/index.ts +51 -47
- package/src/primitives/button/__workshop__/sanityUploadButton.tsx +19 -20
- package/src/primitives/button/__workshop__/styled1.tsx +6 -6
- package/src/primitives/button/button.tsx +20 -26
- package/src/primitives/button/styles.ts +30 -29
- package/src/primitives/card/__workshop__/index.ts +15 -11
- package/src/primitives/card/card.tsx +9 -25
- package/src/primitives/card/styles.ts +119 -114
- package/src/primitives/checkbox/__workshop__/index.ts +10 -6
- package/src/primitives/checkbox/checkbox.tsx +4 -4
- package/src/primitives/checkbox/styles.ts +71 -69
- package/src/primitives/code/__workshop__/index.ts +16 -12
- package/src/primitives/code/code.tsx +3 -5
- package/src/primitives/code/styles.ts +20 -18
- package/src/primitives/container/__workshop__/index.ts +5 -3
- package/src/primitives/container/container.tsx +5 -4
- package/src/primitives/flex/__workshop__/index.ts +8 -4
- package/src/primitives/flex/flex.tsx +7 -23
- package/src/primitives/grid/__workshop__/index.ts +7 -3
- package/src/primitives/grid/grid.tsx +4 -27
- package/src/primitives/heading/__workshop__/index.ts +16 -12
- package/src/primitives/heading/heading.tsx +10 -17
- package/src/primitives/heading/styles.ts +45 -36
- package/src/primitives/inline/__workshop__/index.ts +5 -3
- package/src/primitives/inline/inline.tsx +3 -5
- package/src/primitives/kbd/__workshop__/index.ts +5 -3
- package/src/primitives/kbd/kbd.tsx +12 -13
- package/src/primitives/label/__workshop__/index.ts +16 -12
- package/src/primitives/label/label.tsx +13 -18
- package/src/primitives/label/styles.ts +24 -18
- package/src/primitives/popover/__workshop__/PlainStory.tsx +0 -1
- package/src/primitives/popover/__workshop__/TestStory.tsx +0 -1
- package/src/primitives/popover/__workshop__/index.ts +36 -32
- package/src/primitives/popover/constants.ts +0 -3
- package/src/primitives/popover/floating-ui/size.ts +40 -25
- package/src/primitives/popover/popover.tsx +220 -196
- package/src/primitives/popover/popoverArrow.tsx +42 -48
- package/src/primitives/popover/popoverCard.tsx +12 -22
- package/src/primitives/radio/__workshop__/index.ts +8 -4
- package/src/primitives/radio/radio.tsx +3 -3
- package/src/primitives/radio/styles.ts +73 -73
- package/src/primitives/select/__workshop__/index.ts +8 -4
- package/src/primitives/select/select.tsx +9 -11
- package/src/primitives/select/styles.ts +77 -77
- package/src/primitives/spinner/__workshop__/index.ts +11 -7
- package/src/primitives/spinner/spinner.tsx +2 -5
- package/src/primitives/stack/__workshop__/index.ts +11 -7
- package/src/primitives/stack/stack.tsx +3 -5
- package/src/primitives/switch/__workshop__/index.ts +8 -4
- package/src/primitives/switch/styles.ts +119 -112
- package/src/primitives/switch/switch.tsx +6 -6
- package/src/primitives/text/__workshop__/index.ts +21 -17
- package/src/primitives/text/styles.ts +51 -45
- package/src/primitives/text/text.tsx +11 -16
- package/src/primitives/textArea/__workshop__/index.ts +11 -7
- package/src/primitives/textArea/textArea.tsx +15 -22
- package/src/primitives/textInput/__workshop__/index.ts +46 -42
- package/src/primitives/textInput/__workshop__/plain.tsx +2 -1
- package/src/primitives/textInput/textInput.tsx +49 -69
- package/src/primitives/tooltip/__workshop__/index.ts +11 -7
- package/src/primitives/tooltip/tooltip.tsx +3 -6
- package/src/primitives/tooltip/tooltipArrow.tsx +69 -59
- package/src/styles/border/borderStyle.ts +10 -18
- package/src/styles/box/boxStyle.ts +14 -18
- package/src/styles/flex/flexItemStyle.ts +7 -1
- package/src/styles/flex/flexStyle.ts +14 -9
- package/src/styles/grid/gridItemStyle.ts +18 -30
- package/src/styles/grid/gridStyle.ts +25 -33
- package/src/styles/helpers.ts +2 -2
- package/src/styles/index.ts +0 -1
- package/src/styles/input/textInputStyle.ts +127 -123
- package/src/styles/margin/marginStyle.ts +11 -10
- package/src/styles/margin/marginsStyle.test.ts +12 -10
- package/src/styles/padding/paddingStyle.test.ts +12 -10
- package/src/styles/padding/paddingStyle.ts +9 -10
- package/src/theme/__workshop__/index.ts +26 -22
- package/src/theme/{ThemeContext.ts → themeContext.ts} +0 -0
- package/src/utils/boundaryElement/__workshop__/index.ts +11 -7
- package/src/utils/elementQuery/__workshop__/index.ts +11 -7
- package/src/utils/layer/__workshop__/index.ts +21 -17
- package/src/utils/layer/layer.tsx +4 -6
- package/src/utils/portal/__workshop__/index.ts +11 -7
- package/src/utils/srOnly/srOnly.tsx +8 -10
- package/src/utils/virtualList/__workshop__/index.ts +26 -22
- package/src/utils/virtualList/virtualList.tsx +10 -14
- package/dist/sanity-ui.esm.js.map +0 -1
- package/dist/sanity-ui.js.map +0 -1
- package/src/__workshop__/color/overview.tsx +0 -101
- package/src/__workshop__/index.ts +0 -10
- package/src/icons/__workshop__/.eslintrc +0 -5
- package/src/icons/__workshop__/index.tsx +0 -6
- package/src/icons/__workshop__/overview.tsx +0 -76
- package/src/styles/compose.ts +0 -35
- package/src/utils/srOnly/__workshop__/.eslintrc +0 -5
|
@@ -1,145 +1,150 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {css, FlattenSimpleInterpolation} from 'styled-components'
|
|
2
2
|
import {ThemeProps} from '../../styles'
|
|
3
3
|
import {_colorVarsStyle} from '../../styles/colorVars'
|
|
4
4
|
import {focusRingBorderStyle, focusRingStyle} from '../../styles/focusRing'
|
|
5
5
|
import {CardStyleProps} from './types'
|
|
6
6
|
|
|
7
|
-
export function
|
|
7
|
+
export function cardStyle(
|
|
8
|
+
props: CardStyleProps & ThemeProps
|
|
9
|
+
): Array<FlattenSimpleInterpolation | (() => FlattenSimpleInterpolation)> {
|
|
10
|
+
return [cardBaseStyle(props), cardColorStyle(props)]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function cardBaseStyle(props: CardStyleProps & ThemeProps): FlattenSimpleInterpolation {
|
|
8
14
|
const {$checkered, theme} = props
|
|
9
15
|
const space = theme.sanity.space
|
|
10
16
|
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
},
|
|
17
|
+
return css`
|
|
18
|
+
${$checkered &&
|
|
19
|
+
css`
|
|
20
|
+
background-size: ${space[3]}px ${space[3]}px;
|
|
21
|
+
background-position: 50% 50%;
|
|
22
|
+
background-image: var(--card-bg-image);
|
|
23
|
+
`}
|
|
24
|
+
|
|
25
|
+
&[data-as='button'] {
|
|
26
|
+
-webkit-font-smoothing: inherit;
|
|
27
|
+
appearance: none;
|
|
28
|
+
outline: none;
|
|
29
|
+
font: inherit;
|
|
30
|
+
text-align: inherit;
|
|
31
|
+
border: 0;
|
|
32
|
+
width: stretch;
|
|
33
|
+
}
|
|
29
34
|
|
|
30
35
|
/* &:is(a) */
|
|
31
|
-
|
|
32
|
-
outline:
|
|
33
|
-
|
|
34
|
-
}
|
|
36
|
+
&[data-as='a'] {
|
|
37
|
+
outline: none;
|
|
38
|
+
text-decoration: none;
|
|
39
|
+
}
|
|
35
40
|
|
|
36
41
|
/* &:is(pre) */
|
|
37
|
-
|
|
38
|
-
font:
|
|
39
|
-
}
|
|
40
|
-
|
|
42
|
+
&[data-as='pre'] {
|
|
43
|
+
font: inherit;
|
|
44
|
+
}
|
|
45
|
+
`
|
|
41
46
|
}
|
|
42
47
|
|
|
43
|
-
export function cardColorStyle(props: CardStyleProps & ThemeProps):
|
|
48
|
+
export function cardColorStyle(props: CardStyleProps & ThemeProps): FlattenSimpleInterpolation {
|
|
44
49
|
const {$checkered, $focusRing, theme} = props
|
|
45
50
|
const {focusRing} = theme.sanity
|
|
46
51
|
const {base, card, dark} = theme.sanity.color
|
|
47
52
|
const border = {width: 0, color: 'var(--card-border-color)'}
|
|
48
53
|
|
|
49
|
-
return
|
|
50
|
-
|
|
54
|
+
return css`
|
|
55
|
+
color-scheme: ${dark ? 'dark' : 'light'};
|
|
51
56
|
|
|
52
|
-
|
|
57
|
+
${_colorVarsStyle(base, card.enabled, $checkered)}
|
|
53
58
|
|
|
54
|
-
|
|
55
|
-
color:
|
|
59
|
+
background-color: var(--card-bg-color);
|
|
60
|
+
color: var(--card-fg-color);
|
|
56
61
|
|
|
57
62
|
/* &:is(button) */
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
cursor:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
63
|
+
&[data-as='button'] {
|
|
64
|
+
--card-focus-ring-box-shadow: none;
|
|
65
|
+
|
|
66
|
+
cursor: default;
|
|
67
|
+
box-shadow: var(--card-focus-ring-box-shadow);
|
|
68
|
+
|
|
69
|
+
&:disabled {
|
|
70
|
+
${_colorVarsStyle(base, card.disabled, $checkered)}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&:not(:disabled) {
|
|
74
|
+
&[data-pressed] {
|
|
75
|
+
${_colorVarsStyle(base, card.pressed, $checkered)}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&[data-selected] {
|
|
79
|
+
${_colorVarsStyle(base, card.selected, $checkered)}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@media (hover: hover) {
|
|
83
|
+
&:not([data-pressed]):not([data-selected]) {
|
|
84
|
+
&:hover {
|
|
85
|
+
${_colorVarsStyle(base, card.hovered, $checkered)}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
&:active {
|
|
89
|
+
${_colorVarsStyle(base, card.pressed, $checkered)}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
&:focus {
|
|
95
|
+
--card-focus-ring-box-shadow: ${$focusRing
|
|
91
96
|
? focusRingStyle({base, border, focusRing})
|
|
92
|
-
: undefined
|
|
93
|
-
}
|
|
97
|
+
: undefined};
|
|
98
|
+
}
|
|
94
99
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
+
&:focus:not(:focus-visible) {
|
|
101
|
+
--card-focus-ring-box-shadow: ${$focusRing ? focusRingBorderStyle(border) : undefined};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
100
105
|
|
|
101
106
|
/* &:is(a) */
|
|
102
|
-
|
|
103
|
-
cursor:
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
107
|
+
&[data-as='a'] {
|
|
108
|
+
cursor: pointer;
|
|
109
|
+
box-shadow: var(--card-focus-ring-box-shadow);
|
|
110
|
+
|
|
111
|
+
&[data-disabled] {
|
|
112
|
+
${_colorVarsStyle(base, card.disabled, $checkered)}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&:not([data-disabled]) {
|
|
116
|
+
&[data-pressed] {
|
|
117
|
+
${_colorVarsStyle(base, card.pressed, $checkered)}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
&[data-selected] {
|
|
121
|
+
${_colorVarsStyle(base, card.selected, $checkered)}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@media (hover: hover) {
|
|
125
|
+
&:not([data-pressed]):not([data-selected]) {
|
|
126
|
+
&:hover {
|
|
127
|
+
${_colorVarsStyle(base, card.hovered, $checkered)}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
&:active {
|
|
131
|
+
${_colorVarsStyle(base, card.pressed, $checkered)}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
&:focus {
|
|
137
|
+
--card-focus-ring-box-shadow: ${$focusRing
|
|
133
138
|
? focusRingStyle({base, border, focusRing})
|
|
134
|
-
: undefined
|
|
135
|
-
}
|
|
139
|
+
: undefined};
|
|
140
|
+
}
|
|
136
141
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
+
&:focus:not(:focus-visible) {
|
|
143
|
+
--card-focus-ring-box-shadow: ${$focusRing ? focusRingBorderStyle(border) : undefined};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
142
147
|
|
|
143
|
-
|
|
144
|
-
|
|
148
|
+
${theme.sanity.styles?.card?.root}
|
|
149
|
+
`
|
|
145
150
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import {defineScope} from '@sanity/ui-workshop'
|
|
2
2
|
import {lazy} from 'react'
|
|
3
3
|
|
|
4
|
-
export default defineScope(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'primitives/checkbox',
|
|
6
|
+
title: 'Checkbox',
|
|
7
|
+
stories: [
|
|
8
|
+
{name: 'props', title: 'Props', component: lazy(() => import('./props'))},
|
|
9
|
+
{name: 'example', title: 'Example', component: lazy(() => import('./example'))},
|
|
10
|
+
{name: 'read-only', title: 'Read-only', component: lazy(() => import('./readOnly'))},
|
|
11
|
+
{name: 'multiple-tones', title: 'Multiple tones', component: lazy(() => import('./tones'))},
|
|
12
|
+
],
|
|
13
|
+
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {CheckmarkIcon, RemoveIcon} from '@sanity/icons'
|
|
2
|
-
import {forwardRef,
|
|
2
|
+
import {forwardRef, useEffect} from 'react'
|
|
3
|
+
import styled from 'styled-components'
|
|
3
4
|
import {useForwardedRef, useCustomValidity} from '../../hooks'
|
|
4
|
-
import {compose} from '../../styles'
|
|
5
5
|
import {checkboxBaseStyles, inputElementStyles} from './styles'
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -12,8 +12,8 @@ export interface CheckboxProps {
|
|
|
12
12
|
customValidity?: string
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
const Root =
|
|
16
|
-
const Input =
|
|
15
|
+
const Root = styled.div(checkboxBaseStyles)
|
|
16
|
+
const Input = styled.input(inputElementStyles)
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* @public
|
|
@@ -1,95 +1,97 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {css, FlattenSimpleInterpolation} from 'styled-components'
|
|
2
|
+
import {rem, ThemeProps} from '../../styles'
|
|
3
3
|
import {focusRingBorderStyle, focusRingStyle} from '../../styles/internal'
|
|
4
4
|
|
|
5
|
-
export function checkboxBaseStyles():
|
|
6
|
-
return
|
|
7
|
-
position:
|
|
8
|
-
display:
|
|
9
|
-
|
|
5
|
+
export function checkboxBaseStyles(): FlattenSimpleInterpolation {
|
|
6
|
+
return css`
|
|
7
|
+
position: relative;
|
|
8
|
+
display: inline-block;
|
|
9
|
+
`
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export function inputElementStyles(props: ThemeProps):
|
|
12
|
+
export function inputElementStyles(props: ThemeProps): FlattenSimpleInterpolation {
|
|
13
13
|
const {theme} = props
|
|
14
14
|
const color = theme.sanity.color.input
|
|
15
15
|
const {focusRing, input, radius} = theme.sanity
|
|
16
16
|
|
|
17
|
-
return
|
|
18
|
-
position:
|
|
19
|
-
top: 0
|
|
20
|
-
left: 0
|
|
21
|
-
width:
|
|
22
|
-
height:
|
|
23
|
-
outline:
|
|
24
|
-
opacity: 0
|
|
25
|
-
|
|
26
|
-
padding: 0
|
|
27
|
-
margin: 0
|
|
17
|
+
return css`
|
|
18
|
+
position: absolute;
|
|
19
|
+
top: 0;
|
|
20
|
+
left: 0;
|
|
21
|
+
width: 100%;
|
|
22
|
+
height: 100%;
|
|
23
|
+
outline: none;
|
|
24
|
+
opacity: 0;
|
|
25
|
+
z-index: 1;
|
|
26
|
+
padding: 0;
|
|
27
|
+
margin: 0;
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
position:
|
|
31
|
-
display:
|
|
32
|
-
height: rem(input.checkbox.size)
|
|
33
|
-
width: rem(input.checkbox.size)
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
& + span {
|
|
30
|
+
position: relative;
|
|
31
|
+
display: block;
|
|
32
|
+
height: ${rem(input.checkbox.size)};
|
|
33
|
+
width: ${rem(input.checkbox.size)};
|
|
34
|
+
box-sizing: border-box;
|
|
35
|
+
box-shadow: ${focusRingBorderStyle({
|
|
36
36
|
color: color.default.enabled.border,
|
|
37
37
|
width: input.border.width,
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
'& > svg': {
|
|
43
|
-
display: 'block',
|
|
44
|
-
position: 'absolute',
|
|
45
|
-
opacity: 0,
|
|
46
|
-
height: '100%',
|
|
47
|
-
width: '100%',
|
|
48
|
-
'& > path': {
|
|
49
|
-
vectorEffect: 'non-scaling-stroke',
|
|
50
|
-
strokeWidth: '2 !important',
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
},
|
|
38
|
+
})};
|
|
39
|
+
border-radius: ${rem(radius[2])};
|
|
40
|
+
line-height: 1;
|
|
41
|
+
background-color: ${color.default.enabled.bg};
|
|
54
42
|
|
|
55
|
-
|
|
56
|
-
|
|
43
|
+
& > svg {
|
|
44
|
+
display: block;
|
|
45
|
+
position: absolute;
|
|
46
|
+
opacity: 0;
|
|
47
|
+
height: 100%;
|
|
48
|
+
width: 100%;
|
|
49
|
+
|
|
50
|
+
& > path {
|
|
51
|
+
vector-effect: non-scaling-stroke;
|
|
52
|
+
stroke-width: 2 !important;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&:not(:disabled):focus + span {
|
|
58
|
+
box-shadow: ${focusRingStyle({
|
|
57
59
|
border: {width: input.border.width, color: color.default.enabled.border},
|
|
58
60
|
focusRing,
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
+
})};
|
|
62
|
+
}
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
&:not(:disabled):focus:not(:focus-visible) + span {
|
|
65
|
+
box-shadow: ${focusRingBorderStyle({
|
|
64
66
|
color: color.default.enabled.border,
|
|
65
67
|
width: input.border.width,
|
|
66
|
-
})
|
|
67
|
-
}
|
|
68
|
+
})};
|
|
69
|
+
}
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
opacity: 1
|
|
71
|
-
}
|
|
71
|
+
&:checked + span > svg:first-child {
|
|
72
|
+
opacity: 1;
|
|
73
|
+
}
|
|
72
74
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
&[data-read-only] + span {
|
|
76
|
+
background-color: ${color.default.readOnly.bg};
|
|
77
|
+
box-shadow: ${focusRingBorderStyle({
|
|
76
78
|
width: input.border.width,
|
|
77
79
|
color: color.default.readOnly.border,
|
|
78
|
-
})
|
|
79
|
-
color: color.default.readOnly.fg
|
|
80
|
-
}
|
|
80
|
+
})};
|
|
81
|
+
color: ${color.default.readOnly.fg};
|
|
82
|
+
}
|
|
81
83
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
&:not([data-read-only]):disabled + span {
|
|
85
|
+
background-color: ${color.default.disabled.bg};
|
|
86
|
+
box-shadow: ${focusRingBorderStyle({
|
|
85
87
|
width: input.border.width,
|
|
86
88
|
color: color.default.disabled.border,
|
|
87
|
-
})
|
|
88
|
-
color: color.default.disabled.fg
|
|
89
|
-
}
|
|
89
|
+
})};
|
|
90
|
+
color: ${color.default.disabled.fg};
|
|
91
|
+
}
|
|
90
92
|
|
|
91
|
-
|
|
92
|
-
opacity: 1
|
|
93
|
-
}
|
|
94
|
-
|
|
93
|
+
&:indeterminate + span > svg:last-child {
|
|
94
|
+
opacity: 1;
|
|
95
|
+
}
|
|
96
|
+
`
|
|
95
97
|
}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import {defineScope} from '@sanity/ui-workshop'
|
|
2
2
|
import {lazy} from 'react'
|
|
3
3
|
|
|
4
|
-
export default defineScope(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'primitives/code',
|
|
6
|
+
title: 'Code',
|
|
7
|
+
stories: [
|
|
8
|
+
{
|
|
9
|
+
name: 'props',
|
|
10
|
+
title: 'Props',
|
|
11
|
+
component: lazy(() => import('./props')),
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'optical-alignment',
|
|
15
|
+
title: 'Optical alignment',
|
|
16
|
+
component: lazy(() => import('./opticalAlignment')),
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {forwardRef
|
|
1
|
+
import {forwardRef} from 'react'
|
|
2
2
|
import Refractor from 'react-refractor'
|
|
3
|
+
import styled from 'styled-components'
|
|
3
4
|
import {useArrayProp} from '../../hooks'
|
|
4
|
-
import {compose} from '../../styles'
|
|
5
5
|
import {responsiveCodeFontStyle, ResponsiveFontStyleProps} from '../../styles/internal'
|
|
6
6
|
import {codeBaseStyle} from './styles'
|
|
7
7
|
|
|
@@ -15,9 +15,7 @@ export interface CodeProps {
|
|
|
15
15
|
weight?: string
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const Root =
|
|
19
|
-
compose<ResponsiveFontStyleProps>('pre', [codeBaseStyle, responsiveCodeFontStyle])
|
|
20
|
-
)
|
|
18
|
+
const Root = styled.pre<ResponsiveFontStyleProps>(codeBaseStyle, responsiveCodeFontStyle)
|
|
21
19
|
|
|
22
20
|
/**
|
|
23
21
|
* @public
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {css, FlattenInterpolation, ThemeProps as StyledThemeProps} from 'styled-components'
|
|
2
2
|
import {ThemeProps} from '../../styles'
|
|
3
3
|
import {Theme} from '../../theme'
|
|
4
4
|
|
|
5
|
-
function codeSyntaxHighlightingStyle({theme}: ThemeProps)
|
|
5
|
+
function codeSyntaxHighlightingStyle({theme}: ThemeProps) {
|
|
6
6
|
const color = theme.sanity.color.syntax
|
|
7
7
|
|
|
8
8
|
return {
|
|
@@ -45,24 +45,26 @@ function codeSyntaxHighlightingStyle({theme}: ThemeProps): CSSObject {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export function codeBaseStyle(
|
|
49
|
-
return
|
|
50
|
-
color:
|
|
48
|
+
export function codeBaseStyle(): FlattenInterpolation<StyledThemeProps<Theme>> {
|
|
49
|
+
return css`
|
|
50
|
+
color: var(--card-code-fg-color);
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
& code {
|
|
53
|
+
font-family: inherit;
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
&.refractor .token {
|
|
56
|
+
${codeSyntaxHighlightingStyle}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
color:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
60
|
+
& a {
|
|
61
|
+
color: inherit;
|
|
62
|
+
text-decoration: underline;
|
|
63
|
+
border-radius: 1px;
|
|
64
|
+
}
|
|
63
65
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
66
|
+
& [data-sanity-icon] {
|
|
67
|
+
vertical-align: baseline;
|
|
68
|
+
}
|
|
69
|
+
`
|
|
68
70
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {defineScope} from '@sanity/ui-workshop'
|
|
2
2
|
import {lazy} from 'react'
|
|
3
3
|
|
|
4
|
-
export default defineScope(
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'primitives/container',
|
|
6
|
+
title: 'Container',
|
|
7
|
+
stories: [{name: 'plain', title: 'Plain', component: lazy(() => import('./example'))}],
|
|
8
|
+
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {forwardRef
|
|
1
|
+
import {forwardRef} from 'react'
|
|
2
|
+
import styled from 'styled-components'
|
|
2
3
|
import {useArrayProp} from '../../hooks'
|
|
3
|
-
import {compose} from '../../styles'
|
|
4
4
|
import {Box, BoxProps} from '../box'
|
|
5
5
|
import {ResponsiveWidthProps} from '../types'
|
|
6
6
|
import {containerBaseStyle, responsiveContainerWidthStyle} from './styles'
|
|
@@ -11,8 +11,9 @@ import {ResponsiveWidthStyleProps} from './types'
|
|
|
11
11
|
*/
|
|
12
12
|
export interface ContainerProps extends BoxProps, ResponsiveWidthProps {}
|
|
13
13
|
|
|
14
|
-
const Root =
|
|
15
|
-
|
|
14
|
+
const Root = styled(Box)<ResponsiveWidthStyleProps>(
|
|
15
|
+
containerBaseStyle,
|
|
16
|
+
responsiveContainerWidthStyle
|
|
16
17
|
)
|
|
17
18
|
|
|
18
19
|
/**
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import {defineScope} from '@sanity/ui-workshop'
|
|
2
2
|
import {lazy} from 'react'
|
|
3
3
|
|
|
4
|
-
export default defineScope(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'primitives/flex',
|
|
6
|
+
title: 'Flex',
|
|
7
|
+
stories: [
|
|
8
|
+
{name: 'plain', title: 'Plain', component: lazy(() => import('./example'))},
|
|
9
|
+
{name: 'gap', title: 'Gap', component: lazy(() => import('./gap'))},
|
|
10
|
+
],
|
|
11
|
+
})
|