@sanity/ui 2.0.0-alpha.34 → 2.0.0-alpha.36
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/index.cjs.mjs +4 -3
- package/dist/index.d.ts +29 -22
- package/dist/index.esm.js +397 -518
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +413 -534
- package/dist/index.js.map +1 -1
- package/dist/theme.cjs.mjs +10 -4
- package/dist/theme.d.ts +489 -201
- package/dist/theme.esm.js +2934 -2748
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +2943 -2751
- package/dist/theme.js.map +1 -1
- package/package.json +3 -3
- package/src/core/_compat.ts +7 -7
- package/src/core/components/dialog/dialog.tsx +5 -5
- package/src/core/components/dialog/styles.ts +4 -5
- package/src/core/components/hotkeys/hotkeys.tsx +4 -2
- package/src/core/components/menu/__workshop__/avatarMenu.tsx +50 -0
- package/src/core/components/menu/__workshop__/index.ts +5 -0
- package/src/core/components/menu/menuItem.tsx +7 -1
- package/src/core/components/skeleton/textSkeleton.tsx +12 -14
- package/src/core/components/tree/style.ts +14 -17
- package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +3 -3
- package/src/core/hooks/useMediaIndex/useMediaIndex.ts +2 -3
- package/src/core/primitives/_selectable/style.ts +18 -18
- package/src/core/primitives/avatar/avatar.tsx +3 -3
- package/src/core/primitives/avatar/avatarCounter.tsx +4 -4
- package/src/core/primitives/avatar/avatarStack.tsx +2 -2
- package/src/core/primitives/avatar/styles.ts +7 -8
- package/src/core/primitives/avatar/types.ts +2 -2
- package/src/core/primitives/badge/__workshop__/props.tsx +1 -1
- package/src/core/primitives/badge/__workshop__/tones.tsx +1 -1
- package/src/core/primitives/badge/badge.tsx +1 -1
- package/src/core/primitives/badge/styles.ts +5 -6
- package/src/core/primitives/button/button.tsx +3 -4
- package/src/core/primitives/button/styles.ts +22 -23
- package/src/core/primitives/card/__workshop__/selected.tsx +15 -15
- package/src/core/primitives/card/card.tsx +1 -1
- package/src/core/primitives/card/styles.ts +22 -22
- package/src/core/primitives/checkbox/styles.ts +21 -22
- package/src/core/primitives/code/styles.ts +4 -1
- package/src/core/primitives/container/styles.ts +2 -3
- package/src/core/primitives/heading/styles.ts +4 -2
- package/src/core/primitives/inline/styles.ts +6 -6
- package/src/core/primitives/kbd/kbd.tsx +7 -11
- package/src/core/primitives/label/styles.ts +4 -3
- package/src/core/primitives/popover/helpers.ts +3 -4
- package/src/core/primitives/popover/popover.tsx +8 -4
- package/src/core/primitives/popover/types.ts +1 -1
- package/src/core/primitives/radio/styles.ts +17 -19
- package/src/core/primitives/select/styles.ts +27 -32
- package/src/core/primitives/stack/styles.ts +2 -3
- package/src/core/primitives/switch/__workshop__/props.tsx +11 -31
- package/src/core/primitives/switch/styles.ts +18 -21
- package/src/core/primitives/text/__workshop__/colored.tsx +10 -10
- package/src/core/primitives/text/styles.ts +9 -4
- package/src/core/primitives/tooltip/tooltip.tsx +3 -3
- package/src/core/styles/border/borderStyle.ts +6 -11
- package/src/core/styles/box/boxStyle.ts +5 -9
- package/src/core/styles/card/_cardColorStyle.ts +99 -0
- package/src/core/styles/card/index.ts +1 -0
- package/src/core/styles/flex/flexItemStyle.ts +2 -3
- package/src/core/styles/flex/flexStyle.ts +6 -11
- package/src/core/styles/font/responsiveFont.ts +4 -4
- package/src/core/styles/font/textAlignStyle.ts +3 -3
- package/src/core/styles/grid/gridItemStyle.ts +7 -13
- package/src/core/styles/grid/gridStyle.ts +9 -17
- package/src/core/styles/helpers.ts +5 -3
- package/src/core/styles/input/responsiveInputPaddingStyle.ts +6 -6
- package/src/core/styles/input/textInputStyle.ts +36 -40
- package/src/core/styles/margin/marginsStyle.test.ts +2 -3
- package/src/core/styles/padding/paddingStyle.test.ts +2 -3
- package/src/core/styles/radius/radiusStyle.ts +2 -3
- package/src/core/styles/shadow/shadowStyle.ts +4 -5
- package/src/core/theme/__workshop__/build/Root.tsx +24 -20
- package/src/core/theme/__workshop__/build/story.tsx +22 -26
- package/src/core/theme/__workshop__/canvas.tsx +21 -40
- package/src/core/theme/theme.test.tsx +2 -35
- package/src/core/theme/themeColorProvider.tsx +2 -2
- package/src/core/theme/themeContext.ts +2 -2
- package/src/core/theme/themeProvider.tsx +25 -25
- package/src/core/theme/types.ts +3 -2
- package/src/core/theme/useRootTheme.ts +1 -9
- package/src/core/theme/useTheme.ts +8 -1
- package/src/core/types/card.ts +2 -2
- package/src/core/utils/arrow/arrow.tsx +3 -3
- package/src/core/utils/elementQuery/elementQuery.tsx +3 -3
- package/src/core/utils/virtualList/virtualList.tsx +2 -2
- package/src/theme/build/_deprecated/color/muted/createMuted.ts +2 -2
- package/src/theme/build/buildColorTheme.test.ts +14 -15
- package/src/theme/build/buildColorTheme.ts +239 -292
- package/src/theme/build/buildTheme.test.ts +9 -7
- package/src/theme/build/buildTheme.ts +12 -9
- package/src/theme/build/colorToken.ts +3 -1
- package/src/theme/build/lib/color-fns/contrastRatio.ts +1 -0
- package/src/theme/build/lib/isRecord.ts +3 -0
- package/src/theme/build/merge.ts +18 -13
- package/src/theme/build/renderColorTheme.ts +205 -213
- package/src/theme/build/renderColorValue.ts +15 -8
- package/src/theme/build/resolveColorTokens.ts +177 -198
- package/src/theme/build/theme.test.ts +27 -0
- package/src/theme/config/helpers.ts +16 -8
- package/src/theme/config/system.ts +46 -17
- package/src/theme/config/tokens/color/types.ts +55 -32
- package/src/theme/config/tokens/types.ts +11 -4
- package/src/theme/config/types.ts +5 -11
- package/src/theme/{build/defaults → defaults}/colorPalette.ts +1 -1
- package/src/theme/{build/defaults → defaults}/colorTokens.ts +189 -136
- package/src/theme/{build/defaults → defaults}/config.ts +14 -12
- package/src/theme/{build/defaults → defaults}/fonts.ts +6 -6
- package/src/theme/getScopedTheme.ts +81 -0
- package/src/theme/index.ts +9 -1
- package/src/theme/system/avatar.ts +1 -1
- package/src/theme/system/color/_constants.ts +11 -11
- package/src/theme/system/color/_system.ts +10 -71
- package/src/theme/system/color/avatar.ts +22 -10
- package/src/theme/system/color/badge.ts +18 -7
- package/src/theme/system/color/button.ts +17 -23
- package/src/theme/system/color/color.ts +34 -0
- package/src/theme/system/color/index.ts +3 -10
- package/src/theme/system/color/input.ts +13 -11
- package/src/theme/system/color/kbd.ts +3 -3
- package/src/theme/system/color/selectable.ts +13 -19
- package/src/theme/system/color/shadow.ts +7 -0
- package/src/theme/system/color/state.ts +37 -0
- package/src/theme/system/css.ts +9 -0
- package/src/theme/system/focusRing.ts +7 -0
- package/src/theme/system/index.ts +5 -1
- package/src/theme/system/input.ts +1 -1
- package/src/theme/system/layer.ts +1 -2
- package/src/theme/system/shadow.ts +1 -0
- package/src/theme/system/styles.ts +19 -0
- package/src/theme/system/theme.ts +128 -0
- package/src/theme/system/{color → v0/color}/_generic.ts +2 -1
- package/src/theme/system/v0/color/_system.ts +13 -0
- package/src/theme/system/{color → v0/color}/base.ts +2 -0
- package/src/theme/system/v0/color/button.ts +42 -0
- package/src/theme/system/{color → v0/color}/card.ts +2 -1
- package/src/theme/system/v0/color/color.ts +40 -0
- package/src/theme/system/v0/color/index.ts +11 -0
- package/src/theme/system/v0/color/input.ts +34 -0
- package/src/theme/system/{color/_deprecated → v0/color}/muted.ts +1 -1
- package/src/theme/system/v0/color/selectable.ts +31 -0
- package/src/theme/system/{color/_deprecated → v0/color}/solid.ts +1 -1
- package/src/theme/system/v0/color/spot.ts +13 -0
- package/src/theme/system/v0/index.ts +1 -0
- package/src/theme/versioning/getTheme_v2.ts +38 -0
- package/src/theme/versioning/index.ts +5 -0
- package/src/theme/versioning/is_v0.ts +6 -0
- package/src/theme/versioning/is_v2.ts +6 -0
- package/src/theme/versioning/themeColor_v0_v2.ts +217 -0
- package/src/theme/versioning/v0_v2.ts +72 -0
- package/src/theme/versioning/v2_v0.ts +126 -0
- package/src/core/styles/colorVars/colorVarsStyle.ts +0 -43
- package/src/core/styles/colorVars/index.ts +0 -1
- package/src/core/theme/defaults.ts +0 -7
- package/src/theme/system/_system.ts +0 -95
- package/src/theme/system/color/_deprecated/spot.ts +0 -13
- package/src/theme/themes/studio/config.ts +0 -69
- package/src/theme/themes/studio/fonts.ts +0 -219
- package/src/theme/themes/studio/index.ts +0 -1
- package/src/theme/themes/studio/studioTheme.test.ts +0 -27
- package/src/theme/themes/studio/studioTheme.ts +0 -8
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {defaultThemeConfig} from '../defaults/config'
|
|
2
|
+
import {RootTheme, RootTheme_v2} from '../system'
|
|
3
|
+
import {themeColor_v0_v2} from './themeColor_v0_v2'
|
|
4
|
+
|
|
5
|
+
const cache = new WeakMap<RootTheme, RootTheme_v2>()
|
|
6
|
+
|
|
7
|
+
/** @internal */
|
|
8
|
+
export function v0_v2(v0: RootTheme): RootTheme_v2 {
|
|
9
|
+
if (v0.v2) return v0.v2
|
|
10
|
+
|
|
11
|
+
const cached_v2 = cache.get(v0)
|
|
12
|
+
|
|
13
|
+
if (cached_v2) return cached_v2
|
|
14
|
+
|
|
15
|
+
const {
|
|
16
|
+
avatar,
|
|
17
|
+
button,
|
|
18
|
+
color,
|
|
19
|
+
container,
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
21
|
+
focusRing: _unused_focusRing,
|
|
22
|
+
fonts: font,
|
|
23
|
+
input,
|
|
24
|
+
layer,
|
|
25
|
+
media,
|
|
26
|
+
radius,
|
|
27
|
+
shadows: shadow,
|
|
28
|
+
space,
|
|
29
|
+
styles: style,
|
|
30
|
+
} = v0
|
|
31
|
+
|
|
32
|
+
const v2: RootTheme_v2 = {
|
|
33
|
+
_version: 2,
|
|
34
|
+
avatar,
|
|
35
|
+
button: {
|
|
36
|
+
...defaultThemeConfig.button,
|
|
37
|
+
...button,
|
|
38
|
+
},
|
|
39
|
+
card: defaultThemeConfig.card,
|
|
40
|
+
color: {
|
|
41
|
+
light: {
|
|
42
|
+
transparent: themeColor_v0_v2(color.light.transparent),
|
|
43
|
+
default: themeColor_v0_v2(color.light.default),
|
|
44
|
+
primary: themeColor_v0_v2(color.light.primary),
|
|
45
|
+
positive: themeColor_v0_v2(color.light.positive),
|
|
46
|
+
caution: themeColor_v0_v2(color.light.caution),
|
|
47
|
+
critical: themeColor_v0_v2(color.light.critical),
|
|
48
|
+
},
|
|
49
|
+
dark: {
|
|
50
|
+
transparent: themeColor_v0_v2(color.dark.transparent),
|
|
51
|
+
default: themeColor_v0_v2(color.dark.default),
|
|
52
|
+
primary: themeColor_v0_v2(color.dark.primary),
|
|
53
|
+
positive: themeColor_v0_v2(color.dark.positive),
|
|
54
|
+
caution: themeColor_v0_v2(color.dark.caution),
|
|
55
|
+
critical: themeColor_v0_v2(color.dark.critical),
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
container,
|
|
59
|
+
font,
|
|
60
|
+
input,
|
|
61
|
+
layer: layer ?? defaultThemeConfig.layer,
|
|
62
|
+
media,
|
|
63
|
+
radius,
|
|
64
|
+
shadow,
|
|
65
|
+
space,
|
|
66
|
+
style,
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
cache.set(v0, v2)
|
|
70
|
+
|
|
71
|
+
return v2
|
|
72
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RootTheme,
|
|
3
|
+
RootTheme_v2,
|
|
4
|
+
ThemeColor,
|
|
5
|
+
ThemeColorCard_v2,
|
|
6
|
+
ThemeColorInputState,
|
|
7
|
+
ThemeColorInputState_v2,
|
|
8
|
+
ThemeColorInputStates,
|
|
9
|
+
ThemeColorInputStates_v2,
|
|
10
|
+
} from '../system'
|
|
11
|
+
|
|
12
|
+
const cache = new WeakMap<RootTheme_v2, RootTheme>()
|
|
13
|
+
|
|
14
|
+
/** @internal */
|
|
15
|
+
export function v2_v0(v2: RootTheme_v2): RootTheme {
|
|
16
|
+
const cachedTheme = cache.get(v2)
|
|
17
|
+
|
|
18
|
+
if (cachedTheme) return cachedTheme
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
avatar,
|
|
22
|
+
button,
|
|
23
|
+
color,
|
|
24
|
+
container,
|
|
25
|
+
font: fonts,
|
|
26
|
+
input,
|
|
27
|
+
media,
|
|
28
|
+
radius,
|
|
29
|
+
shadow: shadows,
|
|
30
|
+
space,
|
|
31
|
+
style: styles,
|
|
32
|
+
} = v2
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
_version: 0,
|
|
36
|
+
avatar,
|
|
37
|
+
button,
|
|
38
|
+
container,
|
|
39
|
+
color: {
|
|
40
|
+
light: {
|
|
41
|
+
transparent: themeColor_v2_v0(color.light.transparent),
|
|
42
|
+
default: themeColor_v2_v0(color.light.default),
|
|
43
|
+
primary: themeColor_v2_v0(color.light.primary),
|
|
44
|
+
positive: themeColor_v2_v0(color.light.positive),
|
|
45
|
+
caution: themeColor_v2_v0(color.light.caution),
|
|
46
|
+
critical: themeColor_v2_v0(color.light.critical),
|
|
47
|
+
},
|
|
48
|
+
dark: {
|
|
49
|
+
transparent: themeColor_v2_v0(color.dark.transparent),
|
|
50
|
+
default: themeColor_v2_v0(color.dark.default),
|
|
51
|
+
primary: themeColor_v2_v0(color.dark.primary),
|
|
52
|
+
positive: themeColor_v2_v0(color.dark.positive),
|
|
53
|
+
caution: themeColor_v2_v0(color.dark.caution),
|
|
54
|
+
critical: themeColor_v2_v0(color.dark.critical),
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
focusRing: input.text.focusRing,
|
|
58
|
+
fonts,
|
|
59
|
+
input,
|
|
60
|
+
media,
|
|
61
|
+
radius,
|
|
62
|
+
shadows,
|
|
63
|
+
space,
|
|
64
|
+
styles,
|
|
65
|
+
|
|
66
|
+
v2,
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function themeColor_v2_v0(color_v2: ThemeColorCard_v2): ThemeColor {
|
|
71
|
+
return {
|
|
72
|
+
base: {
|
|
73
|
+
bg: color_v2.bg,
|
|
74
|
+
fg: color_v2.fg,
|
|
75
|
+
border: color_v2.border,
|
|
76
|
+
focusRing: color_v2.focusRing,
|
|
77
|
+
shadow: color_v2.shadow,
|
|
78
|
+
},
|
|
79
|
+
button: color_v2.button,
|
|
80
|
+
card: color_v2.selectable.default,
|
|
81
|
+
dark: color_v2._dark,
|
|
82
|
+
input: {
|
|
83
|
+
default: inputStatesThemeColor_v2_v0(color_v2.input.default),
|
|
84
|
+
invalid: inputStatesThemeColor_v2_v0(color_v2.input.invalid),
|
|
85
|
+
},
|
|
86
|
+
muted: {
|
|
87
|
+
...color_v2.button.ghost,
|
|
88
|
+
transparent: color_v2.button.ghost.default,
|
|
89
|
+
},
|
|
90
|
+
solid: {
|
|
91
|
+
...color_v2.button.default,
|
|
92
|
+
transparent: color_v2.button.default.default,
|
|
93
|
+
},
|
|
94
|
+
spot: {
|
|
95
|
+
gray: color_v2.avatar.gray.bg,
|
|
96
|
+
blue: color_v2.avatar.blue.bg,
|
|
97
|
+
purple: color_v2.avatar.purple.bg,
|
|
98
|
+
magenta: color_v2.avatar.magenta.bg,
|
|
99
|
+
red: color_v2.avatar.red.bg,
|
|
100
|
+
orange: color_v2.avatar.orange.bg,
|
|
101
|
+
yellow: color_v2.avatar.yellow.bg,
|
|
102
|
+
green: color_v2.avatar.green.bg,
|
|
103
|
+
cyan: color_v2.avatar.cyan.bg,
|
|
104
|
+
},
|
|
105
|
+
syntax: color_v2.syntax,
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function inputStatesThemeColor_v2_v0(t: ThemeColorInputStates_v2): ThemeColorInputStates {
|
|
110
|
+
return {
|
|
111
|
+
enabled: inputStateThemeColor_v2_v0(t.enabled),
|
|
112
|
+
disabled: inputStateThemeColor_v2_v0(t.disabled),
|
|
113
|
+
readOnly: inputStateThemeColor_v2_v0(t.readOnly),
|
|
114
|
+
hovered: inputStateThemeColor_v2_v0(t.hovered),
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function inputStateThemeColor_v2_v0(t: ThemeColorInputState_v2): ThemeColorInputState {
|
|
119
|
+
return {
|
|
120
|
+
bg: t.bg,
|
|
121
|
+
bg2: t.muted.bg,
|
|
122
|
+
border: t.border,
|
|
123
|
+
fg: t.fg,
|
|
124
|
+
placeholder: t.placeholder,
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {ThemeColorBase, ThemeColorGenericState} from '@sanity/ui/theme'
|
|
2
|
-
import {CSSObject} from '@sanity/ui/theme'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @internal
|
|
6
|
-
*/
|
|
7
|
-
export function _colorVarsStyle(
|
|
8
|
-
base: ThemeColorBase,
|
|
9
|
-
color: ThemeColorGenericState,
|
|
10
|
-
checkered = false,
|
|
11
|
-
): CSSObject {
|
|
12
|
-
return {
|
|
13
|
-
// Base
|
|
14
|
-
// @todo: rename to "--base-"?
|
|
15
|
-
'--card-shadow-outline-color': base.shadow.outline,
|
|
16
|
-
'--card-shadow-umbra-color': base.shadow.umbra,
|
|
17
|
-
'--card-shadow-penumbra-color': base.shadow.penumbra,
|
|
18
|
-
'--card-shadow-ambient-color': base.shadow.ambient,
|
|
19
|
-
'--card-focus-ring-color': base.focusRing,
|
|
20
|
-
'--card-icon-color': color.icon,
|
|
21
|
-
|
|
22
|
-
// Card
|
|
23
|
-
'--card-bg-color': color.bg,
|
|
24
|
-
'--card-bg2-color': color.bg2,
|
|
25
|
-
'--card-bg-image': checkered
|
|
26
|
-
? `repeating-conic-gradient(${color.bg} 0% 25%, ${color.bg2 || color.bg} 0% 50%)`
|
|
27
|
-
: undefined,
|
|
28
|
-
'--card-fg-color': color.fg,
|
|
29
|
-
'--card-border-color': color.border,
|
|
30
|
-
'--card-muted-fg-color': color.muted?.fg,
|
|
31
|
-
'--card-accent-fg-color': color.accent?.fg,
|
|
32
|
-
'--card-link-fg-color': color.link?.fg,
|
|
33
|
-
'--card-code-bg-color': color.code?.bg,
|
|
34
|
-
'--card-code-fg-color': color.code?.fg,
|
|
35
|
-
'--card-skeleton-color-from': color.skeleton?.from,
|
|
36
|
-
'--card-skeleton-color-to': color.skeleton?.to,
|
|
37
|
-
|
|
38
|
-
// @todo: deprecate
|
|
39
|
-
'--card-link-color': color.link?.fg,
|
|
40
|
-
'--card-hairline-soft-color': color.border,
|
|
41
|
-
'--card-hairline-hard-color': color.border,
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './colorVarsStyle'
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import type {StyledObject} from 'styled-components'
|
|
2
|
-
import {ThemeAvatar} from './avatar'
|
|
3
|
-
import {ThemeColor} from './color'
|
|
4
|
-
import {ThemeColorSchemes} from './color'
|
|
5
|
-
import {ThemeFonts, ThemeFontWeightKey} from './fonts'
|
|
6
|
-
import {ThemeInput} from './input'
|
|
7
|
-
import {ThemeLayer} from './layer'
|
|
8
|
-
import {ThemeShadow} from './shadow'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Workaround types that are missing in v6
|
|
12
|
-
* https://github.com/styled-components/styled-components/issues/4062
|
|
13
|
-
* @internal
|
|
14
|
-
* */
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
-
export type CSSObject = StyledObject<any>
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @public
|
|
20
|
-
*/
|
|
21
|
-
export interface ThemeStyles {
|
|
22
|
-
button?: {
|
|
23
|
-
root?: CSSObject
|
|
24
|
-
}
|
|
25
|
-
card?: {
|
|
26
|
-
root?: CSSObject
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @deprecated Use `ThemeStyles` instead
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
export type Styles = ThemeStyles
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @public
|
|
38
|
-
*/
|
|
39
|
-
export interface ThemeFocusRing {
|
|
40
|
-
offset: number
|
|
41
|
-
width: number
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @public
|
|
46
|
-
*/
|
|
47
|
-
export interface BaseTheme<
|
|
48
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
49
|
-
Styles extends {} = {},
|
|
50
|
-
> {
|
|
51
|
-
avatar: ThemeAvatar
|
|
52
|
-
button: {
|
|
53
|
-
border: {width: number}
|
|
54
|
-
focusRing: ThemeFocusRing
|
|
55
|
-
textWeight: ThemeFontWeightKey
|
|
56
|
-
}
|
|
57
|
-
card: {
|
|
58
|
-
border: {width: number}
|
|
59
|
-
focusRing: ThemeFocusRing
|
|
60
|
-
shadow: {outline: number}
|
|
61
|
-
}
|
|
62
|
-
color: ThemeColorSchemes
|
|
63
|
-
container: number[]
|
|
64
|
-
/** @deprecated Use component-specific `focusRing` values instead */
|
|
65
|
-
focusRing: {
|
|
66
|
-
offset: number
|
|
67
|
-
width: number
|
|
68
|
-
}
|
|
69
|
-
fonts: ThemeFonts
|
|
70
|
-
input: ThemeInput
|
|
71
|
-
/**
|
|
72
|
-
* THIS API MAY BE UNSTABLE. DO NOT USE IN PRODUCTION.
|
|
73
|
-
* @beta
|
|
74
|
-
*/
|
|
75
|
-
layer?: ThemeLayer
|
|
76
|
-
media: number[]
|
|
77
|
-
radius: number[]
|
|
78
|
-
shadows: Array<ThemeShadow | null>
|
|
79
|
-
space: number[]
|
|
80
|
-
styles?: Styles
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* @public
|
|
85
|
-
*/
|
|
86
|
-
export type RootTheme = BaseTheme<ThemeStyles>
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* @public
|
|
90
|
-
*/
|
|
91
|
-
export interface Theme {
|
|
92
|
-
sanity: Omit<RootTheme, 'color'> & {
|
|
93
|
-
color: ThemeColor
|
|
94
|
-
}
|
|
95
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {ThemeColorAvatarColorKey} from '../_system'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @public
|
|
5
|
-
* @deprecated Use `ThemeColorAvatarKey` instead
|
|
6
|
-
*/
|
|
7
|
-
export type ThemeColorSpotKey = ThemeColorAvatarColorKey
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @public
|
|
11
|
-
* @deprecated Use `ThemeColorAvatar` instead
|
|
12
|
-
*/
|
|
13
|
-
export type ThemeColorSpot = Record<ThemeColorSpotKey, string>
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import {RootTheme} from '../../system'
|
|
2
|
-
|
|
3
|
-
const STROKE_WIDTH = 1
|
|
4
|
-
const OUTLINE_WIDTH = 0.5
|
|
5
|
-
|
|
6
|
-
export const config: Omit<RootTheme, 'color' | 'fonts'> = {
|
|
7
|
-
avatar: {
|
|
8
|
-
sizes: [
|
|
9
|
-
{distance: -3, size: 19},
|
|
10
|
-
{distance: -6, size: 25},
|
|
11
|
-
{distance: -9, size: 35},
|
|
12
|
-
],
|
|
13
|
-
focusRing: {offset: 0, width: 1},
|
|
14
|
-
},
|
|
15
|
-
button: {
|
|
16
|
-
textWeight: 'medium',
|
|
17
|
-
border: {width: STROKE_WIDTH},
|
|
18
|
-
focusRing: {offset: -1, width: 1},
|
|
19
|
-
},
|
|
20
|
-
card: {
|
|
21
|
-
border: {width: STROKE_WIDTH},
|
|
22
|
-
focusRing: {offset: -1, width: 1},
|
|
23
|
-
shadow: {outline: OUTLINE_WIDTH},
|
|
24
|
-
},
|
|
25
|
-
container: [480, 640, 960, 1280, 1600, 1920],
|
|
26
|
-
focusRing: {
|
|
27
|
-
offset: -1,
|
|
28
|
-
width: 1,
|
|
29
|
-
},
|
|
30
|
-
media: [360, 600, 900, 1200, 1800, 2400],
|
|
31
|
-
radius: [0, 1, 3, 6, 9, 12, 21],
|
|
32
|
-
shadows: [
|
|
33
|
-
null,
|
|
34
|
-
{umbra: [0, 0, 0, 0], penumbra: [0, 0, 0, 0], ambient: [0, 0, 0, 0]},
|
|
35
|
-
{umbra: [0, 3, 5, -2], penumbra: [0, 6, 10, 0], ambient: [0, 1, 18, 1]},
|
|
36
|
-
{umbra: [0, 7, 8, -4], penumbra: [0, 12, 17, 2], ambient: [0, 5, 22, 4]},
|
|
37
|
-
{umbra: [0, 9, 11, -5], penumbra: [0, 18, 28, 2], ambient: [0, 7, 34, 6]},
|
|
38
|
-
{umbra: [0, 11, 15, -7], penumbra: [0, 24, 38, 3], ambient: [0, 9, 46, 8]},
|
|
39
|
-
],
|
|
40
|
-
space: [0, 4, 8, 12, 20, 32, 52, 84, 136, 220],
|
|
41
|
-
input: {
|
|
42
|
-
border: {
|
|
43
|
-
width: STROKE_WIDTH,
|
|
44
|
-
},
|
|
45
|
-
checkbox: {
|
|
46
|
-
size: 17,
|
|
47
|
-
focusRing: {offset: -1, width: 1},
|
|
48
|
-
},
|
|
49
|
-
radio: {
|
|
50
|
-
size: 17,
|
|
51
|
-
markSize: 9,
|
|
52
|
-
focusRing: {offset: -1, width: 1},
|
|
53
|
-
},
|
|
54
|
-
switch: {
|
|
55
|
-
width: 21,
|
|
56
|
-
height: 13,
|
|
57
|
-
padding: 2,
|
|
58
|
-
transitionDurationMs: 150,
|
|
59
|
-
transitionTimingFunction: 'ease-out',
|
|
60
|
-
focusRing: {offset: 1, width: 1},
|
|
61
|
-
},
|
|
62
|
-
select: {
|
|
63
|
-
focusRing: {offset: -1, width: 1},
|
|
64
|
-
},
|
|
65
|
-
text: {
|
|
66
|
-
focusRing: {offset: -1, width: 1},
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
}
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import {ThemeFonts} from '../../system'
|
|
2
|
-
|
|
3
|
-
export const fonts: ThemeFonts = {
|
|
4
|
-
code: {
|
|
5
|
-
family: 'ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace',
|
|
6
|
-
weights: {
|
|
7
|
-
regular: 400,
|
|
8
|
-
medium: 500,
|
|
9
|
-
semibold: 600,
|
|
10
|
-
bold: 700,
|
|
11
|
-
},
|
|
12
|
-
sizes: [
|
|
13
|
-
{
|
|
14
|
-
ascenderHeight: 4,
|
|
15
|
-
descenderHeight: 4,
|
|
16
|
-
fontSize: 10,
|
|
17
|
-
iconSize: 17,
|
|
18
|
-
lineHeight: 15,
|
|
19
|
-
letterSpacing: 0,
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
ascenderHeight: 5,
|
|
23
|
-
descenderHeight: 5,
|
|
24
|
-
fontSize: 13,
|
|
25
|
-
iconSize: 21,
|
|
26
|
-
lineHeight: 19,
|
|
27
|
-
letterSpacing: 0,
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
ascenderHeight: 6,
|
|
31
|
-
descenderHeight: 6,
|
|
32
|
-
fontSize: 16,
|
|
33
|
-
iconSize: 25,
|
|
34
|
-
lineHeight: 23,
|
|
35
|
-
letterSpacing: 0,
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
ascenderHeight: 7,
|
|
39
|
-
descenderHeight: 7,
|
|
40
|
-
fontSize: 19,
|
|
41
|
-
iconSize: 29,
|
|
42
|
-
lineHeight: 27,
|
|
43
|
-
letterSpacing: 0,
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
ascenderHeight: 8,
|
|
47
|
-
descenderHeight: 8,
|
|
48
|
-
fontSize: 22,
|
|
49
|
-
iconSize: 33,
|
|
50
|
-
lineHeight: 31,
|
|
51
|
-
letterSpacing: 0,
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
},
|
|
55
|
-
heading: {
|
|
56
|
-
family:
|
|
57
|
-
'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Helvetica, Arial, system-ui, sans-serif',
|
|
58
|
-
weights: {
|
|
59
|
-
regular: 700,
|
|
60
|
-
medium: 800,
|
|
61
|
-
semibold: 900,
|
|
62
|
-
bold: 900,
|
|
63
|
-
},
|
|
64
|
-
sizes: [
|
|
65
|
-
{
|
|
66
|
-
ascenderHeight: 5,
|
|
67
|
-
descenderHeight: 5,
|
|
68
|
-
fontSize: 13,
|
|
69
|
-
iconSize: 17,
|
|
70
|
-
lineHeight: 19,
|
|
71
|
-
letterSpacing: 0,
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
ascenderHeight: 6,
|
|
75
|
-
descenderHeight: 6,
|
|
76
|
-
fontSize: 16,
|
|
77
|
-
iconSize: 25,
|
|
78
|
-
lineHeight: 23,
|
|
79
|
-
letterSpacing: 0,
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
ascenderHeight: 7,
|
|
83
|
-
descenderHeight: 7,
|
|
84
|
-
fontSize: 21,
|
|
85
|
-
iconSize: 33,
|
|
86
|
-
lineHeight: 29,
|
|
87
|
-
letterSpacing: 0,
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
ascenderHeight: 8,
|
|
91
|
-
descenderHeight: 8,
|
|
92
|
-
fontSize: 27,
|
|
93
|
-
iconSize: 41,
|
|
94
|
-
lineHeight: 35,
|
|
95
|
-
letterSpacing: 0,
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
ascenderHeight: 9.5,
|
|
99
|
-
descenderHeight: 8.5,
|
|
100
|
-
fontSize: 33,
|
|
101
|
-
iconSize: 49,
|
|
102
|
-
lineHeight: 41,
|
|
103
|
-
letterSpacing: 0,
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
ascenderHeight: 10.5,
|
|
107
|
-
descenderHeight: 9.5,
|
|
108
|
-
fontSize: 38,
|
|
109
|
-
iconSize: 53,
|
|
110
|
-
lineHeight: 47,
|
|
111
|
-
letterSpacing: 0,
|
|
112
|
-
},
|
|
113
|
-
],
|
|
114
|
-
},
|
|
115
|
-
label: {
|
|
116
|
-
family:
|
|
117
|
-
'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", system-ui, sans-serif',
|
|
118
|
-
weights: {
|
|
119
|
-
regular: 600,
|
|
120
|
-
medium: 700,
|
|
121
|
-
semibold: 800,
|
|
122
|
-
bold: 900,
|
|
123
|
-
},
|
|
124
|
-
sizes: [
|
|
125
|
-
{
|
|
126
|
-
ascenderHeight: 2,
|
|
127
|
-
descenderHeight: 2,
|
|
128
|
-
fontSize: 9.8,
|
|
129
|
-
iconSize: 15,
|
|
130
|
-
lineHeight: 11,
|
|
131
|
-
letterSpacing: 0.5,
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
ascenderHeight: 2,
|
|
135
|
-
descenderHeight: 2,
|
|
136
|
-
fontSize: 11.25,
|
|
137
|
-
iconSize: 17,
|
|
138
|
-
lineHeight: 12,
|
|
139
|
-
letterSpacing: 0.5,
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
ascenderHeight: 2,
|
|
143
|
-
descenderHeight: 2,
|
|
144
|
-
fontSize: 12.75,
|
|
145
|
-
iconSize: 19,
|
|
146
|
-
lineHeight: 13,
|
|
147
|
-
letterSpacing: 0.5,
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
ascenderHeight: 2,
|
|
151
|
-
descenderHeight: 2,
|
|
152
|
-
fontSize: 14,
|
|
153
|
-
iconSize: 21,
|
|
154
|
-
lineHeight: 14,
|
|
155
|
-
letterSpacing: 0.5,
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
ascenderHeight: 2,
|
|
159
|
-
descenderHeight: 2,
|
|
160
|
-
fontSize: 15.5,
|
|
161
|
-
iconSize: 23,
|
|
162
|
-
lineHeight: 15,
|
|
163
|
-
letterSpacing: 0.5,
|
|
164
|
-
},
|
|
165
|
-
],
|
|
166
|
-
},
|
|
167
|
-
text: {
|
|
168
|
-
family:
|
|
169
|
-
'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Helvetica, Arial, system-ui, sans-serif',
|
|
170
|
-
weights: {
|
|
171
|
-
regular: 400,
|
|
172
|
-
medium: 500,
|
|
173
|
-
semibold: 600,
|
|
174
|
-
bold: 700,
|
|
175
|
-
},
|
|
176
|
-
sizes: [
|
|
177
|
-
{
|
|
178
|
-
ascenderHeight: 4,
|
|
179
|
-
descenderHeight: 4,
|
|
180
|
-
fontSize: 10,
|
|
181
|
-
iconSize: 17,
|
|
182
|
-
lineHeight: 15,
|
|
183
|
-
letterSpacing: 0,
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
ascenderHeight: 5,
|
|
187
|
-
descenderHeight: 5,
|
|
188
|
-
fontSize: 13,
|
|
189
|
-
iconSize: 21,
|
|
190
|
-
lineHeight: 19,
|
|
191
|
-
letterSpacing: 0,
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
ascenderHeight: 6,
|
|
195
|
-
descenderHeight: 6,
|
|
196
|
-
fontSize: 16,
|
|
197
|
-
iconSize: 25,
|
|
198
|
-
lineHeight: 23,
|
|
199
|
-
letterSpacing: 0,
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
ascenderHeight: 7.5,
|
|
203
|
-
descenderHeight: 6.5,
|
|
204
|
-
fontSize: 19,
|
|
205
|
-
iconSize: 29,
|
|
206
|
-
lineHeight: 27,
|
|
207
|
-
letterSpacing: 0,
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
ascenderHeight: 8.5,
|
|
211
|
-
descenderHeight: 7.5,
|
|
212
|
-
fontSize: 22,
|
|
213
|
-
iconSize: 33,
|
|
214
|
-
lineHeight: 31,
|
|
215
|
-
letterSpacing: 0,
|
|
216
|
-
},
|
|
217
|
-
],
|
|
218
|
-
},
|
|
219
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './studioTheme'
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import {getContrastRatio} from '../../build'
|
|
2
|
-
import {studioTheme} from './studioTheme'
|
|
3
|
-
|
|
4
|
-
const AA_MIN = 4.5
|
|
5
|
-
|
|
6
|
-
it('should …', () => {
|
|
7
|
-
expect(
|
|
8
|
-
getContrastRatio(
|
|
9
|
-
studioTheme.color.light.default.base.bg,
|
|
10
|
-
studioTheme.color.light.default.base.fg,
|
|
11
|
-
),
|
|
12
|
-
).toBeGreaterThan(AA_MIN)
|
|
13
|
-
|
|
14
|
-
expect(
|
|
15
|
-
getContrastRatio(
|
|
16
|
-
studioTheme.color.light.default.card.enabled.bg,
|
|
17
|
-
studioTheme.color.light.default.card.enabled.fg,
|
|
18
|
-
),
|
|
19
|
-
).toBeGreaterThan(AA_MIN)
|
|
20
|
-
|
|
21
|
-
expect(
|
|
22
|
-
getContrastRatio(
|
|
23
|
-
studioTheme.color.light.default.card.enabled.bg,
|
|
24
|
-
studioTheme.color.light.default.card.enabled.muted.fg,
|
|
25
|
-
),
|
|
26
|
-
).toBeGreaterThan(AA_MIN)
|
|
27
|
-
})
|