@sanity/ui 2.0.0-alpha.4 → 2.0.0-alpha.6

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 (114) hide show
  1. package/dist/index.cjs.mjs +3 -1
  2. package/dist/index.d.ts +294 -407
  3. package/dist/index.esm.js +794 -2148
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/index.js +795 -2147
  6. package/dist/index.js.map +1 -1
  7. package/package.json +2 -2
  8. package/src/components/dialog/dialog.tsx +3 -3
  9. package/src/components/dialog/styles.ts +3 -4
  10. package/src/components/menu/__workshop__/closableMenuButton.tsx +2 -2
  11. package/src/components/menu/menuDivider.ts +2 -1
  12. package/src/components/menu/menuGroup.tsx +3 -0
  13. package/src/components/menu/menuItem.tsx +6 -3
  14. package/src/components/skeleton/styles.ts +8 -7
  15. package/src/components/tree/style.ts +19 -20
  16. package/src/primitives/_selectable/style.ts +27 -21
  17. package/src/primitives/avatar/avatar.tsx +8 -3
  18. package/src/primitives/avatar/avatarCounter.tsx +5 -4
  19. package/src/primitives/avatar/spotColors.ts +53 -0
  20. package/src/primitives/avatar/styles.ts +5 -7
  21. package/src/primitives/avatar/types.ts +14 -0
  22. package/src/primitives/badge/styles.ts +7 -8
  23. package/src/primitives/box/__workshop__/responsive.tsx +2 -2
  24. package/src/primitives/button/button.tsx +2 -2
  25. package/src/primitives/button/styles.ts +82 -16
  26. package/src/primitives/card/__workshop__/selected.tsx +8 -9
  27. package/src/primitives/card/card.tsx +43 -7
  28. package/src/primitives/card/styles.ts +30 -22
  29. package/src/primitives/card/types.ts +3 -1
  30. package/src/primitives/checkbox/styles.ts +20 -20
  31. package/src/primitives/code/code.tsx +15 -3
  32. package/src/primitives/code/styles.ts +51 -42
  33. package/src/primitives/heading/styles.ts +6 -5
  34. package/src/primitives/kbd/kbd.tsx +2 -1
  35. package/src/primitives/label/styles.ts +3 -2
  36. package/src/primitives/popover/popoverArrow.tsx +3 -2
  37. package/src/primitives/popover/popoverCard.tsx +6 -2
  38. package/src/primitives/radio/styles.ts +15 -15
  39. package/src/primitives/select/styles.ts +20 -22
  40. package/src/primitives/switch/styles.ts +13 -13
  41. package/src/primitives/text/__workshop__/colored.tsx +10 -11
  42. package/src/primitives/text/styles.ts +10 -9
  43. package/src/primitives/textArea/textArea.tsx +8 -12
  44. package/src/primitives/textInput/textInput.tsx +13 -13
  45. package/src/primitives/tooltip/__workshop__/props.tsx +20 -3
  46. package/src/primitives/tooltip/tooltipArrow.tsx +3 -2
  47. package/src/styles/border/borderStyle.ts +2 -1
  48. package/src/styles/colorVars/colorVarsStyle.ts +71 -32
  49. package/src/styles/focusRing/index.ts +6 -4
  50. package/src/styles/input/textInputStyle.ts +76 -93
  51. package/src/styles/margin/marginsStyle.test.ts +1 -2
  52. package/src/styles/padding/paddingStyle.test.ts +1 -2
  53. package/src/styles/shadow/shadowStyle.ts +5 -5
  54. package/src/theme/__workshop__/color.tsx +2 -2
  55. package/src/theme/__workshop__/index.ts +0 -5
  56. package/src/theme/lib/color-fns/blend/multiply.ts +2 -2
  57. package/src/theme/lib/color-fns/blend/screen.ts +2 -2
  58. package/src/theme/lib/color-fns/convert.ts +15 -1
  59. package/src/theme/lib/color-fns/parse.ts +7 -3
  60. package/src/theme/lib/color-fns/types.ts +11 -0
  61. package/src/theme/lib/theme/color/cssVariables/cardVariables.ts +92 -0
  62. package/src/theme/lib/theme/color/cssVariables/createCssVars.ts +31 -0
  63. package/src/theme/lib/theme/color/cssVariables/cssVars.test.ts +262 -0
  64. package/src/theme/lib/theme/color/cssVariables/index.ts +1 -0
  65. package/src/theme/lib/theme/color/cssVariables/tints.ts +312 -0
  66. package/src/theme/lib/theme/color/cssVariables/tones.ts +67 -0
  67. package/src/theme/lib/theme/color/cssVariables/utils.test.ts +15 -0
  68. package/src/theme/lib/theme/color/cssVariables/utils.ts +9 -0
  69. package/src/theme/lib/theme/color/index.ts +2 -12
  70. package/src/theme/lib/theme/color/types.ts +6 -37
  71. package/src/theme/studioTheme/color.ts +2 -641
  72. package/src/theme/studioTheme/helpers.ts +15 -1
  73. package/src/theme/studioTheme/theme.ts +8 -2
  74. package/src/theme/themeColorProvider.tsx +2 -0
  75. package/src/theme/themeProvider.tsx +27 -8
  76. package/src/theme/toneContext/toneContext.ts +12 -0
  77. package/src/theme/toneContext/toneProvider.tsx +31 -0
  78. package/src/theme/toneContext/types.ts +10 -0
  79. package/src/theme/toneContext/useToneContext.tsx +26 -0
  80. package/src/theme/types.ts +2 -4
  81. package/src/utils/elementQuery/__workshop__/customMedia.tsx +4 -3
  82. package/src/theme/__workshop__/canvas.tsx +0 -395
  83. package/src/theme/lib/theme/color/_generic/index.ts +0 -1
  84. package/src/theme/lib/theme/color/_generic/types.ts +0 -30
  85. package/src/theme/lib/theme/color/base/index.ts +0 -1
  86. package/src/theme/lib/theme/color/base/types.ts +0 -19
  87. package/src/theme/lib/theme/color/button/createButtonModes.ts +0 -20
  88. package/src/theme/lib/theme/color/button/createButtonTones.ts +0 -52
  89. package/src/theme/lib/theme/color/button/index.ts +0 -1
  90. package/src/theme/lib/theme/color/button/types.ts +0 -44
  91. package/src/theme/lib/theme/color/card/createCardStates.ts +0 -58
  92. package/src/theme/lib/theme/color/card/index.ts +0 -1
  93. package/src/theme/lib/theme/color/card/types.ts +0 -18
  94. package/src/theme/lib/theme/color/color.test.ts +0 -63
  95. package/src/theme/lib/theme/color/defaults.ts +0 -390
  96. package/src/theme/lib/theme/color/factory.ts +0 -138
  97. package/src/theme/lib/theme/color/input/createInputModes.ts +0 -84
  98. package/src/theme/lib/theme/color/input/index.ts +0 -1
  99. package/src/theme/lib/theme/color/input/types.ts +0 -28
  100. package/src/theme/lib/theme/color/muted/createMuted.ts +0 -56
  101. package/src/theme/lib/theme/color/muted/index.ts +0 -1
  102. package/src/theme/lib/theme/color/muted/types.ts +0 -24
  103. package/src/theme/lib/theme/color/selectable/createSelectableTones.ts +0 -73
  104. package/src/theme/lib/theme/color/selectable/index.ts +0 -1
  105. package/src/theme/lib/theme/color/selectable/types.ts +0 -29
  106. package/src/theme/lib/theme/color/solid/createSolidTones.ts +0 -56
  107. package/src/theme/lib/theme/color/solid/index.ts +0 -1
  108. package/src/theme/lib/theme/color/solid/types.ts +0 -24
  109. package/src/theme/lib/theme/color/spot/createSpot.ts +0 -21
  110. package/src/theme/lib/theme/color/spot/index.ts +0 -1
  111. package/src/theme/lib/theme/color/spot/types.ts +0 -28
  112. package/src/theme/lib/theme/color/syntax/index.ts +0 -1
  113. package/src/theme/lib/theme/color/syntax/types.ts +0 -41
  114. package/src/theme/studioTheme/tints.ts +0 -152
