@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
@@ -1,9 +1,7 @@
1
1
  import {css} from 'styled-components'
2
2
  import {ThemeProps} from '../../styles'
3
+ import {_colorVarsStyle} from '../../styles/colorVars'
3
4
  import {focusRingBorderStyle, focusRingStyle} from '../../styles/internal'
4
- import {mutableCardVariables} from '../../theme/lib/theme/color/cssVariables/cardVariables'
5
- import {cssVars} from '../../theme/lib/theme/color/cssVariables/createCssVars'
6
- import {getToneCssVar} from '../../theme/lib/theme/color/cssVariables/tones'
7
5
  import {ButtonMode, ButtonTone} from '../../types'
8
6
  import {CSSObject} from '../../types/styled'
9
7
 
@@ -56,65 +54,21 @@ function combineBoxShadow(...boxShadows: (string | undefined)[]): string {
56
54
  export function buttonColorStyles(
57
55
  props: {$mode: ButtonMode; $tone: ButtonTone} & ThemeProps,
58
56
  ): CSSObject[] {
59
- const {$mode, theme, $tone} = props
57
+ const {$mode, theme} = props
60
58
  const {focusRing} = theme.sanity.button
61
59
  const shadow = props.$mode !== 'bleed'
62
- const border = {
63
- width: buttonTheme.border.width,
64
- color:
65
- $mode === 'default'
66
- ? cssVars[$tone]['bg-accent']
67
- : $mode === 'ghost'
68
- ? cssVars[$tone]['border-base']
69
- : cssVars[$tone]['bg-base'],
70
- }
60
+ const base = theme.sanity.color.base
61
+ const mode = theme.sanity.color.button[$mode] || theme.sanity.color.button.default
62
+ const color = mode[props.$tone] || mode.default
63
+ const border = {width: buttonTheme.border.width, color: 'var(--card-border-color)'}
71
64
 
72
65
  return [
66
+ _colorVarsStyle(base, color.enabled),
73
67
  {
74
- // This is going to be used by the text elements inside the button
75
- [mutableCardVariables['fg-color']]:
76
- $mode === 'default' ? cssVars[$tone]['base-text-color'] : cssVars[$tone]['text-primary'],
77
- [mutableCardVariables['muted-fg-color']]:
78
- $mode === 'default' ? cssVars[$tone]['base-text-color'] : cssVars[$tone]['text-secondary'],
79
- [mutableCardVariables['icon-color']]:
80
- $mode === 'default' ? cssVars[$tone]['icon-inverted'] : cssVars[$tone]['icon-default'],
81
- [mutableCardVariables['bg-color']]:
82
- $mode === 'default' ? cssVars[$tone]['bg-accent'] : cssVars[$tone]['bg-base'],
83
-
84
- // Override the default variables for elements used inside buttons
85
- [getToneCssVar('default', 'bg-tint-code')]:
86
- $mode === 'default' ? cssVars[$tone]['bg-accent'] : cssVars[$tone]['bg-tint-code'],
87
- ...($mode === 'default' && {
88
- [getToneCssVar('default', 'text-code')]: cssVars[$tone]['base-text-color'],
89
- [getToneCssVar('default', 'text-code')]: cssVars[$tone]['base-text-color'],
90
- [getToneCssVar('default', 'text-link')]: cssVars[$tone]['base-text-color'],
91
- [getToneCssVar('default', 'text-accent')]: cssVars[$tone]['base-text-color'],
92
- }),
93
-
94
- '&:disabled, &[data-disabled="true"]': {
95
- /* Updates the variables for the */
96
- [mutableCardVariables['fg-color']]: cssVars.primary['text-inactive'],
97
- [mutableCardVariables['muted-fg-color']]: cssVars.primary['text-inactive'],
98
- [mutableCardVariables['icon-color']]: cssVars.primary['border-base'],
99
- [mutableCardVariables['bg-color']]:
100
- $mode === 'default' ? cssVars.primary['bg-tint'] : cssVars.default['bg-base'],
101
- },
102
- },
103
- {
104
- backgroundColor:
105
- $mode === 'default' ? cssVars[$tone]['bg-accent'] : cssVars[$tone]['bg-base'],
106
- color:
107
- $mode === 'default' ? cssVars[$tone]['base-text-color'] : cssVars[$tone]['text-primary'],
68
+ backgroundColor: 'var(--card-bg-color)',
69
+ color: 'var(--card-fg-color)',
108
70
  boxShadow: focusRingBorderStyle(border),
109
- '&:disabled, &[data-disabled="true"]': {
110
- backgroundColor:
111
- $mode === 'default' ? cssVars.primary['bg-tint'] : cssVars.default['bg-base'],
112
- color: cssVars.primary['text-inactive'],
113
- boxShadow: focusRingBorderStyle({
114
- ...border,
115
- color: $mode === 'default' ? cssVars.primary['bg-tint'] : cssVars.primary['border-base'],
116
- }),
117
- },
71
+ '&:disabled, &[data-disabled="true"]': _colorVarsStyle(base, color.disabled),
118
72
  "&:not([data-disabled='true'])": {
119
73
  boxShadow: combineBoxShadow(
120
74
  focusRingBorderStyle(border),
@@ -122,8 +76,8 @@ export function buttonColorStyles(
122
76
  ),
123
77
  '&:focus': {
124
78
  boxShadow: focusRingStyle({
125
- base: {bg: cssVars.positive['border-accent']},
126
- border: {width: 2, color: cssVars.default['bg-base']},
79
+ base,
80
+ border: {width: 2, color: base.bg},
127
81
  focusRing,
128
82
  }),
129
83
  },
@@ -134,31 +88,11 @@ export function buttonColorStyles(
134
88
  ),
135
89
  },
136
90
  '@media (hover: hover)': {
137
- '&:hover': {
138
- backgroundColor:
139
- $mode === 'default'
140
- ? cssVars[$tone]['bg-accent-hover']
141
- : cssVars[$tone]['bg-base-hover'],
142
- },
143
- '&:active': {
144
- backgroundColor:
145
- $mode === 'default'
146
- ? cssVars[$tone]['bg-accent-active']
147
- : cssVars[$tone]['bg-base-active'],
148
- },
149
- '&[data-hovered]': {
150
- backgroundColor:
151
- $mode === 'default'
152
- ? cssVars[$tone]['bg-accent-hover']
153
- : cssVars[$tone]['bg-base-hover'],
154
- },
155
- },
156
- '&[data-selected]': {
157
- backgroundColor:
158
- $mode === 'default'
159
- ? cssVars[$tone]['bg-accent-active']
160
- : cssVars[$tone]['bg-base-active'],
91
+ '&:hover': _colorVarsStyle(base, color.hovered),
92
+ '&:active': _colorVarsStyle(base, color.pressed),
93
+ '&[data-hovered]': _colorVarsStyle(base, color.hovered),
161
94
  },
95
+ '&[data-selected]': _colorVarsStyle(base, color.pressed),
162
96
  },
163
97
  },
164
98
  theme.sanity.styles?.button?.root,
@@ -7,30 +7,31 @@ import {
7
7
  Inline,
8
8
  Stack,
9
9
  Text,
10
+ Theme,
10
11
  ThemeColorToneKey,
11
12
  useRootTheme,
12
13
  } from '@sanity/ui'
13
14
  import {useBoolean} from '@sanity/ui-workshop'
14
15
  import styled, {css} from 'styled-components'
15
- import {mutableCardVariables} from '../../../theme/lib/theme/color/cssVariables/cardVariables'
16
- import {cssVars} from '../../../theme/lib/theme/color/cssVariables/createCssVars'
17
16
 
18
17
  const TextWithTone = styled(Text)<{$tone: ThemeColorToneKey}>(({
19
18
  $tone,
19
+ theme,
20
20
  }: {
21
21
  $tone: ThemeColorToneKey
22
+ theme: Theme
22
23
  }) => {
24
+ const tone = theme.sanity.color.solid[$tone]
25
+
23
26
  return css`
24
27
  &:not([data-selected]) {
25
- ${mutableCardVariables['fg-color']}: ${$tone ? cssVars[$tone]['text-secondary'] : undefined};
26
- ${mutableCardVariables['muted-fg-color']} ${$tone
27
- ? cssVars[$tone]['text-secondary']
28
- : undefined};
28
+ --card-fg-color: ${tone ? tone.enabled.bg : undefined};
29
+ --card-muted-fg-color: ${tone ? tone.enabled.bg : undefined};
29
30
  }
30
31
 
31
32
  [data-ui='Card']:disabled & {
32
- ${mutableCardVariables['fg-color']}: inherit;
33
- ${mutableCardVariables['muted-fg-color']} inherit;
33
+ --card-fg-color: inherit;
34
+ --card-muted-fg-color: inherit;
34
35
  }
35
36
  `
36
37
  })
@@ -10,9 +10,7 @@ import {
10
10
  responsiveShadowStyle,
11
11
  ResponsiveShadowStyleProps,
12
12
  } from '../../styles/internal'
13
- import {ThemeColorName, ThemeColorSchemeKey} from '../../theme'
14
- import {ToneProvider} from '../../theme/toneContext/toneProvider'
15
- import {useToneContext} from '../../theme/toneContext/useToneContext'
13
+ import {ThemeColorProvider, ThemeColorSchemeKey, useRootTheme} from '../../theme'
16
14
  import {CardTone} from '../../types'
17
15
  import {Box, BoxProps} from '../box'
18
16
  import {ResponsiveBorderProps, ResponsiveRadiusProps, ResponsiveShadowProps} from '../types'
@@ -40,12 +38,6 @@ export interface CardProps
40
38
  pressed?: boolean
41
39
  scheme?: ThemeColorSchemeKey
42
40
  tone?: CardTone
43
- /**
44
- * @internal
45
- * Used by the popover, as it creates a new html element that it's ouside of the previous scope of the card.
46
- * So if it's inheriting styles from the parent, it needs to create a new cars context
47
- */
48
- updateCssVars?: boolean
49
41
  }
50
42
 
51
43
  const Root = styled(Box)<
@@ -55,29 +47,6 @@ const Root = styled(Box)<
55
47
  ResponsiveShadowStyleProps
56
48
  >(responsiveBorderStyle, responsiveRadiusStyle, responsiveShadowStyle, cardStyle)
57
49
 
58
- const Wrapper = ({
59
- shouldAddContext,
60
- scheme,
61
- tone,
62
- children,
63
- }: {
64
- shouldAddContext: boolean
65
- scheme: ThemeColorSchemeKey
66
- tone: ThemeColorName
67
- children: React.ReactElement
68
- }): React.ReactElement => {
69
- // Avoid creating a new react context if the card is just inheriting styles from the parent.
70
- if (shouldAddContext) {
71
- return (
72
- <ToneProvider scheme={scheme} tone={tone}>
73
- {children}
74
- </ToneProvider>
75
- )
76
- }
77
-
78
- return children
79
- }
80
-
81
50
  /**
82
51
  * @public
83
52
  */
@@ -96,28 +65,25 @@ export const Card = forwardRef(function Card(
96
65
  borderLeft,
97
66
  pressed,
98
67
  radius = 0,
99
- scheme: schemeProp,
68
+ scheme,
100
69
  selected,
101
70
  shadow,
102
71
  tone: toneProp = 'default',
103
- updateCssVars = false,
104
72
  ...restProps
105
73
  } = props
106
74
 
107
75
  const as = isValidElementType(asProp) ? asProp : 'div'
108
- const toneContext = useToneContext()
109
- const tone = toneProp === 'inherit' ? toneContext.tone : toneProp
110
- const scheme = schemeProp ?? toneContext.scheme
111
- const shouldAddContext = scheme !== toneContext.scheme || tone !== toneContext.tone
76
+ const rootTheme = useRootTheme()
77
+ const tone = toneProp === 'inherit' ? rootTheme.tone : toneProp
112
78
 
79
+ // TODO: Consider adding the wrapper approach for nested cards in which the tones are not changing, avoid unnecessary ThemeColorProvider
113
80
  return (
114
- <Wrapper shouldAddContext={shouldAddContext} scheme={scheme} tone={tone}>
81
+ <ThemeColorProvider scheme={scheme} tone={tone}>
115
82
  <Root
116
83
  data-as={typeof as === 'string' ? as : undefined}
117
- data-scheme={scheme}
84
+ data-scheme={rootTheme.scheme}
118
85
  data-ui="Card"
119
86
  data-tone={tone}
120
- $scheme={scheme ?? toneContext.scheme}
121
87
  {...restProps}
122
88
  $border={useArrayProp(border)}
123
89
  $borderTop={useArrayProp(borderTop)}
@@ -129,7 +95,6 @@ export const Card = forwardRef(function Card(
129
95
  $radius={useArrayProp(radius)}
130
96
  $shadow={useArrayProp(shadow)}
131
97
  $tone={tone}
132
- $updateCssVars={updateCssVars || shouldAddContext}
133
98
  data-checkered={checkered ? '' : undefined}
134
99
  data-pressed={pressed ? '' : undefined}
135
100
  data-selected={selected ? '' : undefined}
@@ -137,6 +102,6 @@ export const Card = forwardRef(function Card(
137
102
  ref={ref}
138
103
  selected={selected}
139
104
  />
140
- </Wrapper>
105
+ </ThemeColorProvider>
141
106
  )
142
107
  })
@@ -1,13 +1,7 @@
1
1
  import {css} from 'styled-components'
2
2
  import {ThemeProps} from '../../styles'
3
- import {
4
- _colorVarStyleActive,
5
- _colorVarStyleDisabled,
6
- _colorVarStyleHover,
7
- _colorVarStyleSelected,
8
- } from '../../styles/colorVars'
3
+ import {_colorVarsStyle} from '../../styles/colorVars'
9
4
  import {focusRingBorderStyle, focusRingStyle} from '../../styles/focusRing'
10
- import {createCssVars, cssVars} from '../../theme/lib/theme/color/cssVariables'
11
5
  import {CardStyleProps} from './types'
12
6
 
13
7
  export function cardStyle(
@@ -25,7 +19,7 @@ export function cardBaseStyle(props: CardStyleProps & ThemeProps): ReturnType<ty
25
19
  css`
26
20
  background-size: ${space[3]}px ${space[3]}px;
27
21
  background-position: 50% 50%;
28
- background-image: ${cssVars.mutable['bg-image']};
22
+ background-image: var(--card-bg-image);
29
23
  `}
30
24
 
31
25
  &[data-as='button'] {
@@ -52,20 +46,18 @@ export function cardBaseStyle(props: CardStyleProps & ThemeProps): ReturnType<ty
52
46
  }
53
47
 
54
48
  export function cardColorStyle(props: CardStyleProps & ThemeProps): ReturnType<typeof css> {
55
- const {$checkered, $focusRing, theme, $tone, $scheme, $updateCssVars} = props
49
+ const {$checkered, $focusRing, theme} = props
56
50
  const {focusRing} = theme.sanity.card
57
-
58
- const border = {width: 0, color: cssVars.positive['border-accent']}
51
+ const {base, card, dark} = theme.sanity.color
52
+ const border = {width: 0, color: 'var(--card-border-color)'}
59
53
 
60
54
  return css`
61
- /* A new css vars context is created, allowing for override of the default tone and changing the scheme */
62
- ${$updateCssVars && createCssVars($scheme, theme.sanity.color.tones, $tone)}
63
- color-scheme: ${$scheme === 'dark' ? 'dark' : 'light'};
64
- ${$checkered &&
65
- `--card-bg-image: repeating-conic-gradient(${cssVars.default['base-bg-card']} 0% 25%, ${cssVars.default['bg-tint']} 0% 50%)`}
55
+ color-scheme: ${dark ? 'dark' : 'light'};
56
+
57
+ ${_colorVarsStyle(base, card.enabled, $checkered)}
66
58
 
67
- background-color: ${cssVars.mutable['bg-color']};
68
- color: ${cssVars.default['text-primary']};
59
+ background-color: var(--card-bg-color);
60
+ color: var(--card-fg-color);
69
61
 
70
62
  /* &:is(button) */
71
63
  &[data-as='button'] {
@@ -75,34 +67,34 @@ export function cardColorStyle(props: CardStyleProps & ThemeProps): ReturnType<t
75
67
  box-shadow: var(--card-focus-ring-box-shadow);
76
68
 
77
69
  &:disabled {
78
- ${_colorVarStyleDisabled($checkered)}
70
+ ${_colorVarsStyle(base, card.disabled, $checkered)}
79
71
  }
80
72
 
81
73
  &:not(:disabled) {
82
74
  &[data-pressed] {
83
- ${_colorVarStyleActive()}
75
+ ${_colorVarsStyle(base, card.pressed, $checkered)}
84
76
  }
85
77
 
86
78
  &[data-selected] {
87
- ${_colorVarStyleSelected()}
79
+ ${_colorVarsStyle(base, card.selected, $checkered)}
88
80
  }
89
81
 
90
82
  @media (hover: hover) {
91
83
  &:not([data-pressed]):not([data-selected]) {
92
84
  &[data-hovered],
93
85
  &:hover {
94
- ${_colorVarStyleHover()}
86
+ ${_colorVarsStyle(base, card.hovered, $checkered)}
95
87
  }
96
88
 
97
89
  &:active {
98
- ${_colorVarStyleActive()}
90
+ ${_colorVarsStyle(base, card.pressed, $checkered)}
99
91
  }
100
92
  }
101
93
  }
102
94
 
103
95
  &:focus {
104
96
  --card-focus-ring-box-shadow: ${$focusRing
105
- ? focusRingStyle({border, focusRing})
97
+ ? focusRingStyle({base, border, focusRing})
106
98
  : undefined};
107
99
  }
108
100
 
@@ -118,34 +110,34 @@ export function cardColorStyle(props: CardStyleProps & ThemeProps): ReturnType<t
118
110
  box-shadow: var(--card-focus-ring-box-shadow);
119
111
 
120
112
  &[data-disabled] {
121
- ${_colorVarStyleDisabled($checkered)}
113
+ ${_colorVarsStyle(base, card.disabled, $checkered)}
122
114
  }
123
115
 
124
116
  &:not([data-disabled]) {
125
117
  &[data-pressed] {
126
- ${_colorVarStyleActive()}
118
+ ${_colorVarsStyle(base, card.pressed, $checkered)}
127
119
  }
128
120
 
129
121
  &[data-selected] {
130
- ${_colorVarStyleSelected()}
122
+ ${_colorVarsStyle(base, card.selected, $checkered)}
131
123
  }
132
124
 
133
125
  @media (hover: hover) {
134
126
  &:not([data-pressed]):not([data-selected]) {
135
127
  &[data-hovered],
136
128
  &:hover {
137
- ${_colorVarStyleHover()}
129
+ ${_colorVarsStyle(base, card.hovered, $checkered)}
138
130
  }
139
131
 
140
132
  &:active {
141
- ${_colorVarStyleActive()}
133
+ ${_colorVarsStyle(base, card.pressed, $checkered)}
142
134
  }
143
135
  }
144
136
  }
145
137
 
146
138
  &:focus {
147
139
  --card-focus-ring-box-shadow: ${$focusRing
148
- ? focusRingStyle({border, focusRing})
140
+ ? focusRingStyle({base, border, focusRing})
149
141
  : undefined};
150
142
  }
151
143
 
@@ -1,4 +1,4 @@
1
- import {ThemeColorSchemeKey, ThemeColorToneKey} from '../../theme'
1
+ import {ThemeColorToneKey} from '../../theme'
2
2
 
3
3
  /**
4
4
  * @internal
@@ -7,6 +7,4 @@ export interface CardStyleProps {
7
7
  $checkered: boolean
8
8
  $focusRing: boolean
9
9
  $tone: ThemeColorToneKey
10
- $scheme: ThemeColorSchemeKey
11
- $updateCssVars: boolean
12
10
  }
@@ -1,7 +1,6 @@
1
1
  import {css} from 'styled-components'
2
2
  import {rem, ThemeProps} from '../../styles'
3
3
  import {focusRingBorderStyle, focusRingStyle} from '../../styles/internal'
4
- import {cssVars} from '../../theme/lib/theme/color/cssVariables/createCssVars'
5
4
 
6
5
  export function checkboxBaseStyles(): ReturnType<typeof css> {
7
6
  return css`
@@ -12,6 +11,7 @@ export function checkboxBaseStyles(): ReturnType<typeof css> {
12
11
 
13
12
  export function inputElementStyles(props: ThemeProps): ReturnType<typeof css> {
14
13
  const {theme} = props
14
+ const color = theme.sanity.color.input
15
15
  const {input, radius} = theme.sanity
16
16
  const {focusRing} = input.checkbox
17
17
 
@@ -34,12 +34,12 @@ export function inputElementStyles(props: ThemeProps): ReturnType<typeof css> {
34
34
  width: ${rem(input.checkbox.size)};
35
35
  box-sizing: border-box;
36
36
  box-shadow: ${focusRingBorderStyle({
37
- color: cssVars.default['border-base'],
37
+ color: color.default.enabled.border,
38
38
  width: input.border.width,
39
39
  })};
40
40
  border-radius: ${rem(radius[2])};
41
41
  line-height: 1;
42
- background-color: ${cssVars.default['bg-base']};
42
+ background-color: ${color.default.enabled.bg};
43
43
 
44
44
  & > svg {
45
45
  display: block;
@@ -55,12 +55,12 @@ export function inputElementStyles(props: ThemeProps): ReturnType<typeof css> {
55
55
  }
56
56
  }
57
57
  &:checked + span {
58
- background: ${cssVars.default['text-secondary']};
58
+ background: ${color.default.enabled.bg2};
59
59
  box-shadow: ${focusRingBorderStyle({
60
- color: cssVars.default['text-secondary'],
60
+ color: color.default.enabled.bg2,
61
61
  width: input.border.width,
62
62
  })};
63
- color: ${cssVars.default['bg-base']};
63
+ color: ${color.default.enabled.bg};
64
64
  }
65
65
 
66
66
  /* focus */
@@ -74,47 +74,47 @@ export function inputElementStyles(props: ThemeProps): ReturnType<typeof css> {
74
74
  }
75
75
 
76
76
  &[data-error] + span {
77
- background-color: ${cssVars.critical['border-base']};
77
+ background-color: ${color.invalid.enabled.border};
78
78
  box-shadow: ${focusRingBorderStyle({
79
79
  width: input.border.width,
80
- color: cssVars.critical['text-secondary'],
80
+ color: color.invalid.enabled.bg2,
81
81
  })};
82
- color: ${cssVars.default['text-secondary']};
82
+ color: ${color.default.disabled.fg};
83
83
  }
84
84
  &[data-error]&:checked + span {
85
- background-color: ${cssVars.critical['text-secondary']};
86
- color: ${cssVars.default['bg-base']};
85
+ background-color: ${color.invalid.enabled.bg2};
86
+ color: ${color.default.enabled.bg};
87
87
  }
88
88
  &[data-error]&:checked&:not(:disabled):focus:focus-visible + span {
89
89
  box-shadow: ${focusRingStyle({
90
- border: {width: input.border.width, color: cssVars.critical['text-secondary']},
90
+ border: {width: input.border.width, color: color.invalid.readOnly.bg2},
91
91
  focusRing: {width: 1, offset: 1},
92
92
  })};
93
93
  }
94
94
 
95
95
  &:disabled + span {
96
- background-color: ${cssVars.default['bg-tint']};
96
+ background-color: ${color.default.disabled.bg};
97
97
  box-shadow: ${focusRingBorderStyle({
98
98
  width: input.border.width,
99
- color: cssVars.default['border-base'],
99
+ color: color.default.disabled.border,
100
100
  })};
101
- color: ${cssVars.default['text-secondary']};
101
+ color: ${color.default.disabled.fg};
102
102
  }
103
103
  &:disabled&:checked + span {
104
- background-color: ${cssVars.default['border-base']};
104
+ background-color: ${color.default.disabled.bg2};
105
105
  }
106
106
 
107
107
  &[data-read-only] + span {
108
- background-color: ${cssVars.default['bg-tint']};
108
+ background-color: ${color.default.readOnly.bg};
109
109
  box-shadow: ${focusRingBorderStyle({
110
110
  width: input.border.width,
111
- color: cssVars.default['border-base'],
111
+ color: color.default.readOnly.border,
112
112
  })};
113
- color: ${cssVars.default['text-secondary']};
113
+ color: ${color.default.readOnly.fg};
114
114
  }
115
115
 
116
116
  &[data-read-only]&:checked + span {
117
- background-color: ${cssVars.default['border-base']};
117
+ background-color: ${color.default.readOnly.bg2};
118
118
  }
119
119
 
120
120
  &:checked + span > svg:first-child {
@@ -4,8 +4,7 @@ import Refractor from 'react-refractor'
4
4
  import styled from 'styled-components'
5
5
  import {useArrayProp} from '../../hooks'
6
6
  import {responsiveCodeFontStyle, ResponsiveFontStyleProps} from '../../styles/internal'
7
- import {useToneContext} from '../../theme/toneContext/useToneContext'
8
- import {codeBaseStyle, CodeBaseStyleProps} from './styles'
7
+ import {codeBaseStyle} from './styles'
9
8
 
10
9
  /**
11
10
  * @public
@@ -17,10 +16,7 @@ export interface CodeProps {
17
16
  weight?: string
18
17
  }
19
18
 
20
- const Root = styled.pre<CodeBaseStyleProps & ResponsiveFontStyleProps>(
21
- codeBaseStyle,
22
- responsiveCodeFontStyle,
23
- )
19
+ const Root = styled.pre<ResponsiveFontStyleProps>(codeBaseStyle, responsiveCodeFontStyle)
24
20
 
25
21
  /**
26
22
  * @public
@@ -32,17 +28,9 @@ export const Code = forwardRef(function Code(
32
28
  const {children, language: languageProp, size = 2, weight, ...restProps} = props
33
29
  const language = typeof languageProp === 'string' ? languageProp : undefined
34
30
  const registered = language ? Refractor.hasLanguage(language as any) : false
35
- const {scheme} = useToneContext()
36
31
 
37
32
  return (
38
- <Root
39
- data-ui="Code"
40
- {...restProps}
41
- $size={useArrayProp(size)}
42
- $weight={weight}
43
- ref={ref}
44
- $scheme={scheme}
45
- >
33
+ <Root data-ui="Code" {...restProps} $size={useArrayProp(size)} $weight={weight} ref={ref}>
46
34
  {!(language && registered) && <code>{children}</code>}
47
35
  {language && registered && <Refractor inline language={language} value={String(children)} />}
48
36
  </Root>