@sanity/ui 2.0.0-alpha.10 → 2.0.0-alpha.12

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 (107) hide show
  1. package/dist/index.cjs.mjs +0 -2
  2. package/dist/index.d.ts +404 -281
  3. package/dist/index.esm.js +2305 -5015
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/index.js +2332 -5044
  6. package/dist/index.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/components/dialog/dialog.tsx +3 -3
  9. package/src/components/dialog/styles.ts +4 -3
  10. package/src/components/menu/__workshop__/closableMenuButton.tsx +2 -2
  11. package/src/components/menu/menuDivider.ts +1 -2
  12. package/src/components/menu/menuGroup.tsx +2 -2
  13. package/src/components/menu/menuItem.tsx +4 -4
  14. package/src/components/skeleton/styles.ts +7 -8
  15. package/src/components/tree/style.ts +20 -19
  16. package/src/primitives/_selectable/style.ts +21 -25
  17. package/src/primitives/avatar/avatar.tsx +3 -8
  18. package/src/primitives/avatar/avatarCounter.tsx +4 -5
  19. package/src/primitives/avatar/styles.ts +7 -5
  20. package/src/primitives/avatar/types.ts +0 -14
  21. package/src/primitives/badge/styles.ts +8 -7
  22. package/src/primitives/box/__workshop__/responsive.tsx +2 -2
  23. package/src/primitives/button/button.tsx +2 -2
  24. package/src/primitives/button/styles.ts +16 -82
  25. package/src/primitives/card/__workshop__/selected.tsx +9 -8
  26. package/src/primitives/card/card.tsx +8 -43
  27. package/src/primitives/card/styles.ts +22 -30
  28. package/src/primitives/card/types.ts +1 -3
  29. package/src/primitives/checkbox/styles.ts +20 -20
  30. package/src/primitives/code/code.tsx +3 -15
  31. package/src/primitives/code/styles.ts +42 -51
  32. package/src/primitives/heading/styles.ts +5 -6
  33. package/src/primitives/kbd/kbd.tsx +1 -2
  34. package/src/primitives/label/styles.ts +2 -3
  35. package/src/primitives/popover/popoverArrow.tsx +2 -3
  36. package/src/primitives/popover/popoverCard.tsx +2 -6
  37. package/src/primitives/radio/styles.ts +15 -15
  38. package/src/primitives/select/styles.ts +22 -20
  39. package/src/primitives/switch/styles.ts +13 -13
  40. package/src/primitives/text/__workshop__/colored.tsx +11 -10
  41. package/src/primitives/text/styles.ts +9 -10
  42. package/src/primitives/textArea/textArea.tsx +11 -7
  43. package/src/primitives/textInput/textInput.tsx +12 -12
  44. package/src/primitives/tooltip/__workshop__/props.tsx +3 -20
  45. package/src/primitives/tooltip/tooltipArrow.tsx +2 -3
  46. package/src/styles/border/borderStyle.ts +1 -2
  47. package/src/styles/colorVars/colorVarsStyle.ts +32 -73
  48. package/src/styles/focusRing/index.ts +4 -6
  49. package/src/styles/input/textInputStyle.ts +93 -76
  50. package/src/styles/margin/marginsStyle.test.ts +2 -1
  51. package/src/styles/padding/paddingStyle.test.ts +2 -1
  52. package/src/styles/shadow/shadowStyle.ts +5 -5
  53. package/src/theme/__workshop__/canvas.tsx +395 -0
  54. package/src/theme/__workshop__/color.tsx +2 -2
  55. package/src/theme/__workshop__/index.ts +5 -0
  56. package/src/theme/lib/theme/color/_generic/index.ts +1 -0
  57. package/src/theme/lib/theme/color/_generic/types.ts +30 -0
  58. package/src/theme/lib/theme/color/base/index.ts +1 -0
  59. package/src/theme/lib/theme/color/base/types.ts +19 -0
  60. package/src/theme/lib/theme/color/button/createButtonModes.ts +20 -0
  61. package/src/theme/lib/theme/color/button/createButtonTones.ts +52 -0
  62. package/src/theme/lib/theme/color/button/index.ts +1 -0
  63. package/src/theme/lib/theme/color/button/types.ts +44 -0
  64. package/src/theme/lib/theme/color/card/createCardStates.ts +58 -0
  65. package/src/theme/lib/theme/color/card/index.ts +1 -0
  66. package/src/theme/lib/theme/color/card/types.ts +18 -0
  67. package/src/theme/lib/theme/color/color.test.ts +63 -0
  68. package/src/theme/lib/theme/color/defaults.ts +390 -0
  69. package/src/theme/lib/theme/color/factory.ts +138 -0
  70. package/src/theme/lib/theme/color/index.ts +12 -3
  71. package/src/theme/lib/theme/color/input/createInputModes.ts +84 -0
  72. package/src/theme/lib/theme/color/input/index.ts +1 -0
  73. package/src/theme/lib/theme/color/input/types.ts +28 -0
  74. package/src/theme/lib/theme/color/muted/createMuted.ts +56 -0
  75. package/src/theme/lib/theme/color/muted/index.ts +1 -0
  76. package/src/theme/lib/theme/color/muted/types.ts +24 -0
  77. package/src/theme/lib/theme/color/selectable/createSelectableTones.ts +73 -0
  78. package/src/theme/lib/theme/color/selectable/index.ts +1 -0
  79. package/src/theme/lib/theme/color/selectable/types.ts +29 -0
  80. package/src/theme/lib/theme/color/solid/createSolidTones.ts +56 -0
  81. package/src/theme/lib/theme/color/solid/index.ts +1 -0
  82. package/src/theme/lib/theme/color/solid/types.ts +24 -0
  83. package/src/theme/lib/theme/color/spot/createSpot.ts +21 -0
  84. package/src/theme/lib/theme/color/spot/index.ts +1 -0
  85. package/src/theme/lib/theme/color/spot/types.ts +28 -0
  86. package/src/theme/lib/theme/color/syntax/index.ts +1 -0
  87. package/src/theme/lib/theme/color/syntax/types.ts +41 -0
  88. package/src/theme/lib/theme/color/types.ts +37 -6
  89. package/src/theme/studioTheme/color.ts +661 -6
  90. package/src/theme/studioTheme/theme.ts +2 -8
  91. package/src/theme/{lib/theme/color/cssVariables → studioTheme}/tints.ts +2 -2
  92. package/src/theme/themeColorProvider.tsx +0 -2
  93. package/src/theme/themeProvider.tsx +8 -28
  94. package/src/theme/types.ts +4 -2
  95. package/src/utils/elementQuery/__workshop__/customMedia.tsx +3 -4
  96. package/src/primitives/avatar/spotColors.ts +0 -53
  97. package/src/theme/lib/theme/color/cssVariables/cardVariables.ts +0 -88
  98. package/src/theme/lib/theme/color/cssVariables/createCssVars.ts +0 -31
  99. package/src/theme/lib/theme/color/cssVariables/cssVars.test.ts +0 -262
  100. package/src/theme/lib/theme/color/cssVariables/index.ts +0 -1
  101. package/src/theme/lib/theme/color/cssVariables/tones.ts +0 -67
  102. package/src/theme/lib/theme/color/cssVariables/utils.test.ts +0 -15
  103. package/src/theme/lib/theme/color/cssVariables/utils.ts +0 -9
  104. package/src/theme/toneContext/toneContext.ts +0 -12
  105. package/src/theme/toneContext/toneProvider.tsx +0 -31
  106. package/src/theme/toneContext/types.ts +0 -10
  107. package/src/theme/toneContext/useToneContext.tsx +0 -26
