@sanity/ui 2.0.0-alpha.34 → 2.0.0-alpha.35

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 (163) hide show
  1. package/dist/index.cjs.mjs +4 -3
  2. package/dist/index.d.ts +29 -22
  3. package/dist/index.esm.js +397 -518
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/index.js +413 -534
  6. package/dist/index.js.map +1 -1
  7. package/dist/theme.cjs.mjs +10 -4
  8. package/dist/theme.d.ts +450 -187
  9. package/dist/theme.esm.js +2933 -2750
  10. package/dist/theme.esm.js.map +1 -1
  11. package/dist/theme.js +2942 -2753
  12. package/dist/theme.js.map +1 -1
  13. package/package.json +3 -3
  14. package/src/core/_compat.ts +7 -7
  15. package/src/core/components/dialog/dialog.tsx +5 -5
  16. package/src/core/components/dialog/styles.ts +4 -5
  17. package/src/core/components/hotkeys/hotkeys.tsx +4 -2
  18. package/src/core/components/menu/__workshop__/avatarMenu.tsx +50 -0
  19. package/src/core/components/menu/__workshop__/index.ts +5 -0
  20. package/src/core/components/menu/menuItem.tsx +7 -1
  21. package/src/core/components/skeleton/textSkeleton.tsx +12 -14
  22. package/src/core/components/tree/style.ts +14 -17
  23. package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +3 -3
  24. package/src/core/hooks/useMediaIndex/useMediaIndex.ts +2 -3
  25. package/src/core/primitives/_selectable/style.ts +18 -18
  26. package/src/core/primitives/avatar/avatar.tsx +3 -3
  27. package/src/core/primitives/avatar/avatarCounter.tsx +4 -4
  28. package/src/core/primitives/avatar/avatarStack.tsx +2 -2
  29. package/src/core/primitives/avatar/styles.ts +7 -8
  30. package/src/core/primitives/avatar/types.ts +2 -2
  31. package/src/core/primitives/badge/__workshop__/props.tsx +1 -1
  32. package/src/core/primitives/badge/__workshop__/tones.tsx +1 -1
  33. package/src/core/primitives/badge/badge.tsx +1 -1
  34. package/src/core/primitives/badge/styles.ts +5 -6
  35. package/src/core/primitives/button/button.tsx +3 -4
  36. package/src/core/primitives/button/styles.ts +22 -23
  37. package/src/core/primitives/card/__workshop__/selected.tsx +15 -15
  38. package/src/core/primitives/card/card.tsx +1 -1
  39. package/src/core/primitives/card/styles.ts +22 -22
  40. package/src/core/primitives/checkbox/styles.ts +21 -22
  41. package/src/core/primitives/code/styles.ts +4 -1
  42. package/src/core/primitives/container/styles.ts +2 -3
  43. package/src/core/primitives/heading/styles.ts +4 -2
  44. package/src/core/primitives/inline/styles.ts +6 -6
  45. package/src/core/primitives/kbd/kbd.tsx +7 -11
  46. package/src/core/primitives/label/styles.ts +4 -3
  47. package/src/core/primitives/popover/helpers.ts +3 -4
  48. package/src/core/primitives/popover/popover.tsx +8 -4
  49. package/src/core/primitives/popover/types.ts +1 -1
  50. package/src/core/primitives/radio/styles.ts +17 -19
  51. package/src/core/primitives/select/styles.ts +27 -32
  52. package/src/core/primitives/stack/styles.ts +2 -3
  53. package/src/core/primitives/switch/__workshop__/props.tsx +11 -31
  54. package/src/core/primitives/switch/styles.ts +18 -21
  55. package/src/core/primitives/text/__workshop__/colored.tsx +10 -10
  56. package/src/core/primitives/text/styles.ts +9 -4
  57. package/src/core/primitives/tooltip/tooltip.tsx +3 -3
  58. package/src/core/styles/border/borderStyle.ts +6 -11
  59. package/src/core/styles/box/boxStyle.ts +5 -9
  60. package/src/core/styles/card/_cardColorStyle.ts +99 -0
  61. package/src/core/styles/card/index.ts +1 -0
  62. package/src/core/styles/flex/flexItemStyle.ts +2 -3
  63. package/src/core/styles/flex/flexStyle.ts +6 -11
  64. package/src/core/styles/font/responsiveFont.ts +4 -4
  65. package/src/core/styles/font/textAlignStyle.ts +3 -3
  66. package/src/core/styles/grid/gridItemStyle.ts +7 -13
  67. package/src/core/styles/grid/gridStyle.ts +9 -17
  68. package/src/core/styles/helpers.ts +5 -3
  69. package/src/core/styles/input/responsiveInputPaddingStyle.ts +6 -6
  70. package/src/core/styles/input/textInputStyle.ts +36 -40
  71. package/src/core/styles/margin/marginsStyle.test.ts +2 -3
  72. package/src/core/styles/padding/paddingStyle.test.ts +2 -3
  73. package/src/core/styles/radius/radiusStyle.ts +2 -3
  74. package/src/core/styles/shadow/shadowStyle.ts +4 -5
  75. package/src/core/theme/__workshop__/build/Root.tsx +24 -20
  76. package/src/core/theme/__workshop__/build/story.tsx +22 -26
  77. package/src/core/theme/__workshop__/canvas.tsx +21 -40
  78. package/src/core/theme/theme.test.tsx +2 -35
  79. package/src/core/theme/themeColorProvider.tsx +2 -2
  80. package/src/core/theme/themeContext.ts +2 -2
  81. package/src/core/theme/themeProvider.tsx +25 -25
  82. package/src/core/theme/types.ts +3 -2
  83. package/src/core/theme/useRootTheme.ts +1 -9
  84. package/src/core/theme/useTheme.ts +8 -1
  85. package/src/core/types/card.ts +2 -2
  86. package/src/core/utils/arrow/arrow.tsx +3 -3
  87. package/src/core/utils/elementQuery/elementQuery.tsx +3 -3
  88. package/src/core/utils/virtualList/virtualList.tsx +2 -2
  89. package/src/theme/build/_deprecated/color/muted/createMuted.ts +2 -2
  90. package/src/theme/build/buildColorTheme.test.ts +14 -15
  91. package/src/theme/build/buildColorTheme.ts +239 -292
  92. package/src/theme/build/buildTheme.test.ts +9 -7
  93. package/src/theme/build/buildTheme.ts +12 -9
  94. package/src/theme/build/colorToken.ts +3 -1
  95. package/src/theme/build/lib/color-fns/contrastRatio.ts +1 -0
  96. package/src/theme/build/lib/isRecord.ts +3 -0
  97. package/src/theme/build/merge.ts +18 -13
  98. package/src/theme/build/renderColorTheme.ts +205 -213
  99. package/src/theme/build/renderColorValue.ts +15 -8
  100. package/src/theme/build/resolveColorTokens.ts +177 -198
  101. package/src/theme/build/theme.test.ts +27 -0
  102. package/src/theme/config/helpers.ts +16 -8
  103. package/src/theme/config/system.ts +46 -17
  104. package/src/theme/config/tokens/color/types.ts +55 -32
  105. package/src/theme/config/tokens/types.ts +11 -4
  106. package/src/theme/config/types.ts +5 -11
  107. package/src/theme/{build/defaults → defaults}/colorPalette.ts +1 -1
  108. package/src/theme/{build/defaults → defaults}/colorTokens.ts +189 -136
  109. package/src/theme/{build/defaults → defaults}/config.ts +14 -12
  110. package/src/theme/{build/defaults → defaults}/fonts.ts +6 -6
  111. package/src/theme/getScopedTheme.ts +81 -0
  112. package/src/theme/index.ts +9 -1
  113. package/src/theme/system/avatar.ts +1 -1
  114. package/src/theme/system/color/_constants.ts +11 -11
  115. package/src/theme/system/color/_system.ts +10 -71
  116. package/src/theme/system/color/avatar.ts +22 -10
  117. package/src/theme/system/color/badge.ts +18 -7
  118. package/src/theme/system/color/button.ts +17 -23
  119. package/src/theme/system/color/color.ts +34 -0
  120. package/src/theme/system/color/index.ts +3 -10
  121. package/src/theme/system/color/input.ts +13 -11
  122. package/src/theme/system/color/kbd.ts +3 -3
  123. package/src/theme/system/color/selectable.ts +13 -19
  124. package/src/theme/system/color/shadow.ts +7 -0
  125. package/src/theme/system/color/state.ts +37 -0
  126. package/src/theme/system/css.ts +9 -0
  127. package/src/theme/system/focusRing.ts +7 -0
  128. package/src/theme/system/index.ts +5 -1
  129. package/src/theme/system/input.ts +1 -1
  130. package/src/theme/system/layer.ts +1 -2
  131. package/src/theme/system/shadow.ts +1 -0
  132. package/src/theme/system/styles.ts +19 -0
  133. package/src/theme/system/theme.ts +97 -0
  134. package/src/theme/system/{color → v0/color}/_generic.ts +2 -1
  135. package/src/theme/system/v0/color/_system.ts +13 -0
  136. package/src/theme/system/{color → v0/color}/base.ts +2 -0
  137. package/src/theme/system/v0/color/button.ts +42 -0
  138. package/src/theme/system/{color → v0/color}/card.ts +2 -1
  139. package/src/theme/system/v0/color/color.ts +40 -0
  140. package/src/theme/system/v0/color/index.ts +11 -0
  141. package/src/theme/system/v0/color/input.ts +34 -0
  142. package/src/theme/system/{color/_deprecated → v0/color}/muted.ts +1 -1
  143. package/src/theme/system/v0/color/selectable.ts +31 -0
  144. package/src/theme/system/{color/_deprecated → v0/color}/solid.ts +1 -1
  145. package/src/theme/system/v0/color/spot.ts +13 -0
  146. package/src/theme/system/v0/index.ts +1 -0
  147. package/src/theme/versioning/getTheme_v2.ts +35 -0
  148. package/src/theme/versioning/index.ts +5 -0
  149. package/src/theme/versioning/is_v0.ts +6 -0
  150. package/src/theme/versioning/is_v2.ts +6 -0
  151. package/src/theme/versioning/themeColor_v0_v2.ts +217 -0
  152. package/src/theme/versioning/v0_v2.ts +70 -0
  153. package/src/theme/versioning/v2_v0.ts +128 -0
  154. package/src/core/styles/colorVars/colorVarsStyle.ts +0 -43
  155. package/src/core/styles/colorVars/index.ts +0 -1
  156. package/src/core/theme/defaults.ts +0 -7
  157. package/src/theme/system/_system.ts +0 -95
  158. package/src/theme/system/color/_deprecated/spot.ts +0 -13
  159. package/src/theme/themes/studio/config.ts +0 -69
  160. package/src/theme/themes/studio/fonts.ts +0 -219
  161. package/src/theme/themes/studio/index.ts +0 -1
  162. package/src/theme/themes/studio/studioTheme.test.ts +0 -27
  163. package/src/theme/themes/studio/studioTheme.ts +0 -8
