@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.
Files changed (146) 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} +889 -2678
  5. package/dist/index.esm.js.map +1 -0
  6. package/dist/{sanity-ui.js → index.js} +883 -2688
  7. package/dist/index.js.map +1 -0
  8. package/package.json +114 -23
  9. package/src/components/autocomplete/__workshop__/constrainedHeight.tsx +2 -2
  10. package/src/components/autocomplete/__workshop__/example.tsx +1 -1
  11. package/src/components/autocomplete/__workshop__/index.ts +36 -32
  12. package/src/components/autocomplete/autocomplete.styles.tsx +22 -28
  13. package/src/components/autocomplete/autocomplete.tsx +1 -2
  14. package/src/components/autocomplete/constants.ts +3 -8
  15. package/src/components/breadcrumbs/__workshop__/index.ts +11 -7
  16. package/src/components/breadcrumbs/breadcrumbs.styles.ts +13 -18
  17. package/src/components/dialog/__workshop__/index.ts +13 -9
  18. package/src/components/dialog/dialog.tsx +53 -67
  19. package/src/components/hotkeys/__workshop__/index.ts +11 -3
  20. package/src/components/hotkeys/hotkeys.tsx +12 -16
  21. package/src/components/menu/__workshop__/index.ts +71 -67
  22. package/src/components/menu/menu.tsx +5 -7
  23. package/src/components/menu/menuButton.tsx +16 -14
  24. package/src/components/menu/menuDivider.ts +8 -10
  25. package/src/components/skeleton/__workshop__/index.ts +8 -4
  26. package/src/components/skeleton/skeleton.tsx +4 -6
  27. package/src/components/skeleton/styles.ts +13 -9
  28. package/src/components/skeleton/textSkeleton.tsx +12 -14
  29. package/src/components/tab/__workshop__/index.ts +11 -3
  30. package/src/components/toast/__workshop__/index.ts +16 -4
  31. package/src/components/toast/toast.tsx +6 -11
  32. package/src/components/toast/toastProvider.tsx +18 -22
  33. package/src/components/tree/__workshop__/basic.perf.ts +1 -14
  34. package/src/components/tree/__workshop__/basic.tsx +1 -1
  35. package/src/components/tree/__workshop__/index.ts +12 -8
  36. package/src/components/tree/style.ts +78 -76
  37. package/src/components/tree/treeItem.tsx +7 -12
  38. package/src/global.ts +6 -0
  39. package/src/hooks/useElementRect/__workshop__/index.ts +11 -3
  40. package/src/hooks/useMediaIndex/__workshop__/index.ts +11 -3
  41. package/src/primitives/_selectable/selectable.tsx +4 -7
  42. package/src/primitives/_selectable/style.ts +85 -82
  43. package/src/primitives/avatar/__workshop__/index.ts +16 -12
  44. package/src/primitives/avatar/avatar.tsx +9 -12
  45. package/src/primitives/avatar/avatarCounter.tsx +22 -24
  46. package/src/primitives/avatar/avatarStack.tsx +16 -14
  47. package/src/primitives/avatar/styles.ts +1 -1
  48. package/src/primitives/badge/__workshop__/index.ts +16 -12
  49. package/src/primitives/badge/__workshop__/tones.tsx +1 -1
  50. package/src/primitives/badge/badge.tsx +6 -5
  51. package/src/primitives/box/__workshop__/index.ts +16 -4
  52. package/src/primitives/box/box.tsx +21 -49
  53. package/src/primitives/button/__workshop__/index.ts +51 -47
  54. package/src/primitives/button/__workshop__/sanityUploadButton.tsx +19 -20
  55. package/src/primitives/button/__workshop__/styled1.tsx +6 -6
  56. package/src/primitives/button/button.tsx +20 -26
  57. package/src/primitives/button/styles.ts +30 -29
  58. package/src/primitives/card/__workshop__/index.ts +15 -11
  59. package/src/primitives/card/card.tsx +9 -25
  60. package/src/primitives/card/styles.ts +119 -114
  61. package/src/primitives/checkbox/__workshop__/index.ts +10 -6
  62. package/src/primitives/checkbox/checkbox.tsx +4 -4
  63. package/src/primitives/checkbox/styles.ts +71 -69
  64. package/src/primitives/code/__workshop__/index.ts +16 -12
  65. package/src/primitives/code/code.tsx +3 -5
  66. package/src/primitives/code/styles.ts +20 -18
  67. package/src/primitives/container/__workshop__/index.ts +5 -3
  68. package/src/primitives/container/container.tsx +5 -4
  69. package/src/primitives/flex/__workshop__/index.ts +8 -4
  70. package/src/primitives/flex/flex.tsx +7 -23
  71. package/src/primitives/grid/__workshop__/index.ts +7 -3
  72. package/src/primitives/grid/grid.tsx +4 -27
  73. package/src/primitives/heading/__workshop__/index.ts +16 -12
  74. package/src/primitives/heading/heading.tsx +10 -17
  75. package/src/primitives/heading/styles.ts +45 -36
  76. package/src/primitives/inline/__workshop__/index.ts +5 -3
  77. package/src/primitives/inline/inline.tsx +3 -5
  78. package/src/primitives/kbd/__workshop__/index.ts +5 -3
  79. package/src/primitives/kbd/kbd.tsx +12 -13
  80. package/src/primitives/label/__workshop__/index.ts +16 -12
  81. package/src/primitives/label/label.tsx +13 -18
  82. package/src/primitives/label/styles.ts +24 -18
  83. package/src/primitives/popover/__workshop__/PlainStory.tsx +0 -1
  84. package/src/primitives/popover/__workshop__/TestStory.tsx +0 -1
  85. package/src/primitives/popover/__workshop__/index.ts +36 -32
  86. package/src/primitives/popover/constants.ts +0 -3
  87. package/src/primitives/popover/floating-ui/size.ts +40 -25
  88. package/src/primitives/popover/popover.tsx +220 -196
  89. package/src/primitives/popover/popoverArrow.tsx +42 -48
  90. package/src/primitives/popover/popoverCard.tsx +12 -22
  91. package/src/primitives/radio/__workshop__/index.ts +8 -4
  92. package/src/primitives/radio/radio.tsx +3 -3
  93. package/src/primitives/radio/styles.ts +73 -73
  94. package/src/primitives/select/__workshop__/index.ts +8 -4
  95. package/src/primitives/select/select.tsx +9 -11
  96. package/src/primitives/select/styles.ts +77 -77
  97. package/src/primitives/spinner/__workshop__/index.ts +11 -7
  98. package/src/primitives/spinner/spinner.tsx +2 -5
  99. package/src/primitives/stack/__workshop__/index.ts +11 -7
  100. package/src/primitives/stack/stack.tsx +3 -5
  101. package/src/primitives/switch/__workshop__/index.ts +8 -4
  102. package/src/primitives/switch/styles.ts +119 -112
  103. package/src/primitives/switch/switch.tsx +6 -6
  104. package/src/primitives/text/__workshop__/index.ts +21 -17
  105. package/src/primitives/text/styles.ts +51 -45
  106. package/src/primitives/text/text.tsx +11 -16
  107. package/src/primitives/textArea/__workshop__/index.ts +11 -7
  108. package/src/primitives/textArea/textArea.tsx +15 -22
  109. package/src/primitives/textInput/__workshop__/index.ts +46 -42
  110. package/src/primitives/textInput/__workshop__/plain.tsx +2 -1
  111. package/src/primitives/textInput/textInput.tsx +50 -69
  112. package/src/primitives/tooltip/__workshop__/index.ts +11 -7
  113. package/src/primitives/tooltip/tooltip.tsx +3 -6
  114. package/src/primitives/tooltip/tooltipArrow.tsx +69 -59
  115. package/src/styles/border/borderStyle.ts +10 -18
  116. package/src/styles/box/boxStyle.ts +14 -18
  117. package/src/styles/flex/flexItemStyle.ts +7 -1
  118. package/src/styles/flex/flexStyle.ts +14 -9
  119. package/src/styles/grid/gridItemStyle.ts +18 -30
  120. package/src/styles/grid/gridStyle.ts +25 -33
  121. package/src/styles/helpers.ts +2 -2
  122. package/src/styles/index.ts +0 -1
  123. package/src/styles/input/textInputStyle.ts +127 -123
  124. package/src/styles/margin/marginStyle.ts +11 -10
  125. package/src/styles/margin/marginsStyle.test.ts +12 -10
  126. package/src/styles/padding/paddingStyle.test.ts +12 -10
  127. package/src/styles/padding/paddingStyle.ts +9 -10
  128. package/src/theme/__workshop__/index.ts +26 -22
  129. package/src/theme/{ThemeContext.ts → themeContext.ts} +0 -0
  130. package/src/utils/boundaryElement/__workshop__/index.ts +11 -7
  131. package/src/utils/elementQuery/__workshop__/index.ts +11 -7
  132. package/src/utils/layer/__workshop__/index.ts +21 -17
  133. package/src/utils/layer/layer.tsx +4 -6
  134. package/src/utils/portal/__workshop__/index.ts +11 -7
  135. package/src/utils/srOnly/srOnly.tsx +8 -10
  136. package/src/utils/virtualList/__workshop__/index.ts +26 -22
  137. package/src/utils/virtualList/virtualList.tsx +10 -14
  138. package/dist/sanity-ui.esm.js.map +0 -1
  139. package/dist/sanity-ui.js.map +0 -1
  140. package/src/__workshop__/color/overview.tsx +0 -101
  141. package/src/__workshop__/index.ts +0 -10
  142. package/src/icons/__workshop__/.eslintrc +0 -5
  143. package/src/icons/__workshop__/index.tsx +0 -6
  144. package/src/icons/__workshop__/overview.tsx +0 -76
  145. package/src/styles/compose.ts +0 -35
  146. package/src/utils/srOnly/__workshop__/.eslintrc +0 -5