@@ -1,7 +1,9 @@
1
1
  import {css} from 'styled-components'
2
2
  import {ThemeProps} from '../../styles'
3
- import {_colorVarsStyle} from '../../styles/colorVars'
4
3
  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'
5
7
  import {ButtonMode, ButtonTone} from '../../types'
6
8
  import {CSSObject} from '../../types/styled'
7
9
 
@@ -54,21 +56,65 @@ function combineBoxShadow(...boxShadows: (string | undefined)[]): string {
54
56
  export function buttonColorStyles(
55
57
  props: {$mode: ButtonMode; $tone: ButtonTone} & ThemeProps,
56
58
  ): CSSObject[] {
57
- const {$mode, theme} = props
59
+ const {$mode, theme, $tone} = props
58
60
  const {focusRing} = theme.sanity.button
59
61
  const shadow = props.$mode !== 'bleed'
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)'}
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
+ }
64
71
 
65
72
  return [
66
- _colorVarsStyle(base, color.enabled),
67
73
  {
68
- backgroundColor: 'var(--card-bg-color)',
69
- color: 'var(--card-fg-color)',
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'],
70
108
  boxShadow: focusRingBorderStyle(border),
71
- '&:disabled, &[data-disabled="true"]': _colorVarsStyle(base, color.disabled),
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
+ },
72
118
  "&:not([data-disabled='true'])": {
73
119
  boxShadow: combineBoxShadow(
74
120
  focusRingBorderStyle(border),
@@ -76,8 +122,8 @@ export function buttonColorStyles(
76
122
  ),
77
123
  '&:focus': {
78
124
  boxShadow: focusRingStyle({
79
- base,
80
- border: {width: 2, color: base.bg},
125
+ base: {bg: cssVars.positive['border-accent']},
126
+ border: {width: 2, color: cssVars.default['bg-base']},
81
127
  focusRing,
82
128
  }),
83
129
  },
@@ -88,11 +134,31 @@ export function buttonColorStyles(
88
134
  ),
89
135
  },
90
136
  '@media (hover: hover)': {
91
- '&:hover': _colorVarsStyle(base, color.hovered),
92
- '&:active': _colorVarsStyle(base, color.pressed),
93
- '&[data-hovered]': _colorVarsStyle(base, color.hovered),
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'],
94
161
  },
95
- '&[data-selected]': _colorVarsStyle(base, color.pressed),
96
162
  },
97
163
  },
