@sanity/ui 2.9.0-corel.0 → 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 +110 -54
- package/dist/_chunks-cjs/getTheme_v2.js.map +1 -1
- package/dist/_chunks-es/getTheme_v2.mjs +110 -54
- package/dist/_chunks-es/getTheme_v2.mjs.map +1 -1
- package/dist/_legacy/getTheme_v2.esm.js +110 -54
- package/dist/_legacy/getTheme_v2.esm.js.map +1 -1
- package/dist/index.d.mts +14 -21
- package/dist/index.d.ts +14 -21
- package/dist/index.esm.js +3327 -3068
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3328 -3070
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3327 -3068
- package/dist/index.mjs.map +1 -1
- package/dist/theme.d.mts +8 -8
- package/dist/theme.d.ts +8 -8
- package/dist/theme.esm.js +1144 -592
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +1144 -592
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +1144 -592
- package/dist/theme.mjs.map +1 -1
- package/package.json +60 -52
- package/src/core/__workshop__/constants.ts +15 -19
- package/src/core/components/breadcrumbs/__workshop__/example.tsx +1 -3
- package/src/core/components/breadcrumbs/__workshop__/index.ts +0 -5
- package/src/core/components/breadcrumbs/breadcrumbs.styles.ts +13 -1
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +31 -39
- package/src/core/components/dialog/dialog.tsx +4 -2
- package/src/core/components/menu/__workshop__/tones.tsx +5 -6
- package/src/core/components/menu/menu.tsx +15 -11
- package/src/core/components/menu/menuButton.tsx +14 -36
- package/src/core/components/menu/menuGroup.tsx +2 -1
- package/src/core/components/menu/menuItem.tsx +4 -2
- package/src/core/components/tab/tabList.tsx +3 -11
- package/src/core/components/toast/__workshop__/hook.tsx +1 -1
- package/src/core/components/toast/toast.tsx +2 -2
- package/src/core/components/toast/toastProvider.tsx +5 -6
- package/src/core/components/toast/toastState.ts +6 -0
- package/src/core/constants.ts +1 -1
- package/src/core/hooks/useArrayProp.ts +14 -9
- package/src/core/hooks/useElementRect/__workshop__/example.tsx +2 -2
- package/src/core/primitives/avatar/avatarStack.tsx +2 -5
- package/src/core/primitives/badge/__workshop__/tones.tsx +6 -13
- package/src/core/primitives/button/__workshop__/custom.tsx +4 -3
- package/src/core/primitives/button/__workshop__/props.tsx +1 -1
- package/src/core/primitives/button/button.tsx +6 -11
- package/src/core/primitives/button/styles.ts +1 -1
- 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/flex/flex.tsx +1 -5
- package/src/core/primitives/grid/__workshop__/responsive.tsx +12 -12
- package/src/core/primitives/heading/__workshop__/opticalAlignment.tsx +13 -25
- package/src/core/primitives/heading/heading.tsx +1 -1
- 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 +6 -5
- 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/text/styles.ts +0 -1
- package/src/core/primitives/text/text.tsx +2 -4
- 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/styles/card/_cardColorStyle.ts +8 -8
- package/src/core/styles/flex/flexStyle.ts +0 -18
- package/src/core/styles/flex/types.ts +0 -2
- package/src/core/theme/__workshop__/debug/story.tsx +18 -11
- package/src/core/theme/themeProvider.tsx +4 -6
- package/src/core/utils/elementQuery/elementQuery.tsx +16 -17
- package/src/core/utils/layer/layerProvider.tsx +1 -1
- package/src/theme/build/_deprecated/color/muted/createMuted.ts +2 -2
- package/src/theme/build/buildColorTheme.ts +12 -8
- package/src/theme/build/renderColorTheme.ts +54 -232
- package/src/theme/defaults/colorTokens.ts +13 -18
- package/src/theme/system/color/_constants.ts +6 -10
- package/src/theme/versioning/themeColor_v0_v2.ts +26 -26
- package/src/theme/versioning/v0_v2.ts +4 -4
- package/src/core/components/breadcrumbs/__workshop__/buttons.tsx +0 -58
- package/src/core/primitives/textInput/__workshop__/multipleTones.tsx +0 -20
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {cloneElement, forwardRef, useCallback,
|
|
1
|
+
import {cloneElement, forwardRef, useCallback, useState, Children, isValidElement} from 'react'
|
|
2
2
|
import {styled} from 'styled-components'
|
|
3
3
|
import {Inline, InlineProps} from '../../primitives'
|
|
4
4
|
|
|
@@ -9,10 +9,6 @@ export interface TabListProps extends Omit<InlineProps, 'as' | 'height'> {
|
|
|
9
9
|
children: Array<React.ReactElement | null | undefined | false>
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
function _isReactElement(node: unknown): node is React.ReactElement {
|
|
13
|
-
return Boolean(node)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
12
|
//Limits the width of tabs in tablist
|
|
17
13
|
const CustomInline = styled(Inline)`
|
|
18
14
|
& > div {
|
|
@@ -33,22 +29,18 @@ export const TabList = forwardRef(function TabList(
|
|
|
33
29
|
const {children: childrenProp, ...restProps} = props
|
|
34
30
|
const [focusedIndex, setFocusedIndex] = useState(-1)
|
|
35
31
|
|
|
36
|
-
const children =
|
|
32
|
+
const children: React.ReactElement[] = Children.toArray(childrenProp).filter(isValidElement)
|
|
37
33
|
|
|
38
34
|
const tabs = children.map((child, childIndex) =>
|
|
39
35
|
cloneElement(child, {
|
|
40
36
|
focused: focusedIndex === childIndex,
|
|
41
37
|
key: childIndex,
|
|
42
|
-
onFocus: () =>
|
|
38
|
+
onFocus: () => setFocusedIndex(childIndex),
|
|
43
39
|
}),
|
|
44
40
|
)
|
|
45
41
|
|
|
46
42
|
const numTabs = tabs.length
|
|
47
43
|
|
|
48
|
-
const handleTabFocus = useCallback((tabIdx: number) => {
|
|
49
|
-
setFocusedIndex(tabIdx)
|
|
50
|
-
}, [])
|
|
51
|
-
|
|
52
44
|
const handleKeyDown = useCallback(
|
|
53
45
|
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
54
46
|
if (event.key === 'ArrowLeft') {
|
|
@@ -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 = {
|
|
@@ -8,6 +8,7 @@ import {Box} from '../../primitives'
|
|
|
8
8
|
import {Layer} from '../../utils'
|
|
9
9
|
import {Toast} from './toast'
|
|
10
10
|
import {ToastContext} from './toastContext'
|
|
11
|
+
import {generateToastId} from './toastState'
|
|
11
12
|
import {ToastContextValue, ToastParams} from './types'
|
|
12
13
|
|
|
13
14
|
type ToastState = {
|
|
@@ -45,8 +46,6 @@ const ToastContainer = styled.div`
|
|
|
45
46
|
width: 100%;
|
|
46
47
|
`
|
|
47
48
|
|
|
48
|
-
let toastId = 0
|
|
49
|
-
|
|
50
49
|
/**
|
|
51
50
|
* @public
|
|
52
51
|
*/
|
|
@@ -60,20 +59,20 @@ export function ToastProvider(props: ToastProviderProps): React.ReactElement {
|
|
|
60
59
|
() => ({
|
|
61
60
|
initial: {
|
|
62
61
|
opacity: 0,
|
|
63
|
-
[POPOVER_MOTION_CONTENT_OPACITY_PROPERTY
|
|
62
|
+
[POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: 0,
|
|
64
63
|
y: 32,
|
|
65
64
|
scale: 0.25,
|
|
66
65
|
willChange: 'transform',
|
|
67
66
|
},
|
|
68
67
|
animate: {
|
|
69
68
|
opacity: [0, 1, 1],
|
|
70
|
-
[POPOVER_MOTION_CONTENT_OPACITY_PROPERTY
|
|
69
|
+
[POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: [0, 0, 1],
|
|
71
70
|
y: 0,
|
|
72
71
|
scale: 1,
|
|
73
72
|
},
|
|
74
73
|
exit: {
|
|
75
74
|
opacity: [1, 1, 0],
|
|
76
|
-
[POPOVER_MOTION_CONTENT_OPACITY_PROPERTY
|
|
75
|
+
[POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: [1, 0, 0],
|
|
77
76
|
scale: 0.5,
|
|
78
77
|
transition: prefersReducedMotion ? {duration: 0} : {duration: 0.2},
|
|
79
78
|
},
|
|
@@ -86,7 +85,7 @@ export function ToastProvider(props: ToastProviderProps): React.ReactElement {
|
|
|
86
85
|
// Wrap setState in startTransition to allow React to give input state updates higher priority
|
|
87
86
|
const setState: typeof _setState = (state) => startTransition(() => _setState(state))
|
|
88
87
|
|
|
89
|
-
const id = params.id ||
|
|
88
|
+
const id = params.id || generateToastId()
|
|
90
89
|
const duration = params.duration || 5000
|
|
91
90
|
|
|
92
91
|
const dismiss = () => {
|
package/src/core/constants.ts
CHANGED
|
@@ -13,7 +13,7 @@ export const EMPTY_RECORD: Record<string, never> = {}
|
|
|
13
13
|
/**
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|
|
16
|
-
export const POPOVER_MOTION_CONTENT_OPACITY_PROPERTY = '--motion-content-opacity'
|
|
16
|
+
export const POPOVER_MOTION_CONTENT_OPACITY_PROPERTY = '--motion-content-opacity' as string
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Shared `framer-motion` variants used by `Popover` and `Tooltip` components.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {useState} from 'react'
|
|
2
2
|
import {_getArrayProp} from '../styles'
|
|
3
3
|
|
|
4
4
|
/** @beta */
|
|
@@ -12,14 +12,19 @@ export function useArrayProp<T extends ArrayPropPrimitive = ArrayPropPrimitive>(
|
|
|
12
12
|
val: T | T[] | undefined,
|
|
13
13
|
defaultVal?: T[],
|
|
14
14
|
): T[] {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const [[cachedVal, cachedHash], setCache] = useState<[T[], string]>(() => [
|
|
16
|
+
_getArrayProp(val, defaultVal),
|
|
17
|
+
JSON.stringify(val ?? defaultVal),
|
|
18
|
+
])
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
() => _getArrayProp(val, defaultVal),
|
|
20
|
+
const hash = JSON.stringify(val ?? defaultVal)
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
if (hash !== cachedHash) {
|
|
23
|
+
// If the cached hash has changed, update the cache right away.
|
|
24
|
+
// Calling setState during render is fine in this case, and preferred over a useEffect loop
|
|
25
|
+
// https://19.react.dev/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes
|
|
26
|
+
setCache([_getArrayProp(val, defaultVal), hash])
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return cachedVal
|
|
25
30
|
}
|
|
@@ -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]}>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {getTheme_v2} from '@sanity/ui/theme'
|
|
2
|
-
import {Children, cloneElement, forwardRef, isValidElement
|
|
2
|
+
import {Children, cloneElement, forwardRef, isValidElement} from 'react'
|
|
3
3
|
import {styled, css} from 'styled-components'
|
|
4
4
|
import {EMPTY_RECORD} from '../../constants'
|
|
5
5
|
import {useArrayProp} from '../../hooks'
|
|
@@ -65,10 +65,7 @@ export const AvatarStack = forwardRef(function AvatarStack(
|
|
|
65
65
|
size: sizeProp = 1,
|
|
66
66
|
...restProps
|
|
67
67
|
} = props
|
|
68
|
-
const children
|
|
69
|
-
() => Children.toArray(childrenProp).filter(isValidElement),
|
|
70
|
-
[childrenProp],
|
|
71
|
-
)
|
|
68
|
+
const children: React.ReactElement[] = Children.toArray(childrenProp).filter(isValidElement)
|
|
72
69
|
const maxLength = Math.max(maxLengthProp, 0)
|
|
73
70
|
const size = useArrayProp(sizeProp)
|
|
74
71
|
|
|
@@ -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}>
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
|
|
14
14
|
export default function ButtonStory() {
|
|
15
15
|
const disabled = useBoolean('Disabled', false, 'Props')
|
|
16
|
-
const fontSize = useSelect('Font size', WORKSHOP_TEXT_SIZE_OPTIONS,
|
|
16
|
+
const fontSize = useSelect('Font size', WORKSHOP_TEXT_SIZE_OPTIONS, 2, 'Props')
|
|
17
17
|
const icon = useSelect('Icon', WORKSHOP_ICON_SYMBOL_OPTIONS, 'add-circle', 'Props')
|
|
18
18
|
const iconRight = useSelect('Icon (right)', WORKSHOP_ICON_SYMBOL_OPTIONS, '', 'Props')
|
|
19
19
|
const justify = useSelect('Justify', WORKSHOP_FLEX_JUSTIFY_OPTIONS, 'center', 'Props')
|
|
@@ -9,7 +9,7 @@ import {ButtonMode, ButtonTextAlign, ButtonTone, ButtonWidth, FlexJustify} from
|
|
|
9
9
|
import {Box} from '../box'
|
|
10
10
|
import {Flex} from '../flex'
|
|
11
11
|
import {Spinner} from '../spinner'
|
|
12
|
-
import {Text
|
|
12
|
+
import {Text} from '../text'
|
|
13
13
|
import {ResponsivePaddingProps, ResponsiveRadiusProps} from '../types'
|
|
14
14
|
import {buttonBaseStyles, buttonColorStyles} from './styles'
|
|
15
15
|
|
|
@@ -32,8 +32,6 @@ export interface ButtonProps extends ResponsivePaddingProps, ResponsiveRadiusPro
|
|
|
32
32
|
textAlign?: ButtonTextAlign
|
|
33
33
|
muted?: boolean
|
|
34
34
|
text?: React.ReactNode
|
|
35
|
-
textOverflow?: TextProps['textOverflow']
|
|
36
|
-
textWeight?: TextProps['weight']
|
|
37
35
|
tone?: ButtonTone
|
|
38
36
|
type?: 'button' | 'reset' | 'submit'
|
|
39
37
|
width?: ButtonWidth
|
|
@@ -87,8 +85,6 @@ export const Button = forwardRef(function Button(
|
|
|
87
85
|
space: spaceProp = 3,
|
|
88
86
|
text,
|
|
89
87
|
textAlign,
|
|
90
|
-
textOverflow = 'ellipsis',
|
|
91
|
-
textWeight,
|
|
92
88
|
tone = 'default',
|
|
93
89
|
type = 'button',
|
|
94
90
|
muted = false,
|
|
@@ -146,21 +142,20 @@ export const Button = forwardRef(function Button(
|
|
|
146
142
|
<Box as="span" {...boxProps}>
|
|
147
143
|
<Flex as="span" justify={justify} gap={space}>
|
|
148
144
|
{IconComponent && (
|
|
149
|
-
<Text
|
|
145
|
+
<Text size={fontSize}>
|
|
150
146
|
{isValidElement(IconComponent) && IconComponent}
|
|
151
147
|
{isValidElementType(IconComponent) && <IconComponent />}
|
|
152
148
|
</Text>
|
|
153
149
|
)}
|
|
154
150
|
|
|
155
151
|
{text && (
|
|
156
|
-
<Box
|
|
152
|
+
<Box>
|
|
157
153
|
<Text
|
|
158
|
-
as="span"
|
|
159
154
|
muted={muted}
|
|
160
155
|
align={textAlign}
|
|
161
156
|
size={fontSize}
|
|
162
|
-
textOverflow=
|
|
163
|
-
weight={
|
|
157
|
+
textOverflow="ellipsis"
|
|
158
|
+
weight={button.textWeight}
|
|
164
159
|
>
|
|
165
160
|
{text}
|
|
166
161
|
</Text>
|
|
@@ -168,7 +163,7 @@ export const Button = forwardRef(function Button(
|
|
|
168
163
|
)}
|
|
169
164
|
|
|
170
165
|
{IconRightComponent && (
|
|
171
|
-
<Text
|
|
166
|
+
<Text size={fontSize}>
|
|
172
167
|
{isValidElement(IconRightComponent) && IconRightComponent}
|
|
173
168
|
{isValidElementType(IconRightComponent) && <IconRightComponent />}
|
|
174
169
|
</Text>
|
|
@@ -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]}>
|