@@ -0,0 +1,99 @@
1
+ import {ThemeColorState_v2, ThemeColorCard_v2} from '@sanity/ui/theme'
2
+ import {CSSObject} from '@sanity/ui/theme'
3
+
4
+ /**
5
+ * @internal
6
+ */
7
+ export function _cardColorStyle(
8
+ base: ThemeColorCard_v2,
9
+ color: ThemeColorState_v2,
10
+ checkered = false,
11
+ ): CSSObject {
12
+ return {
13
+ // from base
14
+
15
+ '--card-focus-ring-color': base.focusRing,
16
+
17
+ '--card-shadow-outline-color': base.shadow.outline,
18
+ '--card-shadow-umbra-color': base.shadow.umbra,
19
+ '--card-shadow-penumbra-color': base.shadow.penumbra,
20
+ '--card-shadow-ambient-color': base.shadow.ambient,
21
+
22
+ // from state
23
+
24
+ '--card-accent-fg-color': color.accent.fg,
25
+
26
+ '--card-avatar-gray-bg-color': color.avatar.gray.bg,
27
+ '--card-avatar-gray-fg-color': color.avatar.gray.fg,
28
+ '--card-avatar-blue-bg-color': color.avatar.blue.bg,
29
+ '--card-avatar-blue-fg-color': color.avatar.blue.fg,
30
+ '--card-avatar-purple-bg-color': color.avatar.purple.bg,
31
+ '--card-avatar-purple-fg-color': color.avatar.purple.fg,
32
+ '--card-avatar-magenta-bg-color': color.avatar.magenta.bg,
33
+ '--card-avatar-magenta-fg-color': color.avatar.magenta.fg,
34
+ '--card-avatar-red-bg-color': color.avatar.red.bg,
35
+ '--card-avatar-red-fg-color': color.avatar.red.fg,
36
+ '--card-avatar-orange-bg-color': color.avatar.orange.bg,
37
+ '--card-avatar-orange-fg-color': color.avatar.orange.fg,
38
+ '--card-avatar-yellow-bg-color': color.avatar.yellow.bg,
39
+ '--card-avatar-yellow-fg-color': color.avatar.yellow.fg,
40
+ '--card-avatar-green-bg-color': color.avatar.green.bg,
41
+ '--card-avatar-green-fg-color': color.avatar.green.fg,
42
+ '--card-avatar-cyan-bg-color': color.avatar.cyan.bg,
43
+ '--card-avatar-cyan-fg-color': color.avatar.cyan.fg,
44
+
45
+ '--card-bg-color': color.bg,
46
+ '--card-bg-image': checkered
47
+ ? `repeating-conic-gradient(${color.bg} 0% 25%, ${color.muted.bg} 0% 50%)`
48
+ : undefined,
49
+
50
+ '--card-border-color': color.border,
51
+
52
+ '--card-badge-default-bg-color': color.badge.default.bg,
53
+ '--card-badge-default-dot-color': color.badge.default.dot,
54
+ '--card-badge-default-fg-color': color.badge.default.fg,
55
+ '--card-badge-default-icon-color': color.badge.default.icon,
56
+ '--card-badge-primary-bg-color': color.badge.primary.bg,
57
+ '--card-badge-primary-dot-color': color.badge.primary.dot,
58
+ '--card-badge-primary-fg-color': color.badge.primary.fg,
59
+ '--card-badge-primary-icon-color': color.badge.primary.icon,
60
+ '--card-badge-positive-bg-color': color.badge.positive.bg,
61
+ '--card-badge-positive-dot-color': color.badge.positive.dot,
62
+ '--card-badge-positive-fg-color': color.badge.positive.fg,
63
+ '--card-badge-positive-icon-color': color.badge.positive.icon,
64
+ '--card-badge-caution-bg-color': color.badge.caution.bg,
65
+ '--card-badge-caution-dot-color': color.badge.caution.dot,
66
+ '--card-badge-caution-fg-color': color.badge.caution.fg,
67
+ '--card-badge-caution-icon-color': color.badge.caution.icon,
68
+ '--card-badge-critical-bg-color': color.badge.critical.bg,
69
+ '--card-badge-critical-dot-color': color.badge.critical.dot,
70
+ '--card-badge-critical-fg-color': color.badge.critical.fg,
71
+ '--card-badge-critical-icon-color': color.badge.critical.icon,
72
+
73
+ '--card-code-bg-color': color.code.bg,
74
+ '--card-code-fg-color': color.code.fg,
75
+
76
+ '--card-fg-color': color.fg,
77
+
78
+ '--card-icon-color': color.icon,
79
+
80
+ '--card-kbd-bg-color': color.kbd.bg,
81
+ '--card-kbd-border-color': color.kbd.border,
82
+ '--card-kbd-fg-color': color.kbd.fg,
83
+
84
+ '--card-link-fg-color': color.link.fg,
85
+
86
+ '--card-muted-bg-color': color.muted.bg,
87
+ '--card-muted-fg-color': color.muted.fg,
88
+
89
+ '--card-skeleton-color-from': color.skeleton.from,
90
+ '--card-skeleton-color-to': color.skeleton.to,
91
+
92
+ // deprecated variables (kept for legacy)
93
+
94
+ '--card-bg2-color': color.muted.bg,
95
+ '--card-link-color': color.link.fg,
96
+ '--card-hairline-soft-color': color.border,
97
+ '--card-hairline-hard-color': color.border,
98
+ }
99
+ }
@@ -0,0 +1 @@
1
+ export * from './_cardColorStyle'
@@ -1,4 +1,4 @@
1
- import {CSSObject} from '@sanity/ui/theme'
1
+ import {CSSObject, getTheme_v2} from '@sanity/ui/theme'
2
2
  import {EMPTY_ARRAY} from '../../constants'