98
164
  theme.sanity.styles?.button?.root,
@@ -7,31 +7,30 @@ import {
7
7
  Inline,
8
8
  Stack,
9
9
  Text,
10
- Theme,
11
10
  ThemeColorToneKey,
12
11
  useRootTheme,
13
12
  } from '@sanity/ui'
14
13
  import {useBoolean} from '@sanity/ui-workshop'
15
14
  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'
16
17
 
17
18
  const TextWithTone = styled(Text)<{$tone: ThemeColorToneKey}>(({
18
19
  $tone,
19
- theme,
20
20
  }: {
21
21
  $tone: ThemeColorToneKey
22
- theme: Theme
23
22
  }) => {
24
- const tone = theme.sanity.color.solid[$tone]
25
-
26
23
  return css`
27
24
  &:not([data-selected]) {
28
- --card-fg-color: ${tone ? tone.enabled.bg : undefined};
29
- --card-muted-fg-color: ${tone ? tone.enabled.bg : undefined};
25
+ ${mutableCardVariables['fg-color']}: ${$tone ? cssVars[$tone]['text-secondary'] : undefined};
26
+ ${mutableCardVariables['muted-fg-color']} ${$tone
27
+ ? cssVars[$tone]['text-secondary']
28
+ : undefined};
30
29
  }
31
30
 
32
31
  [data-ui='Card']:disabled & {
33
- --card-fg-color: inherit;
34
- --card-muted-fg-color: inherit;
32
+ ${mutableCardVariables['fg-color']}: inherit;
33
+ ${mutableCardVariables['muted-fg-color']} inherit;
35
34
  }
36
35
  `
37
36
  })
