@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
|
@@ -77,7 +77,7 @@ export function avatarRootStyle(props: AvatarRootStyleProps & ThemeProps): CSSOb
|
|
|
77
77
|
|
|
78
78
|
/* &:is(button) */
|
|
79
79
|
'&[data-as="button"]': {
|
|
80
|
-
|
|
80
|
+
'-webkit-font-smoothing': 'inherit',
|
|
81
81
|
appearance: 'none',
|
|
82
82
|
margin: 0,
|
|
83
83
|
padding: 0,
|
|
@@ -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/badge',
|
|
6
|
+
title: 'Badge',
|
|
7
|
+
stories: [
|
|
8
|
+
{
|
|
9
|
+
name: 'props',
|
|
10
|
+
title: 'Props',
|
|
11
|
+
component: lazy(() => import('./props')),
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'tones',
|
|
15
|
+
title: 'Tones',
|
|
16
|
+
component: lazy(() => import('./tones')),
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
})
|
|
@@ -6,7 +6,7 @@ export default function Tones() {
|
|
|
6
6
|
const mode = useSelect('Mode', WORKSHOP_BADGE_MODE_OPTIONS, 'default', 'Props')
|
|
7
7
|
|
|
8
8
|
return (
|
|
9
|
-
<Flex align="center" height="fill" justify="center">
|
|
9
|
+
<Flex align="center" height="fill" justify="center" padding={4} sizing="border">
|
|
10
10
|
<Inline space={2}>
|
|
11
11
|
<Badge mode={mode}>Default</Badge>
|
|
12
12
|
<Badge mode={mode} tone="primary">
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
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 {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
|
|
5
5
|
import {BadgeMode, BadgeTone} from '../../types'
|
|
6
6
|
import {Box, BoxProps} from '../box'
|
|
@@ -19,8 +19,9 @@ export interface BadgeProps extends BoxProps, ResponsiveRadiusProps {
|
|
|
19
19
|
tone?: BadgeTone
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const Root =
|
|
23
|
-
|
|
22
|
+
const Root = styled(Box)<BadgeStyleProps & ResponsiveRadiusStyleProps>(
|
|
23
|
+
responsiveRadiusStyle,
|
|
24
|
+
badgeStyle
|
|
24
25
|
)
|
|
25
26
|
|
|
26
27
|
/**
|
|
@@ -28,7 +29,7 @@ const Root = memo(
|
|
|
28
29
|
*/
|
|
29
30
|
export const Badge = forwardRef(function Badge(
|
|
30
31
|
props: BadgeProps & React.HTMLProps<HTMLDivElement>,
|
|
31
|
-
ref
|
|
32
|
+
ref
|
|
32
33
|
) {
|
|
33
34
|
const {
|
|
34
35
|
children,
|
|
@@ -1,7 +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
|
-
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'primitives/box',
|
|
6
|
+
title: 'Box',
|
|
7
|
+
stories: [
|
|
8
|
+
{
|
|
9
|
+
name: 'props',
|
|
10
|
+
title: 'Props',
|
|
11
|
+
component: lazy(() => import('./props')),
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'responsive',
|
|
15
|
+
title: 'Responsive',
|
|
16
|
+
component: lazy(() => import('./responsive')),
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
})
|
|
@@ -1,30 +1,18 @@
|
|
|
1
|
-
import {forwardRef
|
|
2
|
-
|
|
1
|
+
import {forwardRef} from 'react'
|
|
2
|
+
import styled from 'styled-components'
|
|
3
3
|
import {useArrayProp} from '../../hooks'
|
|
4
|
-
import {compose} from '../../styles'
|
|
5
4
|
import {
|
|
5
|
+
boxStyle,
|
|
6
|
+
flexItemStyle,
|
|
6
7
|
FlexItemStyleProps,
|
|
8
|
+
responsiveBoxStyle,
|
|
7
9
|
ResponsiveBoxStyleProps,
|
|
10
|
+
responsiveGridItemStyle,
|
|
8
11
|
ResponsiveGridItemStyleProps,
|
|
9
|
-
|
|
12
|
+
responsivePaddingStyle,
|
|
10
13
|
ResponsivePaddingStyleProps,
|
|
11
|
-
__tmp_flexItemStyle,
|
|
12
|
-
boxStyle,
|
|
13
|
-
// responsiveBoxStyle,
|
|
14
|
-
responsiveFlexItemStyle,
|
|
15
|
-
// responsiveGridItemStyle,
|
|
16
14
|
responsiveMarginStyle,
|
|
17
|
-
|
|
18
|
-
responsiveBoxSizingStyle,
|
|
19
|
-
responsiveBoxHeightStyle,
|
|
20
|
-
responsiveBoxOverflowStyle,
|
|
21
|
-
responsiveBoxDisplayStyle,
|
|
22
|
-
responsiveGridItemRowStyle,
|
|
23
|
-
responsiveGridItemRowStartStyle,
|
|
24
|
-
responsiveGridItemRowEndStyle,
|
|
25
|
-
responsiveGridItemColumnStyle,
|
|
26
|
-
responsiveGridItemColumnStartStyle,
|
|
27
|
-
responsiveGridItemColumnEndStyle,
|
|
15
|
+
ResponsiveMarginStyleProps,
|
|
28
16
|
} from '../../styles/internal'
|
|
29
17
|
import {
|
|
30
18
|
ResponsiveBoxProps,
|
|
@@ -46,35 +34,19 @@ export interface BoxProps
|
|
|
46
34
|
as?: React.ElementType | keyof JSX.IntrinsicElements
|
|
47
35
|
}
|
|
48
36
|
|
|
49
|
-
const Root =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
responsiveBoxDisplayStyle,
|
|
63
|
-
// flexItem
|
|
64
|
-
__tmp_flexItemStyle,
|
|
65
|
-
responsiveFlexItemStyle,
|
|
66
|
-
// gridItem
|
|
67
|
-
responsiveGridItemRowStyle,
|
|
68
|
-
responsiveGridItemRowStartStyle,
|
|
69
|
-
responsiveGridItemRowEndStyle,
|
|
70
|
-
responsiveGridItemColumnStyle,
|
|
71
|
-
responsiveGridItemColumnStartStyle,
|
|
72
|
-
responsiveGridItemColumnEndStyle,
|
|
73
|
-
// margin
|
|
74
|
-
responsiveMarginStyle,
|
|
75
|
-
// padding
|
|
76
|
-
responsivePaddingStyle,
|
|
77
|
-
])
|
|
37
|
+
const Root = styled.div<
|
|
38
|
+
FlexItemStyleProps &
|
|
39
|
+
ResponsiveBoxStyleProps &
|
|
40
|
+
ResponsiveGridItemStyleProps &
|
|
41
|
+
ResponsiveMarginStyleProps &
|
|
42
|
+
ResponsivePaddingStyleProps
|
|
43
|
+
>(
|
|
44
|
+
boxStyle,
|
|
45
|
+
flexItemStyle,
|
|
46
|
+
responsiveBoxStyle,
|
|
47
|
+
responsiveGridItemStyle,
|
|
48
|
+
responsiveMarginStyle,
|
|
49
|
+
responsivePaddingStyle
|
|
78
50
|
)
|
|
79
51
|
|
|
80
52
|
/**
|
|
@@ -1,50 +1,54 @@
|
|
|
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
|
-
|
|
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
|
-
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'primitives/button',
|
|
6
|
+
title: 'Button',
|
|
7
|
+
stories: [
|
|
8
|
+
{
|
|
9
|
+
name: 'props',
|
|
10
|
+
title: 'Props',
|
|
11
|
+
component: lazy(() => import('./props')),
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'styled-1',
|
|
15
|
+
title: 'Styled #1',
|
|
16
|
+
component: lazy(() => import('./styled1')),
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'styled-2',
|
|
20
|
+
title: 'Styled #2',
|
|
21
|
+
component: lazy(() => import('./styled2')),
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'stacked',
|
|
25
|
+
title: 'Stacked',
|
|
26
|
+
component: lazy(() => import('./stacked')),
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'custom',
|
|
30
|
+
title: 'Custom',
|
|
31
|
+
component: lazy(() => import('./custom')),
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'mixed-children',
|
|
35
|
+
title: 'Mixed children',
|
|
36
|
+
component: lazy(() => import('./mixedChildren')),
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'upload-button',
|
|
40
|
+
title: 'Upload button',
|
|
41
|
+
component: lazy(() => import('./uploadButton')),
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'sanity-upload-button-workaround',
|
|
45
|
+
title: 'SanityUploadButtonWorkaroundStory',
|
|
46
|
+
component: lazy(() => import('./sanityUploadButton')),
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'custom-icons',
|
|
50
|
+
title: 'Custom icons',
|
|
51
|
+
component: lazy(() => import('./customIcons')),
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
})
|
|
@@ -2,27 +2,26 @@ import {UploadIcon} from '@sanity/icons'
|
|
|
2
2
|
import {Button, Flex} from '@sanity/ui'
|
|
3
3
|
import styled from 'styled-components'
|
|
4
4
|
|
|
5
|
-
const SanityUploadButton = styled(Button)
|
|
6
|
-
|
|
7
|
-
appearance:
|
|
8
|
-
overflow:
|
|
9
|
-
top: 0
|
|
10
|
-
left: 0
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
const SanityUploadButton = styled(Button).attrs({forwardedAs: 'label'})`
|
|
6
|
+
& input {
|
|
7
|
+
-webkit-appearance: none;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
top: 0;
|
|
10
|
+
left: 0;
|
|
11
|
+
width: 100%;
|
|
12
|
+
height: 100%;
|
|
13
|
+
opacity: 0;
|
|
14
|
+
position: absolute;
|
|
15
|
+
max-width: 0;
|
|
16
|
+
width: stretch;
|
|
17
|
+
}
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
width:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
flex: 'none',
|
|
23
|
-
padding: 0,
|
|
24
|
-
},
|
|
25
|
-
})
|
|
19
|
+
& span:nth-child(2) {
|
|
20
|
+
width: 0;
|
|
21
|
+
flex: none;
|
|
22
|
+
padding: 0;
|
|
23
|
+
}
|
|
24
|
+
`
|
|
26
25
|
|
|
27
26
|
export default function SanityUploadButtonWorkaroundStory() {
|
|
28
27
|
return (
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {Button, Flex} from '@sanity/ui'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
3
|
|
|
4
|
-
const StyledButton1 = styled.a
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
4
|
+
const StyledButton1 = styled.a`
|
|
5
|
+
&:hover {
|
|
6
|
+
background-color: red;
|
|
7
|
+
box-shadow: none;
|
|
8
|
+
}
|
|
9
|
+
`
|
|
10
10
|
|
|
11
11
|
export default function StyledButton1Story() {
|
|
12
12
|
return (
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {createElement, forwardRef, isValidElement,
|
|
1
|
+
import {createElement, forwardRef, isValidElement, useMemo} from 'react'
|
|
2
2
|
import {isValidElementType} from 'react-is'
|
|
3
|
+
import styled from 'styled-components'
|
|
3
4
|
import {useArrayProp} from '../../hooks'
|
|
4
|
-
import {
|
|
5
|
+
import {ThemeProps} from '../../styles'
|
|
5
6
|
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
|
|
6
7
|
import {useTheme} from '../../theme'
|
|
7
8
|
import {ButtonMode, ButtonTextAlign, ButtonTone, FlexJustify} from '../../types'
|
|
@@ -34,31 +35,24 @@ export interface ButtonProps extends ResponsivePaddingProps, ResponsiveRadiusPro
|
|
|
34
35
|
type?: 'button' | 'reset' | 'submit'
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
const Root =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
[responsiveRadiusStyle, buttonBaseStyles, buttonColorStyles]
|
|
41
|
-
)
|
|
42
|
-
)
|
|
38
|
+
const Root = styled.button<
|
|
39
|
+
{$mode: ButtonMode; $tone: ButtonTone} & ResponsiveRadiusStyleProps & ThemeProps
|
|
40
|
+
>(responsiveRadiusStyle, buttonBaseStyles, buttonColorStyles)
|
|
43
41
|
|
|
44
|
-
const LoadingBox =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
boxShadow: 'inherit',
|
|
59
|
-
},
|
|
60
|
-
])
|
|
61
|
-
)
|
|
42
|
+
const LoadingBox = styled.div`
|
|
43
|
+
position: absolute;
|
|
44
|
+
top: 0;
|
|
45
|
+
left: 0;
|
|
46
|
+
right: 0;
|
|
47
|
+
bottom: 0;
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
background-color: var(--card-bg-color);
|
|
52
|
+
border-radius: inherit;
|
|
53
|
+
z-index: 1;
|
|
54
|
+
box-shadow: inherit;
|
|
55
|
+
`
|
|
62
56
|
|
|
63
57
|
/**
|
|
64
58
|
* @public
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {CSSObject} from 'styled-components'
|
|
1
|
+
import {css, CSSObject, FlattenSimpleInterpolation} from 'styled-components'
|
|
2
2
|
import {ThemeProps} from '../../styles'
|
|
3
3
|
import {_colorVarsStyle} from '../../styles/colorVars'
|
|
4
4
|
import {focusRingBorderStyle, focusRingStyle} from '../../styles/internal'
|
|
@@ -7,36 +7,37 @@ import {ButtonMode, ButtonTone} from '../../types'
|
|
|
7
7
|
/**
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
|
-
export function buttonBaseStyles():
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
appearance:
|
|
14
|
-
display:
|
|
15
|
-
|
|
16
|
-
font:
|
|
17
|
-
border: 0
|
|
18
|
-
outline:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
10
|
+
export function buttonBaseStyles(): FlattenSimpleInterpolation {
|
|
11
|
+
return css`
|
|
12
|
+
-webkit-font-smoothing: inherit;
|
|
13
|
+
appearance: none;
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
font: inherit;
|
|
17
|
+
border: 0;
|
|
18
|
+
outline: none;
|
|
19
|
+
user-select: none;
|
|
20
|
+
text-decoration: none;
|
|
21
|
+
border: 0;
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
padding: 0;
|
|
24
|
+
margin: 0;
|
|
25
|
+
white-space: nowrap;
|
|
26
|
+
text-align: left;
|
|
27
|
+
position: relative;
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
display:
|
|
30
|
-
flex: 1
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
29
|
+
& > span {
|
|
30
|
+
display: block;
|
|
31
|
+
flex: 1;
|
|
32
|
+
min-width: 0;
|
|
33
|
+
border-radius: inherit;
|
|
34
|
+
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
border: 0
|
|
37
|
-
padding: 0
|
|
38
|
-
}
|
|
39
|
-
|
|
36
|
+
&::-moz-focus-inner {
|
|
37
|
+
border: 0;
|
|
38
|
+
padding: 0;
|
|
39
|
+
}
|
|
40
|
+
`
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
const buttonTheme = {border: {width: 1}}
|
|
@@ -1,14 +1,18 @@
|
|
|
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
|
-
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'primitives/card',
|
|
6
|
+
title: 'Card',
|
|
7
|
+
stories: [
|
|
8
|
+
{name: 'props', title: 'Props', component: lazy(() => import('./props'))},
|
|
9
|
+
{name: 'styled', title: 'Styled', component: lazy(() => import('./styled'))},
|
|
10
|
+
{name: 'interactive', title: 'Interactive', component: lazy(() => import('./interactive'))},
|
|
11
|
+
{name: 'tones', title: 'Tones', component: lazy(() => import('./allTones'))},
|
|
12
|
+
{name: 'as-button', title: 'As button', component: lazy(() => import('./asButton'))},
|
|
13
|
+
{name: 'list-nav', title: 'List navigation', component: lazy(() => import('./listNavigation'))},
|
|
14
|
+
{name: 'checkered', title: 'Checkered', component: lazy(() => import('./checkered'))},
|
|
15
|
+
{name: 'as-component', title: 'As component', component: lazy(() => import('./asComponent'))},
|
|
16
|
+
{name: 'selected', title: 'Selected', component: lazy(() => import('./selected'))},
|
|
17
|
+
],
|
|
18
|
+
})
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import {forwardRef
|
|
1
|
+
import {forwardRef} from 'react'
|
|
2
2
|
import {isValidElementType} from 'react-is'
|
|
3
|
+
import styled from 'styled-components'
|
|
3
4
|
import {useArrayProp} from '../../hooks'
|
|
4
|
-
import {compose} from '../../styles'
|
|
5
5
|
import {
|
|
6
|
-
responsiveBorderBottomStyle,
|
|
7
|
-
responsiveBorderLeftStyle,
|
|
8
|
-
responsiveBorderRightStyle,
|
|
9
6
|
responsiveBorderStyle,
|
|
10
7
|
ResponsiveBorderStyleProps,
|
|
11
|
-
responsiveBorderTopStyle,
|
|
12
8
|
responsiveRadiusStyle,
|
|
13
9
|
ResponsiveRadiusStyleProps,
|
|
14
10
|
responsiveShadowStyle,
|
|
@@ -18,7 +14,7 @@ import {ThemeColorProvider, ThemeColorSchemeKey, useRootTheme} from '../../theme
|
|
|
18
14
|
import {CardTone} from '../../types'
|
|
19
15
|
import {Box, BoxProps} from '../box'
|
|
20
16
|
import {ResponsiveBorderProps, ResponsiveRadiusProps, ResponsiveShadowProps} from '../types'
|
|
21
|
-
import {
|
|
17
|
+
import {cardStyle} from './styles'
|
|
22
18
|
import {CardStyleProps} from './types'
|
|
23
19
|
|
|
24
20
|
/**
|
|
@@ -44,24 +40,12 @@ export interface CardProps
|
|
|
44
40
|
tone?: CardTone
|
|
45
41
|
}
|
|
46
42
|
|
|
47
|
-
const Root =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
>(Box, [
|
|
54
|
-
responsiveBorderStyle,
|
|
55
|
-
responsiveBorderTopStyle,
|
|
56
|
-
responsiveBorderRightStyle,
|
|
57
|
-
responsiveBorderBottomStyle,
|
|
58
|
-
responsiveBorderLeftStyle,
|
|
59
|
-
responsiveRadiusStyle,
|
|
60
|
-
responsiveShadowStyle,
|
|
61
|
-
cardBaseStyle,
|
|
62
|
-
cardColorStyle,
|
|
63
|
-
])
|
|
64
|
-
)
|
|
43
|
+
const Root = styled(Box)<
|
|
44
|
+
CardStyleProps &
|
|
45
|
+
ResponsiveRadiusStyleProps &
|
|
46
|
+
ResponsiveBorderStyleProps &
|
|
47
|
+
ResponsiveShadowStyleProps
|
|
48
|
+
>(responsiveBorderStyle, responsiveRadiusStyle, responsiveShadowStyle, cardStyle)
|
|
65
49
|
|
|
66
50
|
/**
|
|
67
51
|
* @public
|