@sanity/ui 1.8.3 → 2.0.0-alpha.10

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 (137) hide show
  1. package/dist/index.cjs.mjs +3 -0
  2. package/dist/index.d.ts +339 -415
  3. package/dist/index.esm.js +5374 -2489
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/index.js +5375 -2487
  6. package/dist/index.js.map +1 -1
  7. package/package.json +21 -3
  8. package/src/components/autocomplete/autocomplete.tsx +2 -1
  9. package/src/components/dialog/constants.ts +4 -0
  10. package/src/components/dialog/dialog.tsx +89 -27
  11. package/src/components/dialog/styles.ts +3 -4
  12. package/src/components/hotkeys/hotkeys.tsx +2 -1
  13. package/src/components/menu/__workshop__/closableMenuButton.tsx +2 -2
  14. package/src/components/menu/menuButton.tsx +2 -2
  15. package/src/components/menu/menuDivider.ts +2 -1
  16. package/src/components/menu/menuGroup.tsx +24 -25
  17. package/src/components/menu/menuItem.tsx +31 -37
  18. package/src/components/skeleton/styles.ts +8 -7
  19. package/src/components/tab/tab.tsx +2 -1
  20. package/src/components/tree/style.ts +19 -20
  21. package/src/primitives/_selectable/style.ts +25 -23
  22. package/src/primitives/avatar/avatar.tsx +8 -3
  23. package/src/primitives/avatar/avatarCounter.tsx +5 -4
  24. package/src/primitives/avatar/spotColors.ts +53 -0
  25. package/src/primitives/avatar/styles.ts +6 -8
  26. package/src/primitives/avatar/types.ts +14 -0
  27. package/src/primitives/badge/badge.tsx +5 -3
  28. package/src/primitives/badge/styles.ts +7 -8
  29. package/src/primitives/box/__workshop__/responsive.tsx +2 -2
  30. package/src/primitives/button/__workshop__/sanityUploadButton.tsx +1 -2
  31. package/src/primitives/button/button.tsx +8 -9
  32. package/src/primitives/button/styles.ts +100 -17
  33. package/src/primitives/card/__workshop__/selected.tsx +8 -9
  34. package/src/primitives/card/card.tsx +43 -7
  35. package/src/primitives/card/styles.ts +31 -24
  36. package/src/primitives/card/types.ts +3 -1
  37. package/src/primitives/checkbox/checkbox.tsx +1 -0
  38. package/src/primitives/checkbox/styles.ts +53 -23
  39. package/src/primitives/code/code.tsx +15 -3
  40. package/src/primitives/code/styles.ts +51 -42
  41. package/src/primitives/heading/styles.ts +6 -5
  42. package/src/primitives/kbd/kbd.tsx +7 -6
  43. package/src/primitives/label/styles.ts +3 -2
  44. package/src/primitives/popover/popoverArrow.tsx +3 -2
  45. package/src/primitives/popover/popoverCard.tsx +8 -4
  46. package/src/primitives/radio/radio.tsx +1 -0
  47. package/src/primitives/radio/styles.ts +26 -13
  48. package/src/primitives/select/select.tsx +3 -2
  49. package/src/primitives/select/styles.ts +22 -24
  50. package/src/primitives/switch/__workshop__/props.tsx +4 -4
  51. package/src/primitives/switch/styles.ts +19 -12
  52. package/src/primitives/text/__workshop__/colored.tsx +10 -11
  53. package/src/primitives/text/styles.ts +10 -8
  54. package/src/primitives/textArea/textArea.tsx +8 -12
  55. package/src/primitives/textInput/textInput.tsx +15 -14
  56. package/src/primitives/tooltip/__workshop__/props.tsx +20 -3
  57. package/src/primitives/tooltip/tooltip.tsx +2 -2
  58. package/src/primitives/tooltip/tooltipArrow.tsx +3 -2
  59. package/src/primitives/types.ts +3 -2
  60. package/src/styles/border/borderStyle.ts +2 -1
  61. package/src/styles/colorVars/colorVarsStyle.ts +73 -30
  62. package/src/styles/focusRing/index.ts +8 -4
  63. package/src/styles/input/textInputStyle.ts +78 -94
  64. package/src/styles/margin/marginsStyle.test.ts +1 -2
  65. package/src/styles/padding/paddingStyle.test.ts +1 -2
  66. package/src/styles/radius/radiusStyle.ts +14 -4
  67. package/src/styles/radius/types.ts +3 -1
  68. package/src/styles/shadow/shadowStyle.ts +5 -5
  69. package/src/theme/__workshop__/color.tsx +2 -2
  70. package/src/theme/__workshop__/index.ts +0 -5
  71. package/src/theme/lib/color-fns/blend/multiply.ts +2 -2
  72. package/src/theme/lib/color-fns/blend/screen.ts +2 -2
  73. package/src/theme/lib/color-fns/convert.ts +15 -1
  74. package/src/theme/lib/color-fns/parse.ts +7 -3
  75. package/src/theme/lib/color-fns/types.ts +11 -0
  76. package/src/theme/lib/theme/avatar.ts +3 -0
  77. package/src/theme/lib/theme/color/_legacy/createColorTheme.ts +7 -0
  78. package/src/theme/lib/theme/color/_legacy/index.ts +1 -0
  79. package/src/theme/lib/theme/color/_legacy/legacyColor.ts +3997 -0
  80. package/src/theme/lib/theme/color/cssVariables/cardVariables.ts +88 -0
  81. package/src/theme/lib/theme/color/cssVariables/createCssVars.ts +31 -0
  82. package/src/theme/lib/theme/color/cssVariables/cssVars.test.ts +262 -0
  83. package/src/theme/lib/theme/color/cssVariables/index.ts +1 -0
  84. package/src/theme/lib/theme/color/cssVariables/tints.ts +312 -0
  85. package/src/theme/lib/theme/color/cssVariables/tones.ts +67 -0
  86. package/src/theme/lib/theme/color/cssVariables/utils.test.ts +15 -0
  87. package/src/theme/lib/theme/color/cssVariables/utils.ts +9 -0
  88. package/src/theme/lib/theme/color/index.ts +3 -12
  89. package/src/theme/lib/theme/color/types.ts +6 -37
  90. package/src/theme/lib/theme/input.ts +11 -0
  91. package/src/theme/lib/theme/theme.ts +7 -1
  92. package/src/theme/studioTheme/color.ts +6 -633
  93. package/src/theme/studioTheme/fonts.ts +3 -3
  94. package/src/theme/studioTheme/helpers.ts +15 -1
  95. package/src/theme/studioTheme/theme.ts +26 -6
  96. package/src/theme/themeColorProvider.tsx +2 -0
  97. package/src/theme/themeProvider.tsx +28 -8
  98. package/src/theme/toneContext/toneContext.ts +12 -0
  99. package/src/theme/toneContext/toneProvider.tsx +31 -0
  100. package/src/theme/toneContext/types.ts +10 -0
  101. package/src/theme/toneContext/useToneContext.tsx +26 -0
  102. package/src/theme/types.ts +10 -4
  103. package/src/types/index.ts +1 -0
  104. package/src/types/radius.ts +4 -0
  105. package/src/utils/elementQuery/__workshop__/customMedia.tsx +4 -3
  106. package/src/theme/__workshop__/canvas.tsx +0 -395
  107. package/src/theme/lib/theme/color/_generic/index.ts +0 -1
  108. package/src/theme/lib/theme/color/_generic/types.ts +0 -29
  109. package/src/theme/lib/theme/color/base/index.ts +0 -1
  110. package/src/theme/lib/theme/color/base/types.ts +0 -19
  111. package/src/theme/lib/theme/color/button/createButtonModes.ts +0 -20
  112. package/src/theme/lib/theme/color/button/createButtonTones.ts +0 -52
  113. package/src/theme/lib/theme/color/button/index.ts +0 -1
  114. package/src/theme/lib/theme/color/button/types.ts +0 -44
  115. package/src/theme/lib/theme/color/card/createCardStates.ts +0 -58
  116. package/src/theme/lib/theme/color/card/index.ts +0 -1
  117. package/src/theme/lib/theme/color/card/types.ts +0 -18
  118. package/src/theme/lib/theme/color/color.test.ts +0 -62
  119. package/src/theme/lib/theme/color/defaults.ts +0 -382
  120. package/src/theme/lib/theme/color/factory.ts +0 -138
  121. package/src/theme/lib/theme/color/input/createInputModes.ts +0 -84
  122. package/src/theme/lib/theme/color/input/index.ts +0 -1
  123. package/src/theme/lib/theme/color/input/types.ts +0 -27
  124. package/src/theme/lib/theme/color/muted/createMuted.ts +0 -56
  125. package/src/theme/lib/theme/color/muted/index.ts +0 -1
  126. package/src/theme/lib/theme/color/muted/types.ts +0 -24
  127. package/src/theme/lib/theme/color/selectable/createSelectableTones.ts +0 -73
  128. package/src/theme/lib/theme/color/selectable/index.ts +0 -1
  129. package/src/theme/lib/theme/color/selectable/types.ts +0 -29
  130. package/src/theme/lib/theme/color/solid/createSolidTones.ts +0 -56
  131. package/src/theme/lib/theme/color/solid/index.ts +0 -1
  132. package/src/theme/lib/theme/color/solid/types.ts +0 -24
  133. package/src/theme/lib/theme/color/spot/createSpot.ts +0 -21
  134. package/src/theme/lib/theme/color/spot/index.ts +0 -1
  135. package/src/theme/lib/theme/color/spot/types.ts +0 -28
  136. package/src/theme/lib/theme/color/syntax/index.ts +0 -1
  137. package/src/theme/lib/theme/color/syntax/types.ts +0 -41