@@ -10,7 +10,9 @@ import {
10
10
  responsiveShadowStyle,
11
11
  ResponsiveShadowStyleProps,
12
12
  } from '../../styles/internal'
13
- import {ThemeColorProvider, ThemeColorSchemeKey, useRootTheme} from '../../theme'
13
+ import {ThemeColorName, ThemeColorSchemeKey} from '../../theme'
14
+ import {ToneProvider} from '../../theme/toneContext/toneProvider'
15
+ import {useToneContext} from '../../theme/toneContext/useToneContext'
14
16
  import {CardTone} from '../../types'
15
17
  import {Box, BoxProps} from '../box'
16
18
  import {ResponsiveBorderProps, ResponsiveRadiusProps, ResponsiveShadowProps} from '../types'
@@ -38,6 +40,12 @@ export interface CardProps
38
40
  pressed?: boolean
39
41
  scheme?: ThemeColorSchemeKey
40
42
  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
41
49
  }
42
50
 
43
51
  const Root = styled(Box)<
@@ -47,6 +55,29 @@ const Root = styled(Box)<
47
55
  ResponsiveShadowStyleProps
48
56
  >(responsiveBorderStyle, responsiveRadiusStyle, responsiveShadowStyle, cardStyle)
49
57
 
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
+
50
81
  /**
51
82
  * @public
52
83
  */
