@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.
Files changed (144) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +2 -2
  3. package/dist/{types/src/index.d.ts → index.d.ts} +4450 -4398
  4. package/dist/{sanity-ui.esm.js → index.esm.js} +888 -2678
  5. package/dist/index.esm.js.map +1 -0
  6. package/dist/{sanity-ui.js → index.js} +882 -2688
  7. package/dist/index.js.map +1 -0
  8. package/package.json +112 -23
  9. package/src/components/autocomplete/__workshop__/example.tsx +1 -1
  10. package/src/components/autocomplete/__workshop__/index.ts +36 -32
  11. package/src/components/autocomplete/autocomplete.styles.tsx +22 -28
  12. package/src/components/autocomplete/autocomplete.tsx +1 -2
  13. package/src/components/autocomplete/constants.ts +3 -8
  14. package/src/components/breadcrumbs/__workshop__/index.ts +11 -7
  15. package/src/components/breadcrumbs/breadcrumbs.styles.ts +13 -18
  16. package/src/components/dialog/__workshop__/index.ts +13 -9
  17. package/src/components/dialog/dialog.tsx +53 -67
  18. package/src/components/hotkeys/__workshop__/index.ts +11 -3
  19. package/src/components/hotkeys/hotkeys.tsx +12 -16
  20. package/src/components/menu/__workshop__/index.ts +71 -67
  21. package/src/components/menu/menu.tsx +5 -7
  22. package/src/components/menu/menuButton.tsx +16 -14
  23. package/src/components/menu/menuDivider.ts +8 -10
  24. package/src/components/skeleton/__workshop__/index.ts +8 -4
  25. package/src/components/skeleton/skeleton.tsx +4 -6
  26. package/src/components/skeleton/styles.ts +13 -9
  27. package/src/components/skeleton/textSkeleton.tsx +12 -14
  28. package/src/components/tab/__workshop__/index.ts +11 -3
  29. package/src/components/toast/__workshop__/index.ts +16 -4
  30. package/src/components/toast/toast.tsx +6 -11
  31. package/src/components/toast/toastProvider.tsx +18 -22
  32. package/src/components/tree/__workshop__/basic.perf.ts +1 -14
  33. package/src/components/tree/__workshop__/basic.tsx +1 -1
  34. package/src/components/tree/__workshop__/index.ts +12 -8
  35. package/src/components/tree/style.ts +78 -76
  36. package/src/components/tree/treeItem.tsx +7 -12
  37. package/src/hooks/useElementRect/__workshop__/index.ts +11 -3
  38. package/src/hooks/useMediaIndex/__workshop__/index.ts +11 -3
  39. package/src/primitives/_selectable/selectable.tsx +4 -7
  40. package/src/primitives/_selectable/style.ts +85 -82
  41. package/src/primitives/avatar/__workshop__/index.ts +16 -12
  42. package/src/primitives/avatar/avatar.tsx +9 -12
  43. package/src/primitives/avatar/avatarCounter.tsx +22 -24
  44. package/src/primitives/avatar/avatarStack.tsx +16 -14
  45. package/src/primitives/avatar/styles.ts +1 -1
  46. package/src/primitives/badge/__workshop__/index.ts +16 -12
  47. package/src/primitives/badge/__workshop__/tones.tsx +1 -1
  48. package/src/primitives/badge/badge.tsx +6 -5
  49. package/src/primitives/box/__workshop__/index.ts +16 -4
  50. package/src/primitives/box/box.tsx +21 -49
  51. package/src/primitives/button/__workshop__/index.ts +51 -47
  52. package/src/primitives/button/__workshop__/sanityUploadButton.tsx +19 -20
  53. package/src/primitives/button/__workshop__/styled1.tsx +6 -6
  54. package/src/primitives/button/button.tsx +20 -26
  55. package/src/primitives/button/styles.ts +30 -29
  56. package/src/primitives/card/__workshop__/index.ts +15 -11
  57. package/src/primitives/card/card.tsx +9 -25
  58. package/src/primitives/card/styles.ts +119 -114
  59. package/src/primitives/checkbox/__workshop__/index.ts +10 -6
  60. package/src/primitives/checkbox/checkbox.tsx +4 -4
  61. package/src/primitives/checkbox/styles.ts +71 -69
  62. package/src/primitives/code/__workshop__/index.ts +16 -12
  63. package/src/primitives/code/code.tsx +3 -5
  64. package/src/primitives/code/styles.ts +20 -18
  65. package/src/primitives/container/__workshop__/index.ts +5 -3
  66. package/src/primitives/container/container.tsx +5 -4
  67. package/src/primitives/flex/__workshop__/index.ts +8 -4
  68. package/src/primitives/flex/flex.tsx +7 -23
  69. package/src/primitives/grid/__workshop__/index.ts +7 -3
  70. package/src/primitives/grid/grid.tsx +4 -27
  71. package/src/primitives/heading/__workshop__/index.ts +16 -12
  72. package/src/primitives/heading/heading.tsx +10 -17
  73. package/src/primitives/heading/styles.ts +45 -36
  74. package/src/primitives/inline/__workshop__/index.ts +5 -3
  75. package/src/primitives/inline/inline.tsx +3 -5
  76. package/src/primitives/kbd/__workshop__/index.ts +5 -3
  77. package/src/primitives/kbd/kbd.tsx +12 -13
  78. package/src/primitives/label/__workshop__/index.ts +16 -12
  79. package/src/primitives/label/label.tsx +13 -18
  80. package/src/primitives/label/styles.ts +24 -18
  81. package/src/primitives/popover/__workshop__/PlainStory.tsx +0 -1
  82. package/src/primitives/popover/__workshop__/TestStory.tsx +0 -1
  83. package/src/primitives/popover/__workshop__/index.ts +36 -32
  84. package/src/primitives/popover/constants.ts +0 -3
  85. package/src/primitives/popover/floating-ui/size.ts +40 -25
  86. package/src/primitives/popover/popover.tsx +220 -196
  87. package/src/primitives/popover/popoverArrow.tsx +42 -48
  88. package/src/primitives/popover/popoverCard.tsx +12 -22
  89. package/src/primitives/radio/__workshop__/index.ts +8 -4
  90. package/src/primitives/radio/radio.tsx +3 -3
  91. package/src/primitives/radio/styles.ts +73 -73
  92. package/src/primitives/select/__workshop__/index.ts +8 -4
  93. package/src/primitives/select/select.tsx +9 -11
  94. package/src/primitives/select/styles.ts +77 -77
  95. package/src/primitives/spinner/__workshop__/index.ts +11 -7
  96. package/src/primitives/spinner/spinner.tsx +2 -5
  97. package/src/primitives/stack/__workshop__/index.ts +11 -7
  98. package/src/primitives/stack/stack.tsx +3 -5
  99. package/src/primitives/switch/__workshop__/index.ts +8 -4
  100. package/src/primitives/switch/styles.ts +119 -112
  101. package/src/primitives/switch/switch.tsx +6 -6
  102. package/src/primitives/text/__workshop__/index.ts +21 -17
  103. package/src/primitives/text/styles.ts +51 -45
  104. package/src/primitives/text/text.tsx +11 -16
  105. package/src/primitives/textArea/__workshop__/index.ts +11 -7
  106. package/src/primitives/textArea/textArea.tsx +15 -22
  107. package/src/primitives/textInput/__workshop__/index.ts +46 -42
  108. package/src/primitives/textInput/__workshop__/plain.tsx +2 -1
  109. package/src/primitives/textInput/textInput.tsx +49 -69
  110. package/src/primitives/tooltip/__workshop__/index.ts +11 -7
  111. package/src/primitives/tooltip/tooltip.tsx +3 -6
  112. package/src/primitives/tooltip/tooltipArrow.tsx +69 -59
  113. package/src/styles/border/borderStyle.ts +10 -18
  114. package/src/styles/box/boxStyle.ts +14 -18
  115. package/src/styles/flex/flexItemStyle.ts +7 -1
  116. package/src/styles/flex/flexStyle.ts +14 -9
  117. package/src/styles/grid/gridItemStyle.ts +18 -30
  118. package/src/styles/grid/gridStyle.ts +25 -33
  119. package/src/styles/helpers.ts +2 -2
  120. package/src/styles/index.ts +0 -1
  121. package/src/styles/input/textInputStyle.ts +127 -123
  122. package/src/styles/margin/marginStyle.ts +11 -10
  123. package/src/styles/margin/marginsStyle.test.ts +12 -10
  124. package/src/styles/padding/paddingStyle.test.ts +12 -10
  125. package/src/styles/padding/paddingStyle.ts +9 -10
  126. package/src/theme/__workshop__/index.ts +26 -22
  127. package/src/theme/{ThemeContext.ts → themeContext.ts} +0 -0
  128. package/src/utils/boundaryElement/__workshop__/index.ts +11 -7
  129. package/src/utils/elementQuery/__workshop__/index.ts +11 -7
  130. package/src/utils/layer/__workshop__/index.ts +21 -17
  131. package/src/utils/layer/layer.tsx +4 -6
  132. package/src/utils/portal/__workshop__/index.ts +11 -7
  133. package/src/utils/srOnly/srOnly.tsx +8 -10
  134. package/src/utils/virtualList/__workshop__/index.ts +26 -22
  135. package/src/utils/virtualList/virtualList.tsx +10 -14
  136. package/dist/sanity-ui.esm.js.map +0 -1
  137. package/dist/sanity-ui.js.map +0 -1
  138. package/src/__workshop__/color/overview.tsx +0 -101
  139. package/src/__workshop__/index.ts +0 -10
  140. package/src/icons/__workshop__/.eslintrc +0 -5
  141. package/src/icons/__workshop__/index.tsx +0 -6
  142. package/src/icons/__workshop__/overview.tsx +0 -76
  143. package/src/styles/compose.ts +0 -35
  144. 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
