@sanity/ui 2.0.0-beta.2 → 2.0.0-beta.21

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 (91) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +6 -3
  3. package/dist/index.cjs.mjs +11 -36
  4. package/dist/index.d.ts +247 -267
  5. package/dist/index.esm.js +477 -326
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.js +486 -539
  8. package/dist/index.js.map +1 -1
  9. package/dist/theme.cjs.mjs +1 -1
  10. package/dist/theme.d.ts +87 -115
  11. package/dist/theme.esm.js +348 -290
  12. package/dist/theme.esm.js.map +1 -1
  13. package/dist/theme.js +348 -290
  14. package/dist/theme.js.map +1 -1
  15. package/package.json +6 -3
  16. package/src/core/__workshop__/fontsPlugin.tsx +48 -8
  17. package/src/core/_compat.ts +236 -87
  18. package/src/core/components/dialog/dialog.tsx +1 -1
  19. package/src/core/components/dialog/styles.ts +2 -2
  20. package/src/core/components/menu/__workshop__/selectedItem.tsx +7 -2
  21. package/src/core/components/menu/menuButton.tsx +12 -1
  22. package/src/core/components/toast/toast.tsx +17 -2
  23. package/src/core/components/toast/toastProvider.tsx +20 -3
  24. package/src/core/constants.ts +37 -0
  25. package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +6 -3
  26. package/src/core/middleware/origin.ts +47 -0
  27. package/src/core/primitives/badge/badge.tsx +1 -3
  28. package/src/core/primitives/button/button.tsx +9 -11
  29. package/src/core/primitives/heading/styles.ts +4 -0
  30. package/src/core/primitives/kbd/kbd.tsx +2 -0
  31. package/src/core/primitives/popover/popover.tsx +67 -13
  32. package/src/core/primitives/popover/popoverCard.tsx +31 -15
  33. package/src/core/primitives/select/select.tsx +1 -1
  34. package/src/core/primitives/switch/styles.ts +6 -1
  35. package/src/core/primitives/textInput/__workshop__/plain.tsx +1 -1
  36. package/src/core/primitives/textInput/__workshop__/states.tsx +10 -2
  37. package/src/core/primitives/tooltip/tooltip.tsx +46 -56
  38. package/src/core/primitives/tooltip/tooltipCard.tsx +110 -0
  39. package/src/core/styles/card/_cardColorStyle.ts +2 -0
  40. package/src/core/styles/input/textInputStyle.ts +33 -2
  41. package/src/core/styles/margin/marginsStyle.test.ts +2 -2
  42. package/src/core/styles/padding/paddingStyle.test.ts +2 -2
  43. package/src/core/theme/__workshop__/build/Root.tsx +20 -3
  44. package/src/core/theme/__workshop__/build/story.tsx +16 -10
  45. package/src/core/theme/__workshop__/canvas.tsx +7 -7
  46. package/src/core/theme/__workshop__/debug/story.tsx +196 -0
  47. package/src/core/theme/__workshop__/index.ts +5 -0
  48. package/src/core/theme/theme.test.tsx +2 -2
  49. package/src/core/types/button.ts +1 -2
  50. package/src/core/{primitives/tooltip → utils/conditionalWrapper}/conditionalWrapper.tsx +3 -0
  51. package/src/core/utils/conditionalWrapper/index.ts +1 -0
  52. package/src/core/utils/index.ts +1 -0
  53. package/src/theme/build/_deprecated/color/factory.ts +3 -3
  54. package/src/theme/build/buildColorTheme.test.ts +2 -2
  55. package/src/theme/build/buildColorTheme.ts +16 -16
  56. package/src/theme/build/colorToken/colorToken.ts +19 -0
  57. package/src/theme/build/colorToken/compileColorToken.ts +21 -0
  58. package/src/theme/build/colorToken/index.ts +2 -0
  59. package/src/theme/build/colorToken/types.ts +6 -0
  60. package/src/theme/build/renderColorTheme.ts +14 -15
  61. package/src/theme/build/renderColorValue.ts +9 -2
  62. package/src/theme/config/system.ts +12 -10
  63. package/src/theme/config/tokens/color/types.ts +12 -1
  64. package/src/theme/config/tokens/parseTokenKey.ts +1 -0
  65. package/src/theme/config/tokens/parseTokenValue.test.ts +13 -16
  66. package/src/theme/config/tokens/parseTokenValue.ts +45 -14
  67. package/src/theme/config/tokens/types.ts +3 -2
  68. package/src/theme/defaults/colorTokens.ts +279 -253
  69. package/src/theme/defaults/config.ts +2 -2
  70. package/src/theme/getScopedTheme.ts +1 -0
  71. package/src/theme/index.ts +0 -7
  72. package/src/theme/system/color/_constants.ts +5 -2
  73. package/src/theme/system/color/_system.ts +2 -1
  74. package/src/theme/system/color/avatar.ts +2 -12
  75. package/src/theme/system/color/button.ts +4 -20
  76. package/src/theme/system/color/input.ts +3 -11
  77. package/src/theme/system/color/selectable.ts +3 -14
  78. package/src/theme/system/shadow.ts +0 -6
  79. package/src/theme/system/styles.ts +0 -6
  80. package/src/theme/system/theme.ts +11 -1
  81. package/src/theme/system/v0/avatar.ts +1 -1
  82. package/src/theme/system/v0/color/button.ts +4 -4
  83. package/src/theme/system/v0/color/card.ts +2 -2
  84. package/src/theme/system/v0/color/color.ts +0 -1
  85. package/src/theme/system/v0/color/input.ts +3 -3
  86. package/src/theme/system/v0/color/muted.ts +2 -2
  87. package/src/theme/system/v0/color/solid.ts +2 -2
  88. package/src/theme/versioning/getTheme_v2.ts +2 -1
  89. package/src/theme/versioning/themeColor_v0_v2.ts +2 -2
  90. package/src/theme/versioning/v2_v0.ts +3 -2
  91. package/src/theme/build/colorToken.ts +0 -39
