@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,64 +1,74 @@
|
|
|
1
|
-
import {forwardRef
|
|
1
|
+
import {forwardRef} from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
3
|
|
|
4
|
-
const Root =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
4
|
+
const Root = styled.div`
|
|
5
|
+
position: absolute;
|
|
6
|
+
pointer-events: none;
|
|
7
|
+
width: 15px;
|
|
8
|
+
height: 15px;
|
|
9
|
+
fill: none;
|
|
10
|
+
|
|
11
|
+
:empty + & {
|
|
12
|
+
display: none;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
& > svg {
|
|
16
|
+
display: block;
|
|
17
|
+
transform-origin: 7.5px 7.5px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* position: absolute;
|
|
21
|
+
width: 15px;
|
|
22
|
+
height: 15px;
|
|
23
|
+
fill: none;
|
|
24
|
+
|
|
25
|
+
:empty + & {
|
|
26
|
+
display: none;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
& > svg {
|
|
30
|
+
&:not([hidden]) {
|
|
31
|
+
display: block;
|
|
32
|
+
}
|
|
33
|
+
transform-origin: 7.5px 7.5px;
|
|
34
|
+
} */
|
|
35
|
+
|
|
36
|
+
[data-placement^='top'] > & {
|
|
37
|
+
bottom: -27px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
[data-placement^='right'] > & {
|
|
41
|
+
left: -27px;
|
|
42
|
+
|
|
43
|
+
& > svg {
|
|
44
|
+
transform: rotate(90deg);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
[data-placement^='left'] > & {
|
|
49
|
+
right: -27px;
|
|
50
|
+
|
|
51
|
+
& > svg {
|
|
52
|
+
transform: rotate(-90deg);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
[data-placement^='bottom'] > & {
|
|
57
|
+
top: -27px;
|
|
58
|
+
|
|
59
|
+
& > svg {
|
|
60
|
+
transform: rotate(180deg);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
`
|
|
64
|
+
|
|
65
|
+
const Border = styled.path`
|
|
66
|
+
fill: var(--card-shadow-outline-color);
|
|
67
|
+
`
|
|
68
|
+
|
|
69
|
+
const Shape = styled.path`
|
|
70
|
+
fill: var(--card-bg-color);
|
|
71
|
+
`
|
|
62
72
|
|
|
63
73
|
interface TooltipArrowProps {}
|
|
64
74
|
|
|
@@ -5,13 +5,13 @@ import {ResponsiveBorderStyleProps} from './types'
|
|
|
5
5
|
|
|
6
6
|
const BORDER_VALUE = '1px solid var(--card-border-color)'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
export function responsiveBorderStyle(): Array<
|
|
9
|
+
(props: ResponsiveBorderStyleProps & ThemeProps) => CSSObject[]
|
|
10
|
+
> {
|
|
11
|
+
return [border, borderTop, borderRight, borderBottom, borderLeft]
|
|
12
|
+
}
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
function border(props: ResponsiveBorderStyleProps & ThemeProps) {
|
|
15
15
|
const {theme} = props
|
|
16
16
|
const {media} = theme.sanity
|
|
17
17
|
|
|
@@ -20,9 +20,7 @@ export function responsiveBorderStyle(props: ResponsiveBorderStyleProps & ThemeP
|
|
|
20
20
|
)
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
props: ResponsiveBorderStyleProps & ThemeProps
|
|
25
|
-
): CSSObject[] {
|
|
23
|
+
function borderTop(props: ResponsiveBorderStyleProps & ThemeProps) {
|
|
26
24
|
const {theme} = props
|
|
27
25
|
const {media} = theme.sanity
|
|
28
26
|
|
|
@@ -31,9 +29,7 @@ export function responsiveBorderTopStyle(
|
|
|
31
29
|
)
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
props: ResponsiveBorderStyleProps & ThemeProps
|
|
36
|
-
): CSSObject[] {
|
|
32
|
+
function borderRight(props: ResponsiveBorderStyleProps & ThemeProps) {
|
|
37
33
|
const {theme} = props
|
|
38
34
|
const {media} = theme.sanity
|
|
39
35
|
|
|
@@ -42,9 +38,7 @@ export function responsiveBorderRightStyle(
|
|
|
42
38
|
)
|
|
43
39
|
}
|
|
44
40
|
|
|
45
|
-
|
|
46
|
-
props: ResponsiveBorderStyleProps & ThemeProps
|
|
47
|
-
): CSSObject[] {
|
|
41
|
+
function borderBottom(props: ResponsiveBorderStyleProps & ThemeProps) {
|
|
48
42
|
const {theme} = props
|
|
49
43
|
const {media} = theme.sanity
|
|
50
44
|
|
|
@@ -53,9 +47,7 @@ export function responsiveBorderBottomStyle(
|
|
|
53
47
|
)
|
|
54
48
|
}
|
|
55
49
|
|
|
56
|
-
|
|
57
|
-
props: ResponsiveBorderStyleProps & ThemeProps
|
|
58
|
-
): CSSObject[] {
|
|
50
|
+
function borderLeft(props: ResponsiveBorderStyleProps & ThemeProps) {
|
|
59
51
|
const {theme} = props
|
|
60
52
|
const {media} = theme.sanity
|
|
61
53
|
|
|
@@ -24,20 +24,18 @@ export function boxStyle(): CSSObject {
|
|
|
24
24
|
return BASE_STYLE
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
export function responsiveBoxStyle(): Array<
|
|
28
|
+
(props: ResponsiveBoxStyleProps & ThemeProps) => CSSObject[]
|
|
29
|
+
> {
|
|
30
|
+
return [
|
|
31
|
+
responsiveBoxSizingStyle,
|
|
32
|
+
responsiveBoxHeightStyle,
|
|
33
|
+
responsiveBoxOverflowStyle,
|
|
34
|
+
responsiveBoxDisplayStyle,
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
props: ResponsiveBoxStyleProps & ThemeProps
|
|
40
|
-
): CSSObject[] {
|
|
38
|
+
function responsiveBoxDisplayStyle(props: ResponsiveBoxStyleProps & ThemeProps) {
|
|
41
39
|
const {theme} = props
|
|
42
40
|
const {media} = theme.sanity
|
|
43
41
|
|
|
@@ -46,7 +44,7 @@ export function responsiveBoxDisplayStyle(
|
|
|
46
44
|
}))
|
|
47
45
|
}
|
|
48
46
|
|
|
49
|
-
|
|
47
|
+
function responsiveBoxSizingStyle(props: ResponsiveBoxStyleProps & ThemeProps) {
|
|
50
48
|
const {theme} = props
|
|
51
49
|
const {media} = theme.sanity
|
|
52
50
|
|
|
@@ -55,7 +53,7 @@ export function responsiveBoxSizingStyle(props: ResponsiveBoxStyleProps & ThemeP
|
|
|
55
53
|
}))
|
|
56
54
|
}
|
|
57
55
|
|
|
58
|
-
|
|
56
|
+
function responsiveBoxHeightStyle(props: ResponsiveBoxStyleProps & ThemeProps) {
|
|
59
57
|
const {theme} = props
|
|
60
58
|
const {media} = theme.sanity
|
|
61
59
|
|
|
@@ -64,9 +62,7 @@ export function responsiveBoxHeightStyle(props: ResponsiveBoxStyleProps & ThemeP
|
|
|
64
62
|
}))
|
|
65
63
|
}
|
|
66
64
|
|
|
67
|
-
|
|
68
|
-
props: ResponsiveBoxStyleProps & ThemeProps
|
|
69
|
-
): CSSObject[] {
|
|
65
|
+
function responsiveBoxOverflowStyle(props: ResponsiveBoxStyleProps & ThemeProps) {
|
|
70
66
|
const {theme} = props
|
|
71
67
|
const {media} = theme.sanity
|
|
72
68
|
|
|
@@ -4,11 +4,17 @@ import {_responsive} from '../helpers'
|
|
|
4
4
|
import {ThemeProps} from '../types'
|
|
5
5
|
import {ResponsiveFlexItemStyleProps} from './types'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const BASE_STYLE: CSSObject = {
|
|
8
8
|
minWidth: 0,
|
|
9
9
|
minHeight: 0,
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
export function flexItemStyle(): Array<
|
|
13
|
+
CSSObject | ((props: ResponsiveFlexItemStyleProps & ThemeProps) => CSSObject[])
|
|
14
|
+
> {
|
|
15
|
+
return [BASE_STYLE, responsiveFlexItemStyle]
|
|
16
|
+
}
|
|
17
|
+
|
|
12
18
|
export function responsiveFlexItemStyle(
|
|
13
19
|
props: ResponsiveFlexItemStyleProps & ThemeProps
|
|
14
20
|
): CSSObject[] {
|
|
@@ -3,19 +3,24 @@ import {rem, _responsive} from '../helpers'
|
|
|
3
3
|
import {ThemeProps} from '../types'
|
|
4
4
|
import {ResponsiveFlexStyleProps} from './types'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const BASE_STYLE: CSSObject = {
|
|
7
7
|
'&&:not([hidden])': {
|
|
8
8
|
display: 'flex',
|
|
9
9
|
},
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
export function responsiveFlexStyle(): Array<
|
|
13
|
+
CSSObject | ((props: ResponsiveFlexStyleProps & ThemeProps) => CSSObject[])
|
|
14
|
+
> {
|
|
15
|
+
return [
|
|
16
|
+
BASE_STYLE,
|
|
17
|
+
responsiveFlexAlignStyle,
|
|
18
|
+
responsiveFlexGapStyle,
|
|
19
|
+
responsiveFlexWrapStyle,
|
|
20
|
+
responsiveFlexJustifyStyle,
|
|
21
|
+
responsiveFlexDirectionStyle,
|
|
22
|
+
]
|
|
23
|
+
}
|
|
19
24
|
|
|
20
25
|
export function responsiveFlexAlignStyle(
|
|
21
26
|
props: ResponsiveFlexStyleProps & ThemeProps
|
|
@@ -28,7 +33,7 @@ export function responsiveFlexAlignStyle(
|
|
|
28
33
|
})
|
|
29
34
|
}
|
|
30
35
|
|
|
31
|
-
|
|
36
|
+
function responsiveFlexGapStyle(props: ResponsiveFlexStyleProps & ThemeProps) {
|
|
32
37
|
const {theme} = props
|
|
33
38
|
const {media, space} = theme.sanity
|
|
34
39
|
|
|
@@ -3,18 +3,18 @@ import {_responsive} from '../helpers'
|
|
|
3
3
|
import {ThemeProps} from '../types'
|
|
4
4
|
import {ResponsiveGridItemStyleProps} from './types'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
export function responsiveGridItemStyle(): Array<
|
|
7
|
+
(props: ResponsiveGridItemStyleProps & ThemeProps) => CSSObject[]
|
|
8
|
+
> {
|
|
9
|
+
return [
|
|
10
|
+
responsiveGridItemRowStyle,
|
|
11
|
+
responsiveGridItemRowStartStyle,
|
|
12
|
+
responsiveGridItemRowEndStyle,
|
|
13
|
+
responsiveGridItemColumnStyle,
|
|
14
|
+
responsiveGridItemColumnStartStyle,
|
|
15
|
+
responsiveGridItemColumnEndStyle,
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
18
|
|
|
19
19
|
const GRID_ITEM_ROW = {
|
|
20
20
|
auto: 'auto',
|
|
@@ -26,9 +26,7 @@ const GRID_ITEM_COLUMN = {
|
|
|
26
26
|
full: '1 / -1',
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
props: ResponsiveGridItemStyleProps & ThemeProps
|
|
31
|
-
): CSSObject[] {
|
|
29
|
+
function responsiveGridItemRowStyle(props: ResponsiveGridItemStyleProps & ThemeProps) {
|
|
32
30
|
const {theme} = props
|
|
33
31
|
const {media} = theme.sanity
|
|
34
32
|
|
|
@@ -41,9 +39,7 @@ export function responsiveGridItemRowStyle(
|
|
|
41
39
|
})
|
|
42
40
|
}
|
|
43
41
|
|
|
44
|
-
|
|
45
|
-
props: ResponsiveGridItemStyleProps & ThemeProps
|
|
46
|
-
): CSSObject[] {
|
|
42
|
+
function responsiveGridItemRowStartStyle(props: ResponsiveGridItemStyleProps & ThemeProps) {
|
|
47
43
|
const {theme} = props
|
|
48
44
|
const {media} = theme.sanity
|
|
49
45
|
|
|
@@ -52,18 +48,14 @@ export function responsiveGridItemRowStartStyle(
|
|
|
52
48
|
}))
|
|
53
49
|
}
|
|
54
50
|
|
|
55
|
-
|
|
56
|
-
props: ResponsiveGridItemStyleProps & ThemeProps
|
|
57
|
-
): CSSObject[] {
|
|
51
|
+
function responsiveGridItemRowEndStyle(props: ResponsiveGridItemStyleProps & ThemeProps) {
|
|
58
52
|
const {theme} = props
|
|
59
53
|
const {media} = theme.sanity
|
|
60
54
|
|
|
61
55
|
return _responsive(media, props.$rowEnd, (rowEnd) => ({gridRowEnd: rowEnd}))
|
|
62
56
|
}
|
|
63
57
|
|
|
64
|
-
|
|
65
|
-
props: ResponsiveGridItemStyleProps & ThemeProps
|
|
66
|
-
): CSSObject[] {
|
|
58
|
+
function responsiveGridItemColumnStyle(props: ResponsiveGridItemStyleProps & ThemeProps) {
|
|
67
59
|
const {theme} = props
|
|
68
60
|
const {media} = theme.sanity
|
|
69
61
|
|
|
@@ -76,9 +68,7 @@ export function responsiveGridItemColumnStyle(
|
|
|
76
68
|
})
|
|
77
69
|
}
|
|
78
70
|
|
|
79
|
-
|
|
80
|
-
props: ResponsiveGridItemStyleProps & ThemeProps
|
|
81
|
-
): CSSObject[] {
|
|
71
|
+
function responsiveGridItemColumnStartStyle(props: ResponsiveGridItemStyleProps & ThemeProps) {
|
|
82
72
|
const {theme} = props
|
|
83
73
|
const {media} = theme.sanity
|
|
84
74
|
|
|
@@ -87,9 +77,7 @@ export function responsiveGridItemColumnStartStyle(
|
|
|
87
77
|
}))
|
|
88
78
|
}
|
|
89
79
|
|
|
90
|
-
|
|
91
|
-
props: ResponsiveGridItemStyleProps & ThemeProps
|
|
92
|
-
): CSSObject[] {
|
|
80
|
+
function responsiveGridItemColumnEndStyle(props: ResponsiveGridItemStyleProps & ThemeProps) {
|
|
93
81
|
const {theme} = props
|
|
94
82
|
const {media} = theme.sanity
|
|
95
83
|
|
|
@@ -3,7 +3,7 @@ import {rem, _responsive} from '../helpers'
|
|
|
3
3
|
import {ThemeProps} from '../types'
|
|
4
4
|
import {ResponsiveGridStyleProps} from './types'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const GRID_CSS = {
|
|
7
7
|
'&&:not([hidden])': {
|
|
8
8
|
display: 'grid',
|
|
9
9
|
},
|
|
@@ -26,25 +26,23 @@ const GRID_AUTO_ROWS = {
|
|
|
26
26
|
fr: 'minmax(0, 1fr)',
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
props: ResponsiveGridStyleProps & ThemeProps
|
|
47
|
-
): CSSObject[] {
|
|
29
|
+
export function responsiveGridStyle(): Array<
|
|
30
|
+
CSSObject | ((props: ResponsiveGridStyleProps & ThemeProps) => CSSObject[])
|
|
31
|
+
> {
|
|
32
|
+
return [
|
|
33
|
+
GRID_CSS,
|
|
34
|
+
responsiveGridAutoFlowStyle,
|
|
35
|
+
responsiveGridAutoRowsStyle,
|
|
36
|
+
responsiveGridAutoColsStyle,
|
|
37
|
+
responsiveGridColumnsStyle,
|
|
38
|
+
responsiveGridRowsStyle,
|
|
39
|
+
responsiveGridGapStyle,
|
|
40
|
+
responsiveGridGapXStyle,
|
|
41
|
+
responsiveGridGapYStyle,
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function responsiveGridAutoFlowStyle(props: ResponsiveGridStyleProps & ThemeProps) {
|
|
48
46
|
const {theme} = props
|
|
49
47
|
const {media} = theme.sanity
|
|
50
48
|
|
|
@@ -53,9 +51,7 @@ export function responsiveGridAutoFlowStyle(
|
|
|
53
51
|
}))
|
|
54
52
|
}
|
|
55
53
|
|
|
56
|
-
|
|
57
|
-
props: ResponsiveGridStyleProps & ThemeProps
|
|
58
|
-
): CSSObject[] {
|
|
54
|
+
function responsiveGridAutoRowsStyle(props: ResponsiveGridStyleProps & ThemeProps) {
|
|
59
55
|
const {theme} = props
|
|
60
56
|
const {media} = theme.sanity
|
|
61
57
|
|
|
@@ -64,9 +60,7 @@ export function responsiveGridAutoRowsStyle(
|
|
|
64
60
|
}))
|
|
65
61
|
}
|
|
66
62
|
|
|
67
|
-
|
|
68
|
-
props: ResponsiveGridStyleProps & ThemeProps
|
|
69
|
-
): CSSObject[] {
|
|
63
|
+
function responsiveGridAutoColsStyle(props: ResponsiveGridStyleProps & ThemeProps) {
|
|
70
64
|
const {theme} = props
|
|
71
65
|
const {media} = theme.sanity
|
|
72
66
|
|
|
@@ -75,9 +69,7 @@ export function responsiveGridAutoColsStyle(
|
|
|
75
69
|
}))
|
|
76
70
|
}
|
|
77
71
|
|
|
78
|
-
|
|
79
|
-
props: ResponsiveGridStyleProps & ThemeProps
|
|
80
|
-
): CSSObject[] {
|
|
72
|
+
function responsiveGridColumnsStyle(props: ResponsiveGridStyleProps & ThemeProps) {
|
|
81
73
|
const {theme} = props
|
|
82
74
|
const {media} = theme.sanity
|
|
83
75
|
|
|
@@ -86,7 +78,7 @@ export function responsiveGridColumnsStyle(
|
|
|
86
78
|
}))
|
|
87
79
|
}
|
|
88
80
|
|
|
89
|
-
|
|
81
|
+
function responsiveGridRowsStyle(props: ResponsiveGridStyleProps & ThemeProps) {
|
|
90
82
|
const {theme} = props
|
|
91
83
|
const {media} = theme.sanity
|
|
92
84
|
|
|
@@ -95,7 +87,7 @@ export function responsiveGridRowsStyle(props: ResponsiveGridStyleProps & ThemeP
|
|
|
95
87
|
}))
|
|
96
88
|
}
|
|
97
89
|
|
|
98
|
-
|
|
90
|
+
function responsiveGridGapStyle(props: ResponsiveGridStyleProps & ThemeProps) {
|
|
99
91
|
const {theme} = props
|
|
100
92
|
const {media, space} = theme.sanity
|
|
101
93
|
|
|
@@ -104,7 +96,7 @@ export function responsiveGridGapStyle(props: ResponsiveGridStyleProps & ThemePr
|
|
|
104
96
|
}))
|
|
105
97
|
}
|
|
106
98
|
|
|
107
|
-
|
|
99
|
+
function responsiveGridGapXStyle(props: ResponsiveGridStyleProps & ThemeProps) {
|
|
108
100
|
const {theme} = props
|
|
109
101
|
const {media, space} = theme.sanity
|
|
110
102
|
|
|
@@ -113,7 +105,7 @@ export function responsiveGridGapXStyle(props: ResponsiveGridStyleProps & ThemeP
|
|
|
113
105
|
}))
|
|
114
106
|
}
|
|
115
107
|
|
|
116
|
-
|
|
108
|
+
function responsiveGridGapYStyle(props: ResponsiveGridStyleProps & ThemeProps) {
|
|
117
109
|
const {theme} = props
|
|
118
110
|
const {media, space} = theme.sanity
|
|
119
111
|
|
package/src/styles/helpers.ts
CHANGED
|
@@ -55,13 +55,13 @@ export function _getResponsiveSpace(
|
|
|
55
55
|
theme: Theme,
|
|
56
56
|
props: string[],
|
|
57
57
|
spaceIndexes: number[] = EMPTY_ARRAY
|
|
58
|
-
): CSSObject[] {
|
|
58
|
+
): CSSObject[] | null {
|
|
59
59
|
if (!Array.isArray(spaceIndexes)) {
|
|
60
60
|
throw new Error('the property must be array of numbers')
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
if (spaceIndexes.length === 0) {
|
|
64
|
-
return
|
|
64
|
+
return null
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
return _responsive(theme.sanity.media, spaceIndexes, (spaceIndex) =>
|
package/src/styles/index.ts
CHANGED