- WebkitFontSmoothing: 'inherit',
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('primitives/badge', 'Badge', [
5
- {
6
- name: 'props',
7
- title: 'Props',
8
- component: lazy(() => import('./props')),
9
- },
10
- {
11
- name: 'tones',
12
- title: 'Tones',
13
- component: lazy(() => import('./tones')),
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 {ForwardedRef, forwardRef, memo} from 'react'
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 = memo(
23
- compose<ResponsiveRadiusStyleProps & BadgeStyleProps>(Box, [responsiveRadiusStyle, badgeStyle])
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: ForwardedRef<HTMLDivElement>
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('primitives/box', 'Box', [
5
- {name: 'props', title: 'Props', component: lazy(() => import('./props'))},
6
- {name: 'responsive', title: 'Responsive', component: lazy(() => import('./responsive'))},
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, memo} from 'react'
2
- // import styled from 'styled-components'
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
- ResponsiveMarginStyleProps,
12
+ responsivePaddingStyle,
10
13
  ResponsivePaddingStyleProps,
11
- __tmp_flexItemStyle,
12
- boxStyle,
13
- // responsiveBoxStyle,
14
- responsiveFlexItemStyle,
15
- // responsiveGridItemStyle,
16
14
  responsiveMarginStyle,
17
- responsivePaddingStyle,
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 = memo(
50
- compose<
51
- FlexItemStyleProps &
52
- ResponsiveBoxStyleProps &
53
- ResponsiveGridItemStyleProps &
54
- ResponsiveMarginStyleProps &
55
- ResponsivePaddingStyleProps
56
- >('div', [
57
- // box
58
- boxStyle,
59
- responsiveBoxSizingStyle,
60
- responsiveBoxHeightStyle,
61
- responsiveBoxOverflowStyle,
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('primitives/button', 'Button', [
5
- {
6
- name: 'props',
7
- title: 'Props',
8
- component: lazy(() => import('./props')),
9
- },
10
- {
11
- name: 'styled-1',
12
- title: 'Styled #1',
13
- component: lazy(() => import('./styled1')),
14
- },
15
- {
16
- name: 'styled-2',
17
- title: 'Styled #2',
18
- component: lazy(() => import('./styled2')),
19
- },
20
- {
21
- name: 'stacked',
22
- title: 'Stacked',
23
- component: lazy(() => import('./stacked')),
24
- },
25
- {
26
- name: 'custom',
27
- title: 'Custom',
28
- component: lazy(() => import('./custom')),
29
- },
30
- {
31
- name: 'mixed-children',
32
- title: 'Mixed children',
33
- component: lazy(() => import('./mixedChildren')),
34
- },
35
- {
36
- name: 'upload-button',
37
- title: 'Upload button',
38
- component: lazy(() => import('./uploadButton')),
39
- },
40
- {
41
- name: 'sanity-upload-button-workaround',
42
- title: 'SanityUploadButtonWorkaroundStory',
43
- component: lazy(() => import('./sanityUploadButton')),
44
- },
45
- {
46
- name: 'custom-icons',
47
- title: 'Custom icons',
48
- component: lazy(() => import('./customIcons')),
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)['attrs']({forwardedAs: 'label'})({
6
- '& input': {
7
- appearance: 'none',
8
- overflow: 'hidden',
9
- top: 0,
10
- left: 0,
11
- height: '100%',
12
- opacity: 0,
13
- position: 'absolute',
14
- maxWidth: 0,
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
- // width: '100%',
17
- width: 'stretch',
18
- },
19
-
20
- '& span:nth-child(2)': {
21
- width: 0,
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
- '&:hover': {
6
- backgroundColor: 'red',
7
- boxShadow: 'none',
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, memo, useMemo} from 'react'
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 {compose, ThemeProps} from '../../styles'
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 = memo(
38
- compose<{$mode: ButtonMode; $tone: ButtonTone} & ResponsiveRadiusStyleProps & ThemeProps>(
39
- 'button',
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 = memo(
45
- compose('div', [
46
- {
47
- position: 'absolute',
48
- top: 0,
49
- left: 0,
50
- right: 0,
51
- bottom: 0,
52
- display: 'flex',
53
- alignItems: 'center',
54
- justifyContent: 'center',
55
- backgroundColor: 'var(--card-bg-color)',
56
- borderRadius: 'inherit',
57
- zIndex: 1,
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(): CSSObject {
11
- return {
12
- WebkitFontSmoothing: 'inherit',
13
- appearance: 'none',
14
- display: 'inline-flex',
15
- alignItems: 'center',
16
- font: 'inherit',
17
- border: 0,
18
- outline: 'none',
19
- userSelect: 'none',
20
- textDecoration: 'none',
21
- boxSizing: 'border-box',
22
- padding: 0,
23
- margin: 0,
24
- whiteSpace: 'nowrap',
25
- textAlign: 'left',
26
- position: 'relative',
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
- '& > span': {
29
- display: 'block',
30
- flex: 1,
31
- minWidth: 0,
32
- borderRadius: 'inherit',
33
- },
29
+ & > span {
30
+ display: block;
31
+ flex: 1;
32
+ min-width: 0;
33
+ border-radius: inherit;
34
+ }
34
35
 
35
- '&::-moz-focus-inner': {
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('primitives/card', 'Card', [
5
- {name: 'props', title: 'Props', component: lazy(() => import('./props'))},
6
- {name: 'styled', title: 'Styled', component: lazy(() => import('./styled'))},
7
- {name: 'interactive', title: 'Interactive', component: lazy(() => import('./interactive'))},
8
- {name: 'tones', title: 'Tones', component: lazy(() => import('./allTones'))},
9
- {name: 'as-button', title: 'As button', component: lazy(() => import('./asButton'))},
10
- {name: 'list-nav', title: 'List navigation', component: lazy(() => import('./listNavigation'))},
11
- {name: 'checkered', title: 'Checkered', component: lazy(() => import('./checkered'))},
12
- {name: 'as-component', title: 'As component', component: lazy(() => import('./asComponent'))},
13
- {name: 'selected', title: 'Selected', component: lazy(() => import('./selected'))},
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, memo} from 'react'
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 {cardBaseStyle, cardColorStyle} from './styles'
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 = memo(
48
- compose<
49
- CardStyleProps &
50
- ResponsiveRadiusStyleProps &
51
- ResponsiveBorderStyleProps &
52
- ResponsiveShadowStyleProps
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