@@ -65,24 +96,28 @@ export const Card = forwardRef(function Card(
65
96
  borderLeft,
66
97
  pressed,
67
98
  radius = 0,
68
- scheme,
99
+ scheme: schemeProp,
69
100
  selected,
70
101
  shadow,
71
102
  tone: toneProp = 'default',
103
+ updateCssVars = false,
72
104
  ...restProps
73
105
  } = props
74
106
 
75
107
  const as = isValidElementType(asProp) ? asProp : 'div'
76
- const rootTheme = useRootTheme()
77
- const tone = toneProp === 'inherit' ? rootTheme.tone : toneProp
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
78
112
 
79
113
  return (
80
- <ThemeColorProvider scheme={scheme} tone={tone}>
114
+ <Wrapper shouldAddContext={shouldAddContext} scheme={scheme} tone={tone}>
81
115
  <Root
82
116
  data-as={typeof as === 'string' ? as : undefined}
83
- data-scheme={rootTheme.scheme}
117
+ data-scheme={scheme}
84
118
  data-ui="Card"
85
119
  data-tone={tone}
120
+ $scheme={scheme ?? toneContext.scheme}
86
121
  {...restProps}
87
122
  $border={useArrayProp(border)}
88
123
  $borderTop={useArrayProp(borderTop)}
@@ -94,6 +129,7 @@ export const Card = forwardRef(function Card(
94
129
  $radius={useArrayProp(radius)}
95
130
  $shadow={useArrayProp(shadow)}
96
131
  $tone={tone}
132
+ $updateCssVars={updateCssVars || shouldAddContext}
97
133
  data-checkered={checkered ? '' : undefined}
98
134
  data-pressed={pressed ? '' : undefined}
99
135
  data-selected={selected ? '' : undefined}
@@ -101,6 +137,6 @@ export const Card = forwardRef(function Card(
101
137
  ref={ref}
102
138
  selected={selected}
103
139
  />
104
- </ThemeColorProvider>
140
+ </Wrapper>
105
141
  )
106
142
  })
@@ -1,7 +1,13 @@
1
1
  import {css} from 'styled-components'
2
2
  import {ThemeProps} from '../../styles'
3
- import {_colorVarsStyle} from '../../styles/colorVars'
3
+ import {
4
+ _colorVarStyleActive,
5
+ _colorVarStyleDisabled,
6
+ _colorVarStyleHover,
7
+ _colorVarStyleSelected,
8
+ } from '../../styles/colorVars'
4
9
  import {focusRingBorderStyle, focusRingStyle} from '../../styles/focusRing'
10
+ import {createCssVars, cssVars} from '../../theme/lib/theme/color/cssVariables'
5
11
  import {CardStyleProps} from './types'
6
12
 
7
13
  export function cardStyle(
@@ -19,7 +25,7 @@ export function cardBaseStyle(props: CardStyleProps & ThemeProps): ReturnType<ty
19
25
  css`
20
26
  background-size: ${space[3]}px ${space[3]}px;
21
27
  background-position: 50% 50%;
22
- background-image: var(--card-bg-image);
28
+ background-image: ${cssVars.mutable['bg-image']};
23
29
  `}
24
30
 
25
31
  &[data-as='button'] {
@@ -46,18 +52,20 @@ export function cardBaseStyle(props: CardStyleProps & ThemeProps): ReturnType<ty
46
52
  }
47
53
 
48
54
  export function cardColorStyle(props: CardStyleProps & ThemeProps): ReturnType<typeof css> {
49
- const {$checkered, $focusRing, theme} = props
55
+ const {$checkered, $focusRing, theme, $tone, $scheme, $updateCssVars} = props
50
56
  const {focusRing} = theme.sanity.card
51
- const {base, card, dark} = theme.sanity.color
52
- const border = {width: 0, color: 'var(--card-border-color)'}
53
57
 
54
- return css`
55
- color-scheme: ${dark ? 'dark' : 'light'};
58
+ const border = {width: 0, color: cssVars.positive['border-accent']}
56
59
 
57
- ${_colorVarsStyle(base, card.enabled, $checkered)}
60
+ 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%)`}
58
66
 
59
- background-color: var(--card-bg-color);
60
- color: var(--card-fg-color);
67
+ background-color: ${cssVars.mutable['bg-color']};
68
+ color: ${cssVars.default['text-primary']};
61
69
 
62
70
  /* &:is(button) */
63
71
  &[data-as='button'] {
@@ -67,34 +75,34 @@ export function cardColorStyle(props: CardStyleProps & ThemeProps): ReturnType<t
67
75
  box-shadow: var(--card-focus-ring-box-shadow);
68
76
 
69
77
  &:disabled {
70
- ${_colorVarsStyle(base, card.disabled, $checkered)}
78
+ ${_colorVarStyleDisabled($checkered)}
71
79
  }
72
80
 
73
81
  &:not(:disabled) {
74
82
  &[data-pressed] {
75
- ${_colorVarsStyle(base, card.pressed, $checkered)}
83
+ ${_colorVarStyleActive()}
76
84
  }
77
85
 
78
86
  &[data-selected] {
79
- ${_colorVarsStyle(base, card.selected, $checkered)}
87
+ ${_colorVarStyleSelected()}
80
88
  }
81
89
 
82
90
  @media (hover: hover) {
83
91
  &:not([data-pressed]):not([data-selected]) {
84
92
  &[data-hovered],
85
93
  &:hover {
86
- ${_colorVarsStyle(base, card.hovered, $checkered)}
94
+ ${_colorVarStyleHover()}
87
95
  }
88
96
 
89
97
  &:active {
90
- ${_colorVarsStyle(base, card.pressed, $checkered)}
98
+ ${_colorVarStyleActive()}
91
99
  }
92
100
  }
93
101
  }
94
102
 
95
103
  &:focus {
96
104
  --card-focus-ring-box-shadow: ${$focusRing
97
- ? focusRingStyle({base, border, focusRing})
105
+ ? focusRingStyle({border, focusRing})
98
106
  : undefined};
99
107
  }
100
108
 
@@ -110,34 +118,34 @@ export function cardColorStyle(props: CardStyleProps & ThemeProps): ReturnType<t
110
118
  box-shadow: var(--card-focus-ring-box-shadow);
111
119
 
112
120
  &[data-disabled] {
113
- ${_colorVarsStyle(base, card.disabled, $checkered)}
121
+ ${_colorVarStyleDisabled($checkered)}
114
122
  }
115
123
 
116
124
  &:not([data-disabled]) {
117
125
  &[data-pressed] {
118
- ${_colorVarsStyle(base, card.pressed, $checkered)}
126
+ ${_colorVarStyleActive()}
119
127
  }
120
128
 
121
129
  &[data-selected] {
122
- ${_colorVarsStyle(base, card.selected, $checkered)}
130
+ ${_colorVarStyleSelected()}
123
131
  }
124
132
 
125
133
  @media (hover: hover) {
126
134
  &:not([data-pressed]):not([data-selected]) {
127
135
  &[data-hovered],
128
136
  &:hover {
129
- ${_colorVarsStyle(base, card.hovered, $checkered)}
137
+ ${_colorVarStyleHover()}
130
138
  }
131
139
 
132
140
  &:active {
133
- ${_colorVarsStyle(base, card.pressed, $checkered)}
141
+ ${_colorVarStyleActive()}
134
142
  }
135
143
  }
136
144
  }
137
145
 
138
146
  &:focus {
139
147
  --card-focus-ring-box-shadow: ${$focusRing
140
- ? focusRingStyle({base, border, focusRing})
148
+ ? focusRingStyle({border, focusRing})
141
149
  : undefined};
142
150
  }
143
151
 
@@ -1,4 +1,4 @@
1
- import {ThemeColorToneKey} from '../../theme'
1
+ import {ThemeColorSchemeKey, ThemeColorToneKey} from '../../theme'
2
2
 
3
3
  /**
4
4
  * @internal
@@ -7,4 +7,6 @@ export interface CardStyleProps {
7
7
  $checkered: boolean
8
8
  $focusRing: boolean
9
9
  $tone: ThemeColorToneKey
10
+ $scheme: ThemeColorSchemeKey
11
+ $updateCssVars: boolean
10
12
  }
@@ -1,6 +1,7 @@
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'
4
5
 
5
6
  export function checkboxBaseStyles(): ReturnType<typeof css> {
6
7
  return css`
@@ -11,7 +12,6 @@ export function checkboxBaseStyles(): ReturnType<typeof css> {
11
12
 
12
13
  export function inputElementStyles(props: ThemeProps): ReturnType<typeof css> {
13
14
  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: color.default.enabled.border,
37
+ color: cssVars.default['border-base'],
38
38
  width: input.border.width,
39
39
  })};
40
40
  border-radius: ${rem(radius[2])};
41
41
  line-height: 1;
42
- background-color: ${color.default.enabled.bg};
42
+ background-color: ${cssVars.default['bg-base']};
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: ${color.default.enabled.bg2};
58
+ background: ${cssVars.default['text-secondary']};
59
59
  box-shadow: ${focusRingBorderStyle({
60
- color: color.default.enabled.bg2,
60
+ color: cssVars.default['text-secondary'],
61
61
  width: input.border.width,
62
62
  })};
63
- color: ${color.default.enabled.bg};
63
+ color: ${cssVars.default['bg-base']};
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: ${color.invalid.enabled.border};
77
+ background-color: ${cssVars.critical['border-base']};
78
78
  box-shadow: ${focusRingBorderStyle({
79
79
  width: input.border.width,
80
- color: color.invalid.enabled.bg2,
80
+ color: cssVars.critical['text-secondary'],
81
81
  })};
82
- color: ${color.default.disabled.fg};
82
+ color: ${cssVars.default['text-secondary']};
83
83
  }
84
84
  &[data-error]&:checked + span {
85
- background-color: ${color.invalid.enabled.bg2};
86
- color: ${color.default.enabled.bg};
85
+ background-color: ${cssVars.critical['text-secondary']};
86
+ color: ${cssVars.default['bg-base']};
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: color.invalid.readOnly.bg2},
90
+ border: {width: input.border.width, color: cssVars.critical['text-secondary']},
91
91
  focusRing: {width: 1, offset: 1},
92
92
  })};
93
93
  }
94
94
 
95
95
  &:disabled + span {
96
- background-color: ${color.default.disabled.bg};
96
+ background-color: ${cssVars.default['bg-tint']};
97
97
  box-shadow: ${focusRingBorderStyle({
98
98
  width: input.border.width,
99
- color: color.default.disabled.border,
99
+ color: cssVars.default['border-base'],
100
100
  })};
101
- color: ${color.default.disabled.fg};
101
+ color: ${cssVars.default['text-secondary']};
102
102
  }
103
103
  &:disabled&:checked + span {
104
- background-color: ${color.default.disabled.bg2};
104
+ background-color: ${cssVars.default['border-base']};
105
105
  }
106
106
 
107
107
  &[data-read-only] + span {
108
- background-color: ${color.default.readOnly.bg};
108
+ background-color: ${cssVars.default['bg-tint']};
109
109
  box-shadow: ${focusRingBorderStyle({
110
110
  width: input.border.width,
111
- color: color.default.readOnly.border,
111
+ color: cssVars.default['border-base'],
112
112
  })};
113
- color: ${color.default.readOnly.fg};
113
+ color: ${cssVars.default['text-secondary']};
114
114
  }
115
115
 
116
116
  &[data-read-only]&:checked + span {
117
- background-color: ${color.default.readOnly.bg2};
117
+ background-color: ${cssVars.default['border-base']};
118
118
  }
119
119
 
120
120
  &:checked + span > svg:first-child {
@@ -4,7 +4,8 @@ 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 {codeBaseStyle} from './styles'
7
+ import {useToneContext} from '../../theme/toneContext/useToneContext'
8
+ import {codeBaseStyle, CodeBaseStyleProps} from './styles'
8
9
 
9
10
  /**
10
11
  * @public
@@ -16,7 +17,10 @@ export interface CodeProps {
16
17
  weight?: string
17
18
  }
18
19
 
19
- const Root = styled.pre<ResponsiveFontStyleProps>(codeBaseStyle, responsiveCodeFontStyle)
20
+ const Root = styled.pre<CodeBaseStyleProps & ResponsiveFontStyleProps>(
21
+ codeBaseStyle,
22
+ responsiveCodeFontStyle,
23
+ )
20
24
 
21
25
  /**
22
26
  * @public
@@ -28,9 +32,17 @@ export const Code = forwardRef(function Code(
28
32
  const {children, language: languageProp, size = 2, weight, ...restProps} = props
29
33
  const language = typeof languageProp === 'string' ? languageProp : undefined
30
34
  const registered = language ? Refractor.hasLanguage(language as any) : false
35
+ const {scheme} = useToneContext()
31
36
 
32
37
  return (
33
- <Root data-ui="Code" {...restProps} $size={useArrayProp(size)} $weight={weight} ref={ref}>
38
+ <Root
39
+ data-ui="Code"
40
+ {...restProps}
41
+ $size={useArrayProp(size)}
42
+ $weight={weight}
43
+ ref={ref}
44
+ $scheme={scheme}
45
+ >
34
46
  {!(language && registered) && <code>{children}</code>}
35
47
  {language && registered && <Refractor inline language={language} value={String(children)} />}
36
48
  </Root>