@@ -1,27 +1,26 @@
1
- import {Flex, Text, Theme, ThemeColorSpotKey, useTheme} from '@sanity/ui'
1
+ import {Flex, Text, useTheme} from '@sanity/ui'
2
2
  import {useSelect} from '@sanity/ui-workshop'
3
3
  import styled, {css} from 'styled-components'
4
4
  import {WORKSHOP_SPOT_COLOR_OPTIONS} from '../../../__workshop__/constants'
5
+ import {useToneContext} from '../../../theme/toneContext/useToneContext'
6
+ import {spotColor} from '../../avatar/spotColors'
5
7
 
6
- const ColoredText = styled(Text)<{color?: ThemeColorSpotKey}>((props: {
7
- color?: ThemeColorSpotKey
8
- theme: Theme
9
- }) => {
10
- const {spot} = props.theme.sanity.color
11
-
8
+ const ColoredText = styled(Text)<{color: string}>((props: {color: string}) => {
12
9
  return css`
13
- color: ${spot[props.color || 'gray']};
10
+ color: ${props.color};
14
11
  `
15
12
  })
16
13
 
17
14
  export default function ColoredTextStory() {
18
15
  const theme = useTheme()
19
- const color = useSelect('Color', WORKSHOP_SPOT_COLOR_OPTIONS, 'gray')
16
+ const selectedColor = useSelect('Color', WORKSHOP_SPOT_COLOR_OPTIONS, 'gray')
17
+ const {scheme} = useToneContext()
18
+ const color = spotColor[selectedColor ?? 'gray'][scheme]
20
19
 
21
20
  return (
22
21
  <Flex align="center" height="fill" justify="center" padding={[4, 5, 6]} sizing="border">
23
- <ColoredText align="center" color={color} size={4} theme={theme} weight="bold">
24
- {color}
22
+ <ColoredText align="center" color={color.hex} size={4} theme={theme} weight="bold">
23
+ {color.title}
25
24
  </ColoredText>
26
25
  </Flex>
27
26
  )
@@ -1,5 +1,6 @@
1
1
  import {css} from 'styled-components'
2
2
  import {ThemeProps} from '../../styles'
3
+ import {cssVars} from '../../theme'
3
4
 
4
5
  export function textBaseStyle(
5
6
  props: {$accent?: boolean; $muted?: boolean} & ThemeProps,
@@ -8,29 +9,29 @@ export function textBaseStyle(
8
9
  const {weights} = theme.sanity.fonts.text
9
10
 
10
11
  return css`
11
- color: var(--card-fg-color);
12
+ color: ${cssVars.mutable['fg-color']};
12
13
 
13
14
  ${$accent &&
14
15
  css`
15
- color: var(--card-accent-fg-color);
16
+ color: ${cssVars.default['text-accent']};
16
17
  `}
17
18
 
18
19
  ${$muted &&
19
20
  css`
20
- color: var(--card-muted-fg-color);
21
+ color: ${cssVars.mutable['muted-fg-color']};
21
22
  `}
22
23
 
23
24
  & code {
24
25
  font-family: ${theme.sanity.fonts.code.family};
25
26
  border-radius: 1px;
26
- background-color: var(--card-code-bg-color);
27
- color: var(--card-code-fg-color);
27
+ background-color: ${cssVars.default['bg-tint-code']};
28
+ color: ${cssVars.default['text-code']};
28
29
  }
29
30
 
30
31
  & a {
31
32
  text-decoration: none;
32
33
  border-radius: 1px;
33
- color: var(--card-link-color);
34
+ color: ${cssVars.default['text-link']};
34
35
  outline: none;
35
36
 
36
37
  @media (hover: hover) {
@@ -41,8 +42,8 @@ export function textBaseStyle(
41
42
 
42
43
  &:focus {
43
44
  box-shadow:
44
- 0 0 0 1px var(--card-bg-color),
45
- 0 0 0 3px var(--card-focus-ring-color);
45
+ 0 0 0 1px ${cssVars.mutable['bg-color']},
46
+ 0 0 0 3px ${cssVars.positive['border-accent']};
46
47
  }
47
48
 
48
49
  &:focus:not(:focus-visible) {
@@ -62,6 +63,7 @@ export function textBaseStyle(
62
63
 
63
64
  & [data-sanity-icon] {
64
65
  vertical-align: baseline;
66
+ color: ${cssVars.mutable['icon-color']};
65
67
  }
66
68
  `
67
69
  }
@@ -13,7 +13,7 @@ import {
13
13
  textInputFontSizeStyle,
14
14
  textInputRepresentationStyle,
15
15
  } from '../../styles/internal'
16
- import {ThemeFontWeightKey, useRootTheme} from '../../theme'
16
+ import {ThemeColorToneKey, ThemeFontWeightKey} from '../../theme'
17
17
  import {ResponsiveRadiusProps} from '../types'
18
18
 
19
19
  /**
@@ -25,6 +25,7 @@ export interface TextAreaProps extends ResponsiveRadiusProps {
25
25
  fontSize?: number | number[]
26
26
  padding?: number | number[]
27
27
  weight?: ThemeFontWeightKey
28
+ tone?: ThemeColorToneKey
28
29
  }
29
30
 
30
31
  const Root = styled.span(textInputRootStyle)
@@ -60,15 +61,14 @@ export const TextArea = forwardRef(function TextArea(
60
61
  disabled = false,
61
62
  fontSize = 2,
62
63
  padding = 3,
63
- radius = 1,
64
+ radius = 2,
64
65
  weight,
66
+ tone = 'default',
65
67
  ...restProps
66
68
  } = props
67
69
 
68
70
  const ref = useForwardedRef(forwardedRef)
69
71
 
70
- const rootTheme = useRootTheme()
71
-
72
72
  useCustomValidity(ref, customValidity)
73
73
 
74
74
  return (
@@ -76,25 +76,21 @@ export const TextArea = forwardRef(function TextArea(
76
76
  <InputRoot>
77
77
  <Input
78
78
  data-as="textarea"
79
- data-scheme={rootTheme.scheme}
80
- data-tone={rootTheme.tone}
79
+ data-tone={tone}
81
80
  {...restProps}
82
81
  $fontSize={useArrayProp(fontSize)}
83
82
  $padding={useArrayProp(padding)}
84
- $scheme={rootTheme.scheme}
85
83
  $space={useArrayProp(0)}
86
- $tone={rootTheme.tone}
84
+ $tone={tone}
87
85
  $weight={weight}
88
86
  disabled={disabled}
89
87
  ref={ref}
90
88
  />
91
89
  <Presentation
92
90
  $radius={useArrayProp(radius)}
93
- $scheme={rootTheme.scheme}
94
- $tone={rootTheme.tone}
91
+ $tone={tone}
95
92
  data-border={border ? '' : undefined}
96
- data-scheme={rootTheme.scheme}
97
- data-tone={rootTheme.tone}
93
+ data-tone={tone}
98
94
  />
99
95
  </InputRoot>
100
96
  </Root>
@@ -16,7 +16,9 @@ import {
16
16
  textInputRepresentationStyle,
17
17
  textInputRootStyle,
18
18
  } from '../../styles/internal'
19
- import {ThemeFontWeightKey, useRootTheme} from '../../theme'
19
+ import {ThemeColorToneKey, ThemeFontWeightKey} from '../../theme'
20
+ import {useToneContext} from '../../theme/toneContext/useToneContext'
21
+ import {Radius} from '../../types'
20
22
  import {Box} from '../box'
21
23
  import {Button, ButtonProps} from '../button'
22
24
  import {Card} from '../card'
@@ -64,11 +66,12 @@ export interface TextInputProps {
64
66
  onClear?: () => void
65
67
  padding?: number | number[]
66
68
  prefix?: React.ReactNode
67
- radius?: number | number[]
69
+ radius?: Radius | Radius[]
68
70
  space?: number | number[]
69
71
  suffix?: React.ReactNode
70
72
  type?: TextInputType
71
73
  weight?: ThemeFontWeightKey
74
+ tone?: ThemeColorToneKey
72
75
  }
73
76
 
74
77
  const CLEAR_BUTTON_BOX_STYLE: React.CSSProperties = {zIndex: 2}
@@ -155,19 +158,21 @@ export const TextInput = forwardRef(function TextInput(
155
158
  onClear,
156
159
  padding: paddingProp = 3,
157
160
  prefix,
158
- radius: radiusProp = 1,
161
+ radius: radiusProp = 2,
159
162
  readOnly,
160
163
  space: spaceProp = 3,
161
164
  suffix,
162
165
  customValidity,
163
166
  type = 'text',
164
167
  weight,
168
+ tone: toneProp = 'default',
165
169
  ...restProps
166
170
  } = props
167
171
 
168
172
  const ref = useForwardedRef(forwardedRef)
169
173
 
170
- const rootTheme = useRootTheme()
174
+ const toneContext = useToneContext()
175
+ const tone = toneProp === 'default' ? toneContext.tone : toneProp
171
176
 
172
177
  const fontSize = useArrayProp(fontSizeProp)
173
178
  const padding = useArrayProp(paddingProp)
@@ -220,11 +225,9 @@ export const TextInput = forwardRef(function TextInput(
220
225
  $hasPrefix={$hasPrefix}
221
226
  $hasSuffix={$hasSuffix}
222
227
  $radius={radius}
223
- $scheme={rootTheme.scheme}
224
- $tone={rootTheme.tone}
228
+ $tone={tone}
225
229
  data-border={border ? '' : undefined}
226
- data-scheme={rootTheme.scheme}
227
- data-tone={rootTheme.tone}
230
+ data-tone={tone}
228
231
  >
229
232
  {icon && (
230
233
  <LeftBox padding={padding}>
@@ -252,10 +255,10 @@ export const TextInput = forwardRef(function TextInput(
252
255
  iconRight,
253
256
  padding,
254
257
  radius,
255
- rootTheme,
256
258
  $hasClearButton,
257
259
  $hasPrefix,
258
260
  $hasSuffix,
261
+ tone,
259
262
  ],
260
263
  )
261
264
 
@@ -338,22 +341,20 @@ export const TextInput = forwardRef(function TextInput(
338
341
  )
339
342
 
340
343
  return (
341
- <Root data-ui="TextInput" tone={rootTheme.tone}>
344
+ <Root data-ui="TextInput" tone={tone}>
342
345
  {prefixNode}
343
346
 
344
347
  <InputRoot>
345
348
  <Input
346
349
  data-as="input"
347
- data-scheme={rootTheme.scheme}
348
- data-tone={rootTheme.tone}
350
+ data-tone={tone}
349
351
  {...restProps}
350
352
  $fontSize={fontSize}
351
353
  $iconLeft={$hasIcon}
352
354
  $iconRight={$hasIconRight || $hasClearButton}
353
355
  $padding={padding}
354
- $scheme={rootTheme.scheme}
355
356
  $space={space}
356
- $tone={rootTheme.tone}
357
+ $tone={tone}
357
358
  $weight={weight}
358
359
  disabled={disabled}
359
360
  readOnly={readOnly}
@@ -1,4 +1,13 @@
1
- import {Button, Card, Flex, Text, Tooltip, TooltipDelayGroupProvider, Stack} from '@sanity/ui'
1
+ import {
2
+ Button,
3
+ Card,
4
+ Flex,
5
+ Text,
6
+ Tooltip,
7
+ TooltipDelayGroupProvider,
8
+ Stack,
9
+ cssVars,
10
+ } from '@sanity/ui'
2
11
  import {useBoolean, useSelect, useText, useNumber} from '@sanity/ui-workshop'
3
12
  import {
4
13
  WORKSHOP_PLACEMENT_OPTIONS,
@@ -28,7 +37,11 @@ export default function PropsStory() {
28
37
  >
29
38
  <Stack
30
39
  padding={4}
31
- style={{outline: '1px solid var(--card-border-color)', width: '100%', maxWidth: '640px'}}
40
+ style={{
41
+ outline: `1px solid ${cssVars.default['border-base']}`,
42
+ width: '100%',
43
+ maxWidth: '640px',
44
+ }}
32
45
  space={4}
33
46
  >
34
47
  <Text align="center" size={3}>
@@ -52,7 +65,11 @@ export default function PropsStory() {
52
65
  </Stack>
53
66
  <Stack
54
67
  padding={4}
55
- style={{outline: '1px solid var(--card-border-color)', width: '100%', maxWidth: '640px'}}
68
+ style={{
69
+ outline: `1px solid ${cssVars.default['border-base']}`,
70
+ width: '100%',
71
+ maxWidth: '640px',
72
+ }}
56
73
  space={4}
57
74
  >
58
75
  <Text align="center" size={3}>
@@ -81,7 +81,7 @@ export const Tooltip = forwardRef(function Tooltip(
81
81
  disabled,
82
82
  fallbackPlacements: fallbackPlacementsProp = props.fallbackPlacements ??
83
83
  DEFAULT_FALLBACK_PLACEMENTS[props.placement ?? 'bottom'],
84
- padding,
84
+ padding = 3,
85
85
  placement: placementProp = 'bottom',
86
86
  portal,
87
87
  scheme,
@@ -303,7 +303,7 @@ export const Tooltip = forwardRef(function Tooltip(
303
303
  data-ui="Tooltip__card"
304
304
  data-placement={placement}
305
305
  padding={padding}
306
- radius={2}
306
+ radius={3}
307
307
  scheme={scheme}
308
308
  shadow={shadow}
309
309
  >
@@ -1,5 +1,6 @@
1
1
  import {forwardRef} from 'react'
2
2
  import styled from 'styled-components'
3
+ import {cssVars} from '../../theme'
3
4
 
4
5
  const Root = styled.div`
5
6
  position: absolute;
@@ -63,11 +64,11 @@ const Root = styled.div`
63
64
  `
64
65
 
65
66
  const Border = styled.path`
66
- fill: var(--card-shadow-outline-color);
67
+ fill: ${cssVars.default['base-shadow-outline-color']};
67
68
  `
68
69
 
69
70
  const Shape = styled.path`
70
- fill: var(--card-bg-color);
71
+ fill: ${cssVars.mutable['bg-color']};
71
72
  `
72
73
 
73
74
  interface TooltipArrowProps {}
@@ -17,6 +17,7 @@ import {
17
17
  GridItemRow,
18
18
  GridItemRowEnd,
19
19
  GridItemRowStart,
20
+ Radius,
20
21
  } from '../types'
21
22
 
22
23
  /**
@@ -113,7 +114,7 @@ export interface ResponsivePaddingProps {
113
114
  * @public
114
115
  */
115
116
  export interface ResponsiveRadiusProps {
116
- radius?: number | number[]
117
+ radius?: Radius | Radius[]
117
118
  }
118
119
 
119
120
  /**
@@ -131,7 +132,7 @@ export interface ResponsiveWidthProps {
131
132
  }
132
133
 
133
134
  /**
134
- * @beta
135
+ * @public
135
136
  */
136
137
  export type Delay =
137
138
  | number
@@ -1,9 +1,10 @@
1
+ import {cssVars} from '../../theme'
1
2
  import {CSSObject} from '../../types/styled'
2
3
  import {_responsive} from '../helpers'
3
4
  import {ThemeProps} from '../types'
4
5
  import {ResponsiveBorderStyleProps} from './types'
5
6
 
6
- const BORDER_VALUE = '1px solid var(--card-border-color)'
7
+ const BORDER_VALUE = `1px solid ${cssVars.default['border-base']}`
7
8
 
8
9
  export function responsiveBorderStyle(): Array<
9
10
  (props: ResponsiveBorderStyleProps & ThemeProps) => CSSObject[]
@@ -1,41 +1,84 @@
1
- import {ThemeColorBase, ThemeColorGenericState} from '../../theme'
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'
2
4
  import {CSSObject} from '../../types/styled'
3
5
 
4
6
  /**
5
7
  * @internal
8
+ * Card overrides in disabled states
6
9
  */
7
- export function _colorVarsStyle(
8
- base: ThemeColorBase,
9
- color: ThemeColorGenericState,
10
- checkered = false,
11
- ): CSSObject {
10
+ export function _colorVarStyleDisabled(checkered = false): CSSObject {
12
11
  return {
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,
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'],
20
16
 
21
- // Card
22
- '--card-bg-color': color.bg,
23
- '--card-bg-image': checkered
24
- ? `repeating-conic-gradient(${color.bg} 0% 25%, ${color.bg2 || color.bg} 0% 50%)`
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%)`
25
24
  : undefined,
26
- '--card-fg-color': color.fg,
27
- '--card-border-color': color.border,
28
- '--card-muted-fg-color': color.muted?.fg,
29
- '--card-accent-fg-color': color.accent?.fg,
30
- '--card-link-fg-color': color.link?.fg,
31
- '--card-code-bg-color': color.code?.bg,
32
- '--card-code-fg-color': color.code?.fg,
33
- '--card-skeleton-color-from': color.skeleton?.from,
34
- '--card-skeleton-color-to': color.skeleton?.to,
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
+ }
35
62
 
36
- // @todo: deprecate
37
- '--card-link-color': color.link?.fg,
38
- '--card-hairline-soft-color': color.border,
39
- '--card-hairline-hard-color': color.border,
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,
40
83
  }
41
84
  }
@@ -1,3 +1,5 @@
1
+ import {FocusRing, cssVars} from '../../theme'
2
+
1
3
  export function focusRingBorderStyle(border: {color: string; width: number}): string {
2
4
  return `inset 0 0 0 ${border.width}px ${border.color}`
3
5
  }
@@ -5,18 +7,20 @@ export function focusRingBorderStyle(border: {color: string; width: number}): st
5
7
  export function focusRingStyle(opts: {
6
8
  base?: {bg: string}
7
9
  border?: {color: string; width: number}
8
- focusRing: {offset: number; width: number}
10
+ focusRing: FocusRing
9
11
  }): string {
10
12
  const {base, border, focusRing} = opts
11
13
  const focusRingOutsetWidth = focusRing.offset + focusRing.width
12
14
  const focusRingInsetWidth = 0 - focusRing.offset
13
- const bgColor = base ? base.bg : 'var(--card-bg-color)'
15
+ const bgColor = base ? base.bg : cssVars.mutable['bg-color']
14
16
 
15
17
  return [
16
- focusRingInsetWidth > 0 && `inset 0 0 0 ${focusRingInsetWidth}px var(--card-focus-ring-color)`,
18
+ focusRingInsetWidth > 0 &&
19
+ `inset 0 0 0 ${focusRingInsetWidth}px ${cssVars.positive['border-accent']}`,
17
20
  border && focusRingBorderStyle(border),
18
21
  focusRingInsetWidth < 0 && `0 0 0 ${0 - focusRingInsetWidth}px ${bgColor}`,
19
- focusRingOutsetWidth > 0 && `0 0 0 ${focusRingOutsetWidth}px var(--card-focus-ring-color)`,
22
+ focusRingOutsetWidth > 0 &&
23
+ `0 0 0 ${focusRingOutsetWidth}px ${cssVars.positive['border-accent']}`,
20
24
  ]
21
25
  .filter(Boolean)
22
26
  .join(',')