@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
@@ -1,145 +1,150 @@
1
- import {CSSObject} from 'styled-components'
1
+ import {css, FlattenSimpleInterpolation} from 'styled-components'
2
2
  import {ThemeProps} from '../../styles'
3
3
  import {_colorVarsStyle} from '../../styles/colorVars'
4
4
  import {focusRingBorderStyle, focusRingStyle} from '../../styles/focusRing'
5
5
  import {CardStyleProps} from './types'
6
6
 
7
- export function cardBaseStyle(props: CardStyleProps & ThemeProps): CSSObject {
7
+ export function cardStyle(
8
+ props: CardStyleProps & ThemeProps
9
+ ): Array<FlattenSimpleInterpolation | (() => FlattenSimpleInterpolation)> {
10
+ return [cardBaseStyle(props), cardColorStyle(props)]
11
+ }
12
+
13
+ export function cardBaseStyle(props: CardStyleProps & ThemeProps): FlattenSimpleInterpolation {
8
14
  const {$checkered, theme} = props
9
15
  const space = theme.sanity.space
10
16
 
11
- return {
12
- ...($checkered
13
- ? {
14
- backgroundSize: `${space[3]}px ${space[3]}px`,
15
- backgroundPosition: '50% 50%',
16
- backgroundImage: 'var(--card-bg-image)',
17
- }
18
- : {}),
19
-
20
- '&[data-as="button"]': {
21
- WebkitFontSmoothing: 'inherit',
22
- appearance: 'none',
23
- outline: 'none',
24
- font: 'inherit',
25
- textAlign: 'inherit',
26
- border: 0,
27
- width: 'stretch',
28
- },
17
+ return css`
18
+ ${$checkered &&
19
+ css`
20
+ background-size: ${space[3]}px ${space[3]}px;
21
+ background-position: 50% 50%;
22
+ background-image: var(--card-bg-image);
23
+ `}
24
+
25
+ &[data-as='button'] {
26
+ -webkit-font-smoothing: inherit;
27
+ appearance: none;
28
+ outline: none;
29
+ font: inherit;
30
+ text-align: inherit;
31
+ border: 0;
32
+ width: stretch;
33
+ }
29
34
 
30
35
  /* &:is(a) */
31
- '&[data-as="a"]': {
32
- outline: 'none',
33
- textDecoration: 'none',
34
- },
36
+ &[data-as='a'] {
37
+ outline: none;
38
+ text-decoration: none;
39
+ }
35
40
 
36
41
  /* &:is(pre) */
37
- '&[data-as="pre"]': {
38
- font: 'inherit',
39
- },
40
- }
42
+ &[data-as='pre'] {
43
+ font: inherit;
44
+ }
45
+ `
41
46
  }
42
47
 
43
- export function cardColorStyle(props: CardStyleProps & ThemeProps): CSSObject {
48
+ export function cardColorStyle(props: CardStyleProps & ThemeProps): FlattenSimpleInterpolation {
44
49
  const {$checkered, $focusRing, theme} = props
45
50
  const {focusRing} = theme.sanity
46
51
  const {base, card, dark} = theme.sanity.color
47
52
  const border = {width: 0, color: 'var(--card-border-color)'}
48
53
 
49
- return {
50
- colorScheme: dark ? 'dark' : 'light',
54
+ return css`
55
+ color-scheme: ${dark ? 'dark' : 'light'};
51
56
 
52
- ..._colorVarsStyle(base, card.enabled, $checkered),
57
+ ${_colorVarsStyle(base, card.enabled, $checkered)}
53
58
 
54
- backgroundColor: 'var(--card-bg-color)',
55
- color: 'var(--card-fg-color)',
59
+ background-color: var(--card-bg-color);
60
+ color: var(--card-fg-color);
56
61
 
57
62
  /* &:is(button) */
58
- '&[data-as="button"]': {
59
- '--card-focus-ring-box-shadow': 'none',
60
-
61
- cursor: 'default',
62
- boxShadow: 'var(--card-focus-ring-box-shadow)',
63
-
64
- '&:disabled': {
65
- ..._colorVarsStyle(base, card.disabled, $checkered),
66
- },
67
-
68
- '&:not(:disabled)': {
69
- '&[data-pressed]': {
70
- ..._colorVarsStyle(base, card.pressed, $checkered),
71
- },
72
-
73
- '&[data-selected]': {
74
- ..._colorVarsStyle(base, card.selected, $checkered),
75
- },
76
-
77
- '@media (hover: hover)': {
78
- '&:not([data-pressed]):not([data-selected])': {
79
- '&:hover': {
80
- ..._colorVarsStyle(base, card.hovered, $checkered),
81
- },
82
-
83
- '&:active': {
84
- ..._colorVarsStyle(base, card.pressed, $checkered),
85
- },
86
- },
87
- },
88
-
89
- '&:focus': {
90
- '--card-focus-ring-box-shadow': $focusRing
63
+ &[data-as='button'] {
64
+ --card-focus-ring-box-shadow: none;
65
+
66
+ cursor: default;
67
+ box-shadow: var(--card-focus-ring-box-shadow);
68
+
69
+ &:disabled {
70
+ ${_colorVarsStyle(base, card.disabled, $checkered)}
71
+ }
72
+
73
+ &:not(:disabled) {
74
+ &[data-pressed] {
75
+ ${_colorVarsStyle(base, card.pressed, $checkered)}
76
+ }
77
+
78
+ &[data-selected] {
79
+ ${_colorVarsStyle(base, card.selected, $checkered)}
80
+ }
81
+
82
+ @media (hover: hover) {
83
+ &:not([data-pressed]):not([data-selected]) {
84
+ &:hover {
85
+ ${_colorVarsStyle(base, card.hovered, $checkered)}
86
+ }
87
+
88
+ &:active {
89
+ ${_colorVarsStyle(base, card.pressed, $checkered)}
90
+ }
91
+ }
92
+ }
93
+
94
+ &:focus {
95
+ --card-focus-ring-box-shadow: ${$focusRing
91
96
  ? focusRingStyle({base, border, focusRing})
92
- : undefined,
93
- },
97
+ : undefined};
98
+ }
94
99
 
95
- '&:focus:not(:focus-visible)': {
96
- '--card-focus-ring-box-shadow': $focusRing ? focusRingBorderStyle(border) : undefined,
97
- },
98
- },
99
- },
100
+ &:focus:not(:focus-visible) {
101
+ --card-focus-ring-box-shadow: ${$focusRing ? focusRingBorderStyle(border) : undefined};
102
+ }
103
+ }
104
+ }
100
105
 
101
106
  /* &:is(a) */
102
- '&[data-as="a"]': {
103
- cursor: 'pointer',
104
- boxShadow: 'var(--card-focus-ring-box-shadow)',
105
-
106
- '&[data-disabled]': {
107
- ..._colorVarsStyle(base, card.disabled, $checkered),
108
- },
109
-
110
- '&:not([data-disabled])': {
111
- '&[data-pressed]': {
112
- ..._colorVarsStyle(base, card.pressed, $checkered),
113
- },
114
-
115
- '&[data-selected]': {
116
- ..._colorVarsStyle(base, card.selected, $checkered),
117
- },
118
-
119
- '@media (hover: hover)': {
120
- '&:not([data-pressed]):not([data-selected])': {
121
- '&:hover': {
122
- ..._colorVarsStyle(base, card.hovered, $checkered),
123
- },
124
-
125
- '&:active': {
126
- ..._colorVarsStyle(base, card.pressed, $checkered),
127
- },
128
- },
129
- },
130
-
131
- '&:focus': {
132
- '--card-focus-ring-box-shadow': $focusRing
107
+ &[data-as='a'] {
108
+ cursor: pointer;
109
+ box-shadow: var(--card-focus-ring-box-shadow);
110
+
111
+ &[data-disabled] {
112
+ ${_colorVarsStyle(base, card.disabled, $checkered)}
113
+ }
114
+
115
+ &:not([data-disabled]) {
116
+ &[data-pressed] {
117
+ ${_colorVarsStyle(base, card.pressed, $checkered)}
118
+ }
119
+
120
+ &[data-selected] {
121
+ ${_colorVarsStyle(base, card.selected, $checkered)}
122
+ }
123
+
124
+ @media (hover: hover) {
125
+ &:not([data-pressed]):not([data-selected]) {
126
+ &:hover {
127
+ ${_colorVarsStyle(base, card.hovered, $checkered)}
128
+ }
129
+
130
+ &:active {
131
+ ${_colorVarsStyle(base, card.pressed, $checkered)}
132
+ }
133
+ }
134
+ }
135
+
136
+ &:focus {
137
+ --card-focus-ring-box-shadow: ${$focusRing
133
138
  ? focusRingStyle({base, border, focusRing})
134
- : undefined,
135
- },
139
+ : undefined};
140
+ }
136
141
 
137
- '&:focus:not(:focus-visible)': {
138
- '--card-focus-ring-box-shadow': $focusRing ? focusRingBorderStyle(border) : undefined,
139
- },
140
- },
141
- },
142
+ &:focus:not(:focus-visible) {
143
+ --card-focus-ring-box-shadow: ${$focusRing ? focusRingBorderStyle(border) : undefined};
144
+ }
145
+ }
146
+ }
142
147
 
143
- ...theme.sanity.styles?.card?.root,
144
- }
148
+ ${theme.sanity.styles?.card?.root}
149
+ `
145
150
  }
@@ -1,9 +1,13 @@
1
1
  import {defineScope} from '@sanity/ui-workshop'
2
2
  import {lazy} from 'react'
3
3
 
4
- export default defineScope('primitives/checkbox', 'Checkbox', [
5
- {name: 'props', title: 'Props', component: lazy(() => import('./props'))},
6
- {name: 'example', title: 'Example', component: lazy(() => import('./example'))},
7
- {name: 'read-only', title: 'Read-only', component: lazy(() => import('./readOnly'))},
8
- {name: 'multiple-tones', title: 'Multiple tones', component: lazy(() => import('./tones'))},
9
- ])
4
+ export default defineScope({
5
+ name: 'primitives/checkbox',
6
+ title: 'Checkbox',
7
+ stories: [
8
+ {name: 'props', title: 'Props', component: lazy(() => import('./props'))},
9
+ {name: 'example', title: 'Example', component: lazy(() => import('./example'))},
10
+ {name: 'read-only', title: 'Read-only', component: lazy(() => import('./readOnly'))},
11
+ {name: 'multiple-tones', title: 'Multiple tones', component: lazy(() => import('./tones'))},
12
+ ],
13
+ })
@@ -1,7 +1,7 @@
1
1
  import {CheckmarkIcon, RemoveIcon} from '@sanity/icons'
2
- import {forwardRef, memo, useEffect} from 'react'
2
+ import {forwardRef, useEffect} from 'react'
3
+ import styled from 'styled-components'
3
4
  import {useForwardedRef, useCustomValidity} from '../../hooks'
4
- import {compose} from '../../styles'
5
5
  import {checkboxBaseStyles, inputElementStyles} from './styles'
6
6
 
7
7
  /**
@@ -12,8 +12,8 @@ export interface CheckboxProps {
12
12
  customValidity?: string
13
13
  }
14
14
 
15
- const Root = memo(compose('div', [checkboxBaseStyles]))
16
- const Input = memo(compose('input', [inputElementStyles]))
15
+ const Root = styled.div(checkboxBaseStyles)
16
+ const Input = styled.input(inputElementStyles)
17
17
 
18
18
  /**
19
19
  * @public
@@ -1,95 +1,97 @@
1
- import {CSSObject} from 'styled-components'
2
- import {ThemeProps, rem} from '../../styles'
1
+ import {css, FlattenSimpleInterpolation} from 'styled-components'
2
+ import {rem, ThemeProps} from '../../styles'
3
3
  import {focusRingBorderStyle, focusRingStyle} from '../../styles/internal'
4
4
 
5
- export function checkboxBaseStyles(): CSSObject {
6
- return {
7
- position: 'relative',
8
- display: 'inline-block',
9
- }
5
+ export function checkboxBaseStyles(): FlattenSimpleInterpolation {
6
+ return css`
7
+ position: relative;
8
+ display: inline-block;
9
+ `
10
10
  }
11
11
 
12
- export function inputElementStyles(props: ThemeProps): CSSObject {
12
+ export function inputElementStyles(props: ThemeProps): FlattenSimpleInterpolation {
13
13
  const {theme} = props
14
14
  const color = theme.sanity.color.input
15
15
  const {focusRing, input, radius} = theme.sanity
16
16
 
17
- return {
18
- position: 'absolute',
19
- top: 0,
20
- left: 0,
21
- width: '100%',
22
- height: '100%',
23
- outline: 'none',
24
- opacity: 0,
25
- zIndex: 1,
26
- padding: 0,
27
- margin: 0,
17
+ return css`
18
+ position: absolute;
19
+ top: 0;
20
+ left: 0;
21
+ width: 100%;
22
+ height: 100%;
23
+ outline: none;
24
+ opacity: 0;
25
+ z-index: 1;
26
+ padding: 0;
27
+ margin: 0;
28
28
 
29
- '& + span': {
30
- position: 'relative',
31
- display: 'block',
32
- height: rem(input.checkbox.size),
33
- width: rem(input.checkbox.size),
34
- boxSizing: 'border-box',
35
- boxShadow: focusRingBorderStyle({
29
+ & + span {
30
+ position: relative;
31
+ display: block;
32
+ height: ${rem(input.checkbox.size)};
33
+ width: ${rem(input.checkbox.size)};
34
+ box-sizing: border-box;
35
+ box-shadow: ${focusRingBorderStyle({
36
36
  color: color.default.enabled.border,
37
37
  width: input.border.width,
38
- }),
39
- borderRadius: rem(radius[2]),
40
- lineHeight: 1,
41
- backgroundColor: color.default.enabled.bg,
42
- '& > svg': {
43
- display: 'block',
44
- position: 'absolute',
45
- opacity: 0,
46
- height: '100%',
47
- width: '100%',
48
- '& > path': {
49
- vectorEffect: 'non-scaling-stroke',
50
- strokeWidth: '2 !important',
51
- },
52
- },
53
- },
38
+ })};
39
+ border-radius: ${rem(radius[2])};
40
+ line-height: 1;
41
+ background-color: ${color.default.enabled.bg};
54
42
 
55
- '&:not(:disabled):focus + span': {
56
- boxShadow: focusRingStyle({
43
+ & > svg {
44
+ display: block;
45
+ position: absolute;
46
+ opacity: 0;
47
+ height: 100%;
48
+ width: 100%;
49
+
50
+ & > path {
51
+ vector-effect: non-scaling-stroke;
52
+ stroke-width: 2 !important;
53
+ }
54
+ }
55
+ }
56
+
57
+ &:not(:disabled):focus + span {
58
+ box-shadow: ${focusRingStyle({
57
59
  border: {width: input.border.width, color: color.default.enabled.border},
58
60
  focusRing,
59
- }),
60
- },
61
+ })};
62
+ }
61
63
 
62
- '&:not(:disabled):focus:not(:focus-visible) + span': {
63
- boxShadow: focusRingBorderStyle({
64
+ &:not(:disabled):focus:not(:focus-visible) + span {
65
+ box-shadow: ${focusRingBorderStyle({
64
66
  color: color.default.enabled.border,
65
67
  width: input.border.width,
66
- }),
67
- },
68
+ })};
69
+ }
68
70
 
69
- '&:checked + span > svg:first-child': {
70
- opacity: 1,
71
- },
71
+ &:checked + span > svg:first-child {
72
+ opacity: 1;
73
+ }
72
74
 
73
- '&[data-read-only] + span': {
74
- backgroundColor: color.default.readOnly.bg,
75
- boxShadow: focusRingBorderStyle({
75
+ &[data-read-only] + span {
76
+ background-color: ${color.default.readOnly.bg};
77
+ box-shadow: ${focusRingBorderStyle({
76
78
  width: input.border.width,
77
79
  color: color.default.readOnly.border,
78
- }),
79
- color: color.default.readOnly.fg,
80
- },
80
+ })};
81
+ color: ${color.default.readOnly.fg};
82
+ }
81
83
 
82
- '&:not([data-read-only]):disabled + span': {
83
- backgroundColor: color.default.disabled.bg,
84
- boxShadow: focusRingBorderStyle({
84
+ &:not([data-read-only]):disabled + span {
85
+ background-color: ${color.default.disabled.bg};
86
+ box-shadow: ${focusRingBorderStyle({
85
87
  width: input.border.width,
86
88
  color: color.default.disabled.border,
87
- }),
88
- color: color.default.disabled.fg,
89
- },
89
+ })};
90
+ color: ${color.default.disabled.fg};
91
+ }
90
92
 
91
- '&:indeterminate + span > svg:last-child': {
92
- opacity: 1,
93
- },
94
- }
93
+ &:indeterminate + span > svg:last-child {
94
+ opacity: 1;
95
+ }
96
+ `
95
97
  }
@@ -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/code', 'Code', [
5
- {
6
- name: 'props',
7
- title: 'Props',
8
- component: lazy(() => import('./props')),
9
- },
10
- {
11
- name: 'optical-alignment',
12
- title: 'Optical alignment',
13
- component: lazy(() => import('./opticalAlignment')),
14
- },
15
- ])
4
+ export default defineScope({
5
+ name: 'primitives/code',
6
+ title: 'Code',
7
+ stories: [
8
+ {
9
+ name: 'props',
10
+ title: 'Props',
11
+ component: lazy(() => import('./props')),
12
+ },
13
+ {
14
+ name: 'optical-alignment',
15
+ title: 'Optical alignment',
16
+ component: lazy(() => import('./opticalAlignment')),
17
+ },
18
+ ],
19
+ })
@@ -1,7 +1,7 @@
1
- import {forwardRef, memo} from 'react'
1
+ import {forwardRef} from 'react'
2
2
  import Refractor from 'react-refractor'
3
+ import styled from 'styled-components'
3
4
  import {useArrayProp} from '../../hooks'
4
- import {compose} from '../../styles'
5
5
  import {responsiveCodeFontStyle, ResponsiveFontStyleProps} from '../../styles/internal'
6
6
  import {codeBaseStyle} from './styles'
7
7
 
@@ -15,9 +15,7 @@ export interface CodeProps {
15
15
  weight?: string
16
16
  }
17
17
 
18
- const Root = memo(
19
- compose<ResponsiveFontStyleProps>('pre', [codeBaseStyle, responsiveCodeFontStyle])
20
- )
18
+ const Root = styled.pre<ResponsiveFontStyleProps>(codeBaseStyle, responsiveCodeFontStyle)
21
19
 
22
20
  /**
23
21
  * @public
@@ -1,8 +1,8 @@
1
- import {CSSObject} from 'styled-components'
1
+ import {css, FlattenInterpolation, ThemeProps as StyledThemeProps} from 'styled-components'
2
2
  import {ThemeProps} from '../../styles'
3
3
  import {Theme} from '../../theme'
4
4
 
5
- function codeSyntaxHighlightingStyle({theme}: ThemeProps): CSSObject {
5
+ function codeSyntaxHighlightingStyle({theme}: ThemeProps) {
6
6
  const color = theme.sanity.color.syntax
7
7
 
8
8
  return {
@@ -45,24 +45,26 @@ function codeSyntaxHighlightingStyle({theme}: ThemeProps): CSSObject {
45
45
  }
46
46
  }
47
47
 
48
- export function codeBaseStyle({theme}: {theme: Theme}): CSSObject {
49
- return {
50
- color: 'var(--card-code-fg-color)',
48
+ export function codeBaseStyle(): FlattenInterpolation<StyledThemeProps<Theme>> {
49
+ return css`
50
+ color: var(--card-code-fg-color);
51
51
 
52
- '& code': {
53
- fontFamily: 'inherit',
52
+ & code {
53
+ font-family: inherit;
54
54
 
55
- '&.refractor .token': codeSyntaxHighlightingStyle({theme}),
56
- },
55
+ &.refractor .token {
56
+ ${codeSyntaxHighlightingStyle}
57
+ }
58
+ }
57
59
 
58
- '& a': {
59
- color: 'inherit',
60
- textDecoration: 'underline',
61
- borderRadius: '1px',
62
- },
60
+ & a {
61
+ color: inherit;
62
+ text-decoration: underline;
63
+ border-radius: 1px;
64
+ }
63
65
 
64
- '& [data-sanity-icon]': {
65
- verticalAlign: 'baseline',
66
- },
67
- }
66
+ & [data-sanity-icon] {
67
+ vertical-align: baseline;
68
+ }
69
+ `
68
70
  }
@@ -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/container', 'Container', [
5
- {name: 'plain', title: 'Plain', component: lazy(() => import('./example'))},
6
- ])
4
+ export default defineScope({
5
+ name: 'primitives/container',
6
+ title: 'Container',
7
+ stories: [{name: 'plain', title: 'Plain', component: lazy(() => import('./example'))}],
8
+ })
@@ -1,6 +1,6 @@
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 {Box, BoxProps} from '../box'
5
5
  import {ResponsiveWidthProps} from '../types'
6
6
  import {containerBaseStyle, responsiveContainerWidthStyle} from './styles'
@@ -11,8 +11,9 @@ import {ResponsiveWidthStyleProps} from './types'
11
11
  */
12
12
  export interface ContainerProps extends BoxProps, ResponsiveWidthProps {}
13
13
 
14
- const Root = memo(
15
- compose<ResponsiveWidthStyleProps>(Box, [containerBaseStyle, responsiveContainerWidthStyle])
14
+ const Root = styled(Box)<ResponsiveWidthStyleProps>(
15
+ containerBaseStyle,
16
+ responsiveContainerWidthStyle
16
17
  )
17
18
 
18
19
  /**
@@ -1,7 +1,11 @@
1
1
  import {defineScope} from '@sanity/ui-workshop'
2
2
  import {lazy} from 'react'
3
3
 
4
- export default defineScope('primitives/flex', 'Flex', [
5
- {name: 'plain', title: 'Plain', component: lazy(() => import('./example'))},
6
- {name: 'gap', title: 'Gap', component: lazy(() => import('./gap'))},
7
- ])
4
+ export default defineScope({
5
+ name: 'primitives/flex',
6
+ title: 'Flex',
7
+ stories: [
8
+ {name: 'plain', title: 'Plain', component: lazy(() => import('./example'))},
9
+ {name: 'gap', title: 'Gap', component: lazy(() => import('./gap'))},
10
+ ],
11
+ })