@@ -13,7 +13,7 @@ import {
13
13
  textInputFontSizeStyle,
14
14
  textInputRepresentationStyle,
15
15
  } from '../../styles/internal'
16
- import {ThemeColorToneKey, ThemeFontWeightKey} from '../../theme'
16
+ import {ThemeFontWeightKey, useRootTheme} from '../../theme'
17
17
  import {ResponsiveRadiusProps} from '../types'
18
18
 
19
19
  /**
@@ -25,7 +25,6 @@ export interface TextAreaProps extends ResponsiveRadiusProps {
25
25
  fontSize?: number | number[]
26
26
  padding?: number | number[]
27
27
  weight?: ThemeFontWeightKey
28
- tone?: ThemeColorToneKey
29
28
  }
30
29
 
31
30
  const Root = styled.span(textInputRootStyle)
@@ -63,12 +62,13 @@ export const TextArea = forwardRef(function TextArea(
63
62
  padding = 3,
64
63
  radius = 2,
65
64
  weight,
66
- tone = 'default',
67
65
  ...restProps
68
66
  } = props
69
67
 
70
68
  const ref = useForwardedRef(forwardedRef)
71
69
 
70
+ const rootTheme = useRootTheme()
71
+
72
72
  useCustomValidity(ref, customValidity)
73
73
 
74
74
  return (
@@ -76,21 +76,25 @@ export const TextArea = forwardRef(function TextArea(
76
76
  <InputRoot>
77
77
  <Input
78
78
  data-as="textarea"
79
- data-tone={tone}
79
+ data-scheme={rootTheme.scheme}
80
+ data-tone={rootTheme.tone}
80
81
  {...restProps}
81
82
  $fontSize={useArrayProp(fontSize)}
82
83
  $padding={useArrayProp(padding)}
84
+ $scheme={rootTheme.scheme}
83
85
  $space={useArrayProp(0)}
84
- $tone={tone}
86
+ $tone={rootTheme.tone}
85
87
  $weight={weight}
86
88
  disabled={disabled}
87
89
  ref={ref}
88
90
  />
89
91
  <Presentation
90
92
  $radius={useArrayProp(radius)}
91
- $tone={tone}
93
+ $scheme={rootTheme.scheme}
94
+ $tone={rootTheme.tone}
92
95
  data-border={border ? '' : undefined}
93
- data-tone={tone}
96
+ data-scheme={rootTheme.scheme}
97
+ data-tone={rootTheme.tone}
94
98
  />
95
99
  </InputRoot>
96
100
  </Root>
@@ -16,8 +16,7 @@ import {
16
16
  textInputRepresentationStyle,
17
17
  textInputRootStyle,
18
18
  } from '../../styles/internal'
19
- import {ThemeColorToneKey, ThemeFontWeightKey} from '../../theme'
20
- import {useToneContext} from '../../theme/toneContext/useToneContext'
19
+ import {ThemeFontWeightKey, useRootTheme} from '../../theme'
21
20
  import {Radius} from '../../types'
22
21
  import {Box} from '../box'
23
22
  import {Button, ButtonProps} from '../button'
@@ -71,7 +70,6 @@ export interface TextInputProps {
71
70
  suffix?: React.ReactNode
72
71
  type?: TextInputType
73
72
  weight?: ThemeFontWeightKey
74
- tone?: ThemeColorToneKey
75
73
  }
76
74
 
77
75
  const CLEAR_BUTTON_BOX_STYLE: React.CSSProperties = {zIndex: 2}
@@ -165,14 +163,12 @@ export const TextInput = forwardRef(function TextInput(
165
163
  customValidity,
166
164
  type = 'text',
167
165
  weight,
168
- tone: toneProp = 'default',
169
166
  ...restProps
170
167
  } = props
171
168
 
172
169
  const ref = useForwardedRef(forwardedRef)
173
170
 
174
- const toneContext = useToneContext()
175
- const tone = toneProp === 'default' ? toneContext.tone : toneProp
171
+ const rootTheme = useRootTheme()
176
172
 
177
173
  const fontSize = useArrayProp(fontSizeProp)
178
174
  const padding = useArrayProp(paddingProp)
@@ -225,9 +221,11 @@ export const TextInput = forwardRef(function TextInput(
225
221
  $hasPrefix={$hasPrefix}
226
222
  $hasSuffix={$hasSuffix}
227
223
  $radius={radius}
228
- $tone={tone}
224
+ $scheme={rootTheme.scheme}
225
+ $tone={rootTheme.tone}
229
226
  data-border={border ? '' : undefined}
230
- data-tone={tone}
227
+ data-scheme={rootTheme.scheme}
228
+ data-tone={rootTheme.tone}
231
229
  >
232
230
  {icon && (
233
231
  <LeftBox padding={padding}>
@@ -255,10 +253,10 @@ export const TextInput = forwardRef(function TextInput(
255
253
  iconRight,
256
254
  padding,
257
255
  radius,
256
+ rootTheme,
258
257
  $hasClearButton,
259
258
  $hasPrefix,
260
259
  $hasSuffix,
261
- tone,
262
260
  ],
263
261
  )
264
262
 
@@ -341,20 +339,22 @@ export const TextInput = forwardRef(function TextInput(
341
339
  )
342
340
 
343
341
  return (
344
- <Root data-ui="TextInput" tone={tone}>
342
+ <Root data-ui="TextInput" tone={rootTheme.tone}>
345
343
  {prefixNode}
346
344
 
347
345
  <InputRoot>
348
346
  <Input
349
347
  data-as="input"
350
- data-tone={tone}
348
+ data-scheme={rootTheme.scheme}
349
+ data-tone={rootTheme.tone}
351
350
  {...restProps}
352
351
  $fontSize={fontSize}
353
352
  $iconLeft={$hasIcon}
354
353
  $iconRight={$hasIconRight || $hasClearButton}
355
354
  $padding={padding}
355
+ $scheme={rootTheme.scheme}
356
356
  $space={space}
357
- $tone={tone}
357
+ $tone={rootTheme.tone}
358
358
  $weight={weight}
359
359
  disabled={disabled}
360
360
  readOnly={readOnly}
@@ -1,13 +1,4 @@
1
- import {
2
- Button,
3
- Card,
4
- Flex,
5
- Text,
6
- Tooltip,
7
- TooltipDelayGroupProvider,
8
- Stack,
9
- cssVars,
10
- } from '@sanity/ui'
1
+ import {Button, Card, Flex, Text, Tooltip, TooltipDelayGroupProvider, Stack} from '@sanity/ui'
11
2
  import {useBoolean, useSelect, useText, useNumber} from '@sanity/ui-workshop'
12
3
  import {
13
4
  WORKSHOP_PLACEMENT_OPTIONS,
@@ -37,11 +28,7 @@ export default function PropsStory() {
37
28
  >
38
29
  <Stack
39
30
  padding={4}
40
- style={{
41
- outline: `1px solid ${cssVars.default['border-base']}`,
42
- width: '100%',
43
- maxWidth: '640px',
44
- }}
31
+ style={{outline: '1px solid var(--card-border-color)', width: '100%', maxWidth: '640px'}}
45
32
  space={4}
46
33
  >
47
34
  <Text align="center" size={3}>
@@ -65,11 +52,7 @@ export default function PropsStory() {
65
52
  </Stack>
66
53
  <Stack
67
54
  padding={4}
68
- style={{
69
- outline: `1px solid ${cssVars.default['border-base']}`,
70
- width: '100%',
71
- maxWidth: '640px',
72
- }}
55
+ style={{outline: '1px solid var(--card-border-color)', width: '100%', maxWidth: '640px'}}
73
56
  space={4}
74
57
  >
75
58
  <Text align="center" size={3}>
@@ -1,6 +1,5 @@
1
1
  import {forwardRef} from 'react'
2
2
  import styled from 'styled-components'
3
- import {cssVars} from '../../theme'
4
3
 
5
4
  const Root = styled.div`
6
5
  position: absolute;
@@ -64,11 +63,11 @@ const Root = styled.div`
64
63
  `
65
64
 
66
65
  const Border = styled.path`
67
- fill: ${cssVars.default['base-shadow-outline-color']};
66
+ fill: var(--card-shadow-outline-color);
68
67
  `
69
68
 
70
69
  const Shape = styled.path`
71
- fill: ${cssVars.mutable['bg-color']};
70
+ fill: var(--card-bg-color);
72
71
  `
73
72
 
74
73
  interface TooltipArrowProps {}
@@ -1,10 +1,9 @@
1
- import {cssVars} from '../../theme'
2
1
  import {CSSObject} from '../../types/styled'
3
2
  import {_responsive} from '../helpers'
4
3
  import {ThemeProps} from '../types'
5
4
  import {ResponsiveBorderStyleProps} from './types'
6
5
 
7
- const BORDER_VALUE = `1px solid ${cssVars.default['border-base']}`
6
+ const BORDER_VALUE = '1px solid var(--card-border-color)'
8
7
 
9
8
  export function responsiveBorderStyle(): Array<
10
9
  (props: ResponsiveBorderStyleProps & ThemeProps) => CSSObject[]
@@ -1,84 +1,43 @@
1
- import {ThemeColorToneKey, cssVars} from '../../theme'
2
- import {mutableCardVariables} from '../../theme/lib/theme/color/cssVariables/cardVariables'
3
- import {getToneCssVar} from '../../theme/lib/theme/color/cssVariables/tones'
1
+ import {ThemeColorBase, ThemeColorGenericState} from '../../theme'
4
2
  import {CSSObject} from '../../types/styled'
5
3
 
6
4
  /**
7
5
  * @internal
8
- * Card overrides in disabled states
9
6
  */
