@sanity/ui 2.0.0-alpha.5 → 2.0.0-alpha.7

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 (115) hide show
  1. package/dist/index.cjs.mjs +3 -1
  2. package/dist/index.d.ts +294 -407
  3. package/dist/index.esm.js +971 -2333
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/index.js +972 -2332
  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 +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 +22 -23
  13. package/src/components/menu/menuItem.tsx +30 -36
  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 +25 -22
  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/badge.tsx +4 -2
  23. package/src/primitives/badge/styles.ts +7 -8
  24. package/src/primitives/box/__workshop__/responsive.tsx +2 -2
  25. package/src/primitives/button/button.tsx +2 -2
  26. package/src/primitives/button/styles.ts +82 -16
  27. package/src/primitives/card/__workshop__/selected.tsx +8 -9
  28. package/src/primitives/card/card.tsx +43 -7
  29. package/src/primitives/card/styles.ts +30 -22
  30. package/src/primitives/card/types.ts +3 -1
  31. package/src/primitives/checkbox/styles.ts +20 -20
  32. package/src/primitives/code/code.tsx +15 -3
  33. package/src/primitives/code/styles.ts +51 -42
  34. package/src/primitives/heading/styles.ts +6 -5
  35. package/src/primitives/kbd/kbd.tsx +2 -1
  36. package/src/primitives/label/styles.ts +3 -2
  37. package/src/primitives/popover/popoverArrow.tsx +3 -2
  38. package/src/primitives/popover/popoverCard.tsx +6 -2
  39. package/src/primitives/radio/styles.ts +15 -15
  40. package/src/primitives/select/styles.ts +20 -22
  41. package/src/primitives/switch/styles.ts +13 -13
  42. package/src/primitives/text/__workshop__/colored.tsx +10 -11
  43. package/src/primitives/text/styles.ts +10 -9
  44. package/src/primitives/textArea/textArea.tsx +7 -11
  45. package/src/primitives/textInput/textInput.tsx +12 -12
  46. package/src/primitives/tooltip/__workshop__/props.tsx +20 -3
  47. package/src/primitives/tooltip/tooltipArrow.tsx +3 -2
  48. package/src/styles/border/borderStyle.ts +2 -1
  49. package/src/styles/colorVars/colorVarsStyle.ts +73 -32
  50. package/src/styles/focusRing/index.ts +6 -4
  51. package/src/styles/input/textInputStyle.ts +76 -93
  52. package/src/styles/margin/marginsStyle.test.ts +1 -2
  53. package/src/styles/padding/paddingStyle.test.ts +1 -2
  54. package/src/styles/shadow/shadowStyle.ts +5 -5
  55. package/src/theme/__workshop__/color.tsx +2 -2
  56. package/src/theme/__workshop__/index.ts +0 -5
  57. package/src/theme/lib/color-fns/blend/multiply.ts +2 -2
  58. package/src/theme/lib/color-fns/blend/screen.ts +2 -2
  59. package/src/theme/lib/color-fns/convert.ts +15 -1
  60. package/src/theme/lib/color-fns/parse.ts +7 -3
  61. package/src/theme/lib/color-fns/types.ts +11 -0
  62. package/src/theme/lib/theme/color/cssVariables/cardVariables.ts +92 -0
  63. package/src/theme/lib/theme/color/cssVariables/createCssVars.ts +31 -0
  64. package/src/theme/lib/theme/color/cssVariables/cssVars.test.ts +262 -0
  65. package/src/theme/lib/theme/color/cssVariables/index.ts +1 -0
  66. package/src/theme/lib/theme/color/cssVariables/tints.ts +312 -0
  67. package/src/theme/lib/theme/color/cssVariables/tones.ts +67 -0
  68. package/src/theme/lib/theme/color/cssVariables/utils.test.ts +15 -0
  69. package/src/theme/lib/theme/color/cssVariables/utils.ts +9 -0
  70. package/src/theme/lib/theme/color/index.ts +2 -12
  71. package/src/theme/lib/theme/color/types.ts +6 -37
  72. package/src/theme/studioTheme/color.ts +2 -641
  73. package/src/theme/studioTheme/helpers.ts +15 -1
  74. package/src/theme/studioTheme/theme.ts +9 -3
  75. package/src/theme/themeColorProvider.tsx +2 -0
  76. package/src/theme/themeProvider.tsx +27 -8
  77. package/src/theme/toneContext/toneContext.ts +12 -0
  78. package/src/theme/toneContext/toneProvider.tsx +31 -0
  79. package/src/theme/toneContext/types.ts +10 -0
  80. package/src/theme/toneContext/useToneContext.tsx +26 -0
  81. package/src/theme/types.ts +2 -4
  82. package/src/utils/elementQuery/__workshop__/customMedia.tsx +4 -3
  83. package/src/theme/__workshop__/canvas.tsx +0 -395
  84. package/src/theme/lib/theme/color/_generic/index.ts +0 -1
  85. package/src/theme/lib/theme/color/_generic/types.ts +0 -30
  86. package/src/theme/lib/theme/color/base/index.ts +0 -1
  87. package/src/theme/lib/theme/color/base/types.ts +0 -19
  88. package/src/theme/lib/theme/color/button/createButtonModes.ts +0 -20
  89. package/src/theme/lib/theme/color/button/createButtonTones.ts +0 -52
  90. package/src/theme/lib/theme/color/button/index.ts +0 -1
  91. package/src/theme/lib/theme/color/button/types.ts +0 -44
  92. package/src/theme/lib/theme/color/card/createCardStates.ts +0 -58
  93. package/src/theme/lib/theme/color/card/index.ts +0 -1
  94. package/src/theme/lib/theme/color/card/types.ts +0 -18
  95. package/src/theme/lib/theme/color/color.test.ts +0 -63
  96. package/src/theme/lib/theme/color/defaults.ts +0 -390
  97. package/src/theme/lib/theme/color/factory.ts +0 -138
  98. package/src/theme/lib/theme/color/input/createInputModes.ts +0 -84
  99. package/src/theme/lib/theme/color/input/index.ts +0 -1
  100. package/src/theme/lib/theme/color/input/types.ts +0 -28
  101. package/src/theme/lib/theme/color/muted/createMuted.ts +0 -56
  102. package/src/theme/lib/theme/color/muted/index.ts +0 -1
  103. package/src/theme/lib/theme/color/muted/types.ts +0 -24
  104. package/src/theme/lib/theme/color/selectable/createSelectableTones.ts +0 -73
  105. package/src/theme/lib/theme/color/selectable/index.ts +0 -1
  106. package/src/theme/lib/theme/color/selectable/types.ts +0 -29
  107. package/src/theme/lib/theme/color/solid/createSolidTones.ts +0 -56
  108. package/src/theme/lib/theme/color/solid/index.ts +0 -1
  109. package/src/theme/lib/theme/color/solid/types.ts +0 -24
  110. package/src/theme/lib/theme/color/spot/createSpot.ts +0 -21
  111. package/src/theme/lib/theme/color/spot/index.ts +0 -1
  112. package/src/theme/lib/theme/color/spot/types.ts +0 -28
  113. package/src/theme/lib/theme/color/syntax/index.ts +0 -1
  114. package/src/theme/lib/theme/color/syntax/types.ts +0 -41
  115. package/src/theme/studioTheme/tints.ts +0 -152
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ui",
3
- "version": "2.0.0-alpha.5",
3
+ "version": "2.0.0-alpha.7",
4
4
  "sideEffects": false,
