@sanity/ui 2.0.0-alpha.1 → 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 (120) hide show
  1. package/dist/index.cjs.mjs +3 -0
  2. package/dist/index.d.ts +309 -411
  3. package/dist/index.esm.js +5098 -2428
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/index.js +5230 -2557
  6. package/dist/index.js.map +1 -1
  7. package/package.json +2 -2
  8. package/src/components/dialog/constants.ts +4 -0
  9. package/src/components/dialog/dialog.tsx +86 -24
  10. package/src/components/dialog/styles.ts +3 -4
  11. package/src/components/menu/__workshop__/closableMenuButton.tsx +2 -2
  12. package/src/components/menu/menuDivider.ts +2 -1
  13. package/src/components/menu/menuGroup.tsx +22 -23
  14. package/src/components/menu/menuItem.tsx +31 -37
  15. package/src/components/skeleton/styles.ts +8 -7
  16. package/src/components/tree/style.ts +19 -20
  17. package/src/primitives/_selectable/style.ts +25 -22
  18. package/src/primitives/avatar/avatar.tsx +8 -3
  19. package/src/primitives/avatar/avatarCounter.tsx +5 -4
  20. package/src/primitives/avatar/spotColors.ts +53 -0
  21. package/src/primitives/avatar/styles.ts +5 -7
  22. package/src/primitives/avatar/types.ts +14 -0
  23. package/src/primitives/badge/badge.tsx +5 -3
  24. package/src/primitives/badge/styles.ts +7 -8
  25. package/src/primitives/box/__workshop__/responsive.tsx +2 -2
  26. package/src/primitives/button/button.tsx +2 -2
  27. package/src/primitives/button/styles.ts +82 -16
  28. package/src/primitives/card/__workshop__/selected.tsx +8 -9
  29. package/src/primitives/card/card.tsx +43 -7
  30. package/src/primitives/card/styles.ts +30 -22
  31. package/src/primitives/card/types.ts +3 -1
  32. package/src/primitives/checkbox/styles.ts +20 -20
  33. package/src/primitives/code/code.tsx +15 -3
  34. package/src/primitives/code/styles.ts +51 -42
  35. package/src/primitives/heading/styles.ts +6 -5
  36. package/src/primitives/kbd/kbd.tsx +2 -1
  37. package/src/primitives/label/styles.ts +3 -2
  38. package/src/primitives/popover/popoverArrow.tsx +3 -2
  39. package/src/primitives/popover/popoverCard.tsx +6 -2
  40. package/src/primitives/radio/styles.ts +15 -15
  41. package/src/primitives/select/styles.ts +20 -22
  42. package/src/primitives/switch/styles.ts +13 -13
  43. package/src/primitives/text/__workshop__/colored.tsx +10 -11
  44. package/src/primitives/text/styles.ts +10 -9
  45. package/src/primitives/textArea/textArea.tsx +8 -12
  46. package/src/primitives/textInput/textInput.tsx +13 -13
  47. package/src/primitives/tooltip/__workshop__/props.tsx +20 -3
  48. package/src/primitives/tooltip/tooltipArrow.tsx +3 -2
  49. package/src/styles/border/borderStyle.ts +2 -1
  50. package/src/styles/colorVars/colorVarsStyle.ts +73 -32
  51. package/src/styles/focusRing/index.ts +6 -4
  52. package/src/styles/input/textInputStyle.ts +76 -93
  53. package/src/styles/margin/marginsStyle.test.ts +1 -2
  54. package/src/styles/padding/paddingStyle.test.ts +1 -2
  55. package/src/styles/shadow/shadowStyle.ts +5 -5
  56. package/src/theme/__workshop__/color.tsx +2 -2
  57. package/src/theme/__workshop__/index.ts +0 -5
  58. package/src/theme/lib/color-fns/blend/multiply.ts +2 -2
  59. package/src/theme/lib/color-fns/blend/screen.ts +2 -2
  60. package/src/theme/lib/color-fns/convert.ts +15 -1
  61. package/src/theme/lib/color-fns/parse.ts +7 -3
  62. package/src/theme/lib/color-fns/types.ts +11 -0
  63. package/src/theme/lib/theme/color/_legacy/createColorTheme.ts +7 -0
  64. package/src/theme/lib/theme/color/_legacy/index.ts +1 -0
  65. package/src/theme/lib/theme/color/_legacy/legacyColor.ts +3997 -0
  66. package/src/theme/lib/theme/color/cssVariables/cardVariables.ts +88 -0
  67. package/src/theme/lib/theme/color/cssVariables/createCssVars.ts +31 -0
  68. package/src/theme/lib/theme/color/cssVariables/cssVars.test.ts +262 -0
  69. package/src/theme/lib/theme/color/cssVariables/index.ts +1 -0
  70. package/src/theme/lib/theme/color/cssVariables/tints.ts +312 -0
  71. package/src/theme/lib/theme/color/cssVariables/tones.ts +67 -0
  72. package/src/theme/lib/theme/color/cssVariables/utils.test.ts +15 -0
  73. package/src/theme/lib/theme/color/cssVariables/utils.ts +9 -0
  74. package/src/theme/lib/theme/color/index.ts +3 -12
  75. package/src/theme/lib/theme/color/types.ts +6 -37
  76. package/src/theme/lib/theme/theme.ts +9 -4
  77. package/src/theme/studioTheme/color.ts +2 -641
  78. package/src/theme/studioTheme/helpers.ts +15 -1
  79. package/src/theme/studioTheme/theme.ts +13 -3
  80. package/src/theme/themeColorProvider.tsx +2 -0
  81. package/src/theme/themeProvider.tsx +28 -8
  82. package/src/theme/toneContext/toneContext.ts +12 -0
  83. package/src/theme/toneContext/toneProvider.tsx +31 -0
  84. package/src/theme/toneContext/types.ts +10 -0
  85. package/src/theme/toneContext/useToneContext.tsx +26 -0
  86. package/src/theme/types.ts +2 -4
  87. package/src/utils/elementQuery/__workshop__/customMedia.tsx +4 -3
  88. package/src/theme/__workshop__/canvas.tsx +0 -395
  89. package/src/theme/lib/theme/color/_generic/index.ts +0 -1
  90. package/src/theme/lib/theme/color/_generic/types.ts +0 -30
  91. package/src/theme/lib/theme/color/base/index.ts +0 -1
  92. package/src/theme/lib/theme/color/base/types.ts +0 -19
  93. package/src/theme/lib/theme/color/button/createButtonModes.ts +0 -20
  94. package/src/theme/lib/theme/color/button/createButtonTones.ts +0 -52
  95. package/src/theme/lib/theme/color/button/index.ts +0 -1
  96. package/src/theme/lib/theme/color/button/types.ts +0 -44
  97. package/src/theme/lib/theme/color/card/createCardStates.ts +0 -58
  98. package/src/theme/lib/theme/color/card/index.ts +0 -1
  99. package/src/theme/lib/theme/color/card/types.ts +0 -18
  100. package/src/theme/lib/theme/color/color.test.ts +0 -63
  101. package/src/theme/lib/theme/color/defaults.ts +0 -390
  102. package/src/theme/lib/theme/color/factory.ts +0 -138
  103. package/src/theme/lib/theme/color/input/createInputModes.ts +0 -84
  104. package/src/theme/lib/theme/color/input/index.ts +0 -1
  105. package/src/theme/lib/theme/color/input/types.ts +0 -28
  106. package/src/theme/lib/theme/color/muted/createMuted.ts +0 -56
  107. package/src/theme/lib/theme/color/muted/index.ts +0 -1
  108. package/src/theme/lib/theme/color/muted/types.ts +0 -24
  109. package/src/theme/lib/theme/color/selectable/createSelectableTones.ts +0 -73
  110. package/src/theme/lib/theme/color/selectable/index.ts +0 -1
  111. package/src/theme/lib/theme/color/selectable/types.ts +0 -29
  112. package/src/theme/lib/theme/color/solid/createSolidTones.ts +0 -56
  113. package/src/theme/lib/theme/color/solid/index.ts +0 -1
  114. package/src/theme/lib/theme/color/solid/types.ts +0 -24
  115. package/src/theme/lib/theme/color/spot/createSpot.ts +0 -21
  116. package/src/theme/lib/theme/color/spot/index.ts +0 -1
  117. package/src/theme/lib/theme/color/spot/types.ts +0 -28
  118. package/src/theme/lib/theme/color/syntax/index.ts +0 -1
  119. package/src/theme/lib/theme/color/syntax/types.ts +0 -41
  120. package/src/theme/studioTheme/tints.ts +0 -152