10
- export function _colorVarStyleDisabled(checkered = false): CSSObject {
7
+ export function _colorVarsStyle(
8
+ base: ThemeColorBase,
9
+ color: ThemeColorGenericState,
10
+ checkered = false,
11
+ ): CSSObject {
11
12
  return {
12
- [getToneCssVar('default', 'text-link')]: cssVars.default['text-secondary'],
13
- [getToneCssVar('default', 'text-accent')]: cssVars.default['text-secondary'],
14
- [getToneCssVar('default', 'text-code')]: cssVars.default['text-secondary'],
15
- [getToneCssVar('default', 'text-primary')]: cssVars.default['text-secondary'],
13
+ // Base
14
+ // @todo: rename to "--base-"?
15
+ '--card-shadow-outline-color': base.shadow.outline,
16
+ '--card-shadow-umbra-color': base.shadow.umbra,
17
+ '--card-shadow-penumbra-color': base.shadow.penumbra,
18
+ '--card-shadow-ambient-color': base.shadow.ambient,
19
+ '--card-focus-ring-color': base.focusRing,
20
+ '--card-icon-color': color.iconColor,
16
21
 
17
- [mutableCardVariables['fg-color']]: cssVars.primary['text-secondary'],
18
- [mutableCardVariables['muted-fg-color']]: cssVars.primary['text-secondary'],
19
- [mutableCardVariables['icon-color']]: cssVars.primary['border-base'],
20
- [mutableCardVariables['accent-color']]: cssVars.primary['base-bg-card'],
21
- [mutableCardVariables['bg-color']]: cssVars.primary['bg-tint'],
22
- [mutableCardVariables['bg-image']]: checkered
23
- ? `repeating-conic-gradient(${cssVars.default['base-bg-card']} 0% 25%, ${cssVars.default['bg-tint']} 0% 50%)`
22
+ // Card
23
+ '--card-bg-color': color.bg,
24
+ '--card-bg2-color': color.bg2,
25
+ '--card-bg-image': checkered
26
+ ? `repeating-conic-gradient(${color.bg} 0% 25%, ${color.bg2 || color.bg} 0% 50%)`
24
27
  : undefined,
25
- }
26
- }
27
-
28
- /**
29
- * @internal
30
- * Card overrides in selected states
31
- */
32
- export function _colorVarStyleSelected(): CSSObject {
33
- return {
34
- [mutableCardVariables['bg-color']]: cssVars.default['bg-accent'],
35
- [mutableCardVariables['fg-color']]: cssVars.default['bg-base'],
36
- [mutableCardVariables['muted-fg-color']]: cssVars.default['base-bg-card'],
37
- [mutableCardVariables['accent-color']]: cssVars.default['base-bg-card'],
38
- [mutableCardVariables['icon-color']]: cssVars.primary['bg-base'],
39
- }
40
- }
41
-
42
- /**
43
- * @internal
44
- * Card overrides in hover
45
- */
46
- export function _colorVarStyleHover(): CSSObject {
47
- return {
48
- [mutableCardVariables['bg-color']]: cssVars.default['bg-base-hover'],
49
- [getToneCssVar('default', 'bg-tint')]: cssVars.default['bg-base-active'],
50
- }
51
- }
52
-
53
- /**
54
- * @internal
55
- * Card overrides in active / pressed states
56
- */
57
- export function _colorVarStyleActive(): CSSObject {
58
- return {
59
- [mutableCardVariables['bg-color']]: cssVars.default['bg-base-active'],
60
- }
61
- }
28
+ '--card-fg-color': color.fg,
29
+ '--card-border-color': color.border,
30
+ '--card-muted-fg-color': color.muted?.fg,
31
+ '--card-accent-fg-color': color.accent?.fg,
32
+ '--card-link-fg-color': color.link?.fg,
33
+ '--card-code-bg-color': color.code?.bg,
34
+ '--card-code-fg-color': color.code?.fg,
35
+ '--card-skeleton-color-from': color.skeleton?.from,
36
+ '--card-skeleton-color-to': color.skeleton?.to,
62
37
 
63
- /**
64
- * @internal
65
- * Selectable needs to redefine bg-color and fg-color
66
- */
67
- export function _selectableVarStyle(tone: ThemeColorToneKey): CSSObject {
68
- return {
69
- [mutableCardVariables['bg-color']]: 'inherit',
70
- [mutableCardVariables['fg-color']]:
71
- tone === 'default' ? cssVars.default['text-primary'] : cssVars.default['text-secondary'],
72
- }
73
- }
74
-
75
- /**
76
- * @internal
77
- * Selectable overrides in disabled states, same as card but with different bg-color
78
- */
79
- export function _selectableVarStyleDisabled(): CSSObject {
80
- return {
81
- ..._colorVarStyleDisabled(),
82
- [mutableCardVariables['bg-color']]: undefined,
38
+ // @todo: deprecate
39
+ '--card-link-color': color.link?.fg,
40
+ '--card-hairline-soft-color': color.border,
41
+ '--card-hairline-hard-color': color.border,
83
42
  }
84
43
  }
@@ -1,4 +1,4 @@
1
- import {FocusRing, cssVars} from '../../theme'
1
+ import {FocusRing} from '../../theme'
2
2
 
3
3
  export function focusRingBorderStyle(border: {color: string; width: number}): string {
4
4
  return `inset 0 0 0 ${border.width}px ${border.color}`
@@ -12,15 +12,13 @@ export function focusRingStyle(opts: {
12
12
  const {base, border, focusRing} = opts
13
13
  const focusRingOutsetWidth = focusRing.offset + focusRing.width
14
14
  const focusRingInsetWidth = 0 - focusRing.offset
15
- const bgColor = base ? base.bg : cssVars.mutable['bg-color']
15
+ const bgColor = base ? base.bg : 'var(--card-bg-color)'
16
16
 
17
17
  return [
18
- focusRingInsetWidth > 0 &&
19
- `inset 0 0 0 ${focusRingInsetWidth}px ${cssVars.positive['border-accent']}`,
18
+ focusRingInsetWidth > 0 && `inset 0 0 0 ${focusRingInsetWidth}px var(--card-focus-ring-color)`,
20
19
  border && focusRingBorderStyle(border),
21
20
  focusRingInsetWidth < 0 && `0 0 0 ${0 - focusRingInsetWidth}px ${bgColor}`,
22
- focusRingOutsetWidth > 0 &&
23
- `0 0 0 ${focusRingOutsetWidth}px ${cssVars.positive['border-accent']}`,
21
+ focusRingOutsetWidth > 0 && `0 0 0 ${focusRingOutsetWidth}px var(--card-focus-ring-color)`,
24
22
  ]
25
23
  .filter(Boolean)
26
24
  .join(',')
@@ -1,7 +1,6 @@
1
1
  import {css} from 'styled-components'
2
- import {ThemeColorToneKey, ThemeFontWeightKey} from '../../theme'
3
- import {mutableCardVariables} from '../../theme/lib/theme/color/cssVariables/cardVariables'
4
- import {cssVars} from '../../theme/lib/theme/color/cssVariables/createCssVars'
2
+ import {ThemeColorSchemeKey, ThemeFontWeightKey} from '../../theme'
3
+ import {CardTone} from '../../types'
5
4
  import {CSSObject} from '../../types/styled'
6
5
  import {focusRingBorderStyle, focusRingStyle} from '../focusRing'
7
6
  import {rem, _responsive} from '../helpers'
@@ -12,7 +11,8 @@ import {ThemeProps} from '../types'
12
11
  */
13
12
  export interface TextInputInputStyleProps {
14
13
  $fontSize: number[]
15
- $tone: ThemeColorToneKey
14
+ $scheme: ThemeColorSchemeKey
15
+ $tone: CardTone
16
16
  $weight?: ThemeFontWeightKey
17
17
  }
18
18
 
@@ -22,7 +22,8 @@ export interface TextInputInputStyleProps {
22
22
  export interface TextInputRepresentationStyleProps {
23
23
  $hasPrefix?: boolean
24
24
  $hasSuffix?: boolean
25
- $tone: ThemeColorToneKey
25
+ $scheme: ThemeColorSchemeKey
26
+ $tone: CardTone
26
27
  }
27
28
 
28
29
  const ROOT_STYLE = css`
@@ -40,8 +41,9 @@ export function textInputRootStyle(): ReturnType<typeof css> {
40
41
  export function textInputBaseStyle(
41
42
  props: TextInputInputStyleProps & ThemeProps,
42
43
  ): ReturnType<typeof css> {
43
- const {theme, $tone, $weight} = props
44
+ const {theme, $scheme, $tone, $weight} = props
44
45
  const font = theme.sanity.fonts.text
46
+ const color = theme.sanity.color.input
45
47
 
46
48
  return css`
47
49
  appearance: none;
@@ -79,31 +81,33 @@ export function textInputBaseStyle(
79
81
  color: var(--input-placeholder-color);
80
82
  }
81
83
 
82
- --input-fg-color: ${cssVars[$tone]['text-primary']};
83
- --input-placeholder-color: ${cssVars[$tone]['text-inactive']};
84
+ &[data-scheme='${$scheme}'][data-tone='${$tone}'] {
85
+ --input-fg-color: ${color.default.enabled.fg};
86
+ --input-placeholder-color: ${color.default.enabled.placeholder};
84
87
 
85
- /* enabled */
86
- &:not(:invalid):not(:disabled):not(:read-only) {
87
- --input-fg-color: ${cssVars[$tone]['text-primary']};
88
- --input-placeholder-color: ${cssVars[$tone]['text-inactive']};
89
- }
88
+ /* enabled */
89
+ &:not(:invalid):not(:disabled):not(:read-only) {
90
+ --input-fg-color: ${color.default.enabled.fg};
91
+ --input-placeholder-color: ${color.default.enabled.placeholder};
92
+ }
90
93
 
91
- /* disabled */
92
- &:not(:invalid):disabled {
93
- --input-fg-color: ${cssVars[$tone]['text-primary']};
94
- --input-placeholder-color: ${cssVars[$tone]['text-inactive']};
95
- }
94
+ /* disabled */
95
+ &:not(:invalid):disabled {
96
+ --input-fg-color: ${color.default.disabled.fg};
97
+ --input-placeholder-color: ${color.default.disabled.placeholder};
98
+ }
96
99
 
97
- /* invalid */
98
- &:invalid {
99
- --input-fg-color: ${cssVars.critical['text-primary']};
100
- --input-placeholder-color: ${cssVars.critical['text-inactive']};
101
- }
100
+ /* invalid */
101
+ &:invalid {
102
+ --input-fg-color: ${color.invalid.enabled.fg};
103
+ --input-placeholder-color: ${color.invalid.enabled.placeholder};
104
+ }
102
105
 
103
- /* readOnly */
104
- &:read-only {
105
- --input-fg-color: ${cssVars[$tone]['text-primary']};
106
- --input-placeholder-color: ${cssVars[$tone]['text-inactive']};
106
+ /* readOnly */
107
+ &:read-only {
108
+ --input-fg-color: ${color.default.readOnly.fg};
109
+ --input-placeholder-color: ${color.default.readOnly.placeholder};
110
+ }
107
111
  }
108
112
  `
109
113
  }
@@ -125,9 +129,10 @@ export function textInputFontSizeStyle(props: TextInputInputStyleProps & ThemePr
125
129
  export function textInputRepresentationStyle(
126
130
  props: TextInputRepresentationStyleProps & ThemeProps,
127
131
  ): ReturnType<typeof css> {
128
- const {$hasPrefix, $hasSuffix, $tone, theme} = props
132
+ const {$hasPrefix, $hasSuffix, $scheme, $tone, theme} = props
129
133
  const {input} = theme.sanity
130
134
  const {focusRing} = input.text
135
+ const color = theme.sanity.color.input
131
136
 
132
137
  return css`
133
138
  --input-box-shadow: none;
@@ -141,7 +146,7 @@ export function textInputRepresentationStyle(
141
146
  pointer-events: none;
142
147
  z-index: 0;
143
148
 
144
- background-color: ${cssVars.mutable['bg-color']};
149
+ background-color: var(--card-bg-color);
145
150
  box-shadow: var(--input-box-shadow);
146
151
 
147
152
  border-top-left-radius: ${$hasPrefix ? 0 : undefined};
@@ -149,66 +154,78 @@ export function textInputRepresentationStyle(
149
154
  border-top-right-radius: ${$hasSuffix ? 0 : undefined};
150
155
  border-bottom-right-radius: ${$hasSuffix ? 0 : undefined};
151
156
 
152
- ${mutableCardVariables['bg-color']}: ${cssVars[$tone]['bg-base']};
153
- ${mutableCardVariables['fg-color']}: ${cssVars[$tone]['text-primary']};
154
-
155
- /* enabled */
156
- &[data-border] {
157
- --input-box-shadow: ${focusRingBorderStyle({
158
- color: cssVars[$tone]['border-base'],
159
- width: input.border.width,
160
- })};
161
- }
157
+ &[data-scheme='${$scheme}'][data-tone='${$tone}'] {
158
+ --card-bg-color: ${color.default.enabled.bg};
159
+ --card-fg-color: ${color.default.enabled.fg};
162
160
 
163
- /* invalid */
164
- *:not(:disabled):invalid + & {
165
- ${mutableCardVariables['bg-color']}: ${cssVars.critical['bg-tint']};
166
- ${mutableCardVariables['fg-color']}: ${cssVars.critical['text-primary']};
167
-
168
- &[data-border] {
161
+ /* enabled */
162
+ *:not(:disabled) + &[data-border] {
169
163
  --input-box-shadow: ${focusRingBorderStyle({
170
- color: cssVars.critical['border-base'],
164
+ color: color.default.enabled.border,
171
165
  width: input.border.width,
172
166
  })};
173
167
  }
174
- }
175
168
 
176
- /* focused */
177
- *:not(:disabled):focus + & {
178
- &[data-border] {
179
- --input-box-shadow: ${focusRingStyle({
180
- border: {color: cssVars[$tone]['border-base'], width: input.border.width},
181
- focusRing,
182
- })};
169
+ /* invalid */
170
+ *:not(:disabled):invalid + & {
171
+ --card-bg-color: ${color.invalid.enabled.bg};
172
+ --card-fg-color: ${color.invalid.enabled.fg};
173
+
174
+ &[data-border] {
175
+ --input-box-shadow: ${focusRingBorderStyle({
176
+ color: color.invalid.enabled.border,
177
+ width: input.border.width,
178
+ })};
179
+ }
183
180
  }
184
181
 
185
- &:not([data-border]) {
186
- --input-box-shadow: ${focusRingStyle({focusRing})};
182
+ /* focused */
183
+ *:not(:disabled):focus + & {
184
+ &[data-border] {
185
+ --input-box-shadow: ${focusRingStyle({
186
+ border: {color: color.default.enabled.border, width: input.border.width},
187
+ focusRing,
188
+ })};
189
+ }
190
+
191
+ &:not([data-border]) {
192
+ --input-box-shadow: ${focusRingStyle({focusRing})};
193
+ }
187
194
  }
188
- }
189
-
190
- /* disabled */
191
- *:disabled + & {
192
- ${mutableCardVariables['bg-color']}: ${cssVars.default['bg-tint']} !important;
193
- ${mutableCardVariables['fg-color']}: ${cssVars.default['text-primary']} !important;
194
- }
195
195
 
196
- /* readOnly */
197
- *:read-only + & {
198
- ${mutableCardVariables['bg-color']}: ${cssVars.default['bg-tint']} !important;
199
- ${mutableCardVariables['fg-color']}: ${cssVars.default['text-primary']} !important;
200
- }
196
+ /* disabled */
197
+ *:disabled + & {
198
+ --card-bg-color: ${color.default.disabled.bg} !important;
199
+ --card-fg-color: ${color.default.disabled.fg} !important;
200
+
201
+ &[data-border] {
202
+ --input-box-shadow: ${focusRingBorderStyle({
203
+ color: color.default.disabled.border,
204
+ width: input.border.width,
205
+ })};
206
+ }
207
+ }
201
208
 
202
- /* hovered */
203
- @media (hover: hover) {
209
+ /* readOnly */
210
+ *:read-only + & {
211
+ --card-bg-color: ${color.default.readOnly.bg} !important;
212
+ --card-fg-color: ${color.default.readOnly.fg} !important;
213
+ }
204
214
 
205
- *:not(:disabled):not(:read-only):not(:invalid):not(:focus):hover + &[data-border] {
206
- --input-box-shadow: ${focusRingBorderStyle({
207
- color: cssVars.default['border-base-hover'],
208
- width: input.border.width,
209
- })};
215
+ /* hovered */
216
+ @media (hover: hover) {
217
+ *:not(:disabled):not(:read-only):not(:invalid):hover + & {
218
+ --card-bg-color: ${color.default.hovered.bg};
219
+ --card-fg-color: ${color.default.hovered.fg};
220
+ }
221
+
222
+ *:not(:disabled):not(:read-only):not(:invalid):not(:focus):hover + &[data-border] {
223
+ --input-box-shadow: ${focusRingBorderStyle({
224
+ color: color.default.hovered.border,
225
+ width: input.border.width,
226
+ })};
227
+ }
210
228
  }
211
229
  }
212
- }
213
230
  `
214
231
  }
@@ -3,7 +3,8 @@
3
3
  import {studioTheme, Theme} from '../../theme'
4
4
  import {responsiveMarginStyle} from './marginStyle'
5
5
 
6
- const theme: Theme = {sanity: studioTheme}
6
+ const {color, ...restTheme} = studioTheme
7
+ const theme: Theme = {sanity: {...restTheme, color: color.light.default}}
7
8
 
8
9
  describe('styles/margin', () => {
9
10
  it('should 1', () => {
@@ -3,7 +3,8 @@
3
3
  import {studioTheme, Theme} from '../../theme'
4
4
  import {responsivePaddingStyle} from './paddingStyle'
5
5
 
6
- const theme: Theme = {sanity: studioTheme}
6
+ const {color, ...restTheme} = studioTheme
7
+ const theme: Theme = {sanity: {...restTheme, color: color.light.default}}
7
8
 
8
9
  describe('styles/padding', () => {
9
10
  it('should 1', () => {
@@ -1,5 +1,5 @@
1
1
  import {EMPTY_RECORD} from '../../constants'
2
- import {BoxShadow, ThemeShadow, cssVars} from '../../theme'
2
+ import {BoxShadow, ThemeShadow} from '../../theme'
3
3
  import {CSSObject} from '../../types/styled'
4
4
  import {rem, _responsive} from '../helpers'
5
5
  import {ThemeProps} from '../types'
@@ -12,10 +12,10 @@ function toBoxShadow(shadow: BoxShadow, color: string) {
12
12
  function shadowStyle(shadow: ThemeShadow | null): CSSObject {
13
13
  if (!shadow) return EMPTY_RECORD
14
14
 
15
- const outline = `0 0 0 ${rem(1)} ${cssVars.default['base-shadow-outline-color']}`
16
- const umbra = toBoxShadow(shadow.umbra, cssVars.default['base-shadow-umbra-color'])
17
- const penumbra = toBoxShadow(shadow.penumbra, cssVars.default['base-shadow-penumbra-color'])
18
- const ambient = toBoxShadow(shadow.ambient, cssVars.default['base-shadow-ambient-color'])
15
+ const outline = `0 0 0 ${rem(1)} var(--card-shadow-outline-color)`
16
+ const umbra = toBoxShadow(shadow.umbra, 'var(--card-shadow-umbra-color)')
17
+ const penumbra = toBoxShadow(shadow.penumbra, 'var(--card-shadow-penumbra-color)')
18
+ const ambient = toBoxShadow(shadow.ambient, 'var(--card-shadow-ambient-color)')
19
19
 
20
20
  return {boxShadow: `${outline}, ${umbra}, ${penumbra}, ${ambient}`}
21
21
  }