@sanity/ui 1.0.0-beta.32 → 1.0.0-beta.34
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/LICENSE +1 -1
- package/dist/{types/src/index.d.ts → index.d.ts} +136 -68
- package/dist/{sanity-ui.esm.js → index.esm.js} +698 -1525
- package/dist/index.esm.js.map +1 -0
- package/dist/{sanity-ui.js → index.js} +697 -1539
- package/dist/index.js.map +1 -0
- package/package.json +112 -23
- package/src/components/autocomplete/__workshop__/example.tsx +1 -1
- package/src/components/autocomplete/__workshop__/index.ts +36 -32
- package/src/components/autocomplete/autocomplete.tsx +1 -2
- package/src/components/autocomplete/constants.ts +3 -8
- package/src/components/breadcrumbs/__workshop__/index.ts +11 -7
- package/src/components/dialog/__workshop__/index.ts +13 -9
- package/src/components/hotkeys/__workshop__/index.ts +11 -3
- package/src/components/menu/__workshop__/index.ts +71 -67
- package/src/components/menu/menuButton.tsx +16 -14
- package/src/components/skeleton/__workshop__/index.ts +8 -4
- package/src/components/tab/__workshop__/index.ts +11 -3
- package/src/components/toast/__workshop__/index.ts +16 -4
- package/src/components/tree/__workshop__/basic.perf.ts +1 -14
- package/src/components/tree/__workshop__/basic.tsx +1 -1
- package/src/components/tree/__workshop__/index.ts +12 -8
- package/src/hooks/useElementRect/__workshop__/index.ts +11 -3
- package/src/hooks/useMediaIndex/__workshop__/index.ts +11 -3
- package/src/primitives/avatar/__workshop__/index.ts +16 -12
- package/src/primitives/badge/__workshop__/index.ts +16 -12
- package/src/primitives/badge/__workshop__/tones.tsx +1 -1
- package/src/primitives/box/__workshop__/index.ts +16 -4
- package/src/primitives/button/__workshop__/index.ts +51 -47
- package/src/primitives/card/__workshop__/index.ts +15 -11
- package/src/primitives/checkbox/__workshop__/index.ts +10 -6
- package/src/primitives/code/__workshop__/index.ts +16 -12
- package/src/primitives/container/__workshop__/index.ts +5 -3
- package/src/primitives/flex/__workshop__/index.ts +8 -4
- package/src/primitives/grid/__workshop__/index.ts +7 -3
- package/src/primitives/heading/__workshop__/index.ts +16 -12
- package/src/primitives/inline/__workshop__/index.ts +5 -3
- package/src/primitives/kbd/__workshop__/index.ts +5 -3
- package/src/primitives/label/__workshop__/index.ts +16 -12
- package/src/primitives/popover/__workshop__/PlainStory.tsx +0 -1
- package/src/primitives/popover/__workshop__/TestStory.tsx +0 -1
- package/src/primitives/popover/__workshop__/index.ts +36 -32
- package/src/primitives/popover/constants.ts +0 -3
- package/src/primitives/popover/floating-ui/size.ts +40 -25
- package/src/primitives/popover/popover.tsx +54 -41
- package/src/primitives/popover/popoverCard.tsx +9 -16
- package/src/primitives/radio/__workshop__/index.ts +8 -4
- package/src/primitives/select/__workshop__/index.ts +8 -4
- package/src/primitives/spinner/__workshop__/index.ts +11 -7
- package/src/primitives/stack/__workshop__/index.ts +11 -7
- package/src/primitives/switch/__workshop__/index.ts +8 -4
- package/src/primitives/text/__workshop__/index.ts +21 -17
- package/src/primitives/textArea/__workshop__/index.ts +11 -7
- package/src/primitives/textInput/__workshop__/index.ts +46 -42
- package/src/primitives/textInput/__workshop__/plain.tsx +2 -1
- package/src/primitives/tooltip/__workshop__/index.ts +11 -7
- package/src/theme/__workshop__/index.ts +26 -22
- package/src/theme/{ThemeContext.ts → themeContext.ts} +0 -0
- package/src/utils/boundaryElement/__workshop__/index.ts +11 -7
- package/src/utils/elementQuery/__workshop__/index.ts +11 -7
- package/src/utils/layer/__workshop__/index.ts +21 -17
- package/src/utils/portal/__workshop__/index.ts +11 -7
- package/src/utils/virtualList/__workshop__/index.ts +26 -22
- package/dist/sanity-ui.esm.js.map +0 -1
- package/dist/sanity-ui.js.map +0 -1
- package/src/__workshop__/color/overview.tsx +0 -101
- package/src/__workshop__/index.ts +0 -10
- package/src/icons/__workshop__/.eslintrc +0 -5
- package/src/icons/__workshop__/index.tsx +0 -6
- package/src/icons/__workshop__/overview.tsx +0 -76
- package/src/utils/srOnly/__workshop__/.eslintrc +0 -5
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import {black, ColorTints, ColorValue, COLOR_HUES, hues, white} from '@sanity/color'
|
|
2
|
-
import {Box, Card, Code, Flex, Grid, Heading, Stack, useToast} from '@sanity/ui'
|
|
3
|
-
import {useCallback} from 'react'
|
|
4
|
-
import {hexToRgb, rgbToHsl} from '../../theme'
|
|
5
|
-
|
|
6
|
-
function ucfirst(str: string) {
|
|
7
|
-
return str.slice(0, 1).toUpperCase() + str.slice(1)
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const clipboard = {
|
|
11
|
-
write(text: string) {
|
|
12
|
-
const type = 'text/plain'
|
|
13
|
-
const blob = new Blob([text], {type})
|
|
14
|
-
const data = [new ClipboardItem({[type]: blob as any})]
|
|
15
|
-
|
|
16
|
-
return navigator.clipboard.write(data)
|
|
17
|
-
},
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default function ColorOverviewStory(): React.ReactElement {
|
|
21
|
-
return (
|
|
22
|
-
<Grid columns={[1, 1, 2, 3]} gapX={[4, 4, 5]} gapY={[5, 5, 6]} padding={[4, 5, 6]}>
|
|
23
|
-
{COLOR_HUES.map((hueKey) => (
|
|
24
|
-
<ColorHuePreview tints={hues[hueKey]} hueKey={hueKey} key={hueKey} />
|
|
25
|
-
))}
|
|
26
|
-
</Grid>
|
|
27
|
-
)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function ColorHuePreview(props: {hueKey: string; tints: ColorTints}) {
|
|
31
|
-
const {hueKey, tints} = props
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<Box>
|
|
35
|
-
<Heading as="h2" size={1}>
|
|
36
|
-
{ucfirst(hueKey)}
|
|
37
|
-
</Heading>
|
|
38
|
-
|
|
39
|
-
<Stack marginTop={[3, 3, 4]} space={1}>
|
|
40
|
-
{Object.entries(tints).map(([tintKey, tint]) => {
|
|
41
|
-
return <ColorTintPreview key={tintKey} tint={tint} />
|
|
42
|
-
})}
|
|
43
|
-
</Stack>
|
|
44
|
-
</Box>
|
|
45
|
-
)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function ColorTintPreview(props: {tint: ColorValue}) {
|
|
49
|
-
const {tint} = props
|
|
50
|
-
const hsl = rgbToHsl(hexToRgb(tint.hex))
|
|
51
|
-
const {push: pushToast} = useToast()
|
|
52
|
-
|
|
53
|
-
const handleClick = useCallback(() => {
|
|
54
|
-
clipboard
|
|
55
|
-
.write(tint.hex)
|
|
56
|
-
.then(() => {
|
|
57
|
-
pushToast({
|
|
58
|
-
title: (
|
|
59
|
-
<>
|
|
60
|
-
Copied {tint.title} (<code>{tint.hex}</code>) to clipboard!
|
|
61
|
-
</>
|
|
62
|
-
),
|
|
63
|
-
})
|
|
64
|
-
})
|
|
65
|
-
.catch((err) => {
|
|
66
|
-
// eslint-disable-next-line no-console
|
|
67
|
-
console.log(err)
|
|
68
|
-
pushToast({
|
|
69
|
-
status: 'error',
|
|
70
|
-
title: <>Copied not write to clipboard!</>,
|
|
71
|
-
})
|
|
72
|
-
})
|
|
73
|
-
}, [pushToast, tint])
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<Card
|
|
77
|
-
__unstable_focusRing
|
|
78
|
-
as="button"
|
|
79
|
-
onClick={handleClick}
|
|
80
|
-
radius={2}
|
|
81
|
-
style={{
|
|
82
|
-
['--card-bg-color' as any]: tint.hex,
|
|
83
|
-
['--card-fg-color' as any]: hsl.l < 50 ? white.hex : black.hex,
|
|
84
|
-
cursor: 'pointer',
|
|
85
|
-
}}
|
|
86
|
-
>
|
|
87
|
-
<Flex padding={3}>
|
|
88
|
-
<Box flex={1}>
|
|
89
|
-
<Code size={1} style={{color: 'inherit'}}>
|
|
90
|
-
{tint.title}
|
|
91
|
-
</Code>
|
|
92
|
-
</Box>
|
|
93
|
-
<Box>
|
|
94
|
-
<Code size={1} style={{color: 'inherit'}}>
|
|
95
|
-
{tint.hex}
|
|
96
|
-
</Code>
|
|
97
|
-
</Box>
|
|
98
|
-
</Flex>
|
|
99
|
-
</Card>
|
|
100
|
-
)
|
|
101
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import {Icon, icons, IconSymbol, SearchIcon} from '@sanity/icons'
|
|
2
|
-
import {Box, Card, Code, Container, Flex, Heading, Stack, Text, TextInput} from '@sanity/ui'
|
|
3
|
-
import {useCallback, useMemo, useState} from 'react'
|
|
4
|
-
import {packages} from '$packages'
|
|
5
|
-
|
|
6
|
-
function ucfirst(str: string) {
|
|
7
|
-
return str.slice(0, 1).toUpperCase() + str.slice(1)
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function toPascalCase(str: string) {
|
|
11
|
-
const p = str.split('-')
|
|
12
|
-
|
|
13
|
-
return p.map(ucfirst).join('')
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default function OverviewStory() {
|
|
17
|
-
const [query, setQuery] = useState('')
|
|
18
|
-
|
|
19
|
-
const iconKeys = useMemo(() => {
|
|
20
|
-
return Object.keys(icons).filter((iconKey) => {
|
|
21
|
-
return query === '' ? true : iconKey.includes(query.toLowerCase())
|
|
22
|
-
})
|
|
23
|
-
}, [query])
|
|
24
|
-
|
|
25
|
-
const handleQueryChange = useCallback((event: React.ChangeEvent<HTMLInputElement>) => {
|
|
26
|
-
setQuery(event.currentTarget.value)
|
|
27
|
-
}, [])
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<Card padding={[4, 5, 6]}>
|
|
31
|
-
<Container width={1}>
|
|
32
|
-
<Stack space={4}>
|
|
33
|
-
<Heading as="h1">@sanity/icons v{packages.icons?.version}</Heading>
|
|
34
|
-
<Text as="p" muted>
|
|
35
|
-
{packages.icons?.description}
|
|
36
|
-
</Text>
|
|
37
|
-
<Card border padding={3} radius={2}>
|
|
38
|
-
<Code language="bash">{`npm install @sanity/icons\n\n# Install peer dependencies\nnpm install react`}</Code>
|
|
39
|
-
</Card>
|
|
40
|
-
</Stack>
|
|
41
|
-
|
|
42
|
-
<Box marginTop={[3, 4, 5]} marginBottom={3}>
|
|
43
|
-
<TextInput
|
|
44
|
-
icon={SearchIcon}
|
|
45
|
-
onChange={handleQueryChange}
|
|
46
|
-
placeholder="Filter by name…"
|
|
47
|
-
radius={2}
|
|
48
|
-
value={query}
|
|
49
|
-
/>
|
|
50
|
-
</Box>
|
|
51
|
-
|
|
52
|
-
{iconKeys.length === 0 && <Text>No matches</Text>}
|
|
53
|
-
|
|
54
|
-
{iconKeys.length > 0 && (
|
|
55
|
-
<Stack space={3}>
|
|
56
|
-
{iconKeys.map((iconKey) => (
|
|
57
|
-
<Card border key={iconKey} overflow="hidden" radius={2}>
|
|
58
|
-
<Flex align="center" gap={4} padding={4}>
|
|
59
|
-
<Heading>
|
|
60
|
-
<Icon symbol={iconKey as IconSymbol} />
|
|
61
|
-
</Heading>
|
|
62
|
-
<Text>{iconKey}</Text>
|
|
63
|
-
</Flex>
|
|
64
|
-
<Card overflow="auto" padding={4} tone="transparent">
|
|
65
|
-
<Code language="typescript">{`import {${toPascalCase(
|
|
66
|
-
iconKey
|
|
67
|
-
)}Icon} from '@sanity/icons'`}</Code>
|
|
68
|
-
</Card>
|
|
69
|
-
</Card>
|
|
70
|
-
))}
|
|
71
|
-
</Stack>
|
|
72
|
-
)}
|
|
73
|
-
</Container>
|
|
74
|
-
</Card>
|
|
75
|
-
)
|
|
76
|
-
}
|