5
5
  "types": "./dist/index.d.ts",
6
6
  "source": "./src/index.ts",
@@ -11,7 +11,7 @@ import {useArrayProp, useClickOutside, useForwardedRef, useGlobalKeyDown} from '
11
11
  import {Box, Button, Card, CardProps, Container, Flex, Text} from '../../primitives'
12
12
  import {ResponsivePaddingProps, ResponsiveWidthProps} from '../../primitives/types'
13
13
  import {responsivePaddingStyle, ResponsivePaddingStyleProps} from '../../styles/internal'
14
- import {ThemeColorSchemeKey, useTheme} from '../../theme'
14
+ import {ThemeColorSchemeKey, cssVars, useTheme} from '../../theme'
15
15
  import {DialogPosition, Radius} from '../../types'
16
16
  import {Layer, LayerProps, Portal, useBoundaryElement, useLayer, usePortal} from '../../utils'
17
17
  import {BORDER_OFFSET_X} from './constants'
@@ -139,7 +139,7 @@ const DialogHeader = styled(Card)<DialogHeaderProps>`
139
139
  left: ${BORDER_OFFSET_X}px;
140
140
  right: ${BORDER_OFFSET_X}px;
141
141
  bottom: -1px;
142
- border-bottom: 1px solid var(--card-border-color);
142
+ border-bottom: 1px solid ${cssVars.default['border-base']};
143
143
  width: auto;
144
144
  opacity: ${(props) => (props.$isContentScrollable && props.$hasScrolledFromTop ? 1 : 0)};
145
145
  transition: opacity 200ms ease-in;
@@ -164,7 +164,7 @@ const DialogFooter = styled(Box)<DialogFooterProps>`
164
164
  left: ${BORDER_OFFSET_X}px;