@@ -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>
@@ -1,57 +1,66 @@
1
- import {css, ExecutionContext} from 'styled-components'
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'
2
5
 
3
- function codeSyntaxHighlightingStyle({theme}: ExecutionContext) {
4
- const color = theme.sanity.color.syntax
6
+ function codeSyntaxHighlightingStyle(scheme: ThemeColorSchemeKey) {
7
+ const dark = scheme === 'dark'
8
+ const mainShade = dark ? 400 : 600
9
+ const secondaryShade = dark ? 600 : 400
5
10
 
6
11
  return {
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},
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},
43
48
  }
44
49
  }
45
50
 
46
- export function codeBaseStyle(): ReturnType<typeof css> {
51
+ export interface CodeBaseStyleProps {
52
+ $scheme: ThemeColorSchemeKey
53
+ }
54
+
55
+ export function codeBaseStyle(props: CodeBaseStyleProps): ReturnType<typeof css> {
47
56
  return css`
48
- color: var(--card-code-fg-color);
57
+ color: ${cssVars.default['text-code']};
49
58
 
50
59
  & code {
51
60
  font-family: inherit;
52
61
 
53
62
  &.refractor .token {
54
- ${codeSyntaxHighlightingStyle}
63
+ ${codeSyntaxHighlightingStyle(props.$scheme)}
55
64
  }
56
65
  }
57
66
 
@@ -1,5 +1,6 @@
1
1
  import {css} from 'styled-components'
2
2
  import {ThemeProps} from '../../styles'
3
+ import {cssVars} from '../../theme'
3
4
  import {HeadingStyleProps} from './types'
4
5
 
5
6
  export function headingBaseStyle(props: HeadingStyleProps & ThemeProps): ReturnType<typeof css> {
@@ -8,12 +9,12 @@ export function headingBaseStyle(props: HeadingStyleProps & ThemeProps): ReturnT
8
9
  return css`
9
10
  ${$accent &&
10
11
  css`
11
- color: var(--card-accent-fg-color);
12
+ color: ${cssVars.default['text-accent']}};
12
13
  `}
13
14
 
14
15
  ${$muted &&
15
16
  css`
16
- color: var(--card-muted-fg-color);
17
+ color: ${cssVars.mutable['muted-fg-color']};
17
18
  `}
18
19
 
19
20
  & code {
@@ -24,7 +25,7 @@ export function headingBaseStyle(props: HeadingStyleProps & ThemeProps): ReturnT
24
25
  & a {
25
26
  text-decoration: none;
26
27
  border-radius: 1px;
27
- color: var(--card-link-color);
28
+ color: ${cssVars.default['text-link']};
28
29
  outline: none;
29
30
 
30
31
  @media (hover: hover) {
@@ -35,8 +36,8 @@ export function headingBaseStyle(props: HeadingStyleProps & ThemeProps): ReturnT
35
36
 
36
37
  &:focus {
37
38
  box-shadow:
38
- 0 0 0 1px var(--card-bg-color),
39
- 0 0 0 3px var(--card-focus-ring-color);
39
+ 0 0 0 1px ${cssVars.mutable['bg-color']},
40
+ 0 0 0 3px ${cssVars.positive['border-accent']};
40
41
  }
41
42
 
42
43
  &:focus:not(:focus-visible) {
@@ -2,6 +2,7 @@ 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'
5
6
  import {Radius} from '../../types'
6
7
  import {Box} from '../box'
7
8
  import {Text} from '../text'
@@ -18,7 +19,7 @@ export interface KBDProps {
18
19
 
19
20
  function kbdStyle() {
20
21
  return css`
21
- background: var(--card-bg2-color);
22
+ background: ${cssVars.default['bg-tint']};
22
23
  font: inherit;
23
24
 
24
25
  &:not([hidden]) {
@@ -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 labelBaseStyle(
5
6
  props: {$accent?: boolean; $muted: boolean} & ThemeProps,
@@ -12,12 +13,12 @@ export function labelBaseStyle(
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 {
@@ -1,5 +1,6 @@
1
1
  import {forwardRef} from 'react'
2
2
  import styled from 'styled-components'
3
+ import {cssVars} from '../../theme'
3
4
  import {DEFAULT_POPOVER_ARROW_HEIGHT, DEFAULT_POPOVER_ARROW_WIDTH} from './constants'
4
5
 
5
6
  const Root = styled.div`
@@ -48,11 +49,11 @@ const Root = styled.div`
48
49
  `
49
50
 
50
51
  const BorderPath = styled.path`
51
- fill: var(--card-shadow-outline-color);
52
+ fill: ${cssVars.default['base-shadow-outline-color']};
52
53
  `
53
54
 
54
55
  const ShapePath = styled.path`
55
- fill: var(--card-bg-color);
56
+ fill: ${cssVars.mutable['bg-color']};
56
57
  `
57
58
 
58
59
  export const PopoverArrow = forwardRef(function PopoverArrow(
@@ -3,6 +3,7 @@ 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'
6
7
  import {BoxOverflow, CardTone, Placement, PopoverMargins, Radius} from '../../types'
7
8
  import {useLayer} from '../../utils'
8
9
  import {Card} from '../card'
@@ -66,8 +67,8 @@ export const PopoverCard = memo(
66
67
  y: yProp,
67
68
  ...restProps
68
69
  } = props
69
-
70
70
  const {zIndex} = useLayer()
71
+ const toneContext = useToneContext()
71
72
 
72
73
  // Get margins: [top, right, bottom, left]
73
74
  const margins: PopoverMargins = useMemo(
@@ -110,14 +111,17 @@ export const PopoverCard = memo(
110
111
  <Root
111
112
  data-ui="Popover"
112
113
  {...restProps}
114
+ data-tone={tone}
113
115
  data-placement={placement}
114
116
  radius={radius}
115
117
  ref={ref}
116
118
  scheme={scheme}
117
119
  shadow={shadow}
118
120
  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}
119
124
  style={rootStyle}
120
- tone={tone}
121
125
  >
122
126
  <Flex data-ui="Popover__wrapper" direction="column" flex={1} overflow={overflow}>
123
127
  <Flex direction="column" flex={1} padding={padding}>
@@ -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 radioBaseStyle(): ReturnType<typeof css> {
6
7
  return css`
@@ -20,7 +21,6 @@ export function inputElementStyle(props: ThemeProps): ReturnType<typeof css> {
20
21
  const {theme} = props
21
22
  const {input} = theme.sanity
22
23
  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: ${color.default.enabled.bg};
48
+ background: ${cssVars.default['bg-base']};
49
49
  box-shadow: ${focusRingBorderStyle({
50
- color: color.default.enabled.border,
50
+ color: cssVars.default['border-base'],
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: ${color.default.enabled.bg2};
62
+ background: ${cssVars.default['text-secondary']};
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: color.default.enabled.border},
70
+ border: {width: input.border.width, color: cssVars.default['border-base']},
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: color.default.enabled.border,
77
+ color: cssVars.default['border-base'],
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: ${color.invalid.enabled.border};
88
+ background-color: ${cssVars.critical['border-base']};
89
89
  box-shadow: ${focusRingBorderStyle({
90
90
  width: input.border.width,
91
- color: color.invalid.enabled.bg2,
91
+ color: cssVars.critical['text-secondary'],
92
92
  })};
93
93
  &::after {
94
- background: ${color.invalid.enabled.bg2};
94
+ background: ${cssVars.critical['text-secondary']};
95
95
  }
96
96
  }
97
97
 
98
98
  /* read only */
99
99
  &[data-read-only] + span {
100
- box-shadow: 0 0 0 1px ${color.default.readOnly.border};
101
- background: ${color.default.readOnly.bg};
100
+ box-shadow: 0 0 0 1px ${cssVars.default['border-base']};
101
+ background: ${cssVars.default['bg-tint']};
102
102
 
103
103
  &::after {
104
- background: ${color.default.readOnly.border};
104
+ background: ${cssVars.default['border-base']};
105
105
  }
106
106
  }
107
107
 
108
108
  /* disabled */
109
109
  &:not([data-read-only]):disabled + span {
110
- box-shadow: 0 0 0 1px ${color.default.disabled.border};
111
- background: ${color.default.disabled.bg};
110
+ box-shadow: 0 0 0 1px ${cssVars.default['border-base']};
111
+ background: ${cssVars.default['bg-tint']};
112
112
 
113
113
  &::after {
114
- background: ${color.default.disabled.border};
114
+ background: ${cssVars.default['border-base']};
115
115
  }
116
116
  }
117
117
  `