@sanity/ui 2.9.0-canary.6 → 2.9.0
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/_chunks-cjs/getTheme_v2.js +26 -0
- package/dist/_chunks-cjs/getTheme_v2.js.map +1 -1
- package/dist/_chunks-es/getTheme_v2.mjs +26 -0
- package/dist/_chunks-es/getTheme_v2.mjs.map +1 -1
- package/dist/_legacy/getTheme_v2.esm.js +26 -0
- package/dist/_legacy/getTheme_v2.esm.js.map +1 -1
- package/dist/index.esm.js +652 -1048
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +651 -1047
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +652 -1048
- package/dist/index.mjs.map +1 -1
- package/dist/theme.d.mts +22 -28
- package/dist/theme.d.ts +22 -28
- package/dist/theme.esm.js +124 -260
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +124 -260
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +124 -260
- package/dist/theme.mjs.map +1 -1
- package/package.json +60 -53
- package/src/core/__workshop__/constants.ts +27 -31
- package/src/core/components/autocomplete/autocomplete.tsx +31 -42
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +47 -35
- package/src/core/components/dialog/dialog.tsx +1 -1
- package/src/core/components/menu/__workshop__/tones.tsx +5 -6
- package/src/core/components/menu/useMenuController.ts +21 -18
- package/src/core/components/toast/__workshop__/hook.tsx +1 -1
- package/src/core/components/toast/toast.tsx +2 -2
- package/src/core/components/tree/treeItem.tsx +15 -18
- package/src/core/hooks/useElementRect/__workshop__/example.tsx +2 -2
- package/src/core/hooks/useMatchMedia.ts +22 -12
- package/src/core/primitives/badge/__workshop__/tones.tsx +6 -13
- package/src/core/primitives/button/__workshop__/custom.tsx +4 -3
- package/src/core/primitives/card/__workshop__/allTones.tsx +6 -8
- package/src/core/primitives/card/__workshop__/asButton.tsx +42 -24
- package/src/core/primitives/card/__workshop__/asComponent.tsx +1 -1
- package/src/core/primitives/card/__workshop__/checkered.tsx +17 -7
- package/src/core/primitives/card/__workshop__/interactive.tsx +10 -3
- package/src/core/primitives/card/__workshop__/listNavigation.tsx +5 -3
- package/src/core/primitives/card/__workshop__/props.tsx +7 -5
- package/src/core/primitives/card/__workshop__/selected.tsx +4 -1
- package/src/core/primitives/checkbox/__workshop__/tones.tsx +6 -0
- package/src/core/primitives/code/__workshop__/props.tsx +1 -1
- package/src/core/primitives/container/__workshop__/example.tsx +1 -1
- package/src/core/primitives/flex/__workshop__/example.tsx +3 -3
- package/src/core/primitives/grid/__workshop__/responsive.tsx +12 -12
- package/src/core/primitives/heading/__workshop__/opticalAlignment.tsx +13 -25
- package/src/core/primitives/inline/__workshop__/plain.tsx +3 -3
- package/src/core/primitives/label/__workshop__/opticalAlignment.tsx +6 -6
- package/src/core/primitives/popover/__workshop__/AlignedStory.tsx +1 -1
- package/src/core/primitives/popover/__workshop__/MatchReferenceWidthStory.tsx +3 -3
- package/src/core/primitives/popover/__workshop__/OpenOnMountStory.tsx +1 -1
- package/src/core/primitives/popover/__workshop__/PlainStory.tsx +1 -1
- package/src/core/primitives/popover/popover.tsx +140 -74
- package/src/core/primitives/popover/popoverCard.tsx +4 -1
- package/src/core/primitives/radio/__workshop__/plain.tsx +2 -2
- package/src/core/primitives/select/__workshop__/readOnly.tsx +1 -1
- package/src/core/primitives/text/__workshop__/example.tsx +6 -6
- package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +11 -21
- package/src/core/primitives/textArea/__workshop__/plain.tsx +1 -1
- package/src/core/primitives/textInput/__workshop__/index.ts +0 -5
- package/src/core/primitives/textInput/__workshop__/plain.tsx +1 -2
- package/src/core/primitives/textInput/__workshop__/readOnly.tsx +6 -2
- package/src/core/primitives/textInput/__workshop__/tones.tsx +38 -0
- package/src/core/primitives/tooltip/tooltip.tsx +17 -47
- package/src/core/styles/card/_cardColorStyle.ts +8 -0
- package/src/core/theme/__workshop__/debug/story.tsx +18 -11
- package/src/core/utils/portal/portalProvider.tsx +5 -5
- package/src/theme/build/_deprecated/color/factory.ts +1 -1
- package/src/theme/build/_deprecated/color/muted/createMuted.ts +2 -2
- package/src/theme/build/buildColorTheme.ts +47 -37
- package/src/theme/build/renderColorTheme.ts +26 -30
- package/src/theme/build/resolveColorTokens.ts +51 -115
- package/src/theme/config/tokens/color/types.ts +4 -18
- package/src/theme/defaults/colorTokens.ts +8 -5
- package/src/theme/getScopedTheme.ts +9 -2
- package/src/theme/system/color/_constants.ts +6 -2
- package/src/theme/system/color/badge.ts +3 -7
- package/src/theme/system/v0/color/_system.ts +8 -4
- package/src/theme/system/v0/color/color.ts +3 -2
- package/src/theme/versioning/themeColor_v0_v2.ts +26 -0
- package/src/theme/versioning/v0_v2.ts +4 -0
- package/src/core/primitives/textInput/__workshop__/multipleTones.tsx +0 -20
|
@@ -36,28 +36,31 @@ export function useMenuController(props: {
|
|
|
36
36
|
activeIndexRef.current = nextActiveIndex
|
|
37
37
|
}, [])
|
|
38
38
|
|
|
39
|
-
const mount = (
|
|
40
|
-
|
|
39
|
+
const mount = useCallback(
|
|
40
|
+
(element: HTMLElement | null, selected?: boolean): (() => void) => {
|
|
41
|
+
if (!element) return () => undefined
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
if (elementsRef.current.indexOf(element) === -1) {
|
|
44
|
+
elementsRef.current.push(element)
|
|
45
|
+
_sortElements(rootElementRef.current, elementsRef.current)
|
|
46
|
+
}
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
if (selected) {
|
|
49
|
+
const selectedIndex = elementsRef.current.indexOf(element)
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
setActiveIndex(selectedIndex)
|
|
52
|
+
}
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
return () => {
|
|
55
|
+
const idx = elementsRef.current.indexOf(element)
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
if (idx > -1) {
|
|
58
|
+
elementsRef.current.splice(idx, 1)
|
|
59
|
+
}
|
|
58
60
|
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
+
},
|
|
62
|
+
[rootElementRef, setActiveIndex],
|
|
63
|
+
)
|
|
61
64
|
|
|
62
65
|
const handleKeyDown = useCallback(
|
|
63
66
|
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
@@ -167,7 +170,7 @@ export function useMenuController(props: {
|
|
|
167
170
|
[setActiveIndex],
|
|
168
171
|
)
|
|
169
172
|
|
|
170
|
-
const handleItemMouseLeave = () => {
|
|
173
|
+
const handleItemMouseLeave = useCallback(() => {
|
|
171
174
|
// Set the active index to -2 to deactivate all menu items
|
|
172
175
|
// when the user moves the mouse away from the menu item.
|
|
173
176
|
// We avoid using -1 because it would focus the first menu item,
|
|
@@ -175,7 +178,7 @@ export function useMenuController(props: {
|
|
|
175
178
|
// between two menu items or a menu divider.
|
|
176
179
|
setActiveIndex(-2)
|
|
177
180
|
rootElementRef.current?.focus()
|
|
178
|
-
}
|
|
181
|
+
}, [rootElementRef, setActiveIndex])
|
|
179
182
|
|
|
180
183
|
// Set focus on the currently active element
|
|
181
184
|
useEffect(() => {
|
|
@@ -23,14 +23,14 @@ const STATUS_CARD_TONE: {[key: string]: ThemeColorStateToneKey} = {
|
|
|
23
23
|
error: 'critical',
|
|
24
24
|
warning: 'caution',
|
|
25
25
|
success: 'positive',
|
|
26
|
-
info: '
|
|
26
|
+
info: 'neutral',
|
|
27
27
|
} as const
|
|
28
28
|
|
|
29
29
|
const BUTTON_TONE = {
|
|
30
30
|
error: 'critical',
|
|
31
31
|
warning: 'caution',
|
|
32
32
|
success: 'positive',
|
|
33
|
-
info: '
|
|
33
|
+
info: 'neutral',
|
|
34
34
|
} satisfies {[key: string]: ButtonTone}
|
|
35
35
|
|
|
36
36
|
const ROLES = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {ToggleArrowRightIcon} from '@sanity/icons'
|
|
2
2
|
import {ThemeFontWeightKey} from '@sanity/ui/theme'
|
|
3
|
-
import {memo, useCallback, useEffect, useId, useMemo, useRef
|
|
3
|
+
import {memo, useCallback, useEffect, useId, useMemo, useRef} from 'react'
|
|
4
4
|
import {styled} from 'styled-components'
|
|
5
5
|
import {Box, BoxProps, Flex, Text} from '../../primitives'
|
|
6
6
|
import {
|
|
@@ -64,21 +64,18 @@ export const TreeItem = memo(function TreeItem(
|
|
|
64
64
|
weight,
|
|
65
65
|
...restProps
|
|
66
66
|
} = props
|
|
67
|
-
const
|
|
67
|
+
const rootRef = useRef<HTMLLIElement | null>(null)
|
|
68
68
|
const treeitemRef = useRef<HTMLDivElement | null>(null)
|
|
69
69
|
const tree = useTree()
|
|
70
70
|
const {path, registerItem, setExpanded, setFocusedElement} = tree
|
|
71
71
|
const _id = useId()
|
|
72
72
|
const id = idProp || _id
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return [result, result.join('/')]
|
|
77
|
-
}, [id, path])
|
|
73
|
+
const itemPath = useMemo(() => path.concat([id || '']), [id, path])
|
|
74
|
+
const itemKey = itemPath.join('/')
|
|
78
75
|
const itemState = tree.state[itemKey]
|
|
79
|
-
const focused = tree.focusedElement ===
|
|
76
|
+
const focused = tree.focusedElement === rootRef.current
|
|
80
77
|
const expanded = itemState?.expanded === undefined ? expandedProp : itemState?.expanded || false
|
|
81
|
-
const tabIndex = tree.focusedElement && tree.focusedElement ===
|
|
78
|
+
const tabIndex = tree.focusedElement && tree.focusedElement === rootRef.current ? 0 : -1
|
|
82
79
|
const contextValue = useMemo(
|
|
83
80
|
() => ({...tree, level: tree.level + 1, path: itemPath}),
|
|
84
81
|
[itemPath, tree],
|
|
@@ -97,28 +94,28 @@ export const TreeItem = memo(function TreeItem(
|
|
|
97
94
|
) {
|
|
98
95
|
event.stopPropagation()
|
|
99
96
|
setExpanded(itemKey, !expanded)
|
|
100
|
-
setFocusedElement(
|
|
97
|
+
setFocusedElement(rootRef.current)
|
|
101
98
|
}
|
|
102
99
|
},
|
|
103
|
-
[expanded, itemKey, onClick,
|
|
100
|
+
[expanded, itemKey, onClick, setExpanded, setFocusedElement],
|
|
104
101
|
)
|
|
105
102
|
|
|
106
103
|
const handleKeyDown = useCallback(
|
|
107
104
|
(event: React.KeyboardEvent<HTMLElement>) => {
|
|
108
105
|
if (focused && event.key === 'Enter') {
|
|
109
|
-
const el = treeitemRef.current ||
|
|
106
|
+
const el = treeitemRef.current || rootRef.current
|
|
110
107
|
|
|
111
108
|
el?.click()
|
|
112
109
|
}
|
|
113
110
|
},
|
|
114
|
-
[focused
|
|
111
|
+
[focused],
|
|
115
112
|
)
|
|
116
113
|
|
|
117
114
|
useEffect(() => {
|
|
118
|
-
if (!
|
|
115
|
+
if (!rootRef.current) return
|
|
119
116
|
|
|
120
|
-
return registerItem(
|
|
121
|
-
}, [expanded, itemPath, registerItem,
|
|
117
|
+
return registerItem(rootRef.current, itemPath.join('/'), expanded, selected)
|
|
118
|
+
}, [expanded, itemPath, registerItem, selected])
|
|
122
119
|
|
|
123
120
|
const content = (
|
|
124
121
|
<Flex padding={padding}>
|
|
@@ -157,7 +154,7 @@ export const TreeItem = memo(function TreeItem(
|
|
|
157
154
|
data-ui="TreeItem"
|
|
158
155
|
{...restProps}
|
|
159
156
|
onClick={handleClick}
|
|
160
|
-
ref={
|
|
157
|
+
ref={rootRef}
|
|
161
158
|
role="none"
|
|
162
159
|
>
|
|
163
160
|
<TreeItemBox
|
|
@@ -190,7 +187,7 @@ export const TreeItem = memo(function TreeItem(
|
|
|
190
187
|
aria-expanded={expanded}
|
|
191
188
|
onClick={handleClick}
|
|
192
189
|
onKeyDown={handleKeyDown}
|
|
193
|
-
ref={
|
|
190
|
+
ref={rootRef}
|
|
194
191
|
role="treeitem"
|
|
195
192
|
tabIndex={tabIndex}
|
|
196
193
|
>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {Box, Card, Code, Container, Stack, Text, useElementRect} from '@sanity/ui'
|
|
2
|
-
import {
|
|
2
|
+
import {useState} from 'react'
|
|
3
3
|
import {Grid} from '../../../primitives'
|
|
4
4
|
|
|
5
5
|
export default function ExampleStory() {
|
|
6
6
|
const [element, setElement] = useState<HTMLElement | null>(null)
|
|
7
7
|
const rect = useElementRect(element)
|
|
8
|
-
const size =
|
|
8
|
+
const size = {width: rect?.width || 0, height: rect?.height || 0}
|
|
9
9
|
|
|
10
10
|
return (
|
|
11
11
|
<Box padding={[3, 4, 5]}>
|
|
@@ -11,24 +11,34 @@ export function useMatchMedia(
|
|
|
11
11
|
mediaQueryString: `(${string})`,
|
|
12
12
|
getServerSnapshot?: () => boolean,
|
|
13
13
|
): boolean {
|
|
14
|
-
/**
|
|
15
|
-
* `subscribe` and `getSnapshot` are only called on the client and both need access to the same `matchMedia` instance
|
|
16
|
-
* we don't want to eagerly instantiate it to ensure it's only created when actually used
|
|
17
|
-
*/
|
|
18
|
-
const cachedMatchMedia = useMemo(
|
|
19
|
-
() => (typeof window === 'undefined' ? null : window.matchMedia(mediaQueryString)),
|
|
20
|
-
[mediaQueryString],
|
|
21
|
-
)
|
|
22
14
|
const {subscribe, getSnapshot} = useMemo(() => {
|
|
15
|
+
/**
|
|
16
|
+
* `subscribe` and `getSnapshot` are only called on the client and both need access to the same `matchMedia` instance
|
|
17
|
+
* we don't want to eagerly instantiate it to ensure it's only created when actually used
|
|
18
|
+
*/
|
|
19
|
+
let MEDIA_QUERY_CACHE: MediaQueryList | undefined
|
|
20
|
+
|
|
21
|
+
const getMatchMedia = (): MediaQueryList => {
|
|
22
|
+
if (!MEDIA_QUERY_CACHE) {
|
|
23
|
+
// As this function is only called during `subscribe` and `getSnapshot`, we can assume that the
|
|
24
|
+
// the `window` global is available and we're in a browser environment
|
|
25
|
+
MEDIA_QUERY_CACHE = window.matchMedia(mediaQueryString)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return MEDIA_QUERY_CACHE
|
|
29
|
+
}
|
|
30
|
+
|
|
23
31
|
return {
|
|
24
32
|
subscribe: (onStoreChange: () => void): (() => void) => {
|
|
25
|
-
|
|
33
|
+
const matchMedia = getMatchMedia()
|
|
34
|
+
|
|
35
|
+
matchMedia.addEventListener('change', onStoreChange)
|
|
26
36
|
|
|
27
|
-
return () =>
|
|
37
|
+
return () => matchMedia.removeEventListener('change', onStoreChange)
|
|
28
38
|
},
|
|
29
|
-
getSnapshot: () =>
|
|
39
|
+
getSnapshot: () => getMatchMedia().matches,
|
|
30
40
|
}
|
|
31
|
-
}, [
|
|
41
|
+
}, [mediaQueryString])
|
|
32
42
|
|
|
33
43
|
useDebugValue(mediaQueryString)
|
|
34
44
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {Badge, Flex, Inline} from '@sanity/ui'
|
|
2
|
+
import {THEME_COLOR_STATE_TONES} from '@sanity/ui/theme'
|
|
2
3
|
import {useSelect} from '@sanity/ui-workshop'
|
|
3
4
|
import {WORKSHOP_BADGE_MODE_OPTIONS} from '../../../__workshop__/constants'
|
|
4
5
|
|
|
@@ -8,19 +9,11 @@ export default function Tones() {
|
|
|
8
9
|
return (
|
|
9
10
|
<Flex align="center" height="fill" justify="center" padding={4} sizing="border">
|
|
10
11
|
<Inline space={2}>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
Positive
|
|
17
|
-
</Badge>
|
|
18
|
-
<Badge mode={mode} tone="caution">
|
|
19
|
-
Caution
|
|
20
|
-
</Badge>
|
|
21
|
-
<Badge mode={mode} tone="critical">
|
|
22
|
-
Critical
|
|
23
|
-
</Badge>
|
|
12
|
+
{THEME_COLOR_STATE_TONES.map((tone) => (
|
|
13
|
+
<Badge key={tone} mode={mode} tone={tone}>
|
|
14
|
+
{tone}
|
|
15
|
+
</Badge>
|
|
16
|
+
))}
|
|
24
17
|
</Inline>
|
|
25
18
|
</Flex>
|
|
26
19
|
)
|
|
@@ -3,11 +3,12 @@ import {WORKSHOP_BUTTON_TONE_OPTIONS} from '../../../__workshop__/constants'
|
|
|
3
3
|
|
|
4
4
|
export default function CustomStory() {
|
|
5
5
|
const tones = Object.entries(WORKSHOP_BUTTON_TONE_OPTIONS)
|
|
6
|
+
const len = tones.length
|
|
6
7
|
|
|
7
8
|
return (
|
|
8
|
-
<Flex align="center" height="fill" justify="center">
|
|
9
|
+
<Flex align="center" height="fill" justify="center" padding={4} sizing="border">
|
|
9
10
|
<Stack space={2}>
|
|
10
|
-
<Grid columns={
|
|
11
|
+
<Grid columns={len} gap={1}>
|
|
11
12
|
{tones.map(([title, tone]) => (
|
|
12
13
|
<Button key={tone} mode="ghost" padding={3} tone={tone}>
|
|
13
14
|
<Stack space={2}>
|
|
@@ -24,7 +25,7 @@ export default function CustomStory() {
|
|
|
24
25
|
</Button>
|
|
25
26
|
))}
|
|
26
27
|
</Grid>
|
|
27
|
-
<Grid columns={
|
|
28
|
+
<Grid columns={len} gap={1}>
|
|
28
29
|
{tones.map(([title, tone]) => (
|
|
29
30
|
<Button key={tone} mode="default" padding={3} tone={tone}>
|
|
30
31
|
<Stack space={2}>
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import {Card, Container, Flex, Stack, Text} from '@sanity/ui'
|
|
2
|
-
import {
|
|
2
|
+
import {THEME_COLOR_CARD_TONES} from '@sanity/ui/theme'
|
|
3
3
|
|
|
4
4
|
export default function AllTonesStory() {
|
|
5
|
-
const tones = Object.entries(WORKSHOP_CARD_TONE_OPTIONS)
|
|
6
|
-
|
|
7
5
|
return (
|
|
8
6
|
<Flex align="center" height="fill" justify="center" padding={[4, 5, 6]} sizing="border">
|
|
9
7
|
<Container width={0}>
|
|
10
|
-
<Stack space={
|
|
11
|
-
{
|
|
8
|
+
<Stack space={3}>
|
|
9
|
+
{THEME_COLOR_CARD_TONES.map((tone) => (
|
|
12
10
|
<Card
|
|
13
11
|
key={tone}
|
|
14
|
-
padding={
|
|
12
|
+
padding={3}
|
|
15
13
|
radius={2}
|
|
16
|
-
shadow={
|
|
14
|
+
shadow={2}
|
|
17
15
|
style={{textAlign: 'center'}}
|
|
18
16
|
tone={tone}
|
|
19
17
|
>
|
|
20
|
-
<Text>{
|
|
18
|
+
<Text size={1}>{tone}</Text>
|
|
21
19
|
</Card>
|
|
22
20
|
))}
|
|
23
21
|
</Stack>
|
|
@@ -5,7 +5,7 @@ export default function AsButtonStory() {
|
|
|
5
5
|
const tones = Object.entries(WORKSHOP_CARD_TONE_OPTIONS)
|
|
6
6
|
|
|
7
7
|
return (
|
|
8
|
-
<Flex align="center" height="fill" justify="center" padding={
|
|
8
|
+
<Flex align="center" height="fill" justify="center" padding={4} sizing="border">
|
|
9
9
|
<Container>
|
|
10
10
|
<Grid columns={3} gap={2}>
|
|
11
11
|
<Box>
|
|
@@ -18,14 +18,20 @@ export default function AsButtonStory() {
|
|
|
18
18
|
__unstable_focusRing
|
|
19
19
|
as="button"
|
|
20
20
|
key={tone}
|
|
21
|
-
padding={
|
|
21
|
+
padding={3}
|
|
22
22
|
style={{textAlign: 'center'}}
|
|
23
23
|
tone={tone}
|
|
24
24
|
>
|
|
25
25
|
<Stack space={2}>
|
|
26
|
-
<Text weight="medium">
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
<Text size={1} weight="medium">
|
|
27
|
+
{title}
|
|
28
|
+
</Text>
|
|
29
|
+
<Text muted size={1}>
|
|
30
|
+
Muted
|
|
31
|
+
</Text>
|
|
32
|
+
<Text accent size={1}>
|
|
33
|
+
Accent
|
|
34
|
+
</Text>
|
|
29
35
|
</Stack>
|
|
30
36
|
</Card>
|
|
31
37
|
))}
|
|
@@ -43,14 +49,20 @@ export default function AsButtonStory() {
|
|
|
43
49
|
as="button"
|
|
44
50
|
disabled
|
|
45
51
|
key={tone}
|
|
46
|
-
padding={
|
|
52
|
+
padding={3}
|
|
47
53
|
style={{textAlign: 'center'}}
|
|
48
54
|
tone={tone}
|
|
49
55
|
>
|
|
50
56
|
<Stack space={2}>
|
|
51
|
-
<Text weight="medium">
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
<Text size={1} weight="medium">
|
|
58
|
+
{title}
|
|
59
|
+
</Text>
|
|
60
|
+
<Text size={1} muted>
|
|
61
|
+
Muted
|
|
62
|
+
</Text>
|
|
63
|
+
<Text accent size={1}>
|
|
64
|
+
Accent
|
|
65
|
+
</Text>
|
|
54
66
|
</Stack>
|
|
55
67
|
</Card>
|
|
56
68
|
))}
|
|
@@ -63,21 +75,27 @@ export default function AsButtonStory() {
|
|
|
63
75
|
</Text>
|
|
64
76
|
<Stack marginTop={3} space={2}>
|
|
65
77
|
{tones.map(([title, tone]) => (
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
</
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
<Card
|
|
79
|
+
__unstable_focusRing
|
|
80
|
+
as="button"
|
|
81
|
+
key={tone}
|
|
82
|
+
padding={3}
|
|
83
|
+
selected
|
|
84
|
+
style={{textAlign: 'center'}}
|
|
85
|
+
tone={tone}
|
|
86
|
+
>
|
|
87
|
+
<Stack space={2}>
|
|
88
|
+
<Text size={1} weight="medium">
|
|
89
|
+
{title}
|
|
90
|
+
</Text>
|
|
91
|
+
<Text size={1} muted>
|
|
92
|
+
Muted
|
|
93
|
+
</Text>
|
|
94
|
+
<Text accent size={1}>
|
|
95
|
+
Accent
|
|
96
|
+
</Text>
|
|
97
|
+
</Stack>
|
|
98
|
+
</Card>
|
|
81
99
|
))}
|
|
82
100
|
</Stack>
|
|
83
101
|
</Box>
|
|
@@ -20,7 +20,7 @@ export default function AsComponentStory() {
|
|
|
20
20
|
return (
|
|
21
21
|
<Flex align="center" height="fill" justify="center">
|
|
22
22
|
<Card as={CustomLink} data-as="a" {...props} padding={3}>
|
|
23
|
-
<Text>As component</Text>
|
|
23
|
+
<Text size={1}>As component</Text>
|
|
24
24
|
</Card>
|
|
25
25
|
</Flex>
|
|
26
26
|
)
|
|
@@ -1,15 +1,25 @@
|
|
|
1
|
-
import {Card, Flex, Stack} from '@sanity/ui'
|
|
1
|
+
import {Card, Flex, Stack, Text} from '@sanity/ui'
|
|
2
|
+
import {THEME_COLOR_CARD_TONES} from '@sanity/ui/theme'
|
|
2
3
|
|
|
3
4
|
export default function CheckeredStory() {
|
|
4
5
|
return (
|
|
5
6
|
<Flex align="center" height="fill" justify="center" padding={[4, 5, 6]} sizing="border">
|
|
6
7
|
<Stack space={1}>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
{THEME_COLOR_CARD_TONES.map((tone) => (
|
|
9
|
+
<Card
|
|
10
|
+
__unstable_checkered
|
|
11
|
+
border
|
|
12
|
+
key={tone}
|
|
13
|
+
padding={3}
|
|
14
|
+
sizing="border"
|
|
15
|
+
style={{width: 120, height: 60}}
|
|
16
|
+
tone={tone}
|
|
17
|
+
>
|
|
18
|
+
<Text muted size={1}>
|
|
19
|
+
{tone}
|
|
20
|
+
</Text>
|
|
21
|
+
</Card>
|
|
22
|
+
))}
|
|
13
23
|
</Stack>
|
|
14
24
|
</Flex>
|
|
15
25
|
)
|
|
@@ -2,13 +2,20 @@ import {Card, Flex, Stack, Text} from '@sanity/ui'
|
|
|
2
2
|
import {useBoolean} from '@sanity/ui-workshop'
|
|
3
3
|
|
|
4
4
|
export default function InteractiveCardStory() {
|
|
5
|
-
const selected = useBoolean('Selected', false, 'Props')
|
|
6
5
|
const pressed = useBoolean('Pressed', false, 'Props')
|
|
6
|
+
const selected = useBoolean('Selected', false, 'Props')
|
|
7
7
|
|
|
8
8
|
return (
|
|
9
9
|
<Flex align="center" height="fill" justify="center">
|
|
10
|
-
<div
|
|
11
|
-
<Card
|
|
10
|
+
<div>
|
|
11
|
+
<Card
|
|
12
|
+
__unstable_focusRing
|
|
13
|
+
as="button"
|
|
14
|
+
padding={3}
|
|
15
|
+
pressed={pressed}
|
|
16
|
+
selected={selected}
|
|
17
|
+
tabIndex={0}
|
|
18
|
+
>
|
|
12
19
|
<Stack space={3}>
|
|
13
20
|
<Text>
|
|
14
21
|
Text <code>Code</code>
|
|
@@ -64,10 +64,12 @@ function List2() {
|
|
|
64
64
|
|
|
65
65
|
function Preview() {
|
|
66
66
|
return (
|
|
67
|
-
<Flex align="center">
|
|
68
|
-
<Skeleton
|
|
67
|
+
<Flex align="center" gap={2}>
|
|
68
|
+
<Skeleton radius="full" style={{width: 33, height: 33}} />
|
|
69
69
|
<Stack flex={1} space={2}>
|
|
70
|
-
<Text>
|
|
70
|
+
<Text size={1} weight="medium">
|
|
71
|
+
Preview
|
|
72
|
+
</Text>
|
|
71
73
|
<Text muted size={1}>
|
|
72
74
|
Preview
|
|
73
75
|
</Text>
|
|
@@ -13,14 +13,14 @@ export default function PropsStory() {
|
|
|
13
13
|
const border = useBoolean('Border', false, 'Props')
|
|
14
14
|
const checkered = useBoolean('Checkered', false, 'Props')
|
|
15
15
|
const muted = useBoolean('Muted', false, 'Props')
|
|
16
|
-
const padding = useSelect('Padding', WORKSHOP_SPACE_OPTIONS,
|
|
16
|
+
const padding = useSelect('Padding', WORKSHOP_SPACE_OPTIONS, 3, 'Props')
|
|
17
17
|
const radius = useSelect('Radius', WORKSHOP_RADIUS_OPTIONS, 0, 'Props')
|
|
18
18
|
const selected = useBoolean('Selected', false, 'Props')
|
|
19
19
|
const shadow = useSelect('Shadow', WORKSHOP_SHADOW_OPTIONS, 0, 'Props')
|
|
20
20
|
const tone = useSelect('Tone', WORKSHOP_CARD_TONE_OPTIONS, 'default', 'Props')
|
|
21
21
|
|
|
22
22
|
return (
|
|
23
|
-
<Flex align="center" height="fill" justify="center">
|
|
23
|
+
<Flex align="center" height="fill" justify="center" padding={4} sizing="border">
|
|
24
24
|
<Card
|
|
25
25
|
__unstable_checkered={checkered}
|
|
26
26
|
as={as}
|
|
@@ -34,14 +34,16 @@ export default function PropsStory() {
|
|
|
34
34
|
tone={tone}
|
|
35
35
|
>
|
|
36
36
|
<Stack space={3}>
|
|
37
|
-
<Text>
|
|
37
|
+
<Text size={1}>
|
|
38
38
|
Card with <code>padding={padding}</code>, <code>tone={tone}</code>, and{' '}
|
|
39
39
|
<code>shadow={shadow}</code>.
|
|
40
40
|
</Text>
|
|
41
|
-
<Text>
|
|
41
|
+
<Text size={1}>
|
|
42
42
|
Text with <a>link</a>.
|
|
43
43
|
</Text>
|
|
44
|
-
<Text accent
|
|
44
|
+
<Text accent size={1}>
|
|
45
|
+
Text with accent color.
|
|
46
|
+
</Text>
|
|
45
47
|
</Stack>
|
|
46
48
|
</Card>
|
|
47
49
|
</Flex>
|
|
@@ -68,12 +68,14 @@ function Preview({selected}: {selected: boolean}) {
|
|
|
68
68
|
return (
|
|
69
69
|
<Flex>
|
|
70
70
|
<Box flex={1}>
|
|
71
|
-
<Text>Title</Text>
|
|
71
|
+
<Text size={1}>Title</Text>
|
|
72
72
|
</Box>
|
|
73
73
|
<Inline space={3}>
|
|
74
74
|
<TextWithTone
|
|
75
75
|
data-selected={selected ? '' : undefined}
|
|
76
76
|
muted
|
|
77
|
+
size={1}
|
|
78
|
+
weight="medium"
|
|
77
79
|
$tone={rootTheme.tone === 'default' ? 'caution' : 'default'}
|
|
78
80
|
>
|
|
79
81
|
<EditIcon />
|
|
@@ -81,6 +83,7 @@ function Preview({selected}: {selected: boolean}) {
|
|
|
81
83
|
<TextWithTone
|
|
82
84
|
data-selected={selected ? '' : undefined}
|
|
83
85
|
muted
|
|
86
|
+
size={1}
|
|
84
87
|
$tone={rootTheme.tone === 'default' ? 'positive' : 'default'}
|
|
85
88
|
>
|
|
86
89
|
<PublishIcon />
|
|
@@ -4,9 +4,15 @@ export default function MultipleTonesStory() {
|
|
|
4
4
|
return (
|
|
5
5
|
<Flex align="center" height="fill" justify="center" padding={[4, 5, 6]} sizing="border">
|
|
6
6
|
<Stack>
|
|
7
|
+
<Card padding={3} tone="neutral">
|
|
8
|
+
<Checkbox />
|
|
9
|
+
</Card>
|
|
7
10
|
<Card padding={3} tone="primary">
|
|
8
11
|
<Checkbox />
|
|
9
12
|
</Card>
|
|
13
|
+
<Card padding={3} tone="suggest">
|
|
14
|
+
<Checkbox />
|
|
15
|
+
</Card>
|
|
10
16
|
<Card padding={3} tone="positive">
|
|
11
17
|
<Checkbox />
|
|
12
18
|
</Card>
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
export default function PropsStory() {
|
|
9
9
|
const code = useText('Code', `console.log('Hello, world')`, 'Props')
|
|
10
10
|
const language = useSelect('Language', WORKSHOP_CODE_LANGUAGE_OPTIONS, 'typescript', 'Props')
|
|
11
|
-
const size = useSelect('Size', WORKSHOP_TEXT_FONT_SIZE_OPTIONS,
|
|
11
|
+
const size = useSelect('Size', WORKSHOP_TEXT_FONT_SIZE_OPTIONS, 1, 'Props')
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
14
|
<Box padding={[4, 5, 6]}>
|
|
@@ -9,7 +9,7 @@ export default function PlainStory() {
|
|
|
9
9
|
<Flex align="center" height="fill" justify="center" padding={[4, 5, 6]} sizing="border">
|
|
10
10
|
<Container onClick={useAction('onClick')} width={width}>
|
|
11
11
|
<Card padding={4} shadow={1}>
|
|
12
|
-
<Text>
|
|
12
|
+
<Text size={1}>
|
|
13
13
|
Container with <code>max-width={width}</code>
|
|
14
14
|
</Text>
|
|
15
15
|
</Card>
|
|
@@ -18,15 +18,15 @@ export default function ExampleStory() {
|
|
|
18
18
|
return (
|
|
19
19
|
<Flex direction={direction} height="fill" style={{width: '100%'}}>
|
|
20
20
|
<DebugCard flex={1}>
|
|
21
|
-
<Code>1</Code>
|
|
21
|
+
<Code size={1}>1</Code>
|
|
22
22
|
</DebugCard>
|
|
23
23
|
|
|
24
24
|
<DebugCard flex={[1, 2, 3]}>
|
|
25
|
-
<Code>[1,2,3]</Code>
|
|
25
|
+
<Code size={1}>[1,2,3]</Code>
|
|
26
26
|
</DebugCard>
|
|
27
27
|
|
|
28
28
|
<DebugCard flex={['none', 'none', 1]}>
|
|
29
|
-
<Code>['none', 'none', 1]</Code>
|
|
29
|
+
<Code size={1}>['none', 'none', 1]</Code>
|
|
30
30
|
</DebugCard>
|
|
31
31
|
</Flex>
|
|
32
32
|
)
|