3
3
  import {_responsive} from '../helpers'
4
4
  import {ThemeProps} from '../types'
@@ -18,8 +18,7 @@ export function flexItemStyle(): Array<
18
18
  export function responsiveFlexItemStyle(
19
19
  props: ResponsiveFlexItemStyleProps & ThemeProps,
20
20
  ): CSSObject[] {
21
- const {theme} = props
22
- const {media} = theme.sanity
21
+ const {media} = getTheme_v2(props.theme)
23
22
 
24
23
  if (!props.$flex) return EMPTY_ARRAY
25
24
 
@@ -1,4 +1,4 @@
1
- import {CSSObject} from '@sanity/ui/theme'
1
+ import {CSSObject, getTheme_v2} from '@sanity/ui/theme'
2
2
  import {rem, _responsive} from '../helpers'
3
3
  import {ThemeProps} from '../types'
4
4
  import {ResponsiveFlexStyleProps} from './types'
@@ -25,8 +25,7 @@ export function responsiveFlexStyle(): Array<
25
25
  export function responsiveFlexAlignStyle(
26
26
  props: ResponsiveFlexStyleProps & ThemeProps,
27
27
  ): CSSObject[] {
28
- const {theme} = props
29
- const {media} = theme.sanity
28
+ const {media} = getTheme_v2(props.theme)
30
29
 
31
30
  return _responsive(media, props.$align, (align) => {
32
31
  return {alignItems: align}
@@ -34,8 +33,7 @@ export function responsiveFlexAlignStyle(
34
33
  }
35
34
 
36
35
  function responsiveFlexGapStyle(props: ResponsiveFlexStyleProps & ThemeProps) {
37
- const {theme} = props
38
- const {media, space} = theme.sanity
36
+ const {media, space} = getTheme_v2(props.theme)
39
37
 
40
38
  return _responsive(media, props.$gap, (gap) => ({
41
39
  gap: gap ? rem(space[gap]) : undefined,
@@ -43,8 +41,7 @@ function responsiveFlexGapStyle(props: ResponsiveFlexStyleProps & ThemeProps) {
43
41
  }
44
42
 
45
43
  export function responsiveFlexWrapStyle(props: ResponsiveFlexStyleProps & ThemeProps): CSSObject[] {
46
- const {theme} = props
47
- const {media} = theme.sanity
44
+ const {media} = getTheme_v2(props.theme)
48
45
 
49
46
  return _responsive(media, props.$wrap, (wrap) => {
50
47
  return {flexWrap: wrap}
@@ -54,8 +51,7 @@ export function responsiveFlexWrapStyle(props: ResponsiveFlexStyleProps & ThemeP
54
51
  export function responsiveFlexJustifyStyle(
55
52
  props: ResponsiveFlexStyleProps & ThemeProps,
56
53
  ): CSSObject[] {
57
- const {theme} = props
58
- const {media} = theme.sanity
54
+ const {media} = getTheme_v2(props.theme)
59
55
 
60
56
  return _responsive(media, props.$justify, (justify) => {
61
57
  return {justifyContent: justify}
@@ -65,8 +61,7 @@ export function responsiveFlexJustifyStyle(
65
61
  export function responsiveFlexDirectionStyle(
66
62
  props: ResponsiveFlexStyleProps & ThemeProps,
67
63
  ): CSSObject[] {
68
- const {theme} = props
69
- const {media} = theme.sanity
64
+ const {media} = getTheme_v2(props.theme)
70
65
 
71
66
  return _responsive(media, props.$direction, (direction) => {
72
67
  return {flexDirection: direction}
@@ -1,4 +1,4 @@
1
- import {ThemeFontSize, ThemeFontKey} from '@sanity/ui/theme'
1
+ import {ThemeFontSize, ThemeFontKey, getTheme_v2} from '@sanity/ui/theme'
2
2
  import {CSSObject} from '@sanity/ui/theme'
3
3
  import {rem, _responsive} from '../helpers'
4
4
  import {ThemeProps} from '../types'
@@ -12,9 +12,9 @@ export function responsiveFont(
12
12
  fontKey: ThemeFontKey,
13
13
  props: ResponsiveFontStyleProps & ThemeProps,
14
14
  ): CSSObject[] {
15
- const {$size, $weight, theme} = props
16
- const {fonts, media} = theme.sanity
17
- const {family, sizes, weights} = fonts[fontKey]
15
+ const {$size, $weight} = props
16
+ const {font, media} = getTheme_v2(props.theme)
17
+ const {family, sizes, weights} = font[fontKey]
18
18
  const fontWeight = ($weight && weights[$weight]) || weights.regular
19
19
 
20
20
  // @todo: make this configurable
@@ -1,4 +1,4 @@
1
- import {CSSObject} from '@sanity/ui/theme'
1
+ import {CSSObject, getTheme_v2} from '@sanity/ui/theme'
2
2
  import {_responsive} from '../helpers'
3
3
  import {ThemeProps} from '../types'
4
4
  import {ResponsiveTextAlignStyleProps} from './types'
@@ -10,9 +10,9 @@ import {ResponsiveTextAlignStyleProps} from './types'
10
10
  export function responsiveTextAlignStyle(
11
11
  props: ResponsiveTextAlignStyleProps & ThemeProps,
12
12
  ): CSSObject[] {
13
- const {theme} = props
13
+ const {media} = getTheme_v2(props.theme)
14
14
 
15
- return _responsive(theme.sanity.media, props.$align, (textAlign) => {
15
+ return _responsive(media, props.$align, (textAlign) => {
16
16
  return {textAlign}
17
17
  })
18
18
  }
@@ -1,4 +1,4 @@
1
- import {CSSObject} from '@sanity/ui/theme'
1
+ import {CSSObject, getTheme_v2} from '@sanity/ui/theme'
2
2
  import {_responsive} from '../helpers'
3
3
  import {ThemeProps} from '../types'
4
4
  import {ResponsiveGridItemStyleProps} from './types'
@@ -27,8 +27,7 @@ const GRID_ITEM_COLUMN = {
27
27
  }
28
28
 
29
29
  function responsiveGridItemRowStyle(props: ResponsiveGridItemStyleProps & ThemeProps) {
30
- const {theme} = props
31
- const {media} = theme.sanity
30
+ const {media} = getTheme_v2(props.theme)
32
31
 
33
32
  return _responsive(media, props.$row, (row) => {
34
33
  if (typeof row === 'number') {
@@ -40,8 +39,7 @@ function responsiveGridItemRowStyle(props: ResponsiveGridItemStyleProps & ThemeP
40
39
  }
41
40
 
42
41
  function responsiveGridItemRowStartStyle(props: ResponsiveGridItemStyleProps & ThemeProps) {
43
- const {theme} = props
44
- const {media} = theme.sanity
42
+ const {media} = getTheme_v2(props.theme)
45
43
 
46
44
  return _responsive(media, props.$rowStart, (rowStart) => ({
47
45
  gridRowStart: rowStart,
@@ -49,15 +47,13 @@ function responsiveGridItemRowStartStyle(props: ResponsiveGridItemStyleProps & T
49
47
  }
50
48
 
51
49
  function responsiveGridItemRowEndStyle(props: ResponsiveGridItemStyleProps & ThemeProps) {
52
- const {theme} = props
53
- const {media} = theme.sanity
50
+ const {media} = getTheme_v2(props.theme)
54
51
 
55
52
  return _responsive(media, props.$rowEnd, (rowEnd) => ({gridRowEnd: rowEnd}))
56
53
  }
57
54
 
58
55
  function responsiveGridItemColumnStyle(props: ResponsiveGridItemStyleProps & ThemeProps) {
59
- const {theme} = props
60
- const {media} = theme.sanity
56
+ const {media} = getTheme_v2(props.theme)
61
57
 
62
58
  return _responsive(media, props.$column, (column) => {
63
59
  if (typeof column === 'number') {
@@ -69,8 +65,7 @@ function responsiveGridItemColumnStyle(props: ResponsiveGridItemStyleProps & The
69
65
  }
70
66
 
71
67
  function responsiveGridItemColumnStartStyle(props: ResponsiveGridItemStyleProps & ThemeProps) {
72
- const {theme} = props
73
- const {media} = theme.sanity
68
+ const {media} = getTheme_v2(props.theme)
74
69
 
75
70
  return _responsive(media, props.$columnStart, (columnStart) => ({
76
71
  gridColumnStart: columnStart,
@@ -78,8 +73,7 @@ function responsiveGridItemColumnStartStyle(props: ResponsiveGridItemStyleProps
78
73
  }
79
74
 
80
75
  function responsiveGridItemColumnEndStyle(props: ResponsiveGridItemStyleProps & ThemeProps) {
81
- const {theme} = props
82
- const {media} = theme.sanity
76
+ const {media} = getTheme_v2(props.theme)
83
77
 
84
78
  return _responsive(media, props.$columnEnd, (columnEnd) => ({
85
79
  gridColumnEnd: columnEnd,
@@ -1,4 +1,4 @@
1
- import {CSSObject} from '@sanity/ui/theme'
1
+ import {CSSObject, getTheme_v2} from '@sanity/ui/theme'
2
2
  import {rem, _responsive} from '../helpers'
3
3
  import {ThemeProps} from '../types'
4
4
  import {ResponsiveGridStyleProps} from './types'
@@ -43,8 +43,7 @@ export function responsiveGridStyle(): Array<
43
43
  }
44
44
 
45
45
  function responsiveGridAutoFlowStyle(props: ResponsiveGridStyleProps & ThemeProps) {
46
- const {theme} = props
47
- const {media} = theme.sanity
46
+ const {media} = getTheme_v2(props.theme)
48
47
 
49
48
  return _responsive(media, props.$autoFlow, (autoFlow) => ({
50
49
  gridAutoFlow: autoFlow,
@@ -52,8 +51,7 @@ function responsiveGridAutoFlowStyle(props: ResponsiveGridStyleProps & ThemeProp
52
51
  }
53
52
 
54
53
  function responsiveGridAutoRowsStyle(props: ResponsiveGridStyleProps & ThemeProps) {
55
- const {theme} = props
56
- const {media} = theme.sanity
54
+ const {media} = getTheme_v2(props.theme)
57
55
 
58
56
  return _responsive(media, props.$autoRows, (autoRows) => ({
59
57
  gridAutoRows: autoRows && GRID_AUTO_ROWS[autoRows],
@@ -61,8 +59,7 @@ function responsiveGridAutoRowsStyle(props: ResponsiveGridStyleProps & ThemeProp
61
59
  }
62
60
 
63
61
  function responsiveGridAutoColsStyle(props: ResponsiveGridStyleProps & ThemeProps) {
64
- const {theme} = props
65
- const {media} = theme.sanity
62
+ const {media} = getTheme_v2(props.theme)
66
63
 
67
64
  return _responsive(media, props.$autoCols, (autoCols) => ({
68
65
  gridAutoColumns: autoCols && GRID_AUTO_COLUMS[autoCols],
@@ -70,8 +67,7 @@ function responsiveGridAutoColsStyle(props: ResponsiveGridStyleProps & ThemeProp
70
67
  }
71
68
 
72
69
  function responsiveGridColumnsStyle(props: ResponsiveGridStyleProps & ThemeProps) {
73
- const {theme} = props
74
- const {media} = theme.sanity
70
+ const {media} = getTheme_v2(props.theme)
75
71
 
76
72
  return _responsive(media, props.$columns, (columns) => ({
77
73
  gridTemplateColumns: columns && `repeat(${columns},minmax(0,1fr));`,
@@ -79,8 +75,7 @@ function responsiveGridColumnsStyle(props: ResponsiveGridStyleProps & ThemeProps
79
75
  }
80
76
 
81
77
  function responsiveGridRowsStyle(props: ResponsiveGridStyleProps & ThemeProps) {
82
- const {theme} = props
83
- const {media} = theme.sanity
78
+ const {media} = getTheme_v2(props.theme)
84
79
 
85
80
  return _responsive(media, props.$rows, (rows) => ({
86
81
  gridTemplateRows: rows && `repeat(${rows},minmax(0,1fr));`,
@@ -88,8 +83,7 @@ function responsiveGridRowsStyle(props: ResponsiveGridStyleProps & ThemeProps) {
88
83
  }
89
84
 
90
85
  function responsiveGridGapStyle(props: ResponsiveGridStyleProps & ThemeProps) {
91
- const {theme} = props
92
- const {media, space} = theme.sanity
86
+ const {media, space} = getTheme_v2(props.theme)
93
87
 
94
88
  return _responsive(media, props.$gap, (gap) => ({
95
89
  gridGap: gap ? rem(space[gap]) : undefined,
@@ -97,8 +91,7 @@ function responsiveGridGapStyle(props: ResponsiveGridStyleProps & ThemeProps) {
97
91
  }
98
92
 
99
93
  function responsiveGridGapXStyle(props: ResponsiveGridStyleProps & ThemeProps) {
100
- const {theme} = props
101
- const {media, space} = theme.sanity
94
+ const {media, space} = getTheme_v2(props.theme)
102
95
 
103
96
  return _responsive(media, props.$gapX, (gapX) => ({
104
97
  columnGap: gapX ? rem(space[gapX]) : undefined,
@@ -106,8 +99,7 @@ function responsiveGridGapXStyle(props: ResponsiveGridStyleProps & ThemeProps) {
106
99
  }
107
100
 
108
101
  function responsiveGridGapYStyle(props: ResponsiveGridStyleProps & ThemeProps) {
109
- const {theme} = props
110
- const {media, space} = theme.sanity
102
+ const {media, space} = getTheme_v2(props.theme)
111
103
 
112
104
  return _responsive(media, props.$gapY, (gapY) => ({
113
105
  rowGap: gapY ? rem(space[gapY]) : undefined,
@@ -1,4 +1,4 @@
1
- import {Theme} from '@sanity/ui/theme'
1
+ import {Theme, getTheme_v2} from '@sanity/ui/theme'
2
2
  import {CSSObject} from '@sanity/ui/theme'
3
3
  import {EMPTY_ARRAY} from '../constants'
4
4
 
@@ -64,7 +64,9 @@ export function _getResponsiveSpace(
64
64
  return null
65
65
  }
66
66
 
67
- return _responsive(theme.sanity.media, spaceIndexes, (spaceIndex) =>
68
- _fillCSSObject(props, rem(theme.sanity.space[spaceIndex])),
67
+ const {media, space} = getTheme_v2(theme)
68
+
69
+ return _responsive(media, spaceIndexes, (spaceIndex) =>
70
+ _fillCSSObject(props, rem(space[spaceIndex])),
69
71
  )
70
72
  }
@@ -1,4 +1,4 @@
1
- import {CSSObject} from '@sanity/ui/theme'
1
+ import {CSSObject, getTheme_v2} from '@sanity/ui/theme'
2
2
  import {rem, _responsive} from '../helpers'
3
3
  import {ThemeProps} from '../types'
4
4
 
@@ -13,8 +13,8 @@ export interface TextInputResponsivePaddingStyleProps {
13
13
  export function responsiveInputPaddingStyle(
14
14
  props: TextInputResponsivePaddingStyleProps & ThemeProps,
15
15
  ): CSSObject[] {
16
- const {$fontSize, $iconLeft, $iconRight, $padding, $space, theme} = props
17
- const {fonts, media, space: spaceScale} = theme.sanity
16
+ const {$fontSize, $iconLeft, $iconRight, $padding, $space} = props
17
+ const {font, media, space} = getTheme_v2(props.theme)
18
18
  const len = Math.max($padding.length, $space.length, $fontSize.length)
19
19
  const _padding: number[] = []
20
20
  const _space: number[] = []
@@ -27,10 +27,10 @@ export function responsiveInputPaddingStyle(
27
27
  }
28
28
 
29
29
  return _responsive(media, _padding, (_, i) => {
30
- const size = fonts.text.sizes[_fontSize[i]] || fonts.text.sizes[2]
30
+ const size = font.text.sizes[_fontSize[i]] || font.text.sizes[2]
31
31
  const emSize = size.lineHeight - size.ascenderHeight - size.descenderHeight
32
- const p = spaceScale[_padding[i]]
33
- const s = spaceScale[_space[i]]
32
+ const p = space[_padding[i]]
33
+ const s = space[_space[i]]
34
34
 
35
35
  const styles = {
36
36
  paddingTop: rem(p - size.ascenderHeight),
@@ -1,4 +1,4 @@
1
- import {ThemeColorSchemeKey, ThemeFontWeightKey} from '@sanity/ui/theme'
1
+ import {ThemeColorSchemeKey, ThemeFontWeightKey, getTheme_v2} from '@sanity/ui/theme'
2
2
  import {CSSObject} from '@sanity/ui/theme'
3
3
  import {css} from 'styled-components'
4
4
  import {CardTone} from '../../types'
@@ -42,9 +42,8 @@ export function textInputRootStyle(): ReturnType<typeof css> {
42
42
  export function textInputBaseStyle(
43
43
  props: TextInputInputStyleProps & ThemeProps,
44
44
  ): ReturnType<typeof css> {
45
- const {theme, $scheme, $tone, $weight} = props
46
- const font = theme.sanity.fonts.text
47
- const color = theme.sanity.color.input
45
+ const {$scheme, $tone, $weight} = props
46
+ const {color, font} = getTheme_v2(props.theme)
48
47
 
49
48
  return css`
50
49
  appearance: none;
@@ -54,8 +53,8 @@ export function textInputBaseStyle(
54
53
  outline: none;
55
54
  width: 100%;
56
55
  box-sizing: border-box;
57
- font-family: ${font.family};
58
- font-weight: ${($weight && font.weights[$weight]) || font.weights.regular};
56
+ font-family: ${font.text.family};
57
+ font-weight: ${($weight && font.text.weights[$weight]) || font.text.weights.regular};
59
58
  margin: 0;
60
59
  position: relative;
61
60
  z-index: 1;
@@ -83,42 +82,41 @@ export function textInputBaseStyle(
83
82
  }
84
83
 
85
84
  &[data-scheme='${$scheme}'][data-tone='${$tone}'] {
86
- --input-fg-color: ${color.default.enabled.fg};
87
- --input-placeholder-color: ${color.default.enabled.placeholder};
85
+ --input-fg-color: ${color.input.default.enabled.fg};
86
+ --input-placeholder-color: ${color.input.default.enabled.placeholder};
88
87
 
89
88
  /* enabled */
90
89
  &:not(:invalid):not(:disabled):not(:read-only) {
91
- --input-fg-color: ${color.default.enabled.fg};
92
- --input-placeholder-color: ${color.default.enabled.placeholder};
90
+ --input-fg-color: ${color.input.default.enabled.fg};
91
+ --input-placeholder-color: ${color.input.default.enabled.placeholder};
93
92
  }
94
93
 
95
94
  /* disabled */
96
95
  &:not(:invalid):disabled {
97
- --input-fg-color: ${color.default.disabled.fg};
98
- --input-placeholder-color: ${color.default.disabled.placeholder};
96
+ --input-fg-color: ${color.input.default.disabled.fg};
97
+ --input-placeholder-color: ${color.input.default.disabled.placeholder};
99
98
  }
100
99
 
101
100
  /* invalid */
102
101
  &:invalid {
103
- --input-fg-color: ${color.invalid.enabled.fg};
104
- --input-placeholder-color: ${color.invalid.enabled.placeholder};
102
+ --input-fg-color: ${color.input.invalid.enabled.fg};
103
+ --input-placeholder-color: ${color.input.invalid.enabled.placeholder};
105
104
  }
106
105
 
107
106
  /* readOnly */
108
107
  &:read-only {
109
- --input-fg-color: ${color.default.readOnly.fg};
110
- --input-placeholder-color: ${color.default.readOnly.placeholder};
108
+ --input-fg-color: ${color.input.default.readOnly.fg};
109
+ --input-placeholder-color: ${color.input.default.readOnly.placeholder};
111
110
  }
112
111
  }
113
112
  `
114
113
  }
115
114
 
116
115
  export function textInputFontSizeStyle(props: TextInputInputStyleProps & ThemeProps): CSSObject[] {
117
- const {theme} = props
118
- const {fonts, media} = theme.sanity
116
+ const {font, media} = getTheme_v2(props.theme)
119
117
 
120
118
  return _responsive(media, props.$fontSize, (sizeIndex) => {
121
- const size = fonts.text.sizes[sizeIndex] || fonts.text.sizes[2]
119
+ const size = font.text.sizes[sizeIndex] || font.text.sizes[2]
122
120
 
123
121
  return {
124
122
  fontSize: rem(size.fontSize),
@@ -130,10 +128,8 @@ export function textInputFontSizeStyle(props: TextInputInputStyleProps & ThemePr
130
128
  export function textInputRepresentationStyle(
131
129
  props: TextInputRepresentationStyleProps & ThemeProps,
132
130
  ): ReturnType<typeof css> {
133
- const {$hasPrefix, $hasSuffix, $scheme, $tone, $unstableDisableFocusRing, theme} = props
134
- const {input} = theme.sanity
135
- const {focusRing} = input.text
136
- const color = theme.sanity.color.input
131
+ const {$hasPrefix, $hasSuffix, $scheme, $tone, $unstableDisableFocusRing} = props
132
+ const {color, input} = getTheme_v2(props.theme)
137
133
 
138
134
  return css`
139
135
  --input-box-shadow: none;
@@ -156,25 +152,25 @@ export function textInputRepresentationStyle(
156
152
  border-bottom-right-radius: ${$hasSuffix ? 0 : undefined};
157
153
 
158
154
  &[data-scheme='${$scheme}'][data-tone='${$tone}'] {
159
- --card-bg-color: ${color.default.enabled.bg};
160
- --card-fg-color: ${color.default.enabled.fg};
155
+ --card-bg-color: ${color.input.default.enabled.bg};
156
+ --card-fg-color: ${color.input.default.enabled.fg};
161
157
 
162
158
  /* enabled */
163
159
  *:not(:disabled) + &[data-border] {
164
160
  --input-box-shadow: ${focusRingBorderStyle({
165
- color: color.default.enabled.border,
161
+ color: color.input.default.enabled.border,
166
162
  width: input.border.width,
167
163
  })};
168
164
  }
169
165
 
170
166
  /* invalid */
171
167
  *:not(:disabled):invalid + & {
172
- --card-bg-color: ${color.invalid.enabled.bg};
173
- --card-fg-color: ${color.invalid.enabled.fg};
168
+ --card-bg-color: ${color.input.invalid.enabled.bg};
169
+ --card-fg-color: ${color.input.invalid.enabled.fg};
174
170
 
175
171
  &[data-border] {
176
172
  --input-box-shadow: ${focusRingBorderStyle({
177
- color: color.invalid.enabled.border,
173
+ color: color.input.invalid.enabled.border,
178
174
  width: input.border.width,
179
175
  })};
180
176
  }
@@ -186,26 +182,26 @@ export function textInputRepresentationStyle(
186
182
  --input-box-shadow: ${$unstableDisableFocusRing
187
183
  ? undefined
188
184
  : focusRingStyle({
189
- border: {color: color.default.enabled.border, width: input.border.width},
190
- focusRing,
185
+ border: {color: color.input.default.enabled.border, width: input.border.width},
186
+ focusRing: input.text.focusRing,
191
187
  })};
192
188
  }
193
189
 
194
190
  &:not([data-border]) {
195
191
  --input-box-shadow: ${$unstableDisableFocusRing
196
192
  ? undefined
197
- : focusRingStyle({focusRing})};
193
+ : focusRingStyle({focusRing: input.text.focusRing})};
198
194
  }
199
195
  }
200
196
 
201
197
  /* disabled */
202
198
  *:disabled + & {
203
- --card-bg-color: ${color.default.disabled.bg} !important;
204
- --card-fg-color: ${color.default.disabled.fg} !important;
199
+ --card-bg-color: ${color.input.default.disabled.bg} !important;
200
+ --card-fg-color: ${color.input.default.disabled.fg} !important;
205
201
 
206
202
  &[data-border] {
207
203
  --input-box-shadow: ${focusRingBorderStyle({
208
- color: color.default.disabled.border,
204
+ color: color.input.default.disabled.border,
209
205
  width: input.border.width,
210
206
  })};
211
207
  }
@@ -213,20 +209,20 @@ export function textInputRepresentationStyle(
213
209
 
214
210
  /* readOnly */
215
211
  *:read-only + & {
216
- --card-bg-color: ${color.default.readOnly.bg} !important;
217
- --card-fg-color: ${color.default.readOnly.fg} !important;
212
+ --card-bg-color: ${color.input.default.readOnly.bg} !important;
213
+ --card-fg-color: ${color.input.default.readOnly.fg} !important;
218
214
  }
219
215
 
220
216
  /* hovered */
221
217
  @media (hover: hover) {
222
218
  *:not(:disabled):not(:read-only):not(:invalid):hover + & {
223
- --card-bg-color: ${color.default.hovered.bg};
224
- --card-fg-color: ${color.default.hovered.fg};
219
+ --card-bg-color: ${color.input.default.hovered.bg};
220
+ --card-fg-color: ${color.input.default.hovered.fg};
225
221
  }
226
222
 
227
223
  *:not(:disabled):not(:read-only):not(:invalid):not(:focus):hover + &[data-border] {
228
224
  --input-box-shadow: ${focusRingBorderStyle({
229
- color: color.default.hovered.border,
225
+ color: color.input.default.hovered.border,
230
226
  width: input.border.width,
231
227
  })};
232
228
  }
@@ -1,10 +1,9 @@
1
1
  /** @jest-environment jsdom */
2
2
 
3
- import {studioTheme, Theme} from '@sanity/ui/theme'
3
+ import {getScopedTheme, defaultTheme} from '@sanity/ui/theme'
4
4
  import {responsiveMarginStyle} from './marginStyle'
5
5
 
6
- const {color, ...restTheme} = studioTheme
7
- const theme: Theme = {sanity: {...restTheme, color: color.light.default}}
6
+ const theme = getScopedTheme(defaultTheme, 'light', 'default')
8
7
 
9
8
  describe('styles/margin', () => {
10
9
  it('should 1', () => {
@@ -1,10 +1,9 @@
1
1
  /** @jest-environment jsdom */
2
2
 
3
- import {studioTheme, Theme} from '@sanity/ui/theme'
3
+ import {getScopedTheme, defaultTheme} from '@sanity/ui/theme'
4
4
  import {responsivePaddingStyle} from './paddingStyle'
5
5
 
6
- const {color, ...restTheme} = studioTheme
7
- const theme: Theme = {sanity: {...restTheme, color: color.light.default}}
6
+ const theme = getScopedTheme(defaultTheme, 'light', 'default')
8
7
 
9
8
  describe('styles/padding', () => {
10
9
  it('should 1', () => {
@@ -1,11 +1,10 @@
1
- import {CSSObject} from '@sanity/ui/theme'
1
+ import {CSSObject, getTheme_v2} from '@sanity/ui/theme'
2
2
  import {_responsive, rem} from '../helpers'
3
3
  import {ThemeProps} from '../types'
4
4
  import {ResponsiveRadiusStyleProps} from './types'
5
5
 
6
6
  export function responsiveRadiusStyle(props: ResponsiveRadiusStyleProps & ThemeProps): CSSObject[] {
7
- const {theme} = props
8
- const {media, radius} = theme.sanity
7
+ const {media, radius} = getTheme_v2(props.theme)
9
8
 
10
9
  return _responsive(media, props.$radius, (value) => {
11
10
  let borderRadius: string | 0 = 0
@@ -1,4 +1,4 @@
1
- import {ThemeBoxShadow, ThemeShadow} from '@sanity/ui/theme'
1
+ import {ThemeBoxShadow, ThemeShadow, getTheme_v2} from '@sanity/ui/theme'
2
2
  import {CSSObject} from '@sanity/ui/theme'
3
3
  import {EMPTY_RECORD} from '../../constants'
4
4
  import {rem, _responsive} from '../helpers'
@@ -21,10 +21,9 @@ function shadowStyle(shadow: ThemeShadow | null, outlineWidth: number = 1): CSSO
21
21
  }
22
22
 
23
23
  export function responsiveShadowStyle(props: ResponsiveShadowStyleProps & ThemeProps): CSSObject[] {
24
- const {theme} = props
25
- const {card, media, shadows} = theme.sanity
24
+ const {card, media, shadow} = getTheme_v2(props.theme)
26
25
 
27
- return _responsive(media, props.$shadow, (shadow) =>
28
- shadowStyle(shadows[shadow], card.shadow.outline),
26
+ return _responsive(media, props.$shadow, (index) =>
27
+ shadowStyle(shadow[index], card.shadow.outline),
29
28
  )
30
29
  }