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

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,66 +1,57 @@
1
- import {purple, green, yellow, orange, cyan, gray, red, blue, magenta} from '@sanity/color'
2
- import {css} from 'styled-components'
3
- import {ThemeColorSchemeKey} from '../../theme'
4
- import {cssVars} from '../../theme/lib/theme/color/cssVariables/createCssVars'
1
+ import {css, ExecutionContext} from 'styled-components'
5
2
 
6
- function codeSyntaxHighlightingStyle(scheme: ThemeColorSchemeKey) {
7
- const dark = scheme === 'dark'
8
- const mainShade = dark ? 400 : 600
9
- const secondaryShade = dark ? 600 : 400
3
+ function codeSyntaxHighlightingStyle({theme}: ExecutionContext) {
4
+ const color = theme.sanity.color.syntax
10
5
 
11
6
  return {
12
- '&.atrule': {color: purple[mainShade].hex},
13
- '&.attr-name': {color: green[mainShade].hex},
14
- '&.attr-value': {color: yellow[mainShade].hex},
15
- '&.attribute': {color: yellow[mainShade].hex},
16
- '&.boolean': {color: purple[mainShade].hex},
17
- '&.builtin': {color: purple[mainShade].hex},
18
- '&.cdata': {color: yellow[mainShade].hex},
19
- '&.char': {color: yellow[mainShade].hex},
20
- '&.class': {color: orange[mainShade].hex},
21
- '&.class-name': {color: cyan[mainShade].hex},
22
- '&.comment': {color: gray[secondaryShade].hex},
23
- '&.constant': {color: purple[mainShade].hex},
24
- '&.deleted': {color: red[mainShade].hex},
25
- '&.doctype': {color: gray[secondaryShade].hex},
26
- '&.entity': {color: red[mainShade].hex},
27
- '&.function': {color: green[mainShade].hex},
28
- '&.hexcode': {color: blue[mainShade].hex},
29
- '&.id': {color: purple[mainShade].hex},
30
- '&.important': {color: purple[mainShade].hex},
31
- '&.inserted': {color: yellow[mainShade].hex},
32
- '&.keyword': {color: magenta[mainShade].hex},
33
- '&.number': {color: purple[mainShade].hex},
34
- '&.operator': {color: magenta[mainShade].hex},
35
- '&.prolog': {color: gray[secondaryShade].hex},
36
- '&.property': {color: blue[mainShade].hex},
37
- '&.pseudo-class': {color: yellow[mainShade].hex},
38
- '&.pseudo-element': {color: yellow[mainShade].hex},
39
- '&.punctuation': {color: gray[mainShade].hex},
40
- '&.regex': {color: blue[mainShade].hex},
41
- '&.selector': {color: red[mainShade].hex},
42
- '&.string': {color: yellow[mainShade].hex},
43
- '&.symbol': {color: purple[mainShade].hex},
44
- '&.tag': {color: red[mainShade].hex},
45
- '&.unit': {color: orange[mainShade].hex},
46
- '&.url': {color: red[mainShade].hex},
47
- '&.variable': {color: red[mainShade].hex},
7
+ '&.atrule': {color: color.atrule},
8
+ '&.attr-name': {color: color.attrName},
9
+ '&.attr-value': {color: color.attrValue},
10
+ '&.attribute': {color: color.attribute},
11
+ '&.boolean': {color: color.boolean},
12
+ '&.builtin': {color: color.builtin},
13
+ '&.cdata': {color: color.cdata},
14
+ '&.char': {color: color.char},
15
+ '&.class': {color: color.class},
16
+ '&.class-name': {color: color.className},
17
+ '&.comment': {color: color.comment},
18
+ '&.constant': {color: color.constant},
19
+ '&.deleted': {color: color.deleted},
20
+ '&.doctype': {color: color.doctype},
21
+ '&.entity': {color: color.entity},
22
+ '&.function': {color: color.function},
23
+ '&.hexcode': {color: color.hexcode},
24
+ '&.id': {color: color.id},
25
+ '&.important': {color: color.important},
26
+ '&.inserted': {color: color.inserted},
27
+ '&.keyword': {color: color.keyword},
28
+ '&.number': {color: color.number},
29
+ '&.operator': {color: color.operator},
30
+ '&.prolog': {color: color.prolog},
31
+ '&.property': {color: color.property},
32
+ '&.pseudo-class': {color: color.pseudoClass},
33
+ '&.pseudo-element': {color: color.pseudoElement},
34
+ '&.punctuation': {color: color.punctuation},
35
+ '&.regex': {color: color.regex},
36
+ '&.selector': {color: color.selector},
37
+ '&.string': {color: color.string},
38
+ '&.symbol': {color: color.symbol},
39
+ '&.tag': {color: color.tag},
40
+ '&.unit': {color: color.unit},
41
+ '&.url': {color: color.url},
42
+ '&.variable': {color: color.variable},
48
43
  }
49
44
  }
50
45
 
51
- export interface CodeBaseStyleProps {
52
- $scheme: ThemeColorSchemeKey
53
- }
54
-
55
- export function codeBaseStyle(props: CodeBaseStyleProps): ReturnType<typeof css> {
46
+ export function codeBaseStyle(): ReturnType<typeof css> {
56
47
  return css`
57
- color: ${cssVars.default['text-code']};
48
+ color: var(--card-code-fg-color);
58
49
 
59
50
  & code {
60
51
  font-family: inherit;
61
52
 
62
53
  &.refractor .token {
63
- ${codeSyntaxHighlightingStyle(props.$scheme)}
54
+ ${codeSyntaxHighlightingStyle}
64
55
  }
65
56
  }
66
57
 
@@ -1,6 +1,5 @@
1
1
  import {css} from 'styled-components'
2
2
  import {ThemeProps} from '../../styles'
3
- import {cssVars} from '../../theme'
4
3
  import {HeadingStyleProps} from './types'
5
4
 
6
5
  export function headingBaseStyle(props: HeadingStyleProps & ThemeProps): ReturnType<typeof css> {
@@ -9,12 +8,12 @@ export function headingBaseStyle(props: HeadingStyleProps & ThemeProps): ReturnT
9
8
  return css`
10
9
  ${$accent &&
11
10
  css`
12
- color: ${cssVars.default['text-accent']}};
11
+ color: var(--card-accent-fg-color);
13
12
  `}
14
13
 
15
14
  ${$muted &&
16
15
  css`
17
- color: ${cssVars.mutable['muted-fg-color']};
16
+ color: var(--card-muted-fg-color);
18
17
  `}
19
18
 
20
19
  & code {
@@ -25,7 +24,7 @@ export function headingBaseStyle(props: HeadingStyleProps & ThemeProps): ReturnT
25
24
  & a {
26
25
  text-decoration: none;
27
26
  border-radius: 1px;
28
- color: ${cssVars.default['text-link']};
27
+ color: var(--card-link-color);
29
28
  outline: none;
30
29
 
31
30
  @media (hover: hover) {
@@ -36,8 +35,8 @@ export function headingBaseStyle(props: HeadingStyleProps & ThemeProps): ReturnT
36
35
 
37
36
  &:focus {
38
37
  box-shadow:
39
- 0 0 0 1px ${cssVars.mutable['bg-color']},
40
- 0 0 0 3px ${cssVars.positive['border-accent']};
38
+ 0 0 0 1px var(--card-bg-color),
39
+ 0 0 0 3px var(--card-focus-ring-color);
41
40
  }
42
41
 
43
42
  &:focus:not(:focus-visible) {
@@ -2,7 +2,6 @@ import {forwardRef} from 'react'
2
2
  import styled, {css} from 'styled-components'
3
3
  import {useArrayProp} from '../../hooks'
4
4
  import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
5
- import {cssVars} from '../../theme'
6
5
  import {Radius} from '../../types'
7
6
  import {Box} from '../box'
8
7
  import {Text} from '../text'
@@ -19,7 +18,7 @@ export interface KBDProps {
19
18
 
20
19
  function kbdStyle() {
21
20
  return css`
22
- background: ${cssVars.default['bg-tint']};
21
+ background: var(--card-bg2-color);
23
22
  font: inherit;
24
23
 
25
24
  &:not([hidden]) {
@@ -1,6 +1,5 @@
1
1
  import {css} from 'styled-components'
2
2
  import {ThemeProps} from '../../styles'
3
- import {cssVars} from '../../theme'
4
3
 
5
4
  export function labelBaseStyle(
6
5
  props: {$accent?: boolean; $muted: boolean} & ThemeProps,
@@ -13,12 +12,12 @@ export function labelBaseStyle(
13
12
 
14
13
  ${$accent &&
15
14
  css`
16
- color: ${cssVars.default['text-accent']}};
15
+ color: var(--card-accent-fg-color);
17
16
  `}
18
17
 
19
18
  ${$muted &&
20
19
  css`
21
- color: ${cssVars.mutable['muted-fg-color']};
20
+ color: var(--card-muted-fg-color);
22
21
  `}
23
22
 
24
23
  & code {
@@ -1,6 +1,5 @@
1
1
  import {forwardRef} from 'react'
2
2
  import styled from 'styled-components'
3
- import {cssVars} from '../../theme'
4
3
  import {DEFAULT_POPOVER_ARROW_HEIGHT, DEFAULT_POPOVER_ARROW_WIDTH} from './constants'
5
4
 
6
5
  const Root = styled.div`
@@ -49,11 +48,11 @@ const Root = styled.div`
49
48
  `
50
49
 
51
50
  const BorderPath = styled.path`
52
- fill: ${cssVars.default['base-shadow-outline-color']};
51
+ fill: var(--card-shadow-outline-color);
53
52
  `
54
53
 
55
54
  const ShapePath = styled.path`
56
- fill: ${cssVars.mutable['bg-color']};
55
+ fill: var(--card-bg-color);
57
56
  `
58
57
 
59
58
  export const PopoverArrow = forwardRef(function PopoverArrow(
@@ -3,7 +3,6 @@ import React, {CSSProperties, forwardRef, memo, useMemo} from 'react'
3
3
  import styled from 'styled-components'
4
4
  import {FLOATING_STATIC_SIDES} from '../../constants'
5
5
  import {ThemeColorSchemeKey} from '../../theme'
6
- import {useToneContext} from '../../theme/toneContext/useToneContext'
7
6
  import {BoxOverflow, CardTone, Placement, PopoverMargins, Radius} from '../../types'
8
7
  import {useLayer} from '../../utils'
9
8
  import {Card} from '../card'
@@ -67,8 +66,8 @@ export const PopoverCard = memo(
67
66
  y: yProp,
68
67
  ...restProps
69
68
  } = props
69
+
70
70
  const {zIndex} = useLayer()
71
- const toneContext = useToneContext()
72
71
 
73
72
  // Get margins: [top, right, bottom, left]
74
73
  const margins: PopoverMargins = useMemo(
@@ -111,17 +110,14 @@ export const PopoverCard = memo(
111
110
  <Root
112
111
  data-ui="Popover"
113
112
  {...restProps}
114
- data-tone={tone}
115
113
  data-placement={placement}
116
114
  radius={radius}
117
115
  ref={ref}
118
116
  scheme={scheme}
119
117
  shadow={shadow}
120
118
  sizing="border"
121
- // The popover creates a new html element, so it's out of context of the css variables generated in the cards.
122
- updateCssVars
123
- tone={tone === 'inherit' ? toneContext.tone : tone}
124
119
  style={rootStyle}
120
+ tone={tone}
125
121
  >
126
122
  <Flex data-ui="Popover__wrapper" direction="column" flex={1} overflow={overflow}>
127
123
  <Flex direction="column" flex={1} padding={padding}>
@@ -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 radioBaseStyle(): ReturnType<typeof css> {
7
6
  return css`
@@ -21,6 +20,7 @@ export function inputElementStyle(props: ThemeProps): ReturnType<typeof css> {
21
20
  const {theme} = props
22
21
  const {input} = theme.sanity
23
22
  const {focusRing} = input.radio
23
+ const color = theme.sanity.color.input
24
24
  const dist = (input.radio.size - input.radio.markSize) / 2
25
25
 
26
26
  return css`
@@ -45,9 +45,9 @@ export function inputElementStyle(props: ThemeProps): ReturnType<typeof css> {
45
45
  height: ${rem(input.radio.size)};
46
46
  width: ${rem(input.radio.size)};
47
47
  border-radius: ${rem(input.radio.size / 2)};
48
- background: ${cssVars.default['bg-base']};
48
+ background: ${color.default.enabled.bg};
49
49
  box-shadow: ${focusRingBorderStyle({
50
- color: cssVars.default['border-base'],
50
+ color: color.default.enabled.border,
51
51
  width: input.border.width,
52
52
  })};
53
53
 
@@ -59,7 +59,7 @@ export function inputElementStyle(props: ThemeProps): ReturnType<typeof css> {
59
59
  height: ${rem(input.radio.markSize)};
60
60
  width: ${rem(input.radio.markSize)};
61
61
  border-radius: ${rem(input.radio.markSize / 2)};
62
- background: ${cssVars.default['text-secondary']};
62
+ background: ${color.default.enabled.bg2};
63
63
  opacity: 0;
64
64
  }
65
65
  }
@@ -67,14 +67,14 @@ export function inputElementStyle(props: ThemeProps): ReturnType<typeof css> {
67
67
  /* focused */
68
68
  &:not(:disabled):focus + span {
69
69
  box-shadow: ${focusRingStyle({
70
- border: {width: input.border.width, color: cssVars.default['border-base']},
70
+ border: {width: input.border.width, color: color.default.enabled.border},
71
71
  focusRing,
72
72
  })};
73
73
  }
74
74
 
75
75
  &:not(:disabled):focus:not(:focus-visible) + span {
76
76
  box-shadow: ${focusRingBorderStyle({
77
- color: cssVars.default['border-base'],
77
+ color: color.default.enabled.border,
78
78
  width: input.border.width,
79
79
  })};
80
80
  }
@@ -85,33 +85,33 @@ export function inputElementStyle(props: ThemeProps): ReturnType<typeof css> {
85
85
 
86
86
  /* customValidity */
87
87
  &[data-error] + span {
88
- background-color: ${cssVars.critical['border-base']};
88
+ background-color: ${color.invalid.enabled.border};
89
89
  box-shadow: ${focusRingBorderStyle({
90
90
  width: input.border.width,
91
- color: cssVars.critical['text-secondary'],
91
+ color: color.invalid.enabled.bg2,
92
92
  })};
93
93
  &::after {
94
- background: ${cssVars.critical['text-secondary']};
94
+ background: ${color.invalid.enabled.bg2};
95
95
  }
96
96
  }
97
97
 
98
98
  /* read only */
99
99
  &[data-read-only] + span {
100
- box-shadow: 0 0 0 1px ${cssVars.default['border-base']};
101
- background: ${cssVars.default['bg-tint']};
100
+ box-shadow: 0 0 0 1px ${color.default.readOnly.border};
101
+ background: ${color.default.readOnly.bg};
102
102
 
103
103
  &::after {
104
- background: ${cssVars.default['border-base']};
104
+ background: ${color.default.readOnly.border};
105
105
  }
106
106
  }
107
107
 
108
108
  /* disabled */
109
109
  &:not([data-read-only]):disabled + span {
110
- box-shadow: 0 0 0 1px ${cssVars.default['border-base']};
111
- background: ${cssVars.default['bg-tint']};
110
+ box-shadow: 0 0 0 1px ${color.default.disabled.border};
111
+ background: ${color.default.disabled.bg};
112
112
 
113
113
  &::after {
114
- background: ${cssVars.default['border-base']};
114
+ background: ${color.default.disabled.border};
115
115
  }
116
116
  }
117
117
  `
@@ -8,8 +8,6 @@ import {
8
8
  ResponsiveRadiusStyleProps,
9
9
  } from '../../styles/internal'
10
10
  import {ThemeFontSize} from '../../theme'
11
- import {mutableCardVariables} from '../../theme/lib/theme/color/cssVariables/cardVariables'
12
- import {cssVars} from '../../theme/lib/theme/color/cssVariables/createCssVars'
13
11
  import {CSSObject} from '../../types/styled'
14
12
 
15
13
  function rootStyle(): ReturnType<typeof css> {
@@ -47,23 +45,24 @@ function inputColorStyle(props: ThemeProps) {
47
45
  const {theme} = props
48
46
  const {input} = theme.sanity
49
47
  const {focusRing} = input.select
48
+ const color = theme.sanity.color.input
50
49
 
51
50
  return css`
52
51
  /* enabled */
53
- background-color: ${cssVars.default['bg-base']};
54
- color: ${cssVars.default['text-primary']};
52
+ background-color: ${color.default.enabled.bg};
53
+ color: ${color.default.enabled.fg};
55
54
  box-shadow: ${focusRingBorderStyle({
56
- color: cssVars.default['border-base'],
55
+ color: color.default.enabled.border,
57
56
  width: input.border.width,
58
57
  })};
59
58
 
60
59
  /* hovered */
61
60
  @media (hover: hover) {
62
61
  &:not(:disabled):hover {
63
- background-color: ${cssVars.default['bg-base-hover']};
64
- color: ${cssVars.default['text-primary']};
62
+ background-color: ${color.default.hovered.bg};
63
+ color: ${color.default.hovered.fg};
65
64
  box-shadow: ${focusRingBorderStyle({
66
- color: cssVars.default['border-base-hover'],
65
+ color: color.default.hovered.border,
67
66
  width: input.border.width,
68
67
  })};
69
68
  }
@@ -72,27 +71,27 @@ function inputColorStyle(props: ThemeProps) {
72
71
  /* focused */
73
72
  &:not(:disabled):focus {
74
73
  box-shadow: ${focusRingStyle({
75
- border: {width: input.border.width, color: cssVars.default['border-base']},
74
+ border: {width: input.border.width, color: color.default.enabled.border},
76
75
  focusRing,
77
76
  })};
78
77
  }
79
78
 
80
79
  /* read-only */
81
80
  &[data-read-only] {
82
- background-color: ${cssVars.default['bg-tint']};
83
- color: ${cssVars.default['text-primary']};
81
+ background-color: ${color.default.readOnly.bg};
82
+ color: ${color.default.readOnly.fg};
84
83
  box-shadow: ${focusRingBorderStyle({
85
- color: cssVars.default['border-base'],
84
+ color: color.default.readOnly.border,
86
85
  width: input.border.width,
87
86
  })};
88
87
  }
89
88
 
90
89
  /* disabled */
91
90
  &:not([data-read-only]):disabled {
92
- background-color: ${cssVars.default['bg-tint']};
93
- color: ${cssVars.default['text-primary']};
91
+ background-color: ${color.default.disabled.bg};
92
+ color: ${color.default.disabled.fg};
94
93
  box-shadow: ${focusRingBorderStyle({
95
- color: cssVars.default['border-base'],
94
+ color: color.default.disabled.border,
96
95
  width: input.border.width,
97
96
  })};
98
97
  }
@@ -131,7 +130,10 @@ function inputStyle(): Array<
131
130
  ]
132
131
  }
133
132
 
134
- function iconBoxStyle(): ReturnType<typeof css> {
133
+ function iconBoxStyle(props: ThemeProps): ReturnType<typeof css> {
134
+ const {theme} = props
135
+ const color = theme.sanity.color.input
136
+
135
137
  return css`
136
138
  pointer-events: none;
137
139
  position: absolute;
@@ -139,23 +141,23 @@ function iconBoxStyle(): ReturnType<typeof css> {
139
141
  right: 0;
140
142
 
141
143
  /* enabled */
142
- ${mutableCardVariables['fg-color']}: ${cssVars.default['text-primary']};
144
+ --card-fg-color: ${color.default.enabled.fg};
143
145
 
144
146
  /* hover */
145
147
  @media (hover: hover) {
146
148
  select:not(disabled):not(:read-only):hover + && {
147
- ${mutableCardVariables['fg-color']}: ${cssVars.default['text-primary']};
149
+ --card-fg-color: ${color.default.hovered.fg};
148
150
  }
149
151
  }
150
152
 
151
153
  /* disabled */
152
154
  select:disabled + && {
153
- ${mutableCardVariables['fg-color']}: ${cssVars.default['text-primary']};
155
+ --card-fg-color: ${color.default.disabled.fg};
154
156
  }
155
157
 
156
158
  /* read-only */
157
159
  select[data-read-only] + && {
158
- ${mutableCardVariables['fg-color']}: ${cssVars.default['text-primary']};
160
+ --card-fg-color: ${color.default.readOnly.fg};
159
161
  }
160
162
  `
161
163
  }
@@ -1,7 +1,6 @@
1
1
  import {css} from 'styled-components'
2
2
  import {rem, ThemeProps} from '../../styles'
3
3
  import {focusRingStyle} from '../../styles/internal'
4
- import {cssVars} from '../../theme/lib/theme/color/cssVariables/createCssVars'
5
4
 
6
5
  /* Root */
7
6
  export function switchBaseStyles(): ReturnType<typeof css> {
@@ -39,10 +38,11 @@ export function switchRepresentationStyles(props: ThemeProps): ReturnType<typeof
39
38
  const {theme} = props
40
39
  const {input} = theme.sanity
41
40
  const {focusRing} = input.switch
41
+ const color = theme.sanity.color.input
42
42
 
43
43
  return css`
44
- --switch-bg-color: ${cssVars.default['border-base']};
45
- --switch-fg-color: ${cssVars.default['bg-base']};
44
+ --switch-bg-color: ${color.default.enabled.border};
45
+ --switch-fg-color: ${color.default.enabled.bg};
46
46
  --switch-box-shadow: none;
47
47
 
48
48
  &:not([hidden]) {
@@ -79,30 +79,30 @@ export function switchRepresentationStyles(props: ThemeProps): ReturnType<typeof
79
79
  }
80
80
 
81
81
  input:checked + && {
82
- --switch-bg-color: ${cssVars.positive['border-accent']};
83
- --switch-fg-color: ${cssVars.positive['bg-base']};
82
+ --switch-bg-color: var(--card-focus-ring-color);
83
+ --switch-fg-color: ${color.default.enabled.bg};
84
84
  }
85
85
 
86
86
  @media (hover: hover) {
87
87
  input:not(:disabled):hover + && {
88
- --switch-bg-color: ${cssVars.default['border-base']};
89
- --switch-fg-color: ${cssVars.default['bg-base']};
88
+ --switch-bg-color: ${color.default.hovered.border};
89
+ --switch-fg-color: ${color.default.hovered.bg};
90
90
  }
91
91
 
92
92
  input:not(:disabled):checked:hover + && {
93
- --switch-bg-color: ${cssVars.positive['border-accent']};
94
- --switch-fg-color: ${cssVars.positive['bg-base']};
93
+ --switch-bg-color: var(--card-focus-ring-color);
94
+ --switch-fg-color: ${color.default.enabled.bg};
95
95
  }
96
96
  }
97
97
 
98
98
  input:not([data-read-only]):disabled + && {
99
- --switch-bg-color: ${cssVars.default['border-base']};
100
- --switch-fg-color: ${cssVars.default['bg-tint']};
99
+ --switch-bg-color: ${color.default.disabled.border};
100
+ --switch-fg-color: ${color.default.disabled.bg};
101
101
  }
102
102
 
103
103
  input[data-read-only]:disabled + && {
104
- --switch-bg-color: ${cssVars.default['border-base']};
105
- --switch-fg-color: ${cssVars.default['bg-tint']};
104
+ --switch-bg-color: ${color.default.readOnly.border};
105
+ --switch-fg-color: ${color.default.readOnly.bg};
106
106
  }
107
107
  `
108
108
  }
@@ -1,26 +1,27 @@
1
- import {Flex, Text, useTheme} from '@sanity/ui'
1
+ import {Flex, Text, Theme, ThemeColorSpotKey, 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'
7
5
 
8
- const ColoredText = styled(Text)<{color: string}>((props: {color: string}) => {
6
+ const ColoredText = styled(Text)<{color?: ThemeColorSpotKey}>((props: {
7
+ color?: ThemeColorSpotKey
8
+ theme: Theme
9
+ }) => {
10
+ const {spot} = props.theme.sanity.color
11
+
9
12
  return css`
10
- color: ${props.color};
13
+ color: ${spot[props.color || 'gray']};
11
14
  `
12
15
  })
13
16
 
14
17
  export default function ColoredTextStory() {
15
18
  const theme = useTheme()
16
- const selectedColor = useSelect('Color', WORKSHOP_SPOT_COLOR_OPTIONS, 'gray')
17
- const {scheme} = useToneContext()
18
- const color = spotColor[selectedColor ?? 'gray'][scheme]
19
+ const color = useSelect('Color', WORKSHOP_SPOT_COLOR_OPTIONS, 'gray')
19
20
 
20
21
  return (
21
22
  <Flex align="center" height="fill" justify="center" padding={[4, 5, 6]} sizing="border">
22
- <ColoredText align="center" color={color.hex} size={4} theme={theme} weight="bold">
23
- {color.title}
23
+ <ColoredText align="center" color={color} size={4} theme={theme} weight="bold">
24
+ {color}
24
25
  </ColoredText>
25
26
  </Flex>
26
27
  )
@@ -1,6 +1,5 @@
1
1
  import {css} from 'styled-components'
2
2
  import {ThemeProps} from '../../styles'
3
- import {cssVars} from '../../theme'
4
3
 
5
4
  export function textBaseStyle(
6
5
  props: {$accent?: boolean; $muted?: boolean} & ThemeProps,
@@ -9,29 +8,29 @@ export function textBaseStyle(
9
8
  const {weights} = theme.sanity.fonts.text
10
9
 
11
10
  return css`
12
- color: ${cssVars.mutable['fg-color']};
11
+ color: var(--card-fg-color);
13
12
 
14
13
  ${$accent &&
15
14
  css`
16
- color: ${cssVars.default['text-accent']};
15
+ color: var(--card-accent-fg-color);
17
16
  `}
18
17
 
19
18
  ${$muted &&
20
19
  css`
21
- color: ${cssVars.mutable['muted-fg-color']};
20
+ color: var(--card-muted-fg-color);
22
21
  `}
23
22
 
24
23
  & code {
25
24
  font-family: ${theme.sanity.fonts.code.family};
26
25
  border-radius: 1px;
27
- background-color: ${cssVars.default['bg-tint-code']};
28
- color: ${cssVars.default['text-code']};
26
+ background-color: var(--card-code-bg-color);
27
+ color: var(--card-code-fg-color);
29
28
  }
30
29
 
31
30
  & a {
32
31
  text-decoration: none;
33
32
  border-radius: 1px;
34
- color: ${cssVars.default['text-link']};
33
+ color: var(--card-link-color);
35
34
  outline: none;
36
35
 
37
36
  @media (hover: hover) {
@@ -42,8 +41,8 @@ export function textBaseStyle(
42
41
 
43
42
  &:focus {
44
43
  box-shadow:
45
- 0 0 0 1px ${cssVars.mutable['bg-color']},
46
- 0 0 0 3px ${cssVars.positive['border-accent']};
44
+ 0 0 0 1px var(--card-bg-color),
45
+ 0 0 0 3px var(--card-focus-ring-color);
47
46
  }
48
47
 
49
48
  &:focus:not(:focus-visible) {
@@ -63,7 +62,7 @@ export function textBaseStyle(
63
62
 
64
63
  & [data-sanity-icon] {
65
64
  vertical-align: baseline;
66
- color: ${cssVars.mutable['icon-color']};
65
+ color: var(--card-icon-color);
67
66
  }
68
67
  `
69
68
  }