@sanity/ui 3.0.0-static.10 → 3.0.0-static.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 (71) hide show
  1. package/dist/_chunks-cjs/_visual-editing.js +160 -207
  2. package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
  3. package/dist/_chunks-es/_visual-editing.mjs +161 -208
  4. package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
  5. package/dist/_visual-editing.d.mts +1 -3
  6. package/dist/_visual-editing.d.ts +1 -3
  7. package/dist/cli.js +1 -1
  8. package/dist/css.d.mts +115 -2
  9. package/dist/css.d.ts +115 -2
  10. package/dist/css.js +539 -402
  11. package/dist/css.js.map +1 -1
  12. package/dist/css.mjs +541 -404
  13. package/dist/css.mjs.map +1 -1
  14. package/dist/index.d.mts +4 -4
  15. package/dist/index.d.ts +4 -4
  16. package/dist/index.js +50 -17
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +45 -12
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/sanity-theme.css +1 -1
  21. package/dist/system.css +418 -182
  22. package/dist/theme.js +10 -11
  23. package/dist/theme.js.map +1 -1
  24. package/dist/theme.mjs +10 -11
  25. package/dist/theme.mjs.map +1 -1
  26. package/package.json +1 -1
  27. package/src/css/_resp.ts +0 -1
  28. package/src/css/aspects/font/font.style.ts +7 -66
  29. package/src/css/aspects/shadow/shadow.style.ts +16 -41
  30. package/src/css/compile/compilePalette.ts +4 -3
  31. package/src/css/compile/compileSystem.ts +0 -3
  32. package/src/css/compile/compileTheme_v3.ts +233 -219
  33. package/src/css/components/skeleton/skeleton.style.ts +8 -4
  34. package/src/css/constants.ts +9 -0
  35. package/src/css/index.ts +1 -0
  36. package/src/css/primitives/_arrow/_arrow.style.ts +6 -8
  37. package/src/css/primitives/_arrow/_arrow.ts +4 -0
  38. package/src/css/primitives/_selectable/_selectable.style.ts +23 -23
  39. package/src/css/primitives/button/button.style.ts +48 -15
  40. package/src/css/primitives/card/card.style.ts +1 -1
  41. package/src/css/primitives/token/token.style.ts +37 -36
  42. package/src/css/responsiveRules.ts +12 -19
  43. package/src/css/types.ts +106 -3
  44. package/src/css/varNames.ts +101 -4
  45. package/src/css/vars.ts +52 -16
  46. package/src/theme/v3/buildTheme_v3.ts +1 -1
  47. package/src/theme/v3/{defaults.ts → defaultTokens.ts} +1 -2
  48. package/src/theme/v3/index.ts +1 -1
  49. package/src/theme/v3/resolveTokens.ts +9 -9
  50. package/src/ui/RootClassNames.tsx +41 -0
  51. package/src/ui/_compat/helpers.ts +72 -0
  52. package/src/ui/_compat/index.ts +2 -6
  53. package/src/ui/_compat/studioTheme.ts +7 -0
  54. package/src/ui/_compat/types.ts +0 -83
  55. package/src/ui/index.ts +1 -0
  56. package/src/ui/primitives/button/button.tsx +5 -6
  57. package/src/ui/primitives/popover/popover.tsx +25 -7
  58. package/src/ui/primitives/popover/popoverCard.tsx +46 -45
  59. package/src/ui/primitives/tooltip/tooltip.tsx +9 -2
  60. package/src/ui/primitives/tooltip/tooltipCard.tsx +1 -1
  61. package/src/ui/utils/arrow/arrow.tsx +3 -11
  62. package/src/ui/utils/elementQuery/elementQuery.tsx +10 -8
  63. package/src/ui/utils/virtualList/virtualList.tsx +37 -32
  64. package/src/css/components/breadcrumbs/rules.ts +0 -25
  65. package/src/css/components/dialog/rules.ts +0 -78
  66. package/src/css/components/skeleton/rules.ts +0 -113
  67. package/src/css/components/toast/rules.ts +0 -18
  68. package/src/css/components/tree/rules.ts +0 -168
  69. package/src/css/primitives/popover/rules.ts +0 -5
  70. package/src/css/primitives/spinner/rules.ts +0 -21
  71. package/src/css/primitives/token/rules.ts +0 -45