@@ -10,7 +10,7 @@ import {
10
10
  RootBoundary,
11
11
  } from '@floating-ui/react-dom'
12
12
  import {ThemeColorSchemeKey} from '@sanity/ui/theme'
13
- import {AnimatePresence, motion} from 'framer-motion'
13
+ import {AnimatePresence} from 'framer-motion'
14
14
  import {
15
15
  cloneElement,
16
16
  forwardRef,
@@ -19,27 +19,30 @@ import {
19
19
  useMemo,
20
20
  useRef,
21
21
  useState,
22
- CSSProperties,
23
22
  ForwardedRef,
24
23
  useId,
25
24
  } from 'react'
26
25
  import styled from 'styled-components'
27
26
  import {useArrayProp, useForwardedRef} from '../../hooks'
28
27
  import {useDelayedState} from '../../hooks/useDelayedState'
28
+ import {origin} from '../../middleware/origin'
29
29
  import {useTheme_v2} from '../../theme'
30
30
  import {Placement} from '../../types'
31
- import {Arrow, Layer, LayerProps, Portal, useBoundaryElement, usePortal} from '../../utils'
32
- import {Card} from '../card'
31
+ import {
32
+ ConditionalWrapper,
33
+ Layer,
34
+ LayerProps,
35
+ Portal,
36
+ useBoundaryElement,
37
+ usePortal,
38
+ } from '../../utils'
33
39
  import {Delay} from '../types'
34
- import {ConditionalWrapper} from './conditionalWrapper'
35
40
  import {
36
41
  DEFAULT_FALLBACK_PLACEMENTS,
37
- DEFAULT_TOOLTIP_ARROW_HEIGHT,
38
- DEFAULT_TOOLTIP_ARROW_RADIUS,
39
- DEFAULT_TOOLTIP_ARROW_WIDTH,
40
42
  DEFAULT_TOOLTIP_DISTANCE,
41
43
  DEFAULT_TOOLTIP_PADDING,
42
44
  } from './constants'
45
+ import {TooltipCard} from './tooltipCard'
43
46
  import {useTooltipDelayGroup} from './tooltipDelayGroup'
44
47
 
45
48
  /**
@@ -98,6 +101,7 @@ export const Tooltip = forwardRef(function Tooltip(
98
101
  const boundaryElementContext = useBoundaryElement()
99
102
  const {layer} = useTheme_v2()
100
103
  const {
104
+ animate = false,
101
105
  arrow: arrowProp = false,
102
106
  boundaryElement = boundaryElementContext?.element,
103
107
  children: childProp,
@@ -113,7 +117,6 @@ export const Tooltip = forwardRef(function Tooltip(
113
117
  shadow = 2,
114
118
  zOffset = layer.tooltip.zOffset,
115
119
  delay,
116
- animate = false,
117
120
  ...restProps
118
121
  } = props
119
122
  const fallbackPlacements = useArrayProp(fallbackPlacementsProp)
@@ -168,8 +171,14 @@ export const Tooltip = forwardRef(function Tooltip(
168
171
  ret.push(arrow({element: arrowRef, padding: DEFAULT_TOOLTIP_PADDING}))
169
172
  }
170
173
 
174
+ // Determine the origin to scale from.
175
+ // Must be placed after `@sanity/ui/size` and `shift` middleware.
176
+ if (animate) {
177
+ ret.push(origin)
178
+ }
179
+
171
180
  return ret
172
- }, [arrowProp, boundaryElement, fallbackPlacements])
181
+ }, [animate, arrowProp, boundaryElement, fallbackPlacements])
173
182
 
174
183
  const {floatingStyles, placement, middlewareData, refs, update} = useFloating({
175
184
  middleware,
@@ -180,15 +189,8 @@ export const Tooltip = forwardRef(function Tooltip(
180
189
  const arrowX = middlewareData.arrow?.x
181
190
  const arrowY = middlewareData.arrow?.y
182
191
 
183
- const arrowStyle: CSSProperties = useMemo(
184
- () => ({
185
- left: arrowX !== null ? arrowX : undefined,
186
- top: arrowY !== null ? arrowY : undefined,
187
- right: undefined,
188
- bottom: undefined,
189
- }),
190
- [arrowX, arrowY],
191
- )
192
+ const originX = middlewareData['@sanity/ui/origin']?.originX
193
+ const originY = middlewareData['@sanity/ui/origin']?.originY
192
194
 
193
195
  const tooltipId = useId()
194
196
  const [isOpen, setIsOpen] = useDelayedState(false)
@@ -386,7 +388,7 @@ export const Tooltip = forwardRef(function Tooltip(
386
388
 
387
389
  if (disabled) return child
388
390
 
389
- const root = (
391
+ const tooltip = (
390
392
  <Root
391
393
  data-ui="Tooltip"
392
394
  {...restProps}
@@ -395,62 +397,50 @@ export const Tooltip = forwardRef(function Tooltip(
395
397
  zOffset={zOffset}
396
398
  $maxWidth={tooltipWidth}
397
399
  >
398
- <ConditionalWrapper
399
- condition={animate} // Add animation wrapper if it should animate
400
- wrapper={(children) => (
401
- <motion.div
402
- initial={{opacity: 0.5, scale: 0.95}}
403
- animate={{opacity: 1, scale: 1}}
404
- exit={{opacity: 0, scale: 0.95}}
405
- transition={{duration: 0.3, type: 'spring'}}
406
- >
407
- {children}
408
- </motion.div>
409
- )}
400
+ <TooltipCard
401
+ {...restProps}
402
+ animate={animate}
403
+ arrow={arrowProp}
404
+ arrowRef={setArrow}
405
+ arrowX={arrowX}
406
+ arrowY={arrowY}
407
+ originX={originX}
408
+ originY={originY}
409
+ padding={padding}
410
+ placement={placement}
411
+ radius={radius}
412
+ ref={setFloating}
413
+ scheme={scheme}
414
+ shadow={shadow}
410
415
  >
411
- <Card
412
- data-ui="Tooltip__card"
413
- data-placement={placement}
414
- padding={padding}
415
- radius={radius}
416
- scheme={scheme}
417
- shadow={shadow}
418
- >
419
- {content}
420
- {arrowProp && (
421
- <Arrow
422
- ref={setArrow}
423
- style={arrowStyle}
424
- width={DEFAULT_TOOLTIP_ARROW_WIDTH}
425
- height={DEFAULT_TOOLTIP_ARROW_HEIGHT}
426
- radius={DEFAULT_TOOLTIP_ARROW_RADIUS}
427
- />
428
- )}
429
- </Card>
430
- </ConditionalWrapper>
416
+ {content}
417
+ </TooltipCard>
431
418
  </Root>
432
419
  )
433
420
 
434
421
  return (
435
422
  <>
436
- {child}
423
+ {/* the tooltip */}
437
424
  <ConditionalWrapper
