@sanity/ui 1.0.0-next.3 → 1.0.1
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} +889 -2678
- package/dist/index.esm.js.map +1 -0
- package/dist/{sanity-ui.js → index.js} +883 -2688
- package/dist/index.js.map +1 -0
- package/package.json +114 -23
- package/src/components/autocomplete/__workshop__/constrainedHeight.tsx +2 -2
- 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/global.ts +6 -0
- 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 +50 -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,4 +1,4 @@
|
|
|
1
|
-
import {CSSObject} from 'styled-components'
|
|
1
|
+
import {css, CSSObject, FlattenSimpleInterpolation} from 'styled-components'
|
|
2
2
|
import {ThemeColorSchemeKey, ThemeFontWeightKey} from '../../theme'
|
|
3
3
|
import {CardTone} from '../../types'
|
|
4
4
|
import {focusRingBorderStyle, focusRingStyle} from '../focusRing'
|
|
@@ -25,86 +25,90 @@ export interface TextInputRepresentationStyleProps {
|
|
|
25
25
|
$tone: CardTone
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
const ROOT_STYLE
|
|
29
|
-
|
|
30
|
-
display:
|
|
31
|
-
}
|
|
28
|
+
const ROOT_STYLE = css`
|
|
29
|
+
&:not([hidden]) {
|
|
30
|
+
display: flex;
|
|
31
|
+
}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
align-items: center;
|
|
34
|
+
`
|
|
35
35
|
|
|
36
|
-
export function textInputRootStyle():
|
|
36
|
+
export function textInputRootStyle(): FlattenSimpleInterpolation {
|
|
37
37
|
return ROOT_STYLE
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export function textInputBaseStyle(
|
|
40
|
+
export function textInputBaseStyle(
|
|
41
|
+
props: TextInputInputStyleProps & ThemeProps
|
|
42
|
+
): FlattenSimpleInterpolation {
|
|
41
43
|
const {theme, $scheme, $tone, $weight} = props
|
|
42
44
|
const font = theme.sanity.fonts.text
|
|
43
45
|
const color = theme.sanity.color.input
|
|
44
46
|
|
|
45
|
-
return
|
|
46
|
-
appearance:
|
|
47
|
-
background:
|
|
48
|
-
border: 0
|
|
49
|
-
|
|
50
|
-
outline:
|
|
51
|
-
width:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
margin: 0
|
|
56
|
-
position:
|
|
57
|
-
|
|
58
|
-
display:
|
|
47
|
+
return css`
|
|
48
|
+
appearance: none;
|
|
49
|
+
background: none;
|
|
50
|
+
border: 0;
|
|
51
|
+
border-radius: 0;
|
|
52
|
+
outline: none;
|
|
53
|
+
width: 100%;
|
|
54
|
+
box-sizing: border-box;
|
|
55
|
+
font-family: ${font.family};
|
|
56
|
+
font-weight: ${($weight && font.weights[$weight]) || font.weights.regular};
|
|
57
|
+
margin: 0;
|
|
58
|
+
position: relative;
|
|
59
|
+
z-index: 1;
|
|
60
|
+
display: block;
|
|
59
61
|
|
|
60
62
|
/* NOTE: This is a hack to disable Chrome’s autofill styles */
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
&:-webkit-autofill,
|
|
64
|
+
&:-webkit-autofill:hover,
|
|
65
|
+
&:-webkit-autofill:focus,
|
|
66
|
+
&:-webkit-autofill:active {
|
|
67
|
+
-webkit-text-fill-color: var(--input-fg-color) !important;
|
|
68
|
+
transition: background-color 5000s;
|
|
69
|
+
transition-delay: 86400s /* 24h */;
|
|
70
|
+
}
|
|
67
71
|
|
|
68
72
|
/* &:is(textarea) */
|
|
69
|
-
|
|
70
|
-
resize:
|
|
71
|
-
}
|
|
73
|
+
&[data-as='textarea'] {
|
|
74
|
+
resize: none;
|
|
75
|
+
}
|
|
72
76
|
|
|
73
|
-
color:
|
|
77
|
+
color: var(--input-fg-color);
|
|
74
78
|
|
|
75
|
-
|
|
76
|
-
color:
|
|
77
|
-
}
|
|
79
|
+
&::placeholder {
|
|
80
|
+
color: var(--input-placeholder-color);
|
|
81
|
+
}
|
|
78
82
|
|
|
79
|
-
[
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
&[data-scheme='${$scheme}'][data-tone='${$tone}'] {
|
|
84
|
+
--input-fg-color: ${color.default.enabled.fg};
|
|
85
|
+
--input-placeholder-color: ${color.default.enabled.placeholder};
|
|
82
86
|
|
|
83
87
|
/* enabled */
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
+
&:not(:invalid):not(:disabled):not(:read-only) {
|
|
89
|
+
--input-fg-color: ${color.default.enabled.fg};
|
|
90
|
+
--input-placeholder-color: ${color.default.enabled.placeholder};
|
|
91
|
+
}
|
|
88
92
|
|
|
89
93
|
/* disabled */
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
+
&:not(:invalid):disabled {
|
|
95
|
+
--input-fg-color: ${color.default.disabled.fg};
|
|
96
|
+
--input-placeholder-color: ${color.default.disabled.placeholder};
|
|
97
|
+
}
|
|
94
98
|
|
|
95
99
|
/* invalid */
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
+
&:invalid {
|
|
101
|
+
--input-fg-color: ${color.invalid.enabled.fg};
|
|
102
|
+
--input-placeholder-color: ${color.invalid.enabled.placeholder};
|
|
103
|
+
}
|
|
100
104
|
|
|
101
105
|
/* readOnly */
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
106
|
+
&:read-only {
|
|
107
|
+
--input-fg-color: ${color.default.readOnly.fg};
|
|
108
|
+
--input-placeholder-color: ${color.default.readOnly.placeholder};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
`
|
|
108
112
|
}
|
|
109
113
|
|
|
110
114
|
export function textInputFontSizeStyle(props: TextInputInputStyleProps & ThemeProps): CSSObject[] {
|
|
@@ -123,103 +127,103 @@ export function textInputFontSizeStyle(props: TextInputInputStyleProps & ThemePr
|
|
|
123
127
|
|
|
124
128
|
export function textInputRepresentationStyle(
|
|
125
129
|
props: TextInputRepresentationStyleProps & ThemeProps
|
|
126
|
-
):
|
|
130
|
+
): FlattenSimpleInterpolation {
|
|
127
131
|
const {$hasPrefix, $hasSuffix, $scheme, $tone, theme} = props
|
|
128
132
|
const {focusRing, input} = theme.sanity
|
|
129
133
|
const color = theme.sanity.color.input
|
|
130
134
|
|
|
131
|
-
return
|
|
132
|
-
|
|
135
|
+
return css`
|
|
136
|
+
--input-box-shadow: none;
|
|
133
137
|
|
|
134
|
-
position:
|
|
135
|
-
top: 0
|
|
136
|
-
left: 0
|
|
137
|
-
right: 0
|
|
138
|
-
bottom: 0
|
|
139
|
-
display:
|
|
140
|
-
|
|
141
|
-
|
|
138
|
+
position: absolute;
|
|
139
|
+
top: 0;
|
|
140
|
+
left: 0;
|
|
141
|
+
right: 0;
|
|
142
|
+
bottom: 0;
|
|
143
|
+
display: block;
|
|
144
|
+
pointer-events: none;
|
|
145
|
+
z-index: 0;
|
|
142
146
|
|
|
143
|
-
|
|
144
|
-
|
|
147
|
+
background-color: var(--card-bg-color);
|
|
148
|
+
box-shadow: var(--input-box-shadow);
|
|
145
149
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
+
border-top-left-radius: ${$hasPrefix ? 0 : undefined};
|
|
151
|
+
border-bottom-left-radius: ${$hasPrefix ? 0 : undefined};
|
|
152
|
+
border-top-right-radius: ${$hasSuffix ? 0 : undefined};
|
|
153
|
+
border-bottom-right-radius: ${$hasSuffix ? 0 : undefined};
|
|
150
154
|
|
|
151
|
-
[
|
|
152
|
-
|
|
153
|
-
|
|
155
|
+
&[data-scheme='${$scheme}'][data-tone='${$tone}'] {
|
|
156
|
+
--card-bg-color: ${color.default.enabled.bg};
|
|
157
|
+
--card-fg-color: ${color.default.enabled.fg};
|
|
154
158
|
|
|
155
159
|
/* enabled */
|
|
156
|
-
|
|
157
|
-
|
|
160
|
+
*:not(:disabled) + &[data-border] {
|
|
161
|
+
--input-box-shadow: ${focusRingBorderStyle({
|
|
158
162
|
color: color.default.enabled.border,
|
|
159
163
|
width: input.border.width,
|
|
160
|
-
})
|
|
161
|
-
}
|
|
164
|
+
})};
|
|
165
|
+
}
|
|
162
166
|
|
|
163
167
|
/* invalid */
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
168
|
+
*:not(:disabled):invalid + & {
|
|
169
|
+
--card-bg-color: ${color.invalid.enabled.bg};
|
|
170
|
+
--card-fg-color: ${color.invalid.enabled.fg};
|
|
167
171
|
|
|
168
|
-
|
|
169
|
-
|
|
172
|
+
&[data-border] {
|
|
173
|
+
--input-box-shadow: ${focusRingBorderStyle({
|
|
170
174
|
color: color.invalid.enabled.border,
|
|
171
175
|
width: input.border.width,
|
|
172
|
-
})
|
|
173
|
-
}
|
|
174
|
-
}
|
|
176
|
+
})};
|
|
177
|
+
}
|
|
178
|
+
}
|
|
175
179
|
|
|
176
180
|
/* focused */
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
181
|
+
*:not(:disabled):focus + & {
|
|
182
|
+
&[data-border] {
|
|
183
|
+
--input-box-shadow: ${focusRingStyle({
|
|
180
184
|
border: {color: color.default.enabled.border, width: input.border.width},
|
|
181
185
|
focusRing,
|
|
182
|
-
})
|
|
183
|
-
}
|
|
186
|
+
})};
|
|
187
|
+
}
|
|
184
188
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
+
&:not([data-border]) {
|
|
190
|
+
--input-box-shadow: ${focusRingStyle({focusRing})};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
189
193
|
|
|
190
194
|
/* disabled */
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
195
|
+
*:disabled + & {
|
|
196
|
+
--card-bg-color: ${color.default.disabled.bg} !important;
|
|
197
|
+
--card-fg-color: ${color.default.disabled.fg} !important;
|
|
194
198
|
|
|
195
|
-
|
|
196
|
-
|
|
199
|
+
&[data-border] {
|
|
200
|
+
--input-box-shadow: ${focusRingBorderStyle({
|
|
197
201
|
color: color.default.disabled.border,
|
|
198
202
|
width: input.border.width,
|
|
199
|
-
})
|
|
200
|
-
}
|
|
201
|
-
}
|
|
203
|
+
})};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
202
206
|
|
|
203
207
|
/* readOnly */
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
+
*:read-only + & {
|
|
209
|
+
--card-bg-color: ${color.default.readOnly.bg} !important;
|
|
210
|
+
--card-fg-color: ${color.default.readOnly.fg} !important;
|
|
211
|
+
}
|
|
208
212
|
|
|
209
213
|
/* hovered */
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
214
|
+
@media (hover: hover) {
|
|
215
|
+
*:not(:disabled):not(:read-only):not(:invalid):hover + & {
|
|
216
|
+
--card-bg-color: ${color.default.hovered.bg};
|
|
217
|
+
--card-fg-color: ${color.default.hovered.fg};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
*:not(:disabled):not(:read-only):not(:invalid):not(:focus):hover + &[data-border] {
|
|
221
|
+
--input-box-shadow: ${focusRingBorderStyle({
|
|
218
222
|
color: color.default.hovered.border,
|
|
219
223
|
width: input.border.width,
|
|
220
|
-
})
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
224
|
+
})};
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
`
|
|
225
229
|
}
|
|
@@ -3,17 +3,18 @@ import {_getResponsiveSpace} from '../helpers'
|
|
|
3
3
|
import {ThemeProps} from '../types'
|
|
4
4
|
import {ResponsiveMarginStyleProps} from './types'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
export function responsiveMarginStyle(
|
|
7
|
+
props: ResponsiveMarginStyleProps & ThemeProps
|
|
8
|
+
): CSSObject[][] {
|
|
8
9
|
const {theme} = props
|
|
9
10
|
|
|
10
11
|
return [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
]
|
|
12
|
+
_getResponsiveSpace(theme, ['margin'], props.$margin),
|
|
13
|
+
_getResponsiveSpace(theme, ['marginLeft', 'marginRight'], props.$marginX),
|
|
14
|
+
_getResponsiveSpace(theme, ['marginTop', 'marginBottom'], props.$marginY),
|
|
15
|
+
_getResponsiveSpace(theme, ['marginTop'], props.$marginTop),
|
|
16
|
+
_getResponsiveSpace(theme, ['marginRight'], props.$marginRight),
|
|
17
|
+
_getResponsiveSpace(theme, ['marginBottom'], props.$marginBottom),
|
|
18
|
+
_getResponsiveSpace(theme, ['marginLeft'], props.$marginLeft),
|
|
19
|
+
].filter(Boolean) as CSSObject[][]
|
|
19
20
|
}
|
|
@@ -10,22 +10,24 @@ describe('styles/margin', () => {
|
|
|
10
10
|
it('should 1', () => {
|
|
11
11
|
const styles = responsiveMarginStyle({$margin: [0], theme})
|
|
12
12
|
|
|
13
|
-
expect(styles).toEqual([{margin: 0}])
|
|
13
|
+
expect(styles).toEqual([[{margin: 0}]])
|
|
14
14
|
})
|
|
15
15
|
|
|
16
16
|
it('should 2', () => {
|
|
17
17
|
const styles = responsiveMarginStyle({$margin: [0, 1, 2], theme})
|
|
18
18
|
|
|
19
19
|
expect(styles).toEqual([
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
[
|
|
21
|
+
{
|
|
22
|
+
margin: 0,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
'@media screen and (min-width: 360px)': {margin: '0.25rem'},
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
'@media screen and (min-width: 600px)': {margin: '0.5rem'},
|
|
29
|
+
},
|
|
30
|
+
],
|
|
29
31
|
])
|
|
30
32
|
})
|
|
31
33
|
})
|
|
@@ -10,22 +10,24 @@ describe('styles/padding', () => {
|
|
|
10
10
|
it('should 1', () => {
|
|
11
11
|
const styles = responsivePaddingStyle({$padding: [0], theme})
|
|
12
12
|
|
|
13
|
-
expect(styles).toEqual([{padding: 0}])
|
|
13
|
+
expect(styles).toEqual([[{padding: 0}]])
|
|
14
14
|
})
|
|
15
15
|
|
|
16
16
|
it('should 2', () => {
|
|
17
17
|
const styles = responsivePaddingStyle({$padding: [0, 1, 2], theme})
|
|
18
18
|
|
|
19
19
|
expect(styles).toEqual([
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
[
|
|
21
|
+
{
|
|
22
|
+
padding: 0,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
'@media screen and (min-width: 360px)': {padding: '0.25rem'},
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
'@media screen and (min-width: 600px)': {padding: '0.5rem'},
|
|
29
|
+
},
|
|
30
|
+
],
|
|
29
31
|
])
|
|
30
32
|
})
|
|
31
33
|
})
|
|
@@ -3,19 +3,18 @@ import {_getResponsiveSpace} from '../helpers'
|
|
|
3
3
|
import {ThemeProps} from '../types'
|
|
4
4
|
import {ResponsivePaddingStyleProps} from './types'
|
|
5
5
|
|
|
6
|
-
// TODO: refactor this to separate style functions
|
|
7
6
|
export function responsivePaddingStyle(
|
|
8
7
|
props: ResponsivePaddingStyleProps & ThemeProps
|
|
9
|
-
): CSSObject[] {
|
|
8
|
+
): CSSObject[][] {
|
|
10
9
|
const {theme} = props
|
|
11
10
|
|
|
12
11
|
return [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
]
|
|
12
|
+
_getResponsiveSpace(theme, ['padding'], props.$padding),
|
|
13
|
+
_getResponsiveSpace(theme, ['paddingLeft', 'paddingRight'], props.$paddingX),
|
|
14
|
+
_getResponsiveSpace(theme, ['paddingTop', 'paddingBottom'], props.$paddingY),
|
|
15
|
+
_getResponsiveSpace(theme, ['paddingTop'], props.$paddingTop),
|
|
16
|
+
_getResponsiveSpace(theme, ['paddingRight'], props.$paddingRight),
|
|
17
|
+
_getResponsiveSpace(theme, ['paddingBottom'], props.$paddingBottom),
|
|
18
|
+
_getResponsiveSpace(theme, ['paddingLeft'], props.$paddingLeft),
|
|
19
|
+
].filter(Boolean) as CSSObject[][]
|
|
21
20
|
}
|
|
@@ -1,25 +1,29 @@
|
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'theme',
|
|
6
|
+
title: 'Theme',
|
|
7
|
+
stories: [
|
|
8
|
+
{
|
|
9
|
+
name: 'canvas',
|
|
10
|
+
title: 'Canvas',
|
|
11
|
+
component: lazy(() => import('./canvas')),
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'nested-provider',
|
|
15
|
+
title: 'Nested provider',
|
|
16
|
+
component: lazy(() => import('./nestedProvider')),
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'layer',
|
|
20
|
+
title: 'Layer',
|
|
21
|
+
component: lazy(() => import('./layer')),
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'color',
|
|
25
|
+
title: 'Color',
|
|
26
|
+
component: lazy(() => import('./color')),
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
})
|
|
File without changes
|
|
@@ -1,10 +1,14 @@
|
|
|
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
|
-
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'utils/boundaryElement',
|
|
6
|
+
title: 'BoundaryElement',
|
|
7
|
+
stories: [
|
|
8
|
+
{
|
|
9
|
+
name: 'plain',
|
|
10
|
+
title: 'Plain',
|
|
11
|
+
component: lazy(() => import('./plain')),
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
})
|
|
@@ -1,10 +1,14 @@
|
|
|
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
|
-
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'utils/elementQuery',
|
|
6
|
+
title: 'ElementQuery',
|
|
7
|
+
stories: [
|
|
8
|
+
{
|
|
9
|
+
name: 'custom-media',
|
|
10
|
+
title: 'Custom media',
|
|
11
|
+
component: lazy(() => import('./customMedia')),
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
})
|
|
@@ -1,20 +1,24 @@
|
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'utils/layer',
|
|
6
|
+
title: 'Layer',
|
|
7
|
+
stories: [
|
|
8
|
+
{
|
|
9
|
+
name: 'plain',
|
|
10
|
+
title: 'Plain',
|
|
11
|
+
component: lazy(() => import('./plain')),
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'multiple-roots',
|
|
15
|
+
title: 'Multiple roots',
|
|
16
|
+
component: lazy(() => import('./multipleRoots')),
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'responsive-z-offset',
|
|
20
|
+
title: 'Responsive z-offset',
|
|
21
|
+
component: lazy(() => import('./responsiveZOffset')),
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {forwardRef
|
|
1
|
+
import {forwardRef} from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
3
|
import {EMPTY_RECORD} from '../../constants'
|
|
4
4
|
import {LayerProvider} from './layerProvider'
|
|
@@ -16,11 +16,9 @@ interface LayerChildrenProps {
|
|
|
16
16
|
as?: React.ElementType | keyof JSX.IntrinsicElements
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
const Root =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
})
|
|
23
|
-
)
|
|
19
|
+
const Root = styled.div`
|
|
20
|
+
position: relative;
|
|
21
|
+
`
|
|
24
22
|
|
|
25
23
|
const LayerChildren = forwardRef(function LayerChildren(
|
|
26
24
|
props: LayerChildrenProps & Omit<React.HTMLProps<HTMLDivElement>, 'as'>,
|
|
@@ -1,10 +1,14 @@
|
|
|
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
|
-
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'utils/portal',
|
|
6
|
+
title: 'Portal',
|
|
7
|
+
stories: [
|
|
8
|
+
{
|
|
9
|
+
name: 'named',
|
|
10
|
+
title: 'Named portals',
|
|
11
|
+
component: lazy(() => import('./named')),
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
})
|