@@ -15,8 +15,12 @@ import {
15
15
 
16
16
  import {Properties} from '../types'
17
17
  import {px, rem, toBoxShadow} from '../util'
18
+ import {varNames} from '../varNames'
18
19
  import {compileRule} from './compileRule'
19
20
 
21
+ const THEME_COLOR_SCHEMES = ['dark', 'light'] as const
22
+ const THEME_COLOR_VARIANTS = ['tinted', 'solid'] as const
23
+
20
24
  export function compileTheme_v3(theme: Theme_v3): string {
21
25
  return compileRule(':root', compileThemeProperties(theme), {keyframes: {}, media: {}})
22
26
  }
@@ -25,6 +29,7 @@ function compileThemeProperties(theme: Theme_v3): Properties {
25
29
  return {
26
30
  ...buildAvatarThemeProperties(theme),
27
31
  ...buildButtonThemeProperties(theme),
32
+ [varNames.card.shadow.outline]: px(theme.card.shadow.outline),
28
33
  ...buildContainerThemeProperties(theme),
29
34
  ...buildFontCodeThemeProperties(theme),
30
35
  ...buildFontHeadingThemeProperties(theme),
@@ -40,58 +45,62 @@ function compileThemeProperties(theme: Theme_v3): Properties {
40
45
 
41
46
  function buildAvatarThemeProperties(theme: Theme_v3): Properties {
42
47
  return {
43
- [`--avatar-focus-ring-offset`]: px(theme.avatar.focusRing.offset),
44
- [`--avatar-focus-ring-width`]: px(theme.avatar.focusRing.width),
45
- [`--avatar-0-distance`]: px(theme.avatar.sizes[0].distance),
46
- [`--avatar-0-size`]: px(theme.avatar.sizes[0].size),
47
- [`--avatar-1-distance`]: px(theme.avatar.sizes[1].distance),
48
- [`--avatar-1-size`]: px(theme.avatar.sizes[1].size),
49
- [`--avatar-2-distance`]: px(theme.avatar.sizes[2].distance),
50
- [`--avatar-2-size`]: px(theme.avatar.sizes[2].size),
51
- [`--avatar-3-distance`]: px(theme.avatar.sizes[3].distance),
52
- [`--avatar-3-size`]: px(theme.avatar.sizes[3].size),
48
+ [varNames.avatar.focusRing.offset]: px(theme.avatar.focusRing.offset),
49
+ [varNames.avatar.focusRing.width]: px(theme.avatar.focusRing.width),
50
+
51
+ [varNames.avatar.sizes[0].distance]: px(theme.avatar.sizes[0].distance),
52
+ [varNames.avatar.sizes[0].size]: px(theme.avatar.sizes[0].size),
53
+
54
+ [varNames.avatar.sizes[1].distance]: px(theme.avatar.sizes[1].distance),
55
+ [varNames.avatar.sizes[1].size]: px(theme.avatar.sizes[1].size),
56
+
57
+ [varNames.avatar.sizes[2].distance]: px(theme.avatar.sizes[2].distance),
58
+ [varNames.avatar.sizes[2].size]: px(theme.avatar.sizes[2].size),
59
+
60
+ [varNames.avatar.sizes[3].distance]: px(theme.avatar.sizes[3].distance),
61
+ [varNames.avatar.sizes[3].size]: px(theme.avatar.sizes[3].size),
53
62
  }
54
63
  }
55
64
 
56
65
  function buildButtonThemeProperties(theme: Theme_v3): Properties {
57
66
  return {
58
- [`--button-border-width`]: px(theme.button.border.width),
59
- [`--button-focus-ring-offset`]: px(theme.button.focusRing.offset),
60
- [`--button-focus-ring-width`]: px(theme.button.focusRing.width),
61
- // [`--button-text-weight`]: theme.button.textWeight,
67
+ [varNames.button.border.width]: px(theme.button.border.width),
68
+ [varNames.button.focusRing.offset]: px(theme.button.focusRing.offset),
69
+ [varNames.button.focusRing.width]: px(theme.button.focusRing.width),
62
70
  }
63
71
  }
64
72
 
65
73
  function buildContainerThemeProperties(theme: Theme_v3): Properties {
66
74
  return {
67
- [`--container-0`]: px(theme.container[0]),
68
- [`--container-1`]: px(theme.container[1]),
69
- [`--container-2`]: px(theme.container[2]),
70
- [`--container-3`]: px(theme.container[3]),
71
- [`--container-4`]: px(theme.container[4]),
72
- [`--container-5`]: px(theme.container[5]),
75
+ [varNames.container[0]]: px(theme.container[0]),
76
+ [varNames.container[1]]: px(theme.container[1]),
77
+ [varNames.container[2]]: px(theme.container[2]),
78
+ [varNames.container[3]]: px(theme.container[3]),
79
+ [varNames.container[4]]: px(theme.container[4]),
80
+ [varNames.container[5]]: px(theme.container[5]),
73
81
  }
74
82
  }
75
83
 
76
84
  function buildFontCodeThemeProperties(theme: Theme_v3): Properties {
77
85
  const props: Properties = {
78
- '--font-code-family': theme.font.code.family,
79
- '--font-code-feature-settings': theme.font.code.featureSettings,
80
- '--font-code-weight-regular': `${theme.font.code.weights.regular}`,
81
- '--font-code-weight-medium': `${theme.font.code.weights.medium}`,
82
- '--font-code-weight-semibold': `${theme.font.code.weights.semibold}`,
83
- '--font-code-weight-bold': `${theme.font.code.weights.bold}`,
86
+ [varNames.font.code.family]: theme.font.code.family,
87
+ [varNames.font.code.featureSettings]: theme.font.code.featureSettings,
88
+ [varNames.font.code.weights.regular]: `${theme.font.code.weights.regular}`,
89
+ [varNames.font.code.weights.medium]: `${theme.font.code.weights.medium}`,
90
+ [varNames.font.code.weights.semibold]: `${theme.font.code.weights.semibold}`,
91
+ [varNames.font.code.weights.bold]: `${theme.font.code.weights.bold}`,
84
92
  }
85
93
 
86
94
  for (const size of FONT_CODE_SIZE) {
87
- props[`--font-code-${size}-size`] = rem(theme.font.code.sizes[size].fontSize)
88
- props[`--font-code-${size}-line-height`] = rem(theme.font.code.sizes[size].lineHeight)
89
- props[`--font-code-${size}-ascender-height`] = px(theme.font.code.sizes[size].ascenderHeight)
90
- props[`--font-code-${size}-descender-height`] = px(theme.font.code.sizes[size].descenderHeight)
91
- // props[`--font-code-${size}-cap-height`] =
92
- // `calc(var(--font-code-${size}-line-height) - var(--font-code-${size}-ascender-height) - var(--font-code-${size}-descender-height))`
93
- props[`--font-code-${size}-letter-spacing`] = px(theme.font.code.sizes[size].letterSpacing)
94
- props[`--font-code-${size}-icon-size`] = px(theme.font.code.sizes[size].iconSize)
95
+ const v = varNames.font.code.sizes[size]
96
+ const t = theme.font.code.sizes[size]
97
+
98
+ props[v.fontSize] = rem(t.fontSize)
99
+ props[v.lineHeight] = rem(t.lineHeight)
100
+ props[v.ascenderHeight] = px(t.ascenderHeight)
101
+ props[v.descenderHeight] = px(t.descenderHeight)
102
+ props[v.letterSpacing] = px(t.letterSpacing)
103
+ props[v.iconSize] = px(t.iconSize)
95
104
  }
96
105
 
97
106
  return props
@@ -99,29 +108,24 @@ function buildFontCodeThemeProperties(theme: Theme_v3): Properties {
99
108
 
100
109
  function buildFontHeadingThemeProperties(theme: Theme_v3): Properties {
101
110
  const props: Properties = {
102
- '--font-heading-family': theme.font.heading.family,
103
- '--font-heading-feature-settings': theme.font.heading.featureSettings,
104
- '--font-heading-weight-regular': `${theme.font.heading.weights.regular}`,
105
- '--font-heading-weight-medium': `${theme.font.heading.weights.medium}`,
106
- '--font-heading-weight-semibold': `${theme.font.heading.weights.semibold}`,
107
- '--font-heading-weight-bold': `${theme.font.heading.weights.bold}`,
111
+ [varNames.font.heading.family]: theme.font.heading.family,
112
+ [varNames.font.heading.featureSettings]: theme.font.heading.featureSettings,
113
+ [varNames.font.heading.weights.regular]: `${theme.font.heading.weights.regular}`,
114
+ [varNames.font.heading.weights.medium]: `${theme.font.heading.weights.medium}`,
115
+ [varNames.font.heading.weights.semibold]: `${theme.font.heading.weights.semibold}`,
116
+ [varNames.font.heading.weights.bold]: `${theme.font.heading.weights.bold}`,
108
117
  }
109
118
 
110
119
  for (const size of FONT_HEADING_SIZE) {
111
- props[`--font-heading-${size}-size`] = rem(theme.font.heading.sizes[size].fontSize)
112
- props[`--font-heading-${size}-line-height`] = rem(theme.font.heading.sizes[size].lineHeight)
113
- props[`--font-heading-${size}-ascender-height`] = px(
114
- theme.font.heading.sizes[size].ascenderHeight,
115
- )
116
- props[`--font-heading-${size}-descender-height`] = px(
117
- theme.font.heading.sizes[size].descenderHeight,
118
- )
119
- props[`--font-heading-${size}-letter-spacing`] = px(
120
- theme.font.heading.sizes[size].letterSpacing,
121
- )
122
- // props[`--font-heading-${size}-cap-height`] =
123
- // `calc(var(--font-heading-${size}-line-height) - var(--font-heading-${size}-ascender-height) - var(--font-heading-${size}-descender-height))`
124
- props[`--font-heading-${size}-icon-size`] = px(theme.font.heading.sizes[size].iconSize)
120
+ const v = varNames.font.heading.sizes[size]
121
+ const t = theme.font.heading.sizes[size]
122
+
123
+ props[v.fontSize] = rem(t.fontSize)
124
+ props[v.lineHeight] = rem(t.lineHeight)
125
+ props[v.ascenderHeight] = px(t.ascenderHeight)
126
+ props[v.descenderHeight] = px(t.descenderHeight)
127
+ props[v.letterSpacing] = px(t.letterSpacing)
128
+ props[v.iconSize] = px(t.iconSize)
125
129
  }
126
130
 
127
131
  return props
@@ -129,25 +133,24 @@ function buildFontHeadingThemeProperties(theme: Theme_v3): Properties {
129
133
 
130
134
  function buildFontLabelThemeProperties(theme: Theme_v3): Properties {
131
135
  const props: Properties = {
132
- '--font-label-family': theme.font.label.family,
133
- '--font-label-feature-settings': theme.font.label.featureSettings,
134
- '--font-label-weight-regular': `${theme.font.label.weights.regular}`,
135
- '--font-label-weight-medium': `${theme.font.label.weights.medium}`,
136
- '--font-label-weight-semibold': `${theme.font.label.weights.semibold}`,
137
- '--font-label-weight-bold': `${theme.font.label.weights.bold}`,
136
+ [varNames.font.label.family]: theme.font.label.family,
137
+ [varNames.font.label.featureSettings]: theme.font.label.featureSettings,
138
+ [varNames.font.label.weights.regular]: `${theme.font.label.weights.regular}`,
139
+ [varNames.font.label.weights.medium]: `${theme.font.label.weights.medium}`,
140
+ [varNames.font.label.weights.semibold]: `${theme.font.label.weights.semibold}`,
141
+ [varNames.font.label.weights.bold]: `${theme.font.label.weights.bold}`,
138
142
  }
139
143
 
140
144
  for (const size of FONT_LABEL_SIZE) {
141
- props[`--font-label-${size}-size`] = rem(theme.font.label.sizes[size].fontSize)
142
- props[`--font-label-${size}-line-height`] = rem(theme.font.label.sizes[size].lineHeight)
143
- props[`--font-label-${size}-ascender-height`] = px(theme.font.label.sizes[size].ascenderHeight)
144
- props[`--font-label-${size}-descender-height`] = px(
145
- theme.font.label.sizes[size].descenderHeight,
146
- )
147
- // props[`--font-label-${size}-cap-height`] =
148
- // `calc(var(--font-label-${size}-line-height) - var(--font-label-${size}-ascender-height) - var(--font-label-${size}-descender-height))`
149
- props[`--font-label-${size}-letter-spacing`] = px(theme.font.label.sizes[size].letterSpacing)
150
- props[`--font-label-${size}-icon-size`] = px(theme.font.label.sizes[size].iconSize)
145
+ const v = varNames.font.label.sizes[size]
146
+ const t = theme.font.label.sizes[size]
147
+
148
+ props[v.fontSize] = rem(t.fontSize)
149
+ props[v.lineHeight] = rem(t.lineHeight)
150
+ props[v.ascenderHeight] = px(t.ascenderHeight)
151
+ props[v.descenderHeight] = px(t.descenderHeight)
152
+ props[v.letterSpacing] = px(t.letterSpacing)
153
+ props[v.iconSize] = px(t.iconSize)
151
154
  }
152
155
 
153
156
  return props
@@ -155,23 +158,24 @@ function buildFontLabelThemeProperties(theme: Theme_v3): Properties {
155
158
 
156
159
  function buildFontTextThemeProperties(theme: Theme_v3): Properties {
157
160
  const props: Properties = {
158
- '--font-text-family': theme.font.text.family,
159
- '--font-text-feature-settings': theme.font.text.featureSettings,
160
- '--font-text-weight-regular': `${theme.font.text.weights.regular}`,
161
- '--font-text-weight-medium': `${theme.font.text.weights.medium}`,
162
- '--font-text-weight-semibold': `${theme.font.text.weights.semibold}`,
163
- '--font-text-weight-bold': `${theme.font.text.weights.bold}`,
161
+ [varNames.font.text.family]: theme.font.text.family,
162
+ [varNames.font.text.featureSettings]: theme.font.text.featureSettings,
163
+ [varNames.font.text.weights.regular]: `${theme.font.text.weights.regular}`,
164
+ [varNames.font.text.weights.medium]: `${theme.font.text.weights.medium}`,
165
+ [varNames.font.text.weights.semibold]: `${theme.font.text.weights.semibold}`,
166
+ [varNames.font.text.weights.bold]: `${theme.font.text.weights.bold}`,
164
167
  }
165
168
 
166
169
  for (const size of FONT_TEXT_SIZE) {
167
- props[`--font-text-${size}-size`] = rem(theme.font.text.sizes[size].fontSize)
168
- props[`--font-text-${size}-line-height`] = rem(theme.font.text.sizes[size].lineHeight)
169
- props[`--font-text-${size}-ascender-height`] = px(theme.font.text.sizes[size].ascenderHeight)
170
- props[`--font-text-${size}-descender-height`] = px(theme.font.text.sizes[size].descenderHeight)
171
- // props[`--font-text-${size}-cap-height`] =
172
- // `calc(var(--font-text-${size}-line-height) - var(--font-text-${size}-ascender-height) - var(--font-text-${size}-descender-height))`
173
- props[`--font-text-${size}-letter-spacing`] = px(theme.font.text.sizes[size].letterSpacing)
174
- props[`--font-text-${size}-icon-size`] = px(theme.font.text.sizes[size].iconSize)
170
+ const v = varNames.font.text.sizes[size]
171
+ const t = theme.font.text.sizes[size]
172
+
173
+ props[v.fontSize] = rem(t.fontSize)
174
+ props[v.lineHeight] = rem(t.lineHeight)
175
+ props[v.ascenderHeight] = px(t.ascenderHeight)
176
+ props[v.descenderHeight] = px(t.descenderHeight)
177
+ props[v.letterSpacing] = px(t.letterSpacing)
178
+ props[v.iconSize] = px(t.iconSize)
175
179
  }
176
180
 
177
181
  return props
@@ -179,83 +183,84 @@ function buildFontTextThemeProperties(theme: Theme_v3): Properties {
179
183
 
180
184
  function buildInputThemeProperties(theme: Theme_v3): Properties {
181
185
  return {
182
- [`--input-border-width`]: px(theme.input.border.width),
183
- [`--input-checkbox-focus-ring-offset`]: px(theme.input.checkbox.focusRing.offset),
184
- [`--input-checkbox-focus-ring-width`]: px(theme.input.checkbox.focusRing.width),
185
- [`--input-checkbox-size`]: px(theme.input.checkbox.size),
186
- [`--input-radio-focus-ring-offset`]: px(theme.input.radio.focusRing.offset),
187
- [`--input-radio-focus-ring-width`]: px(theme.input.radio.focusRing.width),
188
- [`--input-radio-mark-size`]: px(theme.input.radio.markSize),
189
- [`--input-radio-size`]: px(theme.input.radio.size),
190
- [`--input-select-focus-ring-offset`]: px(theme.input.select.focusRing.offset),
191
- [`--input-select-focus-ring-width`]: px(theme.input.select.focusRing.width),
192
- [`--input-switch-focus-ring-offset`]: px(theme.input.switch.focusRing.offset),
193
- [`--input-switch-focus-ring-width`]: px(theme.input.switch.focusRing.width),
194
- [`--input-switch-height`]: px(theme.input.switch.height),
195
- [`--input-switch-padding`]: px(theme.input.switch.padding),
196
- [`--input-switch-transition-duration-ms`]: `${theme.input.switch.transitionDurationMs}ms`,
197
- [`--input-switch-transition-timing-function`]: theme.input.switch.transitionTimingFunction,
198
- [`--input-switch-width`]: px(theme.input.switch.width),
199
- [`--input-text-focus-ring-offset`]: px(theme.input.text.focusRing.offset),
200
- [`--input-text-focus-ring-width`]: px(theme.input.text.focusRing.width),
186
+ [varNames.input.border.width]: px(theme.input.border.width),
187
+ [varNames.input.checkbox.focusRing.offset]: px(theme.input.checkbox.focusRing.offset),
188
+ [varNames.input.checkbox.focusRing.width]: px(theme.input.checkbox.focusRing.width),
189
+ [varNames.input.checkbox.size]: px(theme.input.checkbox.size),
190
+ [varNames.input.radio.focusRing.offset]: px(theme.input.radio.focusRing.offset),
191
+ [varNames.input.radio.focusRing.width]: px(theme.input.radio.focusRing.width),
192
+ [varNames.input.radio.markSize]: px(theme.input.radio.markSize),
193
+ [varNames.input.radio.size]: px(theme.input.radio.size),
194
+ [varNames.input.select.focusRing.offset]: px(theme.input.select.focusRing.offset),
195
+ [varNames.input.select.focusRing.width]: px(theme.input.select.focusRing.width),
196
+ [varNames.input.switch.focusRing.offset]: px(theme.input.switch.focusRing.offset),
197
+ [varNames.input.switch.focusRing.width]: px(theme.input.switch.focusRing.width),
198
+ [varNames.input.switch.height]: px(theme.input.switch.height),
199
+ [varNames.input.switch.padding]: px(theme.input.switch.padding),
200
+ [varNames.input.switch.transitionDurationMs]: `${theme.input.switch.transitionDurationMs}ms`,
201
+ [varNames.input.switch.transitionTimingFunction]: theme.input.switch.transitionTimingFunction,
202
+ [varNames.input.switch.width]: px(theme.input.switch.width),
203
+ [varNames.input.text.focusRing.offset]: px(theme.input.text.focusRing.offset),
204
+ [varNames.input.text.focusRing.width]: px(theme.input.text.focusRing.width),
201
205
  }
202
206
  }
203
207
 
204
208
  function buildRadiusThemeProperties(theme: Theme_v3): Properties {
205
209
  return {
206
- [`--radius-0`]: rem(theme.radius[0]),
207
- [`--radius-1`]: rem(theme.radius[1]),
208
- [`--radius-2`]: rem(theme.radius[2]),
209
- [`--radius-3`]: rem(theme.radius[3]),
210
- [`--radius-4`]: rem(theme.radius[4]),
211
- [`--radius-5`]: rem(theme.radius[5]),
212
- [`--radius-6`]: rem(theme.radius[6]),
210
+ [varNames.radius[0]]: rem(theme.radius[0]),
211
+ [varNames.radius[1]]: rem(theme.radius[1]),
212
+ [varNames.radius[2]]: rem(theme.radius[2]),
213
+ [varNames.radius[3]]: rem(theme.radius[3]),
214
+ [varNames.radius[4]]: rem(theme.radius[4]),
215
+ [varNames.radius[5]]: rem(theme.radius[5]),
216
+ [varNames.radius[6]]: rem(theme.radius[6]),
213
217
  }
214
218
  }
215
219
 
216
220
  function buildShadowThemeProperties(theme: Theme_v3): Properties {
217
221
  return {
218
- [`--shadow-outline`]: `0 0 0 ${theme.card.shadow.outline}px`,
219
- [`--shadow-0-umbra`]: toBoxShadow(theme.shadow[0]?.umbra),
220
- [`--shadow-0-penumbra`]: toBoxShadow(theme.shadow[0]?.penumbra),
221
- [`--shadow-0-ambient`]: toBoxShadow(theme.shadow[0]?.ambient),
222
- [`--shadow-1-umbra`]: toBoxShadow(theme.shadow[1]?.umbra),
223
- [`--shadow-1-penumbra`]: toBoxShadow(theme.shadow[1]?.penumbra),
224
- [`--shadow-1-ambient`]: toBoxShadow(theme.shadow[1]?.ambient),
225
- [`--shadow-2-umbra`]: toBoxShadow(theme.shadow[2]?.umbra),
226
- [`--shadow-2-penumbra`]: toBoxShadow(theme.shadow[2]?.penumbra),
227
- [`--shadow-2-ambient`]: toBoxShadow(theme.shadow[2]?.ambient),
228
- [`--shadow-3-umbra`]: toBoxShadow(theme.shadow[3]?.umbra),
229
- [`--shadow-3-penumbra`]: toBoxShadow(theme.shadow[3]?.penumbra),
230
- [`--shadow-3-ambient`]: toBoxShadow(theme.shadow[3]?.ambient),
231
- [`--shadow-4-umbra`]: toBoxShadow(theme.shadow[4]?.umbra),
232
- [`--shadow-4-penumbra`]: toBoxShadow(theme.shadow[4]?.penumbra),
233
- [`--shadow-4-ambient`]: toBoxShadow(theme.shadow[4]?.ambient),
234
- [`--shadow-5-umbra`]: toBoxShadow(theme.shadow[5]?.umbra),
235
- [`--shadow-5-penumbra`]: toBoxShadow(theme.shadow[5]?.penumbra),
236
- [`--shadow-5-ambient`]: toBoxShadow(theme.shadow[5]?.ambient),
222
+ [varNames.shadow[0].umbra]: toBoxShadow(theme.shadow[0]?.umbra),
223
+ [varNames.shadow[0].penumbra]: toBoxShadow(theme.shadow[0]?.penumbra),
224
+ [varNames.shadow[0].ambient]: toBoxShadow(theme.shadow[0]?.ambient),
225
+
226
+ [varNames.shadow[1].umbra]: toBoxShadow(theme.shadow[1]?.umbra),
227
+ [varNames.shadow[1].penumbra]: toBoxShadow(theme.shadow[1]?.penumbra),
228
+ [varNames.shadow[1].ambient]: toBoxShadow(theme.shadow[1]?.ambient),
229
+
230
+ [varNames.shadow[2].umbra]: toBoxShadow(theme.shadow[2]?.umbra),
231
+ [varNames.shadow[2].penumbra]: toBoxShadow(theme.shadow[2]?.penumbra),
232
+ [varNames.shadow[2].ambient]: toBoxShadow(theme.shadow[2]?.ambient),
233
+
234
+ [varNames.shadow[3].umbra]: toBoxShadow(theme.shadow[3]?.umbra),
235
+ [varNames.shadow[3].penumbra]: toBoxShadow(theme.shadow[3]?.penumbra),
236
+ [varNames.shadow[3].ambient]: toBoxShadow(theme.shadow[3]?.ambient),
237
+
238
+ [varNames.shadow[4].umbra]: toBoxShadow(theme.shadow[4]?.umbra),
239
+ [varNames.shadow[4].penumbra]: toBoxShadow(theme.shadow[4]?.penumbra),
240
+ [varNames.shadow[4].ambient]: toBoxShadow(theme.shadow[4]?.ambient),
241
+
242
+ [varNames.shadow[5].umbra]: toBoxShadow(theme.shadow[5]?.umbra),
243
+ [varNames.shadow[5].penumbra]: toBoxShadow(theme.shadow[5]?.penumbra),
244
+ [varNames.shadow[5].ambient]: toBoxShadow(theme.shadow[5]?.ambient),
237
245
  }
238
246
  }
239
247
 
240
248
  function buildSpaceThemeProperties(theme: Theme_v3): Properties {
241
249
  return {
242
- [`--space-0`]: rem(theme.space[0]),
243
- [`--space-0_5`]: rem(theme.space[1] / 2),
244
- [`--space-1`]: rem(theme.space[1]),
245
- [`--space-2`]: rem(theme.space[2]),
246
- [`--space-3`]: rem(theme.space[3]),
247
- [`--space-4`]: rem(theme.space[4]),
248
- [`--space-5`]: rem(theme.space[5]),
249
- [`--space-6`]: rem(theme.space[6]),
250
- [`--space-7`]: rem(theme.space[7]),
251
- [`--space-8`]: rem(theme.space[8]),
252
- [`--space-9`]: rem(theme.space[9]),
250
+ [varNames.space[0]]: rem(theme.space[0]),
251
+ [varNames.space[0.5]]: rem(theme.space[1] / 2),
252
+ [varNames.space[1]]: rem(theme.space[1]),
253
+ [varNames.space[2]]: rem(theme.space[2]),
254
+ [varNames.space[3]]: rem(theme.space[3]),
255
+ [varNames.space[4]]: rem(theme.space[4]),
256
+ [varNames.space[5]]: rem(theme.space[5]),
257
+ [varNames.space[6]]: rem(theme.space[6]),
258
+ [varNames.space[7]]: rem(theme.space[7]),
259
+ [varNames.space[8]]: rem(theme.space[8]),
260
+ [varNames.space[9]]: rem(theme.space[9]),
253
261
  }
254
262
  }
255
263
 
256
- const THEME_COLOR_SCHEMES = ['dark', 'light'] as const
257
- const THEME_COLOR_VARIANTS = ['tinted', 'solid'] as const
258
-
259
264
  function buildColorThemeProperties(theme: Theme_v3): Properties {
260
265
  const props: Properties = {}
261
266
 
@@ -264,36 +269,38 @@ function buildColorThemeProperties(theme: Theme_v3): Properties {
264
269
  Object.assign(props, buildColorAvatarThemeProperties(theme, {scheme, cardTone}))
265
270
  Object.assign(props, buildColorCardThemeProperties(theme, {scheme, cardTone}))
266
271
 
267
- // card variants: tinted, solid
268
272
  for (const colorVariant of THEME_COLOR_VARIANTS) {
269
273
  for (const elementTone of THEME_COLOR_STATE_TONES) {
270
- const tokens = theme._tokens.color[cardTone].variant[colorVariant][elementTone]
271
- const prefix = `--color-${scheme}-${cardTone}-${colorVariant}-${elementTone}` as const
274
+ // shorthand to variable names
275
+ const v = varNames.color[scheme][cardTone][colorVariant][elementTone]
276
+
277
+ // shorthand to values
278
+ const t = theme._tokens.color[cardTone].variant[colorVariant][elementTone]
272
279
 
273
280
  const context: RenderColorContext = {
274
- bgVar: `${prefix}-bg-0`,
275
- hue: tokens._hue,
281
+ bgVar: v.bg[0],
282
+ hue: t._hue,
276
283
  scheme,
277
284
  }
278
285
 
279
286
  Object.assign(props, {
280
- [`${prefix}-bg-0`]: renderColor(tokens.bg[0], context),
281
- [`${prefix}-bg-1`]: `color-mix(in srgb, var(${prefix}-bg-0), var(${prefix}-bg-4) 25%)`,
282
- [`${prefix}-bg-2`]: `color-mix(in srgb, var(${prefix}-bg-0), var(${prefix}-bg-4) 50%)`,
283
- [`${prefix}-bg-3`]: `color-mix(in srgb, var(${prefix}-bg-0), var(${prefix}-bg-4) 75%)`,
284
- [`${prefix}-bg-4`]: renderColor(tokens.bg[4], context),
285
-
286
- [`${prefix}-border-0`]: renderColor(tokens.border[0], context),
287
- [`${prefix}-border-1`]: `color-mix(in srgb, var(${prefix}-border-0), var(${prefix}-border-4) 25%)`,
288
- [`${prefix}-border-2`]: `color-mix(in srgb, var(${prefix}-border-0), var(${prefix}-border-4) 50%)`,
289
- [`${prefix}-border-3`]: `color-mix(in srgb, var(${prefix}-border-0), var(${prefix}-border-4) 75%)`,
290
- [`${prefix}-border-4`]: renderColor(tokens.border[4], context),
291
-
292
- [`${prefix}-fg-0`]: renderColor(tokens.fg[0], context),
293
- [`${prefix}-fg-1`]: `color-mix(in srgb, var(${prefix}-fg-0), var(${prefix}-fg-4) 25%)`,
294
- [`${prefix}-fg-2`]: `color-mix(in srgb, var(${prefix}-fg-0), var(${prefix}-fg-4) 50%)`,
295
- [`${prefix}-fg-3`]: `color-mix(in srgb, var(${prefix}-fg-0), var(${prefix}-fg-4) 75%)`,
296
- [`${prefix}-fg-4`]: renderColor(tokens.fg[4], context),
287
+ [v.bg[0]]: renderColor(t.bg[0], context),
288
+ [v.bg[1]]: `color-mix(in srgb, var(${v.bg[0]}), var(${v.bg[4]}) 25%)`,
289
+ [v.bg[2]]: `color-mix(in srgb, var(${v.bg[0]}), var(${v.bg[4]}) 50%)`,
290
+ [v.bg[3]]: `color-mix(in srgb, var(${v.bg[0]}), var(${v.bg[4]}) 75%)`,
291
+ [v.bg[4]]: renderColor(t.bg[4], context),
292
+
293
+ [v.border[0]]: renderColor(t.border[0], context),
294
+ [v.border[1]]: `color-mix(in srgb, var(${v.border[0]}), var(${v.border[4]}) 25%)`,
295
+ [v.border[2]]: `color-mix(in srgb, var(${v.border[0]}), var(${v.border[4]}) 50%)`,
296
+ [v.border[3]]: `color-mix(in srgb, var(${v.border[0]}), var(${v.border[4]}) 75%)`,
297
+ [v.border[4]]: renderColor(t.border[4], context),
298
+
299
+ [v.fg[0]]: renderColor(t.fg[0], context),
300
+ [v.fg[1]]: `color-mix(in srgb, var(${v.fg[0]}), var(${v.fg[4]}) 25%)`,
301
+ [v.fg[2]]: `color-mix(in srgb, var(${v.fg[0]}), var(${v.fg[4]}) 50%)`,
302
+ [v.fg[3]]: `color-mix(in srgb, var(${v.fg[0]}), var(${v.fg[4]}) 75%)`,
303
+ [v.fg[4]]: renderColor(t.fg[4], context),
297
304
  } satisfies Properties)
298
305
  }
299
306
  }
@@ -308,21 +315,22 @@ function buildColorAvatarThemeProperties(
308
315
  options: {scheme: ThemeColorSchemeKey; cardTone: ThemeColorCardToneKey},
309
316
  ): Properties {
310
317
  const {scheme, cardTone} = options
311
- const tokens = theme._tokens.color[cardTone]
312
- const prefix = `--color-${scheme}-${cardTone}` as const
318
+
319
+ const v = varNames.color[scheme][cardTone]
320
+ const t = theme._tokens.color[cardTone]
313
321
 
314
322
  const props: Properties = {}
315
323
 
316
324
  for (const hue of HUES) {
317
325
  const context: RenderColorContext = {
318
- bgVar: `${prefix}-bg-0`,
319
- hue: tokens.avatar[hue]._hue ?? hue,
326
+ bgVar: varNames.color.bg,
327
+ hue: t.avatar[hue]._hue ?? hue,
320
328
  scheme,
321
329
  }
322
330
 
323
331
  Object.assign(props, {
324
- [`${prefix}-avatar-${hue}-bg`]: renderColor(tokens.avatar[hue].bg, context),
325
- [`${prefix}-avatar-${hue}-fg`]: renderColor(tokens.avatar[hue].fg, context),
332
+ [v.avatar[hue].bg]: renderColor(t.avatar[hue].bg, context),
333
+ [v.avatar[hue].fg]: renderColor(t.avatar[hue].fg, context),
326
334
  } satisfies Properties)
327
335
  }
328
336
 
@@ -334,67 +342,73 @@ function buildColorCardThemeProperties(
334
342
  options: {scheme: ThemeColorSchemeKey; cardTone: ThemeColorCardToneKey},
335
343
  ): Properties {
336
344
  const {scheme, cardTone} = options
337
- const tokens = theme._tokens.color[cardTone]
338
- const prefix = `--color-${scheme}-${cardTone}` as const
339
- const context: RenderColorContext = {bgVar: `${prefix}-bg-0`, hue: tokens._hue, scheme}
345
+
346
+ const v = varNames.color[scheme][cardTone]
347
+ const t = theme._tokens.color[cardTone]
348
+
349
+ const context: RenderColorContext = {
350
+ bgVar: varNames.color.bg,
351
+ hue: t._hue,
352
+ scheme,
353
+ }
340
354
 
341
355
  const props: Properties = {
342
356
  // backdrop
343
- [`${prefix}-backdrop`]: renderColor(tokens.backdrop, context),
357
+ [v.backdrop]: renderColor(t.backdrop, context),
344
358
 
345
359
  // code
346
- [`${prefix}-code-bg`]: renderColor(tokens.code.bg, context),
347
- [`${prefix}-code-fg`]: renderColor(tokens.code.fg, context),
360
+ [v.code.bg]: renderColor(t.code.bg, context),
361
+ [v.code.fg]: renderColor(t.code.fg, context),
348
362
 
349
363
  // code / token
350
- [`${prefix}-code-token-atrule`]: renderColor(tokens.code.token.atrule, context),
351
- [`${prefix}-code-token-attr-name`]: renderColor(tokens.code.token.attrName, context),
352
- [`${prefix}-code-token-attr-value`]: renderColor(tokens.code.token.attrValue, context),
353
- [`${prefix}-code-token-attribute`]: renderColor(tokens.code.token.attribute, context),
354
- [`${prefix}-code-token-boolean`]: renderColor(tokens.code.token.boolean, context),
355
- [`${prefix}-code-token-builtin`]: renderColor(tokens.code.token.builtin, context),
356
- [`${prefix}-code-token-cdata`]: renderColor(tokens.code.token.cdata, context),
357
- [`${prefix}-code-token-char`]: renderColor(tokens.code.token.char, context),
358
- [`${prefix}-code-token-class-name`]: renderColor(tokens.code.token.className, context),
359
- [`${prefix}-code-token-class`]: renderColor(tokens.code.token.class, context),
360
- [`${prefix}-code-token-comment`]: renderColor(tokens.code.token.comment, context),
361
- [`${prefix}-code-token-constant`]: renderColor(tokens.code.token.constant, context),
362
- [`${prefix}-code-token-deleted`]: renderColor(tokens.code.token.deleted, context),
363
- [`${prefix}-code-token-doctype`]: renderColor(tokens.code.token.doctype, context),
364
- [`${prefix}-code-token-entity`]: renderColor(tokens.code.token.entity, context),
365
- [`${prefix}-code-token-function`]: renderColor(tokens.code.token.function, context),
366
- [`${prefix}-code-token-hexcode`]: renderColor(tokens.code.token.hexcode, context),
367
- [`${prefix}-code-token-id`]: renderColor(tokens.code.token.id, context),
368
- [`${prefix}-code-token-important`]: renderColor(tokens.code.token.important, context),
369
- [`${prefix}-code-token-inserted`]: renderColor(tokens.code.token.inserted, context),
370
- [`${prefix}-code-token-keyword`]: renderColor(tokens.code.token.keyword, context),
371
- [`${prefix}-code-token-number`]: renderColor(tokens.code.token.number, context),
372
- [`${prefix}-code-token-operator`]: renderColor(tokens.code.token.operator, context),
373
- [`${prefix}-code-token-prolog`]: renderColor(tokens.code.token.prolog, context),
374
- [`${prefix}-code-token-property`]: renderColor(tokens.code.token.property, context),
375
- [`${prefix}-code-token-pseudo-class`]: renderColor(tokens.code.token.pseudoClass, context),
376
- [`${prefix}-code-token-pseudo-eelement`]: renderColor(tokens.code.token.pseudoElement, context),
377
- [`${prefix}-code-token-punctuation`]: renderColor(tokens.code.token.punctuation, context),
378
- [`${prefix}-code-token-regex`]: renderColor(tokens.code.token.regex, context),
379
- [`${prefix}-code-token-selector`]: renderColor(tokens.code.token.selector, context),
380
- [`${prefix}-code-token-string`]: renderColor(tokens.code.token.string, context),
381
- [`${prefix}-code-token-symbol`]: renderColor(tokens.code.token.symbol, context),
382
- [`${prefix}-code-token-tag`]: renderColor(tokens.code.token.tag, context),
383
- [`${prefix}-code-token-unit`]: renderColor(tokens.code.token.unit, context),
384
- [`${prefix}-code-token-url`]: renderColor(tokens.code.token.url, context),
385
- [`${prefix}-code-token-variable`]: renderColor(tokens.code.token.variable, context),
364
+ [v.code.token.atrule]: renderColor(t.code.token.atrule, context),
365
+ [v.code.token.attrName]: renderColor(t.code.token.attrName, context),
366
+ [v.code.token.attrValue]: renderColor(t.code.token.attrValue, context),
367
+ [v.code.token.attribute]: renderColor(t.code.token.attribute, context),
368
+ [v.code.token.boolean]: renderColor(t.code.token.boolean, context),
369
+ [v.code.token.builtin]: renderColor(t.code.token.builtin, context),
370
+ [v.code.token.cdata]: renderColor(t.code.token.cdata, context),
371
+ [v.code.token.char]: renderColor(t.code.token.char, context),
372
+ [v.code.token.className]: renderColor(t.code.token.className, context),
373
+ [v.code.token.class]: renderColor(t.code.token.class, context),
374
+ [v.code.token.comment]: renderColor(t.code.token.comment, context),
375
+ [v.code.token.constant]: renderColor(t.code.token.constant, context),
376
+ [v.code.token.deleted]: renderColor(t.code.token.deleted, context),
377
+ [v.code.token.doctype]: renderColor(t.code.token.doctype, context),
378
+ [v.code.token.entity]: renderColor(t.code.token.entity, context),
379
+ [v.code.token.function]: renderColor(t.code.token.function, context),
380
+ [v.code.token.hexcode]: renderColor(t.code.token.hexcode, context),
381
+ [v.code.token.id]: renderColor(t.code.token.id, context),
382
+ [v.code.token.important]: renderColor(t.code.token.important, context),
383
+ [v.code.token.inserted]: renderColor(t.code.token.inserted, context),
384
+ [v.code.token.keyword]: renderColor(t.code.token.keyword, context),
385
+ [v.code.token.number]: renderColor(t.code.token.number, context),
386
+ [v.code.token.operator]: renderColor(t.code.token.operator, context),
387
+ [v.code.token.prolog]: renderColor(t.code.token.prolog, context),
388
+ [v.code.token.property]: renderColor(t.code.token.property, context),
389
+ [v.code.token.pseudoClass]: renderColor(t.code.token.pseudoClass, context),
390
+ [v.code.token.pseudoElement]: renderColor(t.code.token.pseudoElement, context),
391
+ [v.code.token.punctuation]: renderColor(t.code.token.punctuation, context),
392
+ [v.code.token.regex]: renderColor(t.code.token.regex, context),
393
+ [v.code.token.selector]: renderColor(t.code.token.selector, context),
394
+ [v.code.token.string]: renderColor(t.code.token.string, context),
395
+ [v.code.token.symbol]: renderColor(t.code.token.symbol, context),
396
+ [v.code.token.tag]: renderColor(t.code.token.tag, context),
397
+ [v.code.token.unit]: renderColor(t.code.token.unit, context),
398
+ [v.code.token.url]: renderColor(t.code.token.url, context),
399
+ [v.code.token.variable]: renderColor(t.code.token.variable, context),
386
400
 
387
401
  // focus ring
388
- [`${prefix}-focus-ring`]: renderColor(tokens.focusRing, context),
402
+ [v.focusRing]: renderColor(t.focusRing, context),
389
403
 
390
404
  // link
391
- [`${prefix}-link-fg`]: renderColor(tokens.link.fg, context),
405
+ [v.link.fg]: renderColor(t.link.fg, context),
392
406
 
393
407
  // shadow
394
- [`${prefix}-shadow-outline`]: renderColor(tokens.shadow.outline, context),
395
- [`${prefix}-shadow-umbra`]: renderColor(tokens.shadow.umbra, context),
396
- [`${prefix}-shadow-penumbra`]: renderColor(tokens.shadow.penumbra, context),
397
- [`${prefix}-shadow-ambient`]: renderColor(tokens.shadow.ambient, context),
408
+ [v.shadow.outline]: renderColor(t.shadow.outline, context),
409
+ [v.shadow.umbra]: renderColor(t.shadow.umbra, context),
410
+ [v.shadow.penumbra]: renderColor(t.shadow.penumbra, context),
411
+ [v.shadow.ambient]: renderColor(t.shadow.ambient, context),
398
412
  }
399
413
 
400
414
  return props