438
425
  condition={animate}
439
- wrapper={(children) => <AnimatePresence>{children}</AnimatePresence>} // Add AnimatePresence if it should animate
426
+ wrapper={(children) => <AnimatePresence>{children}</AnimatePresence>}
440
427
  >
441
428
  {showTooltip && (
442
429
  <ConditionalWrapper
443
- condition={!!portalProp} // Add portal if portalProp is set
430
+ condition={!!portalProp}
444
431
  wrapper={(children) => (
445
432
  <Portal __unstable_name={typeof portalProp === 'string' ? portalProp : undefined}>
446
433
  {children}
447
434
  </Portal>
448
435
  )}
449
436
  >
450
- {root}
437
+ {tooltip}
451
438
  </ConditionalWrapper>
452
439
  )}
453
440
  </ConditionalWrapper>
441
+
442
+ {/* the referred element */}
443
+ {child}
454
444
  </>
455
445
  )
456
446
  })
@@ -0,0 +1,110 @@
1
+ import {ThemeColorSchemeKey} from '@sanity/ui/theme'
2
+ import {MotionProps, motion} from 'framer-motion'
3
+ import React, {CSSProperties, forwardRef, memo, useMemo} from 'react'
4
+ import styled from 'styled-components'
5
+ import {POPOVER_MOTION_CONTENT_OPACITY_PROPERTY, POPOVER_MOTION_PROPS} from '../../constants'
6
+ import {Placement, Radius} from '../../types'
7
+ import {Arrow} from '../../utils'
8
+ import {Card, CardProps} from '../card'
9
+ import {
10
+ DEFAULT_TOOLTIP_ARROW_HEIGHT,
11
+ DEFAULT_TOOLTIP_ARROW_RADIUS,
12
+ DEFAULT_TOOLTIP_ARROW_WIDTH,
13
+ } from './constants'
14
+
15
+ const MotionCard = styled(motion(Card))`
16
+ & > * {
17
+ opacity: var(${POPOVER_MOTION_CONTENT_OPACITY_PROPERTY}, 1);
18
+ will-change: opacity;
19
+ }
20
+ `
21
+
22
+ /**
23
+ * @internal
24
+ */
25
+ export const TooltipCard = memo(
26
+ forwardRef(function TooltipCard(
27
+ props: {
28
+ animate?: boolean
29
+ arrow: boolean
30
+ arrowRef: React.Ref<HTMLDivElement>
31
+ arrowX?: number
32
+ arrowY?: number
33
+ originX?: number
34
+ originY?: number
35
+ padding?: number | number[]
36
+ placement?: Placement
37
+ radius?: Radius | Radius[]
38
+ scheme?: ThemeColorSchemeKey
39
+ shadow?: number | number[]
40
+ } & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'height' | 'width'>,
41
+ ref: React.ForwardedRef<HTMLDivElement>,
42
+ ) {
43
+ const {
44
+ animate,
45
+ arrow,
46
+ arrowRef,
47
+ arrowX,
48
+ arrowY,
49
+ children,
50
+ originX,
51
+ originY,
52
+ padding,
53
+ placement,
54
+ radius,
55
+ scheme,
56
+ shadow,
57
+ style,
58
+ ...restProps
59
+ } = props
60
+
61
+ const rootStyle: CSSProperties = useMemo(
62
+ () => ({
63
+ originX,
64
+ originY,
65
+ willChange: animate ? 'transform' : undefined,
66
+ ...style,
67
+ }),
68
+ [animate, originX, originY, style],
69
+ )
70
+
71
+ const arrowStyle: CSSProperties = useMemo(
72
+ () => ({
73
+ left: arrowX !== null ? arrowX : undefined,
74
+ top: arrowY !== null ? arrowY : undefined,
75
+ right: undefined,
76
+ bottom: undefined,
77
+ }),
78
+ [arrowX, arrowY],
79
+ )
80
+
81
+ return (
82
+ <MotionCard
83
+ data-ui="Tooltip__card"
84
+ {...(restProps as CardProps & MotionProps)}
85
+ data-placement={placement}
86
+ padding={padding}
87
+ radius={radius}
88
+ ref={ref}
89
+ scheme={scheme}
90
+ shadow={shadow}
91
+ style={rootStyle}
92
+ {...(animate ? POPOVER_MOTION_PROPS : {})}
93
+ >
94
+ {children}
95
+
96
+ {arrow && (
97
+ <Arrow
98
+ ref={arrowRef}
99
+ style={arrowStyle}
100
+ width={DEFAULT_TOOLTIP_ARROW_WIDTH}
101
+ height={DEFAULT_TOOLTIP_ARROW_HEIGHT}
102
+ radius={DEFAULT_TOOLTIP_ARROW_RADIUS}
103
+ />
104
+ )}
105
+ </MotionCard>
106
+ )
107
+ }),
108
+ )
109
+
110
+ TooltipCard.displayName = 'TooltipCard'
@@ -12,6 +12,8 @@ export function _cardColorStyle(
12
12
  return {
13
13
  // from base
14
14
 
15
+ '--card-backdrop-color': base.backdrop,
16
+
15
17
  '--card-focus-ring-color': base.focusRing,
16
18
 
17
19
  '--card-shadow-outline-color': base.shadow.outline,
@@ -195,9 +195,10 @@ export function textInputRepresentationStyle(
195
195
  }
196
196
 
197
197
  /* disabled */
198
- *:disabled + & {
198
+ *:not(:invalid):disabled + & {
199
199
  --card-bg-color: ${color.input.default.disabled.bg} !important;
200
200
  --card-fg-color: ${color.input.default.disabled.fg} !important;
201
+ --card-icon-color: ${color.input.default.disabled.fg} !important;
201
202
 
202
203
  &[data-border] {
203
204
  --input-box-shadow: ${focusRingBorderStyle({
@@ -207,12 +208,30 @@ export function textInputRepresentationStyle(
207
208
  }
208
209
  }
209
210
 
211
+ *:invalid:disabled + & {
212
+ --card-bg-color: ${color.input.invalid.disabled.bg} !important;
213
+ --card-fg-color: ${color.input.invalid.disabled.fg} !important;
214
+ --card-icon-color: ${color.input.invalid.disabled.fg} !important;
215
+
216
+ &[data-border] {
217
+ --input-box-shadow: ${focusRingBorderStyle({
218
+ color: color.input.invalid.disabled.border,
219
+ width: input.border.width,
220
+ })};
221
+ }
222
+ }
223
+
210
224
  /* readOnly */
211
- *:read-only + & {
225
+ *:not(:invalid):read-only + & {
212
226
  --card-bg-color: ${color.input.default.readOnly.bg} !important;
213
227
  --card-fg-color: ${color.input.default.readOnly.fg} !important;
214
228
  }
215
229
 
230
+ *:invalid:read-only + & {
231
+ --card-bg-color: ${color.input.invalid.readOnly.bg} !important;
232
+ --card-fg-color: ${color.input.invalid.readOnly.fg} !important;
233
+ }
234
+
216
235
  /* hovered */
217
236
  @media (hover: hover) {
218
237
  *:not(:disabled):not(:read-only):not(:invalid):hover + & {
@@ -220,12 +239,24 @@ export function textInputRepresentationStyle(
220
239
  --card-fg-color: ${color.input.default.hovered.fg};
221
240
  }
222
241
 
242
+ *:invalid:not(:disabled):not(:read-only):hover + & {
243
+ --card-bg-color: ${color.input.invalid.hovered.bg};
244
+ --card-fg-color: ${color.input.invalid.hovered.fg};
245
+ }
246
+
223
247
  *:not(:disabled):not(:read-only):not(:invalid):not(:focus):hover + &[data-border] {
224
248
  --input-box-shadow: ${focusRingBorderStyle({
225
249
  color: color.input.default.hovered.border,
226
250
  width: input.border.width,
227
251
  })};
228
252
  }
253
+
254
+ *:invalid:not(:disabled):not(:read-only):not(:focus):hover + &[data-border] {
255
+ --input-box-shadow: ${focusRingBorderStyle({
256
+ color: color.input.invalid.hovered.border,
257
+ width: input.border.width,
258
+ })};
259
+ }
229
260
  }
230
261
  }
231
262
  `
@@ -1,9 +1,9 @@
1
1
  /** @jest-environment jsdom */
2
2
 
3
- import {getScopedTheme, defaultTheme} from '@sanity/ui/theme'
3
+ import {buildTheme, getScopedTheme} from '@sanity/ui/theme'
4
4
  import {responsiveMarginStyle} from './marginStyle'
5
5
 
6
- const theme = getScopedTheme(defaultTheme, 'light', 'default')
6
+ const theme = getScopedTheme(buildTheme(), 'light', 'default')
7
7
 
8
8
  describe('styles/margin', () => {
9
9
  it('should 1', () => {
@@ -1,9 +1,9 @@
1
1
  /** @jest-environment jsdom */
2
2
 
3
- import {getScopedTheme, defaultTheme} from '@sanity/ui/theme'
3
+ import {buildTheme, getScopedTheme} from '@sanity/ui/theme'
4
4
  import {responsivePaddingStyle} from './paddingStyle'
5
5
 
6
- const theme = getScopedTheme(defaultTheme, 'light', 'default')
6
+ const theme = getScopedTheme(buildTheme(), 'light', 'default')
7
7
 
8
8
  describe('styles/padding', () => {
9
9
  it('should 1', () => {
@@ -159,6 +159,7 @@ export const Root = styled.div((props) => {
159
159
  --link-fg: var(--card-enabled-link-fg);
160
160
  --code-bg: var(--card-enabled-code-bg);
161
161
  --code-fg: var(--card-enabled-code-fg);
162
+ --kbd-bg: var(--card-enabled-kbd-bg);
162
163
  --skeleton-from: var(--card-enabled-skeleton-from);
163
164
  --skeleton-to: var(--card-enabled-skeleton-to);
164
165
 
@@ -322,15 +323,15 @@ export const Root = styled.div((props) => {
322
323
  color: var(--icon);
323
324
  }
324
325
 
325
- .muted-fg {
326
+ .muted {
326
327
  color: var(--muted-fg);
327
328
  }
328
329
 
329
- .accent-fg {
330
+ .accent {
330
331
  color: var(--accent-fg);
331
332
  }
332
333
 
333
- .link-fg {
334
+ .link {
334
335
  color: var(--link-fg);
335
336
  }
336
337
 
@@ -339,6 +340,22 @@ export const Root = styled.div((props) => {
339
340
  color: var(--code-fg);
340
341
  }
341
342
 
343
+ .kbd {
344
+ background-color: var(--kbd-bg);
345
+ color: var(--kbd-fg);
346
+ }
347
+
348
+ .badge {
349
+ background-color: var(--badge-bg);
350
+ color: var(--badge-fg);
351
+ }
352
+
353
+ .badge--default {
354
+ --badge-bg: var(--badge-default-bg);
355
+ --badge-fg: var(--badge-default-fg);
356
+ --badge-border: var(--badge-default-border);
357
+ }
358
+
342
359
  .skeleton-from {
343
360
  color: var(--skeleton-from);
344
361
  }
@@ -1,27 +1,27 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
 
3
3
  import {
4
- ThemeColorButtonStates_v2,
4
+ ThemeColorButtonTone_v2,
5
5
  ThemeColorCard_v2,
6
- ThemeColorInputStates_v2,
6
+ ThemeColorInputMode_v2,
7
7
  ThemeColorState_v2,
8
8
  } from '@sanity/ui/theme'
9
9
  import {
10
- THEME_COLOR_CARD_TONES,
11
10
  THEME_COLOR_BUTTON_MODES,
11
+ THEME_COLOR_CARD_TONES,
12
12
  THEME_COLOR_INPUT_MODES,
13
13
  THEME_COLOR_STATE_TONES,
14
14
  ThemeColorCardToneKey,
15
15
  ThemeColorInputModeKey,
16
16
  } from '@sanity/ui/theme'
17
- import {defaultTheme} from '@sanity/ui/theme'
17
+ import {buildTheme} from '@sanity/ui/theme'
18
18
  import {ReactElement} from 'react'
19
19
  import {rem} from '../../../styles'
20
20
  import {useTheme_v2} from '../../useTheme'
21
21
  import {getCSSProps} from './helpers'
22
22
  import {Root} from './Root'
23
23
 
24
- const theme = defaultTheme
24
+ const theme = buildTheme()
25
25
 
26
26
  export default function BuildStory(): ReactElement {
27
27
  return (
@@ -268,7 +268,7 @@ function StatePreview(props: {theme: ThemeColorState_v2}) {
268
268
  )
269
269
  }
270
270
 
271
- function ButtonPreview(props: {theme: ThemeColorButtonStates_v2}) {
271
+ function ButtonPreview(props: {theme: ThemeColorButtonTone_v2}) {
272
272
  const {theme: button} = props
273
273
 
274
274
  return (
@@ -289,18 +289,24 @@ function ButtonPreview(props: {theme: ThemeColorButtonStates_v2}) {
289
289
  <div className="icon" style={{flex: 'none'}}>
290
290
  &copy;
291
291
  </div>
292
- <div className="muted-fg" style={{flex: 'none'}}>
292
+ <div className="muted" style={{flex: 'none'}}>
293
293
  m
294
294
  </div>
295
- <div className="accent-fg" style={{flex: 'none'}}>
295
+ <div className="accent" style={{flex: 'none'}}>
296
296
  a
297
297
  </div>
298
- <div className="link-fg" style={{flex: 'none'}}>
298
+ <div className="link" style={{flex: 'none'}}>
299
299
  l
300
300
  </div>
301
301
  <div className="code" style={{flex: 'none'}}>
302
302
  c
303
303
  </div>
304
+ <div className="kbd" style={{flex: 'none'}}>
305
+ k
306
+ </div>
307
+ <div className="badge badge--default" style={{flex: 'none'}}>
308
+ b
309
+ </div>
304
310
  <div style={{flex: 'none'}}>
305
311
  <CheckeredBackground />
306
312
  </div>
@@ -424,7 +430,7 @@ function Skeleton() {
424
430
  )
425
431
  }
426
432
 
427
- function InputPreview(props: {mode: ThemeColorInputModeKey; theme: ThemeColorInputStates_v2}) {
433
+ function InputPreview(props: {mode: ThemeColorInputModeKey; theme: ThemeColorInputMode_v2}) {
428
434
  const {mode, theme: input} = props
429
435
 
430
436
  return (
@@ -10,14 +10,14 @@ import {
10
10
  useRootTheme,
11
11
  } from '@sanity/ui'
12
12
  import {
13
- ThemeColorButtonStates_v2,
14
- ThemeColorButtonTones_v2,
13
+ ThemeColorButtonMode_v2,
14
+ ThemeColorButtonTone_v2,
15
15
  ThemeColorButton_v2,
16
+ ThemeColorCard_v2,
16
17
  ThemeColorScheme_v2,
17
- ThemeColorSelectableStates_v2,
18
+ ThemeColorSelectableTone_v2,
18
19
  ThemeColorSelectable_v2,
19
20
  ThemeColorState_v2,
20
- ThemeColorCard_v2,
21
21
  getContrastRatio,
22
22
  mix,
23
23
  parseColor,
@@ -202,7 +202,7 @@ function ColorButton(props: {color: ThemeColorButton_v2}) {
202
202
  )
203
203
  }
204
204
 
205
- function ColorButtonMode(props: {color: ThemeColorButtonTones_v2}) {
205
+ function ColorButtonMode(props: {color: ThemeColorButtonMode_v2}) {
206
206
  const {color} = props
207
207
 
208
208
  return (
@@ -243,7 +243,7 @@ function ColorButtonMode(props: {color: ThemeColorButtonTones_v2}) {
243
243
  )
244
244
  }
245
245
 
246
- function ColorGenericStates(props: {color: ThemeColorButtonStates_v2}) {
246
+ function ColorGenericStates(props: {color: ThemeColorButtonTone_v2}) {
247
247
  const {color} = props
248
248
 
249
249
  return (
@@ -335,7 +335,7 @@ function ColorSelectable(props: {color: ThemeColorSelectable_v2}) {
335
335
  )
336
336
  }
337
337
 
338
- function ColorSelectableTone(props: {color: ThemeColorSelectableStates_v2}) {
338
+ function ColorSelectableTone(props: {color: ThemeColorSelectableTone_v2}) {
339
339
  const {color} = props
340
340
 
341
341
  return (