@@ -1,17 +1,11 @@
1
- import {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 {
5
+ flexItemStyle,
5
6
  FlexItemStyleProps,
7
+ responsiveFlexStyle,
6
8
  ResponsiveFlexStyleProps,
7
- __tmp_flexItemStyle,
8
- __tmp_flexStyle,
9
- responsiveFlexAlignStyle,
10
- responsiveFlexDirectionStyle,
11
- responsiveFlexGapStyle,
12
- responsiveFlexItemStyle,
13
- responsiveFlexJustifyStyle,
14
- responsiveFlexWrapStyle,
15
9
  } from '../../styles/internal'
16
10
  import {Box, BoxProps} from '../box'
17
11
  import {ResponsiveFlexProps, ResponsiveFlexItemProps} from '../types'
@@ -26,19 +20,9 @@ export interface FlexProps
26
20
  gap?: number | number[]
27
21
  }
28
22
 
29
- const Root = memo(
30
- compose<FlexItemStyleProps & ResponsiveFlexStyleProps>(Box, [
31
- // flexItem
32
- __tmp_flexItemStyle,
33
- responsiveFlexItemStyle,
34
- // flex
35
- __tmp_flexStyle,
36
- responsiveFlexAlignStyle,
37
- responsiveFlexGapStyle,
38
- responsiveFlexWrapStyle,
39
- responsiveFlexJustifyStyle,
40
- responsiveFlexDirectionStyle,
41
- ])
23
+ const Root = styled(Box)<FlexItemStyleProps & ResponsiveFlexStyleProps>(
24
+ flexItemStyle,
25
+ responsiveFlexStyle
42
26
  )
43
27
 
44
28
  /**
@@ -1,6 +1,10 @@
1
1
  import {defineScope} from '@sanity/ui-workshop'
2
2
  import {lazy} from 'react'
3
3
 
4
- export default defineScope('primitives/grid', 'Grid', [
5
- {name: 'responsive', title: 'Responsive', component: lazy(() => import('./responsive'))},
6
- ])
4
+ export default defineScope({
5
+ name: 'primitives/grid',
6
+ title: 'Grid',
7
+ stories: [
8
+ {name: 'responsive', title: 'Responsive', component: lazy(() => import('./responsive'))},
9
+ ],
10
+ })
@@ -1,18 +1,7 @@
1
- import {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
- import {
5
- responsiveGridAutoColsStyle,
6
- responsiveGridAutoFlowStyle,
7
- responsiveGridAutoRowsStyle,
8
- responsiveGridColumnsStyle,
9
- responsiveGridGapStyle,
10
- responsiveGridGapXStyle,
11
- responsiveGridGapYStyle,
12
- responsiveGridRowsStyle,
13
- ResponsiveGridStyleProps,
14
- __tmp_gridStyle,
15
- } from '../../styles/internal'
4
+ import {responsiveGridStyle, ResponsiveGridStyleProps} from '../../styles/internal'
16
5
  import {Box, BoxProps} from '../box'
17
6
  import {ResponsiveGridProps} from '../types'
18
7
 
@@ -21,19 +10,7 @@ import {ResponsiveGridProps} from '../types'
21
10
  */
22
11
  export interface GridProps extends Omit<BoxProps, 'display'>, ResponsiveGridProps {}
23
12
 
24
- const Root = memo(
25
- compose<ResponsiveGridStyleProps>(Box, [
26
- __tmp_gridStyle,
27
- responsiveGridAutoFlowStyle,
28
- responsiveGridAutoRowsStyle,
29
- responsiveGridAutoColsStyle,
30
- responsiveGridColumnsStyle,
31
- responsiveGridRowsStyle,
32
- responsiveGridGapStyle,
33
- responsiveGridGapXStyle,
34
- responsiveGridGapYStyle,
35
- ])
36
- )
13
+ const Root = styled(Box)<ResponsiveGridStyleProps>(responsiveGridStyle)
37
14
 
38
15
  /**
39
16
  * @public
@@ -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/heading', 'Heading', [
5
- {
6
- name: 'plain',
7
- title: 'Plain',
8
- component: lazy(() => import('./plain')),
9
- },
10
- {
11
- name: 'optical-alignment',
12
- title: 'Optical alignment',
13
- component: lazy(() => import('./opticalAlignment')),
14
- },
15
- ])
4
+ export default defineScope({
5
+ name: 'primitives/heading',
6
+ title: 'Heading',
7
+ stories: [
8
+ {
9
+ name: 'plain',
10
+ title: 'Plain',
11
+ component: lazy(() => import('./plain')),
12
+ },
13
+ {
14
+ name: 'optical-alignment',
15
+ title: 'Optical alignment',
16
+ component: lazy(() => import('./opticalAlignment')),
17
+ },
18
+ ],
19
+ })
@@ -1,7 +1,6 @@
1
- import {forwardRef, memo} from 'react'
1
+ import {forwardRef} from 'react'
2
2
  import styled from 'styled-components'
3
3
  import {useArrayProp} from '../../hooks'
4
- import {compose} from '../../styles'
5
4
  import {
6
5
  ResponsiveFontStyleProps,
7
6
  responsiveHeadingFont,
@@ -31,22 +30,16 @@ export interface HeadingProps {
31
30
  weight?: ThemeFontWeightKey
32
31
  }
33
32
 
34
- const Root = memo(
35
- compose<HeadingStyleProps & ResponsiveTextAlignStyleProps & ResponsiveFontStyleProps>('div', [
36
- headingBaseStyle,
37
- responsiveTextAlignStyle,
38
- responsiveHeadingFont,
39
- ])
40
- )
33
+ const Root = styled.div<
34
+ HeadingStyleProps & ResponsiveTextAlignStyleProps & ResponsiveFontStyleProps
35
+ >(headingBaseStyle, responsiveTextAlignStyle, responsiveHeadingFont)
41
36
 
42
- const SpanWithTextOverflow = memo(
43
- styled.span({
44
- display: 'block',
45
- whiteSpace: 'nowrap',
46
- textOverflow: 'ellipsis',
47
- overflow: 'hidden',
48
- })
49
- )
37
+ const SpanWithTextOverflow = styled.span`
38
+ display: block;
39
+ white-space: nowrap;
40
+ text-overflow: ellipsis;
41
+ overflow: hidden;
42
+ `
50
43
 
51
44
  /**
52
45
  * @public
@@ -1,42 +1,51 @@
1
- import {CSSObject} from 'styled-components'
1
+ import {css, FlattenSimpleInterpolation} from 'styled-components'
2
2
  import {ThemeProps} from '../../styles'
3
3
  import {HeadingStyleProps} from './types'
4
4
 
5
- export function headingBaseStyle(props: HeadingStyleProps & ThemeProps): CSSObject {
5
+ export function headingBaseStyle(
6
+ props: HeadingStyleProps & ThemeProps
7
+ ): FlattenSimpleInterpolation {
6
8
  const {$accent, $muted, theme} = props
7
9
 
8
- return {
9
- ...($accent ? {color: 'var(--card-accent-fg-color)'} : {}),
10
- ...($muted ? {color: 'var(--card-muted-fg-color)'} : {}),
11
-
12
- '& code': {
13
- fontFamily: theme.sanity.fonts.code.family,
14
- borderRadius: 1,
15
- },
16
-
17
- '& a': {
18
- textDecoration: 'none',
19
- borderRadius: 1,
20
- color: 'var(--card-link-color)',
21
- outline: 'none',
22
-
23
- '@media (hover: hover)': {
24
- '&:hover': {
25
- textDecoration: 'underline',
26
- },
27
- },
28
-
29
- '&:focus': {
30
- boxShadow: '0 0 0 1px var(--card-bg-color), 0 0 0 3px var(--card-focus-ring-color)',
31
- },
32
-
33
- '&:focus:not(:focus-visible)': {
34
- boxShadow: 'none',
35
- },
36
- },
37
-
38
- '& [data-sanity-icon]': {
39
- verticalAlign: 'baseline',
40
- },
41
- }
10
+ return css`
11
+ ${$accent &&
12
+ css`
13
+ color: var(--card-accent-fg-color);
14
+ `}
15
+
16
+ ${$muted &&
17
+ css`
18
+ color: var(--card-muted-fg-color);
19
+ `}
20
+
21
+ & code {
22
+ font-family: ${theme.sanity.fonts.code.family};
23
+ border-radius: 1px;
24
+ }
25
+
26
+ & a {
27
+ text-decoration: none;
28
+ border-radius: 1px;
29
+ color: var(--card-link-color);
30
+ outline: none;
31
+
32
+ @media (hover: hover) {
33
+ &:hover {
34
+ text-decoration: underline;
35
+ }
36
+ }
37
+
38
+ &:focus {
39
+ box-shadow: 0 0 0 1px var(--card-bg-color), 0 0 0 3px var(--card-focus-ring-color);
40
+ }
41
+
42
+ &:focus:not(:focus-visible) {
43
+ box-shadow: none;
44
+ }
45
+ }
46
+
47
+ & [data-sanity-icon] {
48
+ vertical-align: baseline;
49
+ }
50
+ `
42
51
  }
@@ -1,6 +1,8 @@
1
1
  import {defineScope} from '@sanity/ui-workshop'
2
2
  import {lazy} from 'react'
3
3
 
4
- export default defineScope('primitives/inline', 'Inline', [
5
- {name: 'plain', title: 'Plain', component: lazy(() => import('./plain'))},
6
- ])
4
+ export default defineScope({
5
+ name: 'primitives/inline',
6
+ title: 'Inline',
7
+ stories: [{name: 'plain', title: 'Plain', component: lazy(() => import('./plain'))}],
8
+ })
@@ -1,6 +1,6 @@
1
- import {forwardRef, memo, useMemo} from 'react'
1
+ import {forwardRef, useMemo} from 'react'
2
+ import styled from 'styled-components'
2
3
  import {useArrayProp} from '../../hooks'
3
- import {compose} from '../../styles'
4
4
  import {Box, BoxProps} from '../box'
5
5
  import {childrenToElementArray} from '../helpers'
6
6
  import {inlineBaseStyle, inlineSpaceStyle} from './styles'
@@ -13,9 +13,7 @@ export interface InlineProps extends Omit<BoxProps, 'display'> {
13
13
  space?: number | number[]
14
14
  }
15
15
 
16
- const Root = memo(
17
- compose<ResponsiveInlineSpaceStyleProps>(Box, [inlineBaseStyle, inlineSpaceStyle])
18
- )
16
+ const Root = styled(Box)<ResponsiveInlineSpaceStyleProps>(inlineBaseStyle, inlineSpaceStyle)
19
17
 
20
18
  /**
21
19
  * @public
@@ -1,6 +1,8 @@
1
1
  import {defineScope} from '@sanity/ui-workshop'
2
2
  import {lazy} from 'react'
3
3
 
4
- export default defineScope('primitives/kbd', 'KBD', [
5
- {name: 'plain', title: 'Plain', component: lazy(() => import('./plain'))},
6
- ])
4
+ export default defineScope({
5
+ name: 'primitives/kbd',
6
+ title: 'KBD',
7
+ stories: [{name: 'plain', title: 'Plain', component: lazy(() => import('./plain'))}],
8
+ })
@@ -1,7 +1,6 @@
1
- import {forwardRef, memo} from 'react'
2
- import {CSSObject} from 'styled-components'
1
+ import {forwardRef} from 'react'
2
+ import styled, {css} from 'styled-components'
3
3
  import {useArrayProp} from '../../hooks'
4
- import {compose} from '../../styles'
5
4
  import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
6
5
  import {Box} from '../box'
7
6
  import {Code} from '../code'
@@ -16,19 +15,19 @@ export interface KBDProps {
16
15
  radius?: number | number[]
17
16
  }
18
17
 
19
- function kbdStyle(): CSSObject {
20
- return {
21
- background: 'var(--card-bg-color)',
22
- font: 'inherit',
23
- boxShadow: 'inset 0 0 0 1px var(--card-hairline-hard-color)',
18
+ function kbdStyle() {
19
+ return css`
20
+ background: var(--card-bg-color);
21
+ font: inherit;
22
+ box-shadow: inset 0 0 0 1px var(--card-hairline-hard-color);
24
23
 
25
- '&:not([hidden])': {
26
- display: 'inline-block',
27
- },
28
- }
24
+ &:not([hidden]) {
25
+ display: inline-block;
26
+ }
27
+ `
29
28
  }
30
29
 
31
- const Root = memo(compose<ResponsiveRadiusStyleProps>('kbd', [responsiveRadiusStyle, kbdStyle]))
30
+ const Root = styled.kbd<ResponsiveRadiusStyleProps>(responsiveRadiusStyle, kbdStyle)
32
31
 
33
32
  /**
34
33
  * @public
@@ -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/label', 'Label', [
5
- {
6
- name: 'plain',
7
- title: 'Plain',
8
- component: lazy(() => import('./plain')),
9
- },
10
- {
11
- name: 'optical-alignment',
12
- title: 'Optical alignment',
13
- component: lazy(() => import('./opticalAlignment')),
14
- },
15
- ])
4
+ export default defineScope({
5
+ name: 'primitives/label',
6
+ title: 'Label',
7
+ stories: [
8
+ {
9
+ name: 'plain',
10
+ title: 'Plain',
11
+ component: lazy(() => import('./plain')),
12
+ },
13
+ {
14
+ name: 'optical-alignment',
15
+ title: 'Optical alignment',
16
+ component: lazy(() => import('./opticalAlignment')),
17
+ },
18
+ ],
19
+ })
@@ -1,7 +1,6 @@
1
- import {forwardRef, memo} from 'react'
1
+ import {forwardRef} from 'react'
2
2
  import styled from 'styled-components'
3
3
  import {useArrayProp} from '../../hooks'
4
- import {compose} from '../../styles'
5
4
  import {responsiveLabelFont, responsiveTextAlignStyle} from '../../styles/internal'
6
5
  import {ThemeFontWeightKey} from '../../theme'
7
6
  import {TextAlign} from '../../types'
@@ -25,23 +24,19 @@ export interface LabelProps {
25
24
  weight?: ThemeFontWeightKey
26
25
  }
27
26
 
28
- const Root = memo(
29
- compose<{
30
- $accent?: boolean
31
- $align: TextAlign[]
32
- $muted: boolean
33
- $size: number[]
34
- }>('div', [responsiveLabelFont, responsiveTextAlignStyle, labelBaseStyle])
35
- )
27
+ const Root = styled.div<{
28
+ $accent?: boolean
29
+ $align: TextAlign[]
30
+ $muted: boolean
31
+ $size: number[]
32
+ }>(responsiveLabelFont, responsiveTextAlignStyle, labelBaseStyle)
36
33
 
37
- const SpanWithTextOverflow = memo(
38
- styled.span({
39
- display: 'block',
40
- whiteSpace: 'nowrap',
41
- textOverflow: 'ellipsis',
42
- overflow: 'hidden',
43
- })
44
- )
34
+ const SpanWithTextOverflow = styled.span`
35
+ display: block;
36
+ white-space: nowrap;
37
+ text-overflow: ellipsis;
38
+ overflow: hidden;
39
+ `
45
40
 
46
41
  /**
47
42
  * @public
@@ -1,31 +1,37 @@
1
- import {CSSObject} from 'styled-components'
1
+ import {css, FlattenSimpleInterpolation} from 'styled-components'
2
2
  import {ThemeProps} from '../../styles'
3
3
 
4
4
  export function labelBaseStyle(
5
5
  props: {$accent?: boolean; $muted: boolean} & ThemeProps
6
- ): CSSObject {
6
+ ): FlattenSimpleInterpolation {
7
7
  const {$accent, $muted, theme} = props
8
8
  const {fonts} = theme.sanity
9
9
 
10
- return {
11
- textTransform: 'uppercase',
10
+ return css`
11
+ text-transform: uppercase;
12
12
 
13
- ...($accent ? {color: 'var(--card-accent-fg-color)'} : {}),
13
+ ${$accent &&
14
+ css`
15
+ color: var(--card-accent-fg-color);
16
+ `}
14
17
 
15
- ...($muted ? {color: 'var(--card-muted-fg-color)'} : {}),
18
+ ${$muted &&
19
+ css`
20
+ color: var(--card-muted-fg-color);
21
+ `}
16
22
 
17
- '& code': {
18
- fontFamily: fonts.code.family,
19
- borderRadius: 1,
20
- },
23
+ & code {
24
+ font-family: ${fonts.code.family};
25
+ border-radius: 1px;
26
+ }
21
27
 
22
- '& a': {
23
- textDecoration: 'none',
24
- borderRadius: 1,
25
- },
28
+ & a {
29
+ text-decoration: none;
30
+ border-radius: 1px;
31
+ }
26
32
 
27
- '& [data-sanity-icon]': {
28
- verticalAlign: 'baseline',
29
- },
30
- }
33
+ & [data-sanity-icon] {
34
+ vertical-align: baseline;
35
+ }
36
+ `
31
37
  }
@@ -52,7 +52,6 @@ export default function PlainStory() {
52
52
  fallbackPlacements={['top', 'bottom']}
53
53
  matchReferenceWidth={matchReferenceWidth}
54
54
  open={open}
55
- overflow="auto"
56
55
  padding={padding}
57
56
  placement={placement}
58
57
  portal={portal}
@@ -63,7 +63,6 @@ export default function TestStory(): ReactElement {
63
63
  fallbackPlacements={['left', 'bottom', 'right', 'top']}
64
64
  matchReferenceWidth={matchReferenceWidth}
65
65
  open={open}
66
- overflow="auto"
67
66
  padding={3}
68
67
  placement={placement}
69
68
  portal
@@ -1,35 +1,39 @@
1
1
  import {defineScope} from '@sanity/ui-workshop'
2
2
  import {lazy} from 'react'
3
3
 
4
- export default defineScope('primitives/popover', 'Popover', [
5
- {
6
- name: 'test',
7
- title: 'Test',
8
- component: lazy(() => import('./TestStory')),
9
- },
10
- {
11
- name: 'plain',
12
- title: 'Plain',
13
- component: lazy(() => import('./PlainStory')),
14
- },
15
- {
16
- name: 'recursive',
17
- title: 'Recursive',
18
- component: lazy(() => import('./RecursiveStory')),
19
- },
20
- {
21
- name: 'match-ref-width',
22
- title: 'Match reference width',
23
- component: lazy(() => import('./MatchReferenceWidthStory')),
24
- },
25
- {
26
- name: 'margins',
27
- title: 'Margins',
28
- component: lazy(() => import('./MarginsStory')),
29
- },
30
- {
31
- name: 'aligned',
32
- title: 'Aligned',
33
- component: lazy(() => import('./AlignedStory')),
34
- },
35
- ])
4
+ export default defineScope({
5
+ name: 'primitives/popover',
6
+ title: 'Popover',
7
+ stories: [
8
+ {
9
+ name: 'test',
10
+ title: 'Test',
11
+ component: lazy(() => import('./TestStory')),
12
+ },
13
+ {
14
+ name: 'plain',
15
+ title: 'Plain',
16
+ component: lazy(() => import('./PlainStory')),
17
+ },
18
+ {
19
+ name: 'recursive',
20
+ title: 'Recursive',
21
+ component: lazy(() => import('./RecursiveStory')),
22
+ },
23
+ {
24
+ name: 'match-ref-width',
25
+ title: 'Match reference width',
26
+ component: lazy(() => import('./MatchReferenceWidthStory')),
27
+ },
28
+ {
29
+ name: 'margins',
30
+ title: 'Margins',
31
+ component: lazy(() => import('./MarginsStory')),
32
+ },
33
+ {
34
+ name: 'aligned',
35
+ title: 'Aligned',
36
+ component: lazy(() => import('./AlignedStory')),
37
+ },
38
+ ],
39
+ })
@@ -1,10 +1,7 @@
1
1
  import {PopoverMargins} from '../../types'
2
2
 
3
3
  export const DEFAULT_POPOVER_DISTANCE = 4
4
-
5
4
  export const DEFAULT_POPOVER_PADDING = 4
6
-
7
5
  export const DEFAULT_POPOVER_ARROW_WIDTH = 27
8
6
  export const DEFAULT_POPOVER_ARROW_HEIGHT = 11
9
-
10
7
  export const DEFAULT_POPOVER_MARGINS: PopoverMargins = [0, 0, 0, 0]