@sanity/ui 2.0.0-alpha.5 → 2.0.0-alpha.7
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 +971 -2333
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +972 -2332
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- 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 +22 -23
- package/src/components/menu/menuItem.tsx +30 -36
- package/src/components/skeleton/styles.ts +8 -7
- package/src/components/tree/style.ts +19 -20
- package/src/primitives/_selectable/style.ts +25 -22
- 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/badge.tsx +4 -2
- 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 +7 -11
- package/src/primitives/textInput/textInput.tsx +12 -12
- 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 +73 -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 +9 -3
- 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
|
@@ -4,6 +4,7 @@ import {useRootTheme} from './useRootTheme'
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @public
|
|
7
|
+
* @deprecated
|
|
7
8
|
*/
|
|
8
9
|
export interface ThemeColorProviderProps {
|
|
9
10
|
children?: React.ReactNode
|
|
@@ -13,6 +14,7 @@ export interface ThemeColorProviderProps {
|
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* @public
|
|
17
|
+
* @deprecated Use `toneContext` instead.
|
|
16
18
|
*/
|
|
17
19
|
export function ThemeColorProvider(props: ThemeColorProviderProps): React.ReactElement {
|
|
18
20
|
const {children, scheme, tone} = props
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import {useContext, useMemo} from 'react'
|
|
2
|
-
import {ThemeProvider as StyledThemeProvider} from 'styled-components'
|
|
2
|
+
import {ThemeProvider as StyledThemeProvider, createGlobalStyle} from 'styled-components'
|
|
3
3
|
import {DEFAULT_THEME_LAYER} from './defaults'
|
|
4
|
-
import {
|
|
4
|
+
import {ThemeColorName, ThemeColorSchemeKey} from './lib/theme'
|
|
5
|
+
import {createCssVars} from './lib/theme/color/cssVariables'
|
|
6
|
+
import {cssObjectToCssString} from './lib/theme/color/cssVariables/utils'
|
|
5
7
|
import {ThemeContext} from './themeContext'
|
|
8
|
+
import {ToneProvider} from './toneContext/toneProvider'
|
|
6
9
|
import {RootTheme, Theme, ThemeContextValue} from './types'
|
|
7
10
|
|
|
11
|
+
const GlobalVariables = createGlobalStyle<{$vars?: string}>`
|
|
12
|
+
:root {
|
|
13
|
+
${({$vars}) => $vars}
|
|
14
|
+
}
|
|
15
|
+
`
|
|
16
|
+
|
|
8
17
|
/**
|
|
9
18
|
* @public
|
|
10
19
|
*/
|
|
@@ -30,13 +39,12 @@ export function ThemeProvider(props: ThemeProviderProps): React.ReactElement {
|
|
|
30
39
|
const theme: Theme | null = useMemo(() => {
|
|
31
40
|
if (!themeProp) return null
|
|
32
41
|
|
|
33
|
-
const {
|
|
34
|
-
|
|
35
|
-
const color = colorScheme[tone] || colorScheme.default
|
|
42
|
+
const {layer: rootLayer, ...restTheme} = themeProp
|
|
43
|
+
|
|
36
44
|
const layer = rootLayer || DEFAULT_THEME_LAYER
|
|
37
45
|
|
|
38
|
-
return {sanity: {...restTheme,
|
|
39
|
-
}, [
|
|
46
|
+
return {sanity: {...restTheme, layer}}
|
|
47
|
+
}, [themeProp])
|
|
40
48
|
|
|
41
49
|
const value: ThemeContextValue | null = useMemo(
|
|
42
50
|
() =>
|
|
@@ -49,13 +57,24 @@ export function ThemeProvider(props: ThemeProviderProps): React.ReactElement {
|
|
|
49
57
|
[themeProp, scheme, tone],
|
|
50
58
|
)
|
|
51
59
|
|
|
60
|
+
const cssVariables = useMemo(() => {
|
|
61
|
+
if (!themeProp?.color.tones) return
|
|
62
|
+
|
|
63
|
+
return cssObjectToCssString(createCssVars(scheme, themeProp?.color.tones))
|
|
64
|
+
}, [scheme, themeProp?.color.tones])
|
|
65
|
+
|
|
52
66
|
if (!theme) {
|
|
53
67
|
return <pre>ThemeProvider: no "theme" property provided</pre>
|
|
54
68
|
}
|
|
55
69
|
|
|
56
70
|
return (
|
|
57
71
|
<ThemeContext.Provider value={value}>
|
|
58
|
-
<
|
|
72
|
+
<GlobalVariables $vars={cssVariables} />
|
|
73
|
+
<StyledThemeProvider theme={theme}>
|
|
74
|
+
<ToneProvider tone={tone} scheme={scheme}>
|
|
75
|
+
{children}
|
|
76
|
+
</ToneProvider>
|
|
77
|
+
</StyledThemeProvider>
|
|
59
78
|
</ThemeContext.Provider>
|
|
60
79
|
)
|
|
61
80
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {createContext} from 'react'
|
|
2
|
+
import {globalScope} from '../../lib/globalScope'
|
|
3
|
+
import {ToneContextValue} from './types'
|
|
4
|
+
|
|
5
|
+
const key = Symbol.for('@sanity/ui/context/toneContext')
|
|
6
|
+
|
|
7
|
+
globalScope[key] = globalScope[key] || createContext<ToneContextValue | null>(null)
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export const ToneContext: React.Context<ToneContextValue | null> = globalScope[key]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {useMemo} from 'react'
|
|
2
|
+
import {ThemeColorName, ThemeColorSchemeKey, useRootTheme} from '..'
|
|
3
|
+
import {ToneContext} from './toneContext'
|
|
4
|
+
import {ToneContextValue} from './types'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export interface ToneProviderProps {
|
|
10
|
+
children?: React.ReactNode
|
|
11
|
+
scheme?: ThemeColorSchemeKey
|
|
12
|
+
tone: ThemeColorName
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export function ToneProvider(props: ToneProviderProps): React.ReactElement {
|
|
19
|
+
const {children, scheme, tone} = props
|
|
20
|
+
const root = useRootTheme()
|
|
21
|
+
const value: ToneContextValue = useMemo(
|
|
22
|
+
() => ({
|
|
23
|
+
version: 0.0,
|
|
24
|
+
scheme: scheme || root.scheme,
|
|
25
|
+
tone,
|
|
26
|
+
}),
|
|
27
|
+
[root.scheme, scheme, tone],
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
return <ToneContext.Provider value={value}>{children}</ToneContext.Provider>
|
|
31
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import {useContext} from 'react'
|
|
3
|
+
|
|
4
|
+
import {isRecord} from '../../lib/isRecord'
|
|
5
|
+
import {ToneContext} from './toneContext'
|
|
6
|
+
import {ToneContextValue} from './types'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export function useToneContext(): ToneContextValue {
|
|
12
|
+
const value: unknown = useContext(ToneContext)
|
|
13
|
+
|
|
14
|
+
if (!value) {
|
|
15
|
+
throw new Error('useToneContext(): missing context value')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// NOTE: This check is for future-compatiblity
|
|
19
|
+
// - If the value is not an object, it’s not compatible with the current version
|
|
20
|
+
// - If the value is an object, but doesn’t have `version: 0.0`, it’s not compatible with the current version
|
|
21
|
+
if (!isRecord(value) || value.version !== 0.0) {
|
|
22
|
+
throw new Error('useToneContext(): the context value is not compatible')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return value as any as ToneContextValue
|
|
26
|
+
}
|
package/src/theme/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {CSSObject} from '../types/styled'
|
|
2
|
-
import {BaseTheme,
|
|
2
|
+
import {BaseTheme, ThemeColorName, ThemeColorSchemeKey} from './lib/theme'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @public
|
|
@@ -23,9 +23,7 @@ export interface Styles {
|
|
|
23
23
|
* @public
|
|
24
24
|
*/
|
|
25
25
|
export interface Theme {
|
|
26
|
-
sanity:
|
|
27
|
-
color: ThemeColor
|
|
28
|
-
}
|
|
26
|
+
sanity: RootTheme
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
/**
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import {Box, Card, ElementQuery, Text} from '@sanity/ui'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
|
+
import {mutableCardVariables} from '../../../theme/lib/theme/color/cssVariables/cardVariables'
|
|
3
4
|
|
|
4
5
|
const TestCard = styled(Card)`
|
|
5
|
-
|
|
6
|
+
${mutableCardVariables['fg-color']}: orange;
|
|
6
7
|
|
|
7
8
|
[data-eq-min~='0'] > & {
|
|
8
|
-
|
|
9
|
+
${mutableCardVariables['fg-color']}: green;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
[data-eq-min~='1'] > & {
|
|
12
|
-
|
|
13
|
+
${mutableCardVariables['fg-color']}: blue;
|
|
13
14
|
}
|
|
14
15
|
`
|
|
15
16
|
|
|
@@ -1,395 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Box,
|
|
3
|
-
Card,
|
|
4
|
-
CardTone,
|
|
5
|
-
Flex,
|
|
6
|
-
Grid,
|
|
7
|
-
Stack,
|
|
8
|
-
Text,
|
|
9
|
-
ThemeColor,
|
|
10
|
-
ThemeColorButton,
|
|
11
|
-
ThemeColorButtonState,
|
|
12
|
-
ThemeColorButtonStates,
|
|
13
|
-
ThemeColorButtonTones,
|
|
14
|
-
ThemeColorMuted,
|
|
15
|
-
ThemeColorMutedTone,
|
|
16
|
-
ThemeColorProvider,
|
|
17
|
-
ThemeColorScheme,
|
|
18
|
-
ThemeColorSelectable,
|
|
19
|
-
ThemeColorSelectableStates,
|
|
20
|
-
ThemeColorSolid,
|
|
21
|
-
ThemeColorSolidTone,
|
|
22
|
-
useRootTheme,
|
|
23
|
-
} from '@sanity/ui'
|
|
24
|
-
import {useBoolean} from '@sanity/ui-workshop'
|
|
25
|
-
import {createContext, useContext} from 'react'
|
|
26
|
-
import {ThemeColorCard} from '../lib/theme'
|
|
27
|
-
|
|
28
|
-
interface Features {
|
|
29
|
-
light: boolean
|
|
30
|
-
dark: boolean
|
|
31
|
-
|
|
32
|
-
base: boolean
|
|
33
|
-
button: boolean
|
|
34
|
-
card: boolean
|
|
35
|
-
input: boolean
|
|
36
|
-
muted: boolean
|
|
37
|
-
selectable: boolean
|
|
38
|
-
solid: boolean
|
|
39
|
-
spot: boolean
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const defaultFeatures: Features = {
|
|
43
|
-
light: true,
|
|
44
|
-
dark: false,
|
|
45
|
-
|
|
46
|
-
base: false,
|
|
47
|
-
button: false,
|
|
48
|
-
card: false,
|
|
49
|
-
input: false,
|
|
50
|
-
muted: true,
|
|
51
|
-
selectable: false,
|
|
52
|
-
solid: false,
|
|
53
|
-
spot: false,
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const FeaturesContext = createContext<Features>(defaultFeatures)
|
|
57
|
-
|
|
58
|
-
function useFeatures() {
|
|
59
|
-
return useContext(FeaturesContext)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export default function CanvasStory() {
|
|
63
|
-
const {theme} = useRootTheme()
|
|
64
|
-
const features: Features = {
|
|
65
|
-
...defaultFeatures,
|
|
66
|
-
light: useBoolean('Light', defaultFeatures.light, 'Props') ?? defaultFeatures.light,
|
|
67
|
-
dark: useBoolean('Dark', defaultFeatures.dark, 'Props') ?? defaultFeatures.dark,
|
|
68
|
-
base: useBoolean('Base', defaultFeatures.base, 'Props') ?? defaultFeatures.base,
|
|
69
|
-
button: useBoolean('Button', defaultFeatures.button, 'Props') ?? defaultFeatures.button,
|
|
70
|
-
card: useBoolean('Card', defaultFeatures.card, 'Props') ?? defaultFeatures.card,
|
|
71
|
-
input: useBoolean('Input', defaultFeatures.input, 'Props') ?? defaultFeatures.input,
|
|
72
|
-
muted: useBoolean('Muted', defaultFeatures.muted, 'Props') ?? defaultFeatures.muted,
|
|
73
|
-
selectable:
|
|
74
|
-
useBoolean('Selectable', defaultFeatures.selectable, 'Props') ?? defaultFeatures.selectable,
|
|
75
|
-
solid: useBoolean('Solid', defaultFeatures.solid, 'Props') ?? defaultFeatures.solid,
|
|
76
|
-
spot: useBoolean('Spot', defaultFeatures.spot, 'Props') ?? defaultFeatures.spot,
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<FeaturesContext.Provider value={features}>
|
|
81
|
-
<Flex>
|
|
82
|
-
{features.light && (
|
|
83
|
-
<ThemeColorProvider scheme="light">
|
|
84
|
-
<ColorScheme scheme={theme.color.light} />
|
|
85
|
-
</ThemeColorProvider>
|
|
86
|
-
)}
|
|
87
|
-
|
|
88
|
-
{features.dark && (
|
|
89
|
-
<ThemeColorProvider scheme="dark">
|
|
90
|
-
<ColorScheme scheme={theme.color.dark} />
|
|
91
|
-
</ThemeColorProvider>
|
|
92
|
-
)}
|
|
93
|
-
</Flex>
|
|
94
|
-
</FeaturesContext.Provider>
|
|
95
|
-
)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function ColorScheme(props: {scheme: ThemeColorScheme}) {
|
|
99
|
-
const {scheme} = props
|
|
100
|
-
|
|
101
|
-
return (
|
|
102
|
-
<Flex direction="column" flex={1}>
|
|
103
|
-
<Color color={scheme.default} tone="default" />
|
|
104
|
-
<Color color={scheme.transparent} tone="transparent" />
|
|
105
|
-
<Color color={scheme.primary} tone="primary" />
|
|
106
|
-
<Color color={scheme.positive} tone="positive" />
|
|
107
|
-
<Color color={scheme.caution} tone="caution" />
|
|
108
|
-
<Color color={scheme.critical} tone="critical" />
|
|
109
|
-
</Flex>
|
|
110
|
-
)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function Color(props: {color: ThemeColor; tone: CardTone}) {
|
|
114
|
-
const {color, tone} = props
|
|
115
|
-
const features = useFeatures()
|
|
116
|
-
|
|
117
|
-
return (
|
|
118
|
-
<Card padding={[3, 4]} tone={tone}>
|
|
119
|
-
<Stack
|
|
120
|
-
space={[3, 4]}
|
|
121
|
-
// style={{outline: '1px solid #ccc'}}
|
|
122
|
-
>
|
|
123
|
-
{features.base && (
|
|
124
|
-
<Stack
|
|
125
|
-
padding={3}
|
|
126
|
-
space={2}
|
|
127
|
-
style={{
|
|
128
|
-
borderRadius: 3,
|
|
129
|
-
boxShadow: `inset 0 0 0 1px ${color.base.border}`,
|
|
130
|
-
}}
|
|
131
|
-
>
|
|
132
|
-
<Text>Text</Text>
|
|
133
|
-
<Text muted>Muted</Text>
|
|
134
|
-
<Text accent>Accent</Text>
|
|
135
|
-
<Text>
|
|
136
|
-
<a href="#">Link</a>
|
|
137
|
-
</Text>
|
|
138
|
-
<Text>
|
|
139
|
-
<code>Code</code>
|
|
140
|
-
</Text>
|
|
141
|
-
<div
|
|
142
|
-
style={{
|
|
143
|
-
height: 9,
|
|
144
|
-
background: `linear-gradient(to right, ${color.base.skeleton?.from}, ${color.base.skeleton?.to})`,
|
|
145
|
-
}}
|
|
146
|
-
/>
|
|
147
|
-
</Stack>
|
|
148
|
-
)}
|
|
149
|
-
|
|
150
|
-
{features.button && <ColorButton color={color.button} />}
|
|
151
|
-
|
|
152
|
-
{features.card && <ColorCard color={color.card} />}
|
|
153
|
-
|
|
154
|
-
{features.input && (
|
|
155
|
-
<Box padding={2} style={{backgroundColor: color.input.default.enabled.bg}}>
|
|
156
|
-
<Text style={{color: 'inherit'}}>Input</Text>
|
|
157
|
-
</Box>
|
|
158
|
-
)}
|
|
159
|
-
|
|
160
|
-
{features.muted && <ColorMuted color={color.muted} />}
|
|
161
|
-
|
|
162
|
-
{/* @todo: remove use of `muted` here */}
|
|
163
|
-
{features.selectable && <ColorSelectable color={color.selectable || color.muted} />}
|
|
164
|
-
|
|
165
|
-
{features.solid && <ColorSolid color={color.solid} />}
|
|
166
|
-
|
|
167
|
-
{features.spot && (
|
|
168
|
-
<Flex gap={1}>
|
|
169
|
-
<Box flex={1} style={{backgroundColor: color.spot.blue, width: 25, height: 25}} />
|
|
170
|
-
<Box flex={1} style={{backgroundColor: color.spot.purple, width: 25, height: 25}} />
|
|
171
|
-
<Box flex={1} style={{backgroundColor: color.spot.magenta, width: 25, height: 25}} />
|
|
172
|
-
<Box flex={1} style={{backgroundColor: color.spot.red, width: 25, height: 25}} />
|
|
173
|
-
<Box flex={1} style={{backgroundColor: color.spot.yellow, width: 25, height: 25}} />
|
|
174
|
-
<Box flex={1} style={{backgroundColor: color.spot.green, width: 25, height: 25}} />
|
|
175
|
-
<Box flex={1} style={{backgroundColor: color.spot.cyan, width: 25, height: 25}} />
|
|
176
|
-
<Box flex={1} style={{backgroundColor: color.spot.gray, width: 25, height: 25}} />
|
|
177
|
-
</Flex>
|
|
178
|
-
)}
|
|
179
|
-
</Stack>
|
|
180
|
-
</Card>
|
|
181
|
-
)
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
function ColorCard(props: {color: ThemeColorCard}) {
|
|
185
|
-
const {color} = props
|
|
186
|
-
|
|
187
|
-
return (
|
|
188
|
-
<Box style={{backgroundColor: color.enabled.bg}}>
|
|
189
|
-
<ColorGenericStates color={color} />
|
|
190
|
-
</Box>
|
|
191
|
-
)
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function ColorButton(props: {color: ThemeColorButton}) {
|
|
195
|
-
const {color} = props
|
|
196
|
-
|
|
197
|
-
return (
|
|
198
|
-
<Stack space={3}>
|
|
199
|
-
<ColorButtonMode color={color.default} />
|
|
200
|
-
<ColorButtonMode color={color.ghost} />
|
|
201
|
-
<ColorButtonMode color={color.bleed} />
|
|
202
|
-
</Stack>
|
|
203
|
-
)
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
function ColorButtonMode(props: {color: ThemeColorButtonTones}) {
|
|
207
|
-
const {color} = props
|
|
208
|
-
|
|
209
|
-
return (
|
|
210
|
-
<Stack space={1}>
|
|
211
|
-
<Grid columns={5} marginBottom={1} gap={1}>
|
|
212
|
-
<Box>
|
|
213
|
-
<Text align="center" muted size={1}>
|
|
214
|
-
Enabled
|
|
215
|
-
</Text>
|
|
216
|
-
</Box>
|
|
217
|
-
<Box>
|
|
218
|
-
<Text align="center" muted size={1}>
|
|
219
|
-
Hovered
|
|
220
|
-
</Text>
|
|
221
|
-
</Box>
|
|
222
|
-
<Box>
|
|
223
|
-
<Text align="center" muted size={1}>
|
|
224
|
-
Pressed
|
|
225
|
-
</Text>
|
|
226
|
-
</Box>
|
|
227
|
-
<Box>
|
|
228
|
-
<Text align="center" muted size={1}>
|
|
229
|
-
Selected
|
|
230
|
-
</Text>
|
|
231
|
-
</Box>
|
|
232
|
-
<Box>
|
|
233
|
-
<Text align="center" muted size={1}>
|
|
234
|
-
Disabled
|
|
235
|
-
</Text>
|
|
236
|
-
</Box>
|
|
237
|
-
</Grid>
|
|
238
|
-
<ColorGenericStates color={color.default} />
|
|
239
|
-
<ColorGenericStates color={color.primary} />
|
|
240
|
-
<ColorGenericStates color={color.positive} />
|
|
241
|
-
<ColorGenericStates color={color.caution} />
|
|
242
|
-
<ColorGenericStates color={color.critical} />
|
|
243
|
-
</Stack>
|
|
244
|
-
)
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
function ColorGenericStates(props: {color: ThemeColorButtonStates}) {
|
|
248
|
-
const {color} = props
|
|
249
|
-
|
|
250
|
-
return (
|
|
251
|
-
<Grid columns={5} gap={1}>
|
|
252
|
-
<ColorGenericState color={color.enabled} />
|
|
253
|
-
<ColorGenericState color={color.hovered} />
|
|
254
|
-
<ColorGenericState color={color.pressed} />
|
|
255
|
-
<ColorGenericState color={color.selected} />
|
|
256
|
-
<ColorGenericState color={color.disabled} />
|
|
257
|
-
</Grid>
|
|
258
|
-
)
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
function ColorGenericState(props: {color: ThemeColorButtonState}) {
|
|
262
|
-
const {color} = props
|
|
263
|
-
|
|
264
|
-
return (
|
|
265
|
-
<Stack
|
|
266
|
-
padding={2}
|
|
267
|
-
space={2}
|
|
268
|
-
style={{
|
|
269
|
-
backgroundColor: color.bg,
|
|
270
|
-
color: color.fg,
|
|
271
|
-
border: `1px solid ${color.border}`,
|
|
272
|
-
borderRadius: 3,
|
|
273
|
-
}}
|
|
274
|
-
>
|
|
275
|
-
<Flex style={{border: `1px solid ${color.border}`}}>
|
|
276
|
-
<Box flex={1} padding={3} style={{backgroundColor: color.bg}}>
|
|
277
|
-
<Text align="center" size={1} style={{color: 'inherit'}}>
|
|
278
|
-
bg
|
|
279
|
-
</Text>
|
|
280
|
-
</Box>
|
|
281
|
-
<Box flex={1} padding={3} style={{backgroundColor: color.bg2}}>
|
|
282
|
-
<Text align="center" size={1} style={{color: 'inherit'}}>
|
|
283
|
-
bg2
|
|
284
|
-
</Text>
|
|
285
|
-
</Box>
|
|
286
|
-
</Flex>
|
|
287
|
-
|
|
288
|
-
<Text align="center" style={{color: 'inherit'}}>
|
|
289
|
-
Text
|
|
290
|
-
</Text>
|
|
291
|
-
<Text align="center" size={1} style={{color: color.muted.fg}}>
|
|
292
|
-
Muted
|
|
293
|
-
</Text>
|
|
294
|
-
<Text align="center" size={1} style={{color: color.link.fg}}>
|
|
295
|
-
Link
|
|
296
|
-
</Text>
|
|
297
|
-
<Text align="center" size={1} style={{color: color.accent.fg}}>
|
|
298
|
-
Accent
|
|
299
|
-
</Text>
|
|
300
|
-
<Text align="center" size={1} style={{color: color.code.fg}}>
|
|
301
|
-
<span style={{backgroundColor: color.code.bg}}>Code</span>
|
|
302
|
-
</Text>
|
|
303
|
-
<div
|
|
304
|
-
style={{
|
|
305
|
-
height: 9,
|
|
306
|
-
background: `linear-gradient(to right, ${color.skeleton?.from}, ${color.skeleton?.to})`,
|
|
307
|
-
}}
|
|
308
|
-
/>
|
|
309
|
-
</Stack>
|
|
310
|
-
)
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
function ColorMuted(props: {color: ThemeColorMuted}) {
|
|
314
|
-
const {color} = props
|
|
315
|
-
|
|
316
|
-
return (
|
|
317
|
-
<Stack space={1}>
|
|
318
|
-
<ColorMutedTone color={color.default} />
|
|
319
|
-
<ColorMutedTone color={color.primary} />
|
|
320
|
-
<ColorMutedTone color={color.positive} />
|
|
321
|
-
<ColorMutedTone color={color.caution} />
|
|
322
|
-
<ColorMutedTone color={color.critical} />
|
|
323
|
-
</Stack>
|
|
324
|
-
)
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
function ColorMutedTone(props: {color: ThemeColorMutedTone}) {
|
|
328
|
-
const {color} = props
|
|
329
|
-
|
|
330
|
-
return (
|
|
331
|
-
<Grid columns={5} gap={1}>
|
|
332
|
-
<ColorGenericState color={color.enabled} />
|
|
333
|
-
<ColorGenericState color={color.hovered} />
|
|
334
|
-
<ColorGenericState color={color.pressed} />
|
|
335
|
-
<ColorGenericState color={color.selected} />
|
|
336
|
-
<ColorGenericState color={color.disabled} />
|
|
337
|
-
</Grid>
|
|
338
|
-
)
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
function ColorSolid(props: {color: ThemeColorSolid}) {
|
|
342
|
-
const {color} = props
|
|
343
|
-
|
|
344
|
-
return (
|
|
345
|
-
<Stack space={1}>
|
|
346
|
-
<ColorSolidTone color={color.default} />
|
|
347
|
-
<ColorSolidTone color={color.primary} />
|
|
348
|
-
<ColorSolidTone color={color.positive} />
|
|
349
|
-
<ColorSolidTone color={color.caution} />
|
|
350
|
-
<ColorSolidTone color={color.critical} />
|
|
351
|
-
</Stack>
|
|
352
|
-
)
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
function ColorSolidTone(props: {color: ThemeColorSolidTone}) {
|
|
356
|
-
const {color} = props
|
|
357
|
-
|
|
358
|
-
return (
|
|
359
|
-
<Grid columns={5} gap={1}>
|
|
360
|
-
<ColorGenericState color={color.enabled} />
|
|
361
|
-
<ColorGenericState color={color.hovered} />
|
|
362
|
-
<ColorGenericState color={color.pressed} />
|
|
363
|
-
<ColorGenericState color={color.selected} />
|
|
364
|
-
<ColorGenericState color={color.disabled} />
|
|
365
|
-
</Grid>
|
|
366
|
-
)
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
function ColorSelectable(props: {color: ThemeColorSelectable}) {
|
|
370
|
-
const {color} = props
|
|
371
|
-
|
|
372
|
-
return (
|
|
373
|
-
<Stack space={1}>
|
|
374
|
-
<ColorSelectableTone color={color.default} />
|
|
375
|
-
<ColorSelectableTone color={color.primary} />
|
|
376
|
-
<ColorSelectableTone color={color.positive} />
|
|
377
|
-
<ColorSelectableTone color={color.caution} />
|
|
378
|
-
<ColorSelectableTone color={color.critical} />
|
|
379
|
-
</Stack>
|
|
380
|
-
)
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
function ColorSelectableTone(props: {color: ThemeColorSelectableStates}) {
|
|
384
|
-
const {color} = props
|
|
385
|
-
|
|
386
|
-
return (
|
|
387
|
-
<Grid columns={5} gap={1}>
|
|
388
|
-
<ColorGenericState color={color.enabled} />
|
|
389
|
-
<ColorGenericState color={color.hovered} />
|
|
390
|
-
<ColorGenericState color={color.pressed} />
|
|
391
|
-
<ColorGenericState color={color.selected} />
|
|
392
|
-
<ColorGenericState color={color.disabled} />
|
|
393
|
-
</Grid>
|
|
394
|
-
)
|
|
395
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './types'
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @public
|
|
3
|
-
*/
|
|
4
|
-
export interface ThemeColorGenericState {
|
|
5
|
-
bg: string
|
|
6
|
-
/**
|
|
7
|
-
* @beta
|
|
8
|
-
*/
|
|
9
|
-
bg2?: string
|
|
10
|
-
border: string
|
|
11
|
-
fg: string
|
|
12
|
-
iconColor: string
|
|
13
|
-
muted: {
|
|
14
|
-
fg: string
|
|
15
|
-
}
|
|
16
|
-
accent: {
|
|
17
|
-
fg: string
|
|
18
|
-
}
|
|
19
|
-
link: {
|
|
20
|
-
fg: string
|
|
21
|
-
}
|
|
22
|
-
code: {
|
|
23
|
-
bg: string
|
|
24
|
-
fg: string
|
|
25
|
-
}
|
|
26
|
-
skeleton?: {
|
|
27
|
-
from: string
|
|
28
|
-
to: string
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './types'
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @public
|
|
3
|
-
*/
|
|
4
|
-
export interface ThemeColorBase {
|
|
5
|
-
bg: string
|
|
6
|
-
fg: string
|
|
7
|
-
border: string
|
|
8
|
-
focusRing: string
|
|
9
|
-
shadow: {
|
|
10
|
-
outline: string
|
|
11
|
-
umbra: string
|
|
12
|
-
penumbra: string
|
|
13
|
-
ambient: string
|
|
14
|
-
}
|
|
15
|
-
skeleton?: {
|
|
16
|
-
from: string
|
|
17
|
-
to: string
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import {ThemeColorBase} from '../base'
|
|
2
|
-
import {ThemeColorBuilderOpts} from '../factory'
|
|
3
|
-
import {ThemeColorMuted} from '../muted'
|
|
4
|
-
import {ThemeColorSolid} from '../solid'
|
|
5
|
-
import {createButtonTones} from './createButtonTones'
|
|
6
|
-
import {ThemeColorButton} from './types'
|
|
7
|
-
|
|
8
|
-
export function createButtonModes(
|
|
9
|
-
opts: ThemeColorBuilderOpts,
|
|
10
|
-
base: ThemeColorBase,
|
|
11
|
-
dark: boolean,
|
|
12
|
-
solid: ThemeColorSolid,
|
|
13
|
-
muted: ThemeColorMuted,
|
|
14
|
-
): ThemeColorButton {
|
|
15
|
-
return {
|
|
16
|
-
default: createButtonTones(opts, base, dark, solid, muted, 'default'),
|
|
17
|
-
ghost: createButtonTones(opts, base, dark, solid, muted, 'ghost'),
|
|
18
|
-
bleed: createButtonTones(opts, base, dark, solid, muted, 'bleed'),
|
|
19
|
-
}
|
|
20
|
-
}
|