165
165
  right: ${BORDER_OFFSET_X}px;
166
166
  top: -1px;
167
- border-top: 1px solid var(--card-border-color);
167
+ border-top: 1px solid ${cssVars.default['border-base']};
168
168
  width: auto;
169
169
  opacity: ${(props) => (props.$isContentScrollable && !props.$hasScrolledToBottom ? 1 : 0)};
170
170
  transition: opacity 200ms ease-in;
@@ -1,4 +1,5 @@
1
1
  import {_responsive, ThemeProps} from '../../styles'
2
+ import {cssVars} from '../../theme'
2
3
  import {DialogPosition} from '../../types'
3
4
  import {CSSObject} from '../../types/styled'
4
5
 
@@ -9,9 +10,7 @@ export interface ResponsiveDialogPositionStyleProps {
9
10
  $position: DialogPosition[]
10
11
  }
11
12
 
12
- export function dialogStyle({theme}: ThemeProps): CSSObject {
13
- const color = theme.sanity.color.base
14
-
13
+ export function dialogStyle(): CSSObject {
15
14
  return {
16
15
  '&:not([hidden])': {
17
16
  display: 'flex',
@@ -24,7 +23,7 @@ export function dialogStyle({theme}: ThemeProps): CSSObject {
24
23
  alignItems: 'center',
25
24
  justifyContent: 'center',
26
25
  outline: 'none',
27
- background: color.shadow.umbra,
26
+ background: cssVars.default['base-shadow-umbra-color'],
28
27
  }
29
28
  }
30
29
 
@@ -1,5 +1,5 @@
1
1
  import {AddIcon} from '@sanity/icons'
2
- import {Box, Button, Menu, MenuButton, MenuButtonProps, MenuItem, Stack} from '@sanity/ui'
2
+ import {Box, Button, Menu, MenuButton, MenuButtonProps, MenuItem, Stack, cssVars} from '@sanity/ui'
3
3
  import {useRef} from 'react'
4
4
 
5
5
  const POPOVER_PROPS: MenuButtonProps['popover'] = {
@@ -23,7 +23,7 @@ export default function ClosableMenuButtonStory() {
23
23
  <MenuItem text="Item 3" />
24
24
  <MenuItem text="Item 4" />
25
25
  </Stack>
26
- <Stack padding={1} style={{borderTop: '1px solid var(--card-border-color)'}}>
26
+ <Stack padding={1} style={{borderTop: `1px solid ${cssVars.default['border-base']}`}}>
27
27
  <Button
28
28
  icon={AddIcon}
29
29
  onClick={() => {
@@ -1,4 +1,5 @@
1
1
  import styled from 'styled-components'
2
+ import {cssVars} from '../../theme'
2
3
 
3
4
  /**
4
5
  * @public
@@ -6,6 +7,6 @@ import styled from 'styled-components'
6
7
  export const MenuDivider = styled.hr`
7
8
  height: 1px;
8
9
  border: 0;
9
- background: var(--card-hairline-soft-color);
10
+ background: ${cssVars.default['border-base']};
10
11
  margin: 0;
11
12
  `
@@ -4,6 +4,7 @@ import {isValidElementType} from 'react-is'
4
4
  import {useArrayProp} from '../../hooks'
5
5
  import {Box, Flex, Popover, PopoverProps, Text} from '../../primitives'
6
6
  import {Selectable} from '../../primitives/_selectable'
7
+ import {useToneContext} from '../../theme/toneContext/useToneContext'
7
8
  import {Radius, SelectableTone} from '../../types'
8
9
  import {Menu} from './menu'
9
10
  import {useMenu} from './useMenu'
@@ -33,7 +34,7 @@ export function MenuGroup(
33
34
  const {
34
35
  as = 'button',
35
36
  children,
36
- fontSize,
37
+ fontSize = 1,
37
38
  icon,
38
39
  onClick,
39
40
  padding = 3,
@@ -44,6 +45,7 @@ export function MenuGroup(
44
45
  tone = 'default',
45
46
  ...restProps
46
47
  } = props
48
+ const {scheme} = useToneContext()
47
49
  const menu = useMenu()
48
50
  const {
49
51
  activeElement,
@@ -166,6 +168,7 @@ export function MenuGroup(
166
168
  data-selected={!withinMenu && active ? '' : undefined}
167
169
  $radius={useArrayProp(radius)}
168
170
  $tone={tone}
171
+ $scheme={scheme}
169
172
  onClick={handleClick}
170
173
  onKeyDown={handleKeyDown}
171
174
  onMouseEnter={handleMouseEnter}
@@ -173,28 +176,24 @@ export function MenuGroup(
173
176
  tabIndex={-1}
174
177
  type={as === 'button' ? 'button' : undefined}
175
178
  >
176
- <Box padding={padding}>
177
- <Flex>
178
- {icon && (
179
- <Text size={fontSize}>
180
- {isValidElement(icon) && icon}
181
- {isValidElementType(icon) && createElement(icon)}
182
- </Text>
183
- )}
184
-
185
- <Box flex={1} marginLeft={icon ? space : undefined}>
186
- <Text size={fontSize} textOverflow="ellipsis">
187
- {text}
188
- </Text>
189
- </Box>
190
-
191
- <Box marginLeft={space}>
192
- <Text size={fontSize}>
193
- <ChevronRightIcon />
194
- </Text>
195
- </Box>
196
- </Flex>
197
- </Box>
179
+ <Flex gap={space} padding={padding}>
180
+ {icon && (
181
+ <Text size={fontSize}>
182
+ {isValidElement(icon) && icon}
183
+ {isValidElementType(icon) && createElement(icon)}
184
+ </Text>
185
+ )}
186
+
187
+ <Box flex={1}>
188
+ <Text size={fontSize} textOverflow="ellipsis" weight="medium">
189
+ {text}
190
+ </Text>
191
+ </Box>
192
+
193
+ <Text size={fontSize}>
194
+ <ChevronRightIcon />
195
+ </Text>
196
+ </Flex>
198
197
  </Selectable>
199
198
  </Popover>
200
199
  )
@@ -12,7 +12,8 @@ import {useArrayProp, useForwardedRef} from '../../hooks'
12
12
  import {Box, Flex, Text} from '../../primitives'
13
13
  import {Selectable} from '../../primitives/_selectable'
14
14
  import {ResponsivePaddingProps, ResponsiveRadiusProps} from '../../primitives/types'
15
- import {SelectableTone} from '../../types/selectable'
15
+ import {ThemeColorToneKey} from '../../theme'
16
+ import {useToneContext} from '../../theme/toneContext/useToneContext'
16
17
  import {Hotkeys} from '../hotkeys'
17
18
  import {useMenu} from './useMenu'
18
19
 
@@ -29,7 +30,7 @@ export interface MenuItemProps extends ResponsivePaddingProps, ResponsiveRadiusP
29
30
  selected?: boolean
30
31
  space?: number | number[]
31
32
  text?: React.ReactNode
32
- tone?: SelectableTone
33
+ tone?: ThemeColorToneKey
33
34
  }
34
35
 
35
36
  /**
@@ -64,6 +65,7 @@ export const MenuItem = forwardRef(function MenuItem(
64
65
  tone = 'default',
65
66
  ...restProps
66
67
  } = props
68
+ const {scheme} = useToneContext()
67
69
  const menu = useMenu()
68
70
  const {
69
71
  activeElement,
@@ -120,7 +122,8 @@ export const MenuItem = forwardRef(function MenuItem(
120
122
  forwardedAs={as}
121
123
  $radius={useArrayProp(radius)}
122
124
  $padding={useArrayProp(0)}
123
- $tone={tone}
125
+ $tone={disabled ? 'default' : tone}
126
+ $scheme={scheme}
124
127
  disabled={disabled}
125
128
  onClick={handleClick}
126
129
  onMouseEnter={onItemMouseEnter}
@@ -131,43 +134,34 @@ export const MenuItem = forwardRef(function MenuItem(
131
134
  type={as === 'button' ? 'button' : undefined}
132
135
  >
133
136
  {(icon || text || iconRight) && (
134
- <Box as="span" {...paddingProps}>
135
- <Flex as="span">
136
- {icon && (
137
- <Text size={fontSize}>
138
- {isValidElement(icon) && icon}
139
- {isValidElementType(icon) && createElement(icon)}
140
- </Text>
141
- )}
137
+ <Flex as="span" gap={space} align="center" {...paddingProps}>
138
+ {icon && (
139
+ <Text size={fontSize}>
140
+ {isValidElement(icon) && icon}
141
+ {isValidElementType(icon) && createElement(icon)}
142
+ </Text>
143
+ )}
142
144
 
143
- {text && (
144
- <Box
145
- flex={1}
146
- marginLeft={icon ? space : undefined}
147
- marginRight={iconRight ? space : undefined}
148
- >
149
- <Text size={fontSize} textOverflow="ellipsis">
150
- {text}
151
- </Text>
152
- </Box>
153
- )}
145
+ {text && (
146
+ <Box flex={1}>
147
+ <Text size={fontSize} textOverflow="ellipsis" weight="medium">
148
+ {text}
149
+ </Text>
150
+ </Box>
151
+ )}
154
152
 
155
- {hotkeys && (
156
- <Box marginLeft={space} style={{marginTop: -4, marginBottom: -4}}>
157
- <Hotkeys fontSize={fontSize} keys={hotkeys} />
158
- </Box>
159
- )}
153
+ {hotkeys && (
154
+ <Hotkeys fontSize={fontSize} keys={hotkeys} style={{marginTop: -4, marginBottom: -4}} />
155
+ )}
160
156
 
161
- {iconRight && (
162
- <Text size={fontSize}>
163
- {isValidElement(iconRight) && iconRight}
164
- {isValidElementType(iconRight) && createElement(iconRight)}
165
- </Text>
166
- )}
167
- </Flex>
168
- </Box>
157
+ {iconRight && (
158
+ <Text size={fontSize}>
159
+ {isValidElement(iconRight) && iconRight}
160
+ {isValidElementType(iconRight) && createElement(iconRight)}
161
+ </Text>
162
+ )}
163
+ </Flex>
169
164
  )}
170
-
171
165
  {children && (
172
166
  <Box as="span" {...paddingProps}>
173
167
  {children}
@@ -1,4 +1,5 @@
1
1
  import {css, keyframes} from 'styled-components'
2
+ import {cssVars} from '../../theme'
2
3
 
3
4
  const keyframe = keyframes`
4
5
  0% {
@@ -12,11 +13,11 @@ const keyframe = keyframes`
12
13
  const animation = css`
13
14
  background-image: linear-gradient(
14
15
  to right,
15
- var(--card-skeleton-color-from),
16
- var(--card-skeleton-color-to),
17
- var(--card-skeleton-color-from),
18
- var(--card-skeleton-color-from),
19
- var(--card-skeleton-color-from)
16
+ ${cssVars.default['skeleton-from']},
17
+ ${cssVars.default['skeleton-to']},
18
+ ${cssVars.default['skeleton-from']},
19
+ ${cssVars.default['skeleton-from']},
20
+ ${cssVars.default['skeleton-from']}
20
21
  );
21
22
  background-position: 100%;
22
23
  background-size: 200% 100%;
@@ -40,11 +41,11 @@ export const skeletonStyle = css<{$animated: boolean; $visible: boolean}>`
40
41
  $animated
41
42
  ? animation
42
43
  : css`
43
- background-color: var(--card-skeleton-color-from);
44
+ background-color: ${cssVars.default['skeleton-from']};
44
45
  `}
45
46
  }
46
47
 
47
48
  @media screen and (prefers-reduced-motion: reduce) {
48
- background-color: var(--card-skeleton-color-from);
49
+ background-color: ${cssVars.default['skeleton-from']};
49
50
  }
50
51
  `
@@ -1,6 +1,12 @@
1
1
  import {css} from 'styled-components'
2
2
  import {rem, ThemeProps} from '../../styles'
3
- import {_colorVarsStyle} from '../../styles/colorVars'
3
+ import {
4
+ _colorVarStyleActive,
5
+ _colorVarStyleHover,
6
+ _colorVarStyleSelected,
7
+ } from '../../styles/colorVars'
8
+ import {cssVars} from '../../theme'
9
+ import {cardVariables} from '../../theme/lib/theme/color/cssVariables/cardVariables'
4
10
 
5
11
  export function treeItemRootStyle(): ReturnType<typeof css> {
6
12
  return css`
@@ -29,34 +35,28 @@ export function treeItemRootStyle(): ReturnType<typeof css> {
29
35
  `
30
36
  }
31
37
 
32
- export function treeItemRootColorStyle(props: ThemeProps): ReturnType<typeof css> {
33
- const {theme} = props
34
- const $tone = 'default'
35
- const {base, muted, selectable} = theme.sanity.color
36
- // @todo: remove use of `muted` here
37
- const tone = selectable ? selectable[$tone] || selectable.default : muted[$tone] || muted.default
38
-
38
+ export function treeItemRootColorStyle(): ReturnType<typeof css> {
39
39
  return css`
40
40
  /* <div role="none"><a data-ui="TreeItem__box" role="treeitem" tabIndex="0"></div> */
41
41
  &[role='none'] {
42
42
  & > [role='treeitem'] {
43
- ${_colorVarsStyle(base, tone.enabled)}
43
+ ${cardVariables}
44
44
 
45
- background-color: var(--card-bg-color);
45
+ background-color:${cssVars.mutable['bg-color']};
46
46
  color: var(--treeitem-fg-color);
47
47
  }
48
48
 
49
49
  &[data-selected] > [role='treeitem'] {
50
- ${_colorVarsStyle(base, tone.pressed)}
50
+ ${_colorVarStyleActive()}
51
51
  }
52
52
 
53
53
  @media (hover: hover) {
54
54
  &:not([data-selected]) > [role='treeitem']:not(:focus):hover {
55
- ${_colorVarsStyle(base, tone.hovered)}
55
+ ${_colorVarStyleHover()}
56
56
  }
57
57
 
58
58
  & > [role='treeitem']:focus {
59
- ${_colorVarsStyle(base, tone.selected)}
59
+ ${_colorVarStyleSelected()}
60
60
  }
61
61
  }
62
62
  }
@@ -64,23 +64,22 @@ export function treeItemRootColorStyle(props: ThemeProps): ReturnType<typeof css
64
64
  /* <div role="treeitem" tabIndex="0"><div data-ui="TreeItem__box"></div> */
65
65
  &[role='treeitem'] {
66
66
  & > [data-ui='TreeItem__box'] {
67
- ${_colorVarsStyle(base, tone.enabled)}
68
-
69
- background-color: var(--card-bg-color);
70
- color: var(--card-fg-color);
67
+ ${cardVariables}
68
+ background-color: ${cssVars.mutable['bg-color']};
69
+ color: ${cssVars.mutable['fg-color']};
71
70
  }
72
71
 
73
72
  &[data-selected] > [data-ui='TreeItem__box'] {
74
- ${_colorVarsStyle(base, tone.pressed)}
73
+ ${_colorVarStyleActive()}
75
74
  }
76
75
 
77
76
  @media (hover: hover) {
78
77
  &:not([data-selected]):not(:focus) > [data-ui='TreeItem__box']:hover {
79
- ${_colorVarsStyle(base, tone.hovered)}
78
+ ${_colorVarStyleHover()}
80
79
  }
81
80
 
82
81
  &:focus > [data-ui='TreeItem__box'] {
83
- ${_colorVarsStyle(base, tone.selected)}
82
+ ${_colorVarStyleSelected()}
84
83
  }
85
84
  }
86
85
  }
@@ -1,13 +1,19 @@
1
1
  import {css} from 'styled-components'
2
2
  import {ThemeProps} from '../../styles'
3
- import {_colorVarsStyle} from '../../styles/colorVars'
4
- import {SelectableTone} from '../../types/selectable'
3
+ import {
4
+ _colorVarStyleHover,
5
+ _selectableVarStyle,
6
+ _selectableVarStyleDisabled,
7
+ } from '../../styles/colorVars'
8
+
9
+ import {ThemeColorSchemeKey, ThemeColorToneKey, createCssVars, cssVars} from '../../theme'
5
10
 
6
11
  /**
7
12
  * @internal
8
13
  */
9
14
  export interface SelectableStyleProps {
10
- $tone: SelectableTone
15
+ $tone: ThemeColorToneKey
16
+ $scheme: ThemeColorSchemeKey
11
17
  }
12
18
 
13
19
  export function selectableBaseStyle(): ReturnType<typeof css> {
@@ -35,43 +41,41 @@ export function selectableBaseStyle(): ReturnType<typeof css> {
35
41
  export function selectableColorStyle(
36
42
  props: SelectableStyleProps & ThemeProps,
37
43
  ): ReturnType<typeof css> {
38
- const {$tone, theme} = props
39
- const {base, muted, selectable} = theme.sanity.color
40
- // @todo: remove use of `muted` here
41
- const tone = selectable ? selectable[$tone] || selectable.default : muted[$tone] || muted.default
44
+ const {theme, $tone, $scheme} = props
42
45
 
43
46
  return css`
44
- ${_colorVarsStyle(base, tone.enabled)}
47
+ ${$tone !== 'default' && createCssVars($scheme, theme.sanity.color.tones, $tone)}
48
+ ${_selectableVarStyle($tone)}
45
49
 
46
- background-color: var(--card-bg-color);
47
- color: var(--card-fg-color);
50
+ background-color: ${cssVars.mutable['bg-color']};
51
+ color: ${cssVars[$tone]['text-secondary']};
48
52
  outline: none;
49
53
 
50
- /* &:is(button) */
54
+ /* &:is(button) - Looks like a button in default mode */
51
55
  &[data-as='button'] {
52
56
  &:disabled {
53
- ${_colorVarsStyle(base, tone.disabled)}
57
+ ${_selectableVarStyleDisabled()}
54
58
  }
55
59
 
56
60
  &:not(:disabled) {
57
61
  &[aria-pressed='true'] {
58
- ${_colorVarsStyle(base, tone.pressed)}
62
+ ${_colorVarStyleHover()}
59
63
  }
60
64
 
61
65
  &[data-selected],
62
66
  &[aria-selected='true'] > & {
63
- ${_colorVarsStyle(base, tone.selected)}
67
+ ${_colorVarStyleHover()}
64
68
  }
65
69
 
66
70
  @media (hover: hover) {
67
71
  &:not([data-selected]) {
68
72
  &[data-hovered],
69
73
  &:hover {
70
- ${_colorVarsStyle(base, tone.hovered)}
74
+ ${_colorVarStyleHover()}
71
75
  }
72
76
 
73
77
  &:active {
74
- ${_colorVarsStyle(base, tone.pressed)}
78
+ ${_colorVarStyleHover()}
75
79
  }
76
80
  }
77
81
  }
@@ -81,27 +85,26 @@ export function selectableColorStyle(
81
85
  /* &:is(a) */
82
86
  &[data-as='a'] {
83
87
  &[data-disabled] {
84
- ${_colorVarsStyle(base, tone.disabled)}
88
+ ${_selectableVarStyleDisabled()}
85
89
  }
86
90
 
87
91
  &:not([data-disabled]) {
88
92
  &[data-pressed] {
89
- ${_colorVarsStyle(base, tone.pressed)}
93
+ ${_colorVarStyleHover()}
90
94
  }
91
95
 
92
96
  &[data-selected] {
93
- ${_colorVarsStyle(base, tone.selected)}
97
+ ${_colorVarStyleHover()}
94
98
  }
95
99
 
96
100
  @media (hover: hover) {
97
101
  &:not([data-selected]) {
98
102
  &[data-hovered],
99
103
  &:hover {
100
- ${_colorVarsStyle(base, tone.hovered)}
104
+ ${_colorVarStyleHover()}
101
105
  }
102
-
103
106
  &:active {
104
- ${_colorVarsStyle(base, tone.pressed)}
107
+ ${_colorVarStyleHover()}
105
108
  }
106
109
  }
107
110
  }
@@ -2,10 +2,14 @@ import {forwardRef, useCallback, useEffect, useId, useMemo, useState} from 'reac
2
2
  import ReactIs from 'react-is'
3
3
  import styled from 'styled-components'
4
4
  import {useArrayProp} from '../../hooks'
5
- import {ThemeColorSpotKey, useTheme} from '../../theme'
5
+ import {useTheme} from '../../theme'
6
+
7
+ import {useToneContext} from '../../theme/toneContext/useToneContext'
6
8
  import {AvatarPosition, AvatarSize, AvatarStatus} from '../../types'
7
9
  import {Text} from '../text'
10
+ import {spotColor} from './spotColors'
8
11
  import {avatarStyle, responsiveAvatarSizeStyle} from './styles'
12
+ import {ThemeColorSpotKey} from './types'
9
13
 
10
14
  /**
11
15
  * @public
@@ -63,9 +67,10 @@ export const Avatar = forwardRef(function Avatar(
63
67
  const as = ReactIs.isValidElementType(asProp) ? asProp : 'div'
64
68
  const size = useArrayProp(sizeProp)
65
69
  const theme = useTheme()
66
- const color = theme.sanity.color.spot[colorKey] || theme.sanity.color.spot.gray
70
+ const {scheme} = useToneContext()
71
+
72
+ const color = spotColor[colorKey][scheme].hex
67
73
 
68
- // @todo: remove this
69
74
  const avatarSize = theme.sanity.avatar.sizes[size[0]] || theme.sanity.avatar.sizes[0]
70
75
  const _sizeRem = avatarSize.size
71
76
  const _radius = _sizeRem / 2
@@ -3,6 +3,7 @@ import styled, {css} from 'styled-components'
3
3
  import {EMPTY_RECORD} from '../../constants'
4
4
  import {useArrayProp} from '../../hooks'
5
5
  import {rem, _responsive, ThemeProps} from '../../styles'
6
+ import {cssVars} from '../../theme'
6
7
  import {AvatarSize} from '../../types'
7
8
  import {Text} from '../text'
8
9
 
@@ -32,11 +33,11 @@ function _avatarCounterBaseStyle(props: ThemeProps) {
32
33
  box-sizing: border-box;
33
34
  user-select: none;
34
35
  color: inherit;
35
- color: var(--card-fg-color);
36
- background: var(--card-bg-color);
36
+ color: ${cssVars.mutable['fg-color']};
37
+ background: ${cssVars.mutable['bg-color']};
37
38
  box-shadow:
38
- 0 0 0 1px var(--card-bg-color),
39
- inset 0 0 0 1.5px var(--card-hairline-hard-color);
39
+ 0 0 0 1px ${cssVars.mutable['bg-color']},
40
+ inset 0 0 0 1.5px ${cssVars.default['border-base']});
40
41
  padding: 0 ${rem(theme.sanity.space[2])};
41
42
 
42
43
  &:not([hidden]) {
@@ -0,0 +1,53 @@
1
+ import {
2
+ gray,
3
+ blue,
4
+ purple,
5
+ magenta,
6
+ red,
7
+ orange,
8
+ yellow,
9
+ green,
10
+ cyan,
11
+ ColorTint,
12
+ } from '@sanity/color'
13
+ import {ThemeColorSchemeKey} from '../../theme'
14
+ import {ThemeColorSpotKey} from './types'
15
+
16
+ export const spotColor: Record<ThemeColorSpotKey, Record<ThemeColorSchemeKey, ColorTint>> = {
17
+ gray: {
18
+ dark: gray['400'],
19
+ light: gray['500'],
20
+ },
21
+ blue: {
22
+ dark: blue['400'],
23
+ light: blue['500'],
24
+ },
25
+ purple: {
26
+ dark: purple['400'],
27
+ light: purple['500'],
28
+ },
29
+ magenta: {
30
+ dark: magenta['400'],
31
+ light: magenta['500'],
32
+ },
33
+ red: {
34
+ dark: red['400'],
35
+ light: red['500'],
36
+ },
37
+ orange: {
38
+ dark: orange['400'],
39
+ light: orange['500'],
40
+ },
41
+ yellow: {
42
+ dark: yellow['400'],
43
+ light: yellow['500'],
44
+ },
45
+ green: {
46
+ dark: green['400'],
47
+ light: green['500'],
48
+ },
49
+ cyan: {
50
+ dark: cyan['400'],
51
+ light: cyan['500'],
52
+ },
53
+ }
@@ -1,5 +1,6 @@
1
1
  import {rem, _responsive, ThemeProps} from '../../styles'
2
2
  import {focusRingStyle} from '../../styles/internal'
3
+ import {cssVars} from '../../theme/lib/theme/color/cssVariables/createCssVars'
3
4
  import {CSSObject} from '../../types/styled'
4
5
  import {AvatarRootStyleProps, ResponsiveAvatarSizeStyleProps} from './types'
5
6
 
@@ -64,7 +65,7 @@ export function avatarRootStyle(props: AvatarRootStyleProps & ThemeProps): CSSOb
64
65
  position: 'relative',
65
66
  boxSizing: 'border-box',
66
67
  userSelect: 'none',
67
- boxShadow: '0 0 0 1px var(--card-bg-color)',
68
+ boxShadow: `0 0 0 1px ${cssVars.mutable['bg-color']}`,
68
69
 
69
70
  '&[data-status="inactive"]': {
70
71
  opacity: 0.5,
@@ -123,14 +124,11 @@ export function responsiveAvatarSizeStyle(
123
124
  })
124
125
  }
125
126
 
126
- export function avatarInitialsStyle(props: ThemeProps): CSSObject {
127
- const {theme} = props
128
- const {base} = theme.sanity.color
129
-
127
+ export function avatarInitialsStyle(): CSSObject {
130
128
  return {
131
129
  width: '100%',
132
130
  height: '100%',
133
- color: base.fg,
131
+ color: cssVars.default['text-primary'],
134
132
  alignItems: 'center',
135
133
  justifyContent: 'center',
136
134
  textTransform: 'uppercase',
@@ -146,7 +144,7 @@ export function avatarInitialsStyle(props: ThemeProps): CSSObject {
146
144
  function avatarBgStrokeStyle(): CSSObject {
147
145
  return {
148
146
  strokeWidth: '4px',
149
- stroke: 'var(--card-bg-color)',
147
+ stroke: cssVars.mutable['bg-color'],
150
148
  }
151
149
  }
152
150