@sanity/ui 2.0.0-alpha.36 → 2.0.0-alpha.37

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ui",
3
- "version": "2.0.0-alpha.36",
3
+ "version": "2.0.0-alpha.37",
4
4
  "sideEffects": false,
5
5
  "types": "./dist/index.d.ts",
6
6
  "source": "./exports/index.ts",
@@ -15,9 +15,14 @@ export function buildTheme(config?: ThemeConfig): RootTheme {
15
15
  avatar: config?.avatar ?? defaultThemeConfig.avatar,
16
16
  button: config?.button ?? defaultThemeConfig.button,
17
17
  card: config?.card ?? defaultThemeConfig.card,
18
+ // How colors are generated:
19
+ // 1. Merge custom tokens with default tokens
20
+ // 2. Generate tree of color keys (gray/500, black, white, etc.)
21
+ // 3. Apply mixing and render to hex values
22
+ // render(build(mergeWithDefaults()))
18
23
  color: renderThemeColorSchemes(colorTheme, config),
19
24
  container: config?.container ?? defaultThemeConfig.container,
20
- font: config?.fonts ?? defaultThemeFonts,
25
+ font: config?.font ?? defaultThemeFonts,
21
26
  input: config?.input ?? defaultThemeConfig.input,
22
27
  layer: config?.layer ?? defaultThemeConfig.layer,
23
28
  media: config?.media ?? defaultThemeConfig.media,
@@ -1,10 +1,10 @@
1
1
  import {ColorHueKey, ColorTint as ColorPaletteValue, ColorTintKey} from '@sanity/color'
2
2
  import {
3
- ThemeAvatar,
3
+ ThemeAvatar_v2,
4
4
  ThemeFocusRing,
5
5
  ThemeFontWeightKey,
6
6
  ThemeFonts,
7
- ThemeInput,
7
+ ThemeInput_v2,
8
8
  ThemeLayer,
9
9
  ThemeShadow,
10
10
  ThemeStyles,
@@ -19,7 +19,7 @@ export type ThemeColorPalette = {
19
19
 
20
20
  /** @public */
21
21
  export interface ThemeConfig {
22
- avatar?: ThemeAvatar
22
+ avatar?: ThemeAvatar_v2
23
23
  button?: {
24
24
  border: {width: number}
25
25
  focusRing: ThemeFocusRing
@@ -32,8 +32,8 @@ export interface ThemeConfig {
32
32
  }
33
33
  color?: ThemeColorTokens
34
34
  container?: number[]
35
- fonts?: ThemeFonts
36
- input?: ThemeInput
35
+ font?: ThemeFonts
36
+ input?: ThemeInput_v2
37
37
  layer?: ThemeLayer
38
38
  media?: number[]
39
39
  palette?: ThemeColorPalette
@@ -3,7 +3,7 @@ import {ThemeFocusRing} from './focusRing'
3
3
  /**
4
4
  * @public
5
5
  */
6
- export interface ThemeAvatar {
6
+ export interface ThemeAvatar_v2 {
7
7
  sizes: {
8
8
  /** Spacing between avatars in an <AvatarStack> component (px) */
9
9
  distance: number
@@ -4,7 +4,7 @@ export * from './avatar'
4
4
  export * from './color'
5
5
  export * from './css'
6
6
  export * from './focusRing'
7
- export * from './fonts'
7
+ export * from './font'
8
8
  export * from './input'
9
9
  export * from './layer'
10
10
  export * from './shadow'
@@ -3,7 +3,7 @@ import {ThemeFocusRing} from './focusRing'
3
3
  /**
4
4
  * @public
5
5
  */
6
- export interface ThemeInput {
6
+ export interface ThemeInput_v2 {
7
7
  checkbox: {
8
8
  size: number
9
9
  focusRing: ThemeFocusRing
@@ -1,19 +1,19 @@
1
- import {ThemeAvatar} from './avatar'
1
+ import {ThemeAvatar_v2} from './avatar'
2
2
  import {ThemeColorSchemes_v2, ThemeColorCard_v2} from './color'
3
3
  import {ThemeFocusRing} from './focusRing'
4
- import {ThemeFontWeightKey, ThemeFonts} from './fonts'
5
- import {ThemeInput} from './input'
4
+ import {ThemeFontWeightKey, ThemeFonts} from './font'
5
+ import {ThemeInput_v2} from './input'
6
6
  import {ThemeLayer} from './layer'
7
7
  import {ThemeShadow} from './shadow'
8
8
  import {ThemeStyles} from './styles'
9
- import {ThemeColor, ThemeColorSchemes} from './v0'
9
+ import {ThemeAvatar, ThemeColor, ThemeColorSchemes, ThemeInput} from './v0'
10
10
 
11
11
  /**
12
12
  * @public
13
13
  */
14
14
  export interface RootTheme_v2 {
15
15
  _version: 2
16
- avatar: ThemeAvatar
16
+ avatar: ThemeAvatar_v2
17
17
  button: {
18
18
  border: {width: number}
19
19
  focusRing: ThemeFocusRing
@@ -27,7 +27,7 @@ export interface RootTheme_v2 {
27
27
  color: ThemeColorSchemes_v2
28
28
  container: number[]
29
29
  font: ThemeFonts
30
- input: ThemeInput
30
+ input: ThemeInput_v2
31
31
  layer: ThemeLayer
32
32
  media: number[]
33
33
  radius: number[]
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @public
3
+ * @deprecated Use `ThemeAvatar_v2` instead
4
+ */
5
+ export interface ThemeAvatar {
6
+ sizes: {
7
+ distance: number
8
+ size: number
9
+ }[]
10
+ }
@@ -1 +1,3 @@
1
1
  export * from './color'
2
+ export * from './avatar'
3
+ export * from './input'
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @public
3
+ * @deprecated Use `ThemeInput_v2` instead
4
+ */
5
+ export interface ThemeInput {
6
+ checkbox: {
7
+ size: number
8
+ }
9
+ radio: {
10
+ size: number
11
+ markSize: number
12
+ }
13
+ switch: {
14
+ width: number
15
+ height: number
16
+ padding: number
17
+ transitionDurationMs: number
18
+ transitionTimingFunction: string
19
+ }
20
+ border: {
21
+ width: number
22
+ }
23
+ }
@@ -14,7 +14,10 @@ export function getTheme_v2(theme: Theme): Theme_v2 {
14
14
 
15
15
  const v2: Theme_v2 = {
16
16
  _version: 2,
17
- avatar: theme.sanity.avatar,
17
+ avatar: {
18
+ ...defaultThemeConfig.avatar,
19
+ ...theme.sanity.avatar,
20
+ },
18
21
  button: {
19
22
  ...defaultThemeConfig.button,
20
23
  ...theme.sanity.button,
@@ -23,7 +26,22 @@ export function getTheme_v2(theme: Theme): Theme_v2 {
23
26
  color: themeColor_v0_v2(theme.sanity.color),
24
27
  container: theme.sanity.container,
25
28
  font: theme.sanity.fonts,
26
- input: theme.sanity.input,
29
+ input: {
30
+ ...defaultThemeConfig.input,
31
+ ...theme.sanity.input,
32
+ checkbox: {
33
+ ...defaultThemeConfig.input.checkbox,
34
+ ...theme.sanity.input.checkbox,
35
+ },
36
+ radio: {
37
+ ...defaultThemeConfig.input.radio,
38
+ ...theme.sanity.input.radio,
39
+ },
40
+ switch: {
41
+ ...defaultThemeConfig.input.switch,
42
+ ...theme.sanity.input.switch,
43
+ },
44
+ },
27
45
  layer: theme.sanity.layer ?? defaultThemeConfig.layer,
28
46
  media: theme.sanity.media,
29
47
  radius: theme.sanity.radius,
@@ -31,7 +31,10 @@ export function v0_v2(v0: RootTheme): RootTheme_v2 {
31
31
 
32
32
  const v2: RootTheme_v2 = {
33
33
  _version: 2,
34
- avatar,
34
+ avatar: {
35
+ ...defaultThemeConfig.avatar,
36
+ ...avatar,
37
+ },
35
38
  button: {
36
39
  ...defaultThemeConfig.button,
37
40
  ...button,
@@ -57,7 +60,22 @@ export function v0_v2(v0: RootTheme): RootTheme_v2 {
57
60
  },
58
61
  container,
59
62
  font,
60
- input,
63
+ input: {
64
+ ...defaultThemeConfig.input,
65
+ ...input,
66
+ checkbox: {
67
+ ...defaultThemeConfig.input.checkbox,
68
+ ...input.checkbox,
69
+ },
70
+ radio: {
71
+ ...defaultThemeConfig.input.radio,
72
+ ...input.radio,
73
+ },
74
+ switch: {
75
+ ...defaultThemeConfig.input.switch,
76
+ ...input.switch,
77
+ },
78
+ },
61
79
  layer: layer ?? defaultThemeConfig.layer,
62
80
  media,
63
81
  radius,
File without changes