@sanity/ui 2.0.0-alpha.4 → 2.0.0-alpha.6
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 +3 -1
- package/dist/index.d.ts +294 -407
- package/dist/index.esm.js +794 -2148
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +795 -2147
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/dialog/dialog.tsx +3 -3
- package/src/components/dialog/styles.ts +3 -4
- package/src/components/menu/__workshop__/closableMenuButton.tsx +2 -2
- package/src/components/menu/menuDivider.ts +2 -1
- package/src/components/menu/menuGroup.tsx +3 -0
- package/src/components/menu/menuItem.tsx +6 -3
- package/src/components/skeleton/styles.ts +8 -7
- package/src/components/tree/style.ts +19 -20
- package/src/primitives/_selectable/style.ts +27 -21
- package/src/primitives/avatar/avatar.tsx +8 -3
- package/src/primitives/avatar/avatarCounter.tsx +5 -4
- package/src/primitives/avatar/spotColors.ts +53 -0
- package/src/primitives/avatar/styles.ts +5 -7
- package/src/primitives/avatar/types.ts +14 -0
- package/src/primitives/badge/styles.ts +7 -8
- package/src/primitives/box/__workshop__/responsive.tsx +2 -2
- package/src/primitives/button/button.tsx +2 -2
- package/src/primitives/button/styles.ts +82 -16
- package/src/primitives/card/__workshop__/selected.tsx +8 -9
- package/src/primitives/card/card.tsx +43 -7
- package/src/primitives/card/styles.ts +30 -22
- package/src/primitives/card/types.ts +3 -1
- package/src/primitives/checkbox/styles.ts +20 -20
- package/src/primitives/code/code.tsx +15 -3
- package/src/primitives/code/styles.ts +51 -42
- package/src/primitives/heading/styles.ts +6 -5
- package/src/primitives/kbd/kbd.tsx +2 -1
- package/src/primitives/label/styles.ts +3 -2
- package/src/primitives/popover/popoverArrow.tsx +3 -2
- package/src/primitives/popover/popoverCard.tsx +6 -2
- package/src/primitives/radio/styles.ts +15 -15
- package/src/primitives/select/styles.ts +20 -22
- package/src/primitives/switch/styles.ts +13 -13
- package/src/primitives/text/__workshop__/colored.tsx +10 -11
- package/src/primitives/text/styles.ts +10 -9
- package/src/primitives/textArea/textArea.tsx +8 -12
- package/src/primitives/textInput/textInput.tsx +13 -13
- package/src/primitives/tooltip/__workshop__/props.tsx +20 -3
- package/src/primitives/tooltip/tooltipArrow.tsx +3 -2
- package/src/styles/border/borderStyle.ts +2 -1
- package/src/styles/colorVars/colorVarsStyle.ts +71 -32
- package/src/styles/focusRing/index.ts +6 -4
- package/src/styles/input/textInputStyle.ts +76 -93
- package/src/styles/margin/marginsStyle.test.ts +1 -2
- package/src/styles/padding/paddingStyle.test.ts +1 -2
- package/src/styles/shadow/shadowStyle.ts +5 -5
- package/src/theme/__workshop__/color.tsx +2 -2
- package/src/theme/__workshop__/index.ts +0 -5
- package/src/theme/lib/color-fns/blend/multiply.ts +2 -2
- package/src/theme/lib/color-fns/blend/screen.ts +2 -2
- package/src/theme/lib/color-fns/convert.ts +15 -1
- package/src/theme/lib/color-fns/parse.ts +7 -3
- package/src/theme/lib/color-fns/types.ts +11 -0
- package/src/theme/lib/theme/color/cssVariables/cardVariables.ts +92 -0
- package/src/theme/lib/theme/color/cssVariables/createCssVars.ts +31 -0
- package/src/theme/lib/theme/color/cssVariables/cssVars.test.ts +262 -0
- package/src/theme/lib/theme/color/cssVariables/index.ts +1 -0
- package/src/theme/lib/theme/color/cssVariables/tints.ts +312 -0
- package/src/theme/lib/theme/color/cssVariables/tones.ts +67 -0
- package/src/theme/lib/theme/color/cssVariables/utils.test.ts +15 -0
- package/src/theme/lib/theme/color/cssVariables/utils.ts +9 -0
- package/src/theme/lib/theme/color/index.ts +2 -12
- package/src/theme/lib/theme/color/types.ts +6 -37
- package/src/theme/studioTheme/color.ts +2 -641
- package/src/theme/studioTheme/helpers.ts +15 -1
- package/src/theme/studioTheme/theme.ts +8 -2
- package/src/theme/themeColorProvider.tsx +2 -0
- package/src/theme/themeProvider.tsx +27 -8
- package/src/theme/toneContext/toneContext.ts +12 -0
- package/src/theme/toneContext/toneProvider.tsx +31 -0
- package/src/theme/toneContext/types.ts +10 -0
- package/src/theme/toneContext/useToneContext.tsx +26 -0
- package/src/theme/types.ts +2 -4
- package/src/utils/elementQuery/__workshop__/customMedia.tsx +4 -3
- package/src/theme/__workshop__/canvas.tsx +0 -395
- package/src/theme/lib/theme/color/_generic/index.ts +0 -1
- package/src/theme/lib/theme/color/_generic/types.ts +0 -30
- package/src/theme/lib/theme/color/base/index.ts +0 -1
- package/src/theme/lib/theme/color/base/types.ts +0 -19
- package/src/theme/lib/theme/color/button/createButtonModes.ts +0 -20
- package/src/theme/lib/theme/color/button/createButtonTones.ts +0 -52
- package/src/theme/lib/theme/color/button/index.ts +0 -1
- package/src/theme/lib/theme/color/button/types.ts +0 -44
- package/src/theme/lib/theme/color/card/createCardStates.ts +0 -58
- package/src/theme/lib/theme/color/card/index.ts +0 -1
- package/src/theme/lib/theme/color/card/types.ts +0 -18
- package/src/theme/lib/theme/color/color.test.ts +0 -63
- package/src/theme/lib/theme/color/defaults.ts +0 -390
- package/src/theme/lib/theme/color/factory.ts +0 -138
- package/src/theme/lib/theme/color/input/createInputModes.ts +0 -84
- package/src/theme/lib/theme/color/input/index.ts +0 -1
- package/src/theme/lib/theme/color/input/types.ts +0 -28
- package/src/theme/lib/theme/color/muted/createMuted.ts +0 -56
- package/src/theme/lib/theme/color/muted/index.ts +0 -1
- package/src/theme/lib/theme/color/muted/types.ts +0 -24
- package/src/theme/lib/theme/color/selectable/createSelectableTones.ts +0 -73
- package/src/theme/lib/theme/color/selectable/index.ts +0 -1
- package/src/theme/lib/theme/color/selectable/types.ts +0 -29
- package/src/theme/lib/theme/color/solid/createSolidTones.ts +0 -56
- package/src/theme/lib/theme/color/solid/index.ts +0 -1
- package/src/theme/lib/theme/color/solid/types.ts +0 -24
- package/src/theme/lib/theme/color/spot/createSpot.ts +0 -21
- package/src/theme/lib/theme/color/spot/index.ts +0 -1
- package/src/theme/lib/theme/color/spot/types.ts +0 -28
- package/src/theme/lib/theme/color/syntax/index.ts +0 -1
- package/src/theme/lib/theme/color/syntax/types.ts +0 -41
- package/src/theme/studioTheme/tints.ts +0 -152
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file creates a translation between the tints and the studio colors
|
|
3
|
-
* Providing readable names, and allowing to mix colors and tints in the same ThemeColor.
|
|
4
|
-
* e.g. for positive theme: `{"bg_base": "white", "bg_base_hover": "gray/50", "bg_base_active": "cyan/50"}
|
|
5
|
-
* This is not possible in the previous configuration, as each ThemeColor uses only one tint.
|
|
6
|
-
*/
|
|
7
|
-
import {ColorTintKey, ColorTint, ColorTints, black, hues, white} from '@sanity/color'
|
|
8
|
-
import {ThemeColorName, ThemeColorSchemeKey} from '../lib/theme'
|
|
9
|
-
|
|
10
|
-
export const colorKeys = [
|
|
11
|
-
'text_primary',
|
|
12
|
-
'text_secondary',
|
|
13
|
-
'text_inactive',
|
|
14
|
-
'bg_base',
|
|
15
|
-
'bg_base_hover',
|
|
16
|
-
'bg_base_active',
|
|
17
|
-
'bg_accent',
|
|
18
|
-
'bg_accent_hover',
|
|
19
|
-
'bg_accent_active',
|
|
20
|
-
'bg_tint',
|
|
21
|
-
'icon_default',
|
|
22
|
-
'icon_inverted',
|
|
23
|
-
'border_base',
|
|
24
|
-
'border_accent',
|
|
25
|
-
'border_accent_inverted',
|
|
26
|
-
] as const
|
|
27
|
-
|
|
28
|
-
export type ColorKey = (typeof colorKeys)[number]
|
|
29
|
-
|
|
30
|
-
type ColorTintsDictionary = Record<ColorKey, ColorTint | ColorTintKey>
|
|
31
|
-
const defaultTints: Record<ThemeColorSchemeKey, ColorTintsDictionary> = {
|
|
32
|
-
light: {
|
|
33
|
-
text_primary: '900',
|
|
34
|
-
text_secondary: '600',
|
|
35
|
-
text_inactive: '500',
|
|
36
|
-
bg_base: white,
|
|
37
|
-
bg_base_hover: '50',
|
|
38
|
-
bg_base_active: '100',
|
|
39
|
-
bg_accent: '500',
|
|
40
|
-
bg_accent_hover: '600',
|
|
41
|
-
bg_accent_active: '700',
|
|
42
|
-
bg_tint: '50',
|
|
43
|
-
icon_default: '500',
|
|
44
|
-
icon_inverted: white,
|
|
45
|
-
border_base: '100',
|
|
46
|
-
border_accent: '500',
|
|
47
|
-
border_accent_inverted: white,
|
|
48
|
-
},
|
|
49
|
-
dark: {
|
|
50
|
-
text_primary: '50',
|
|
51
|
-
text_secondary: '300',
|
|
52
|
-
text_inactive: '400',
|
|
53
|
-
bg_base: black,
|
|
54
|
-
bg_base_hover: '900',
|
|
55
|
-
bg_base_active: '800',
|
|
56
|
-
bg_accent: '500',
|
|
57
|
-
bg_accent_hover: '400',
|
|
58
|
-
bg_accent_active: '300',
|
|
59
|
-
bg_tint: '900',
|
|
60
|
-
icon_default: '300',
|
|
61
|
-
icon_inverted: hues.gray[900],
|
|
62
|
-
border_base: '800',
|
|
63
|
-
border_accent: '300',
|
|
64
|
-
border_accent_inverted: hues.gray[900],
|
|
65
|
-
},
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export const colorTints: Record<
|
|
69
|
-
ThemeColorSchemeKey,
|
|
70
|
-
Record<ThemeColorName, ColorTintsDictionary>
|
|
71
|
-
> = {
|
|
72
|
-
light: {
|
|
73
|
-
default: {
|
|
74
|
-
...defaultTints.light,
|
|
75
|
-
bg_accent: '900',
|
|
76
|
-
bg_accent_hover: '950',
|
|
77
|
-
bg_accent_active: black,
|
|
78
|
-
border_accent: '600',
|
|
79
|
-
},
|
|
80
|
-
primary: {
|
|
81
|
-
...defaultTints.light,
|
|
82
|
-
bg_accent: '900',
|
|
83
|
-
bg_accent_hover: '950',
|
|
84
|
-
bg_accent_active: black,
|
|
85
|
-
border_accent: '600',
|
|
86
|
-
},
|
|
87
|
-
positive: {
|
|
88
|
-
...defaultTints.light,
|
|
89
|
-
bg_base_hover: hues.gray[50],
|
|
90
|
-
bg_base_active: '50',
|
|
91
|
-
bg_accent: '400',
|
|
92
|
-
bg_accent_hover: '500',
|
|
93
|
-
bg_accent_active: '600',
|
|
94
|
-
border_accent: '400',
|
|
95
|
-
},
|
|
96
|
-
transparent: defaultTints.light,
|
|
97
|
-
caution: defaultTints.light,
|
|
98
|
-
critical: defaultTints.light,
|
|
99
|
-
},
|
|
100
|
-
dark: {
|
|
101
|
-
default: {
|
|
102
|
-
...defaultTints.dark,
|
|
103
|
-
text_primary: white,
|
|
104
|
-
bg_accent: white,
|
|
105
|
-
bg_accent_hover: '50',
|
|
106
|
-
bg_accent_active: '100',
|
|
107
|
-
},
|
|
108
|
-
primary: {
|
|
109
|
-
...defaultTints.dark,
|
|
110
|
-
text_primary: white,
|
|
111
|
-
bg_accent: white,
|
|
112
|
-
bg_accent_hover: '50',
|
|
113
|
-
bg_accent_active: '100',
|
|
114
|
-
},
|
|
115
|
-
positive: {
|
|
116
|
-
...defaultTints.dark,
|
|
117
|
-
bg_base_hover: hues.gray[900],
|
|
118
|
-
bg_base_active: '900',
|
|
119
|
-
bg_accent: '400',
|
|
120
|
-
bg_accent_hover: '300',
|
|
121
|
-
bg_accent_active: '200',
|
|
122
|
-
border_accent: '400',
|
|
123
|
-
},
|
|
124
|
-
transparent: defaultTints.dark,
|
|
125
|
-
caution: defaultTints.dark,
|
|
126
|
-
critical: defaultTints.dark,
|
|
127
|
-
},
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export const getColorValue = (
|
|
131
|
-
tints: ColorTints,
|
|
132
|
-
dark: boolean,
|
|
133
|
-
tone: ThemeColorName,
|
|
134
|
-
key: ColorKey,
|
|
135
|
-
): ColorTint => {
|
|
136
|
-
const value = colorTints[dark ? 'dark' : 'light'][tone][key]
|
|
137
|
-
|
|
138
|
-
if (typeof value === 'string') {
|
|
139
|
-
return tints[value]
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return value
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export const getColorHex = (
|
|
146
|
-
tints: ColorTints,
|
|
147
|
-
dark: boolean,
|
|
148
|
-
tone: ThemeColorName,
|
|
149
|
-
key: ColorKey,
|
|
150
|
-
): string => {
|
|
151
|
-
return getColorValue(tints, dark, tone, key).hex
|
|
152
|
-
}
|