@sanity/ui 2.0.0-alpha.35 → 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/dist/theme.d.ts +80 -20
- package/dist/theme.esm.js +56 -12
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +56 -12
- package/dist/theme.js.map +1 -1
- package/package.json +1 -1
- package/src/theme/build/buildTheme.ts +6 -1
- package/src/theme/config/types.ts +5 -5
- package/src/theme/system/avatar.ts +1 -1
- package/src/theme/system/index.ts +1 -1
- package/src/theme/system/input.ts +1 -1
- package/src/theme/system/theme.ts +46 -15
- package/src/theme/system/v0/avatar.ts +10 -0
- package/src/theme/system/v0/index.ts +2 -0
- package/src/theme/system/v0/input.ts +23 -0
- package/src/theme/versioning/getTheme_v2.ts +25 -4
- package/src/theme/versioning/v0_v2.ts +25 -5
- package/src/theme/versioning/v2_v0.ts +0 -2
- /package/src/theme/system/{fonts.ts → font.ts} +0 -0
package/package.json
CHANGED
|
@@ -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?.
|
|
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
|
-
|
|
3
|
+
ThemeAvatar_v2,
|
|
4
4
|
ThemeFocusRing,
|
|
5
5
|
ThemeFontWeightKey,
|
|
6
6
|
ThemeFonts,
|
|
7
|
-
|
|
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?:
|
|
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
|
-
|
|
36
|
-
input?:
|
|
35
|
+
font?: ThemeFonts
|
|
36
|
+
input?: ThemeInput_v2
|
|
37
37
|
layer?: ThemeLayer
|
|
38
38
|
media?: number[]
|
|
39
39
|
palette?: ThemeColorPalette
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
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 './
|
|
5
|
-
import {
|
|
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:
|
|
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:
|
|
30
|
+
input: ThemeInput_v2
|
|
31
31
|
layer: ThemeLayer
|
|
32
32
|
media: number[]
|
|
33
33
|
radius: number[]
|
|
@@ -41,36 +41,64 @@ export interface RootTheme_v2 {
|
|
|
41
41
|
*/
|
|
42
42
|
export interface BaseTheme {
|
|
43
43
|
_version?: 0
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Use `v2.avatar` instead
|
|
46
|
+
*/
|
|
44
47
|
avatar: ThemeAvatar
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated Use `v2.button` instead
|
|
50
|
+
*/
|
|
45
51
|
button: {
|
|
46
|
-
border: {width: number}
|
|
47
|
-
focusRing: ThemeFocusRing
|
|
48
52
|
textWeight: ThemeFontWeightKey
|
|
49
53
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
shadow: {outline: number}
|
|
54
|
-
}
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated Use `v2.color` instead
|
|
56
|
+
*/
|
|
55
57
|
color: ThemeColorSchemes
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated Use `v2.container` instead
|
|
60
|
+
*/
|
|
56
61
|
container: number[]
|
|
57
|
-
/**
|
|
62
|
+
/**
|
|
63
|
+
* @deprecated Use component-specific `v2.{button | card | input}.focusRing` values instead
|
|
64
|
+
*/
|
|
58
65
|
focusRing: {
|
|
59
66
|
offset: number
|
|
60
67
|
width: number
|
|
61
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated Use `v2.font` instead
|
|
71
|
+
*/
|
|
62
72
|
fonts: ThemeFonts
|
|
73
|
+
/**
|
|
74
|
+
* @deprecated Use `v2.input` instead
|
|
75
|
+
*/
|
|
63
76
|
input: ThemeInput
|
|
64
77
|
/**
|
|
65
78
|
* THIS API MAY BE UNSTABLE. DO NOT USE IN PRODUCTION.
|
|
66
79
|
* @beta
|
|
80
|
+
* @deprecated Use `v2.layer` instead
|
|
67
81
|
*/
|
|
68
82
|
layer?: ThemeLayer
|
|
83
|
+
/**
|
|
84
|
+
* @deprecated Use `v2.media` instead
|
|
85
|
+
*/
|
|
69
86
|
media: number[]
|
|
87
|
+
/**
|
|
88
|
+
* @deprecated Use `v2.radius` instead
|
|
89
|
+
*/
|
|
70
90
|
radius: number[]
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated Use `v2.shadow` instead
|
|
93
|
+
*/
|
|
71
94
|
shadows: Array<ThemeShadow | null>
|
|
95
|
+
/**
|
|
96
|
+
* @deprecated Use `v2.space` instead
|
|
97
|
+
*/
|
|
72
98
|
space: number[]
|
|
73
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* @deprecated Use `v2.style` instead
|
|
101
|
+
*/
|
|
74
102
|
styles?: ThemeStyles
|
|
75
103
|
|
|
76
104
|
v2?: RootTheme_v2
|
|
@@ -91,6 +119,9 @@ export type Theme_v2 = Omit<RootTheme_v2, 'color'> & {color: ThemeColorCard_v2}
|
|
|
91
119
|
*/
|
|
92
120
|
export interface Theme {
|
|
93
121
|
sanity: Omit<RootTheme, 'color' | 'v2'> & {
|
|
122
|
+
/**
|
|
123
|
+
* @deprecated Use `v2.color` instead
|
|
124
|
+
*/
|
|
94
125
|
color: ThemeColor
|
|
95
126
|
v2?: Theme_v2
|
|
96
127
|
}
|
|
@@ -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,13 +14,34 @@ export function getTheme_v2(theme: Theme): Theme_v2 {
|
|
|
14
14
|
|
|
15
15
|
const v2: Theme_v2 = {
|
|
16
16
|
_version: 2,
|
|
17
|
-
avatar:
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
avatar: {
|
|
18
|
+
...defaultThemeConfig.avatar,
|
|
19
|
+
...theme.sanity.avatar,
|
|
20
|
+
},
|
|
21
|
+
button: {
|
|
22
|
+
...defaultThemeConfig.button,
|
|
23
|
+
...theme.sanity.button,
|
|
24
|
+
},
|
|
25
|
+
card: defaultThemeConfig.card,
|
|
20
26
|
color: themeColor_v0_v2(theme.sanity.color),
|
|
21
27
|
container: theme.sanity.container,
|
|
22
28
|
font: theme.sanity.fonts,
|
|
23
|
-
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
|
+
},
|
|
24
45
|
layer: theme.sanity.layer ?? defaultThemeConfig.layer,
|
|
25
46
|
media: theme.sanity.media,
|
|
26
47
|
radius: theme.sanity.radius,
|
|
@@ -15,7 +15,6 @@ export function v0_v2(v0: RootTheme): RootTheme_v2 {
|
|
|
15
15
|
const {
|
|
16
16
|
avatar,
|
|
17
17
|
button,
|
|
18
|
-
card,
|
|
19
18
|
color,
|
|
20
19
|
container,
|
|
21
20
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -32,9 +31,15 @@ export function v0_v2(v0: RootTheme): RootTheme_v2 {
|
|
|
32
31
|
|
|
33
32
|
const v2: RootTheme_v2 = {
|
|
34
33
|
_version: 2,
|
|
35
|
-
avatar
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
avatar: {
|
|
35
|
+
...defaultThemeConfig.avatar,
|
|
36
|
+
...avatar,
|
|
37
|
+
},
|
|
38
|
+
button: {
|
|
39
|
+
...defaultThemeConfig.button,
|
|
40
|
+
...button,
|
|
41
|
+
},
|
|
42
|
+
card: defaultThemeConfig.card,
|
|
38
43
|
color: {
|
|
39
44
|
light: {
|
|
40
45
|
transparent: themeColor_v0_v2(color.light.transparent),
|
|
@@ -55,7 +60,22 @@ export function v0_v2(v0: RootTheme): RootTheme_v2 {
|
|
|
55
60
|
},
|
|
56
61
|
container,
|
|
57
62
|
font,
|
|
58
|
-
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
|
+
},
|
|
59
79
|
layer: layer ?? defaultThemeConfig.layer,
|
|
60
80
|
media,
|
|
61
81
|
radius,
|
|
@@ -20,7 +20,6 @@ export function v2_v0(v2: RootTheme_v2): RootTheme {
|
|
|
20
20
|
const {
|
|
21
21
|
avatar,
|
|
22
22
|
button,
|
|
23
|
-
card,
|
|
24
23
|
color,
|
|
25
24
|
container,
|
|
26
25
|
font: fonts,
|
|
@@ -36,7 +35,6 @@ export function v2_v0(v2: RootTheme_v2): RootTheme {
|
|
|
36
35
|
_version: 0,
|
|
37
36
|
avatar,
|
|
38
37
|
button,
|
|
39
|
-
card,
|
|
40
38
|
container,
|
|
41
39
|
color: {
|
|
42
40
|
light: {
|
|
File without changes
|