@sanity/ui 5.0.0-alpha.20 → 5.0.0-alpha.22
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.d.ts +17 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -54
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +2 -2
- package/src/components/code/Code.tsx +18 -19
- package/src/components/code/code.props.ts +17 -15
- package/src/components/dialog/Dialog.tsx +1 -1
- package/src/components/heading/Heading.tsx +8 -3
- package/src/components/heading/heading.css +0 -5
- package/src/components/heading/heading.props.ts +9 -4
- package/src/css/classes/system/shadow.css +45 -0
- package/src/css/global/reset.css +4 -0
- package/src/types/Code.ts +0 -3
- package/src/version.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/ui",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.22",
|
|
4
4
|
"description": "Sanity UI Library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@sanity-labs/design-tokens": "0.0.2-alpha.
|
|
51
|
+
"@sanity-labs/design-tokens": "0.0.2-alpha.10",
|
|
52
52
|
"@sanity/icons": "^5.2.1",
|
|
53
53
|
"clsx": "^2.1.1",
|
|
54
54
|
"comment-json": "^5.0.0",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import clsx from 'clsx'
|
|
2
|
-
import {
|
|
2
|
+
import {lazy, Suspense} from 'react'
|
|
3
3
|
|
|
4
|
-
import {type CodeTag} from '../../types/Code'
|
|
5
4
|
import {getProps} from '../../utils/getProps'
|
|
6
5
|
import {suffixClassName} from '../../utils/suffixClassName'
|
|
7
6
|
import {type CodeProps, codeProps} from './code.props'
|
|
@@ -11,26 +10,26 @@ const LazyRefractor = lazy(() => import('./LazyRefractor'))
|
|
|
11
10
|
const codeClassName = suffixClassName('sui-Code')
|
|
12
11
|
|
|
13
12
|
/** @public */
|
|
14
|
-
export function Code
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
<code>{children}</code>
|
|
25
|
-
</Component>
|
|
26
|
-
)
|
|
27
|
-
}
|
|
13
|
+
export function Code({size = 2, ...props}: CodeProps) {
|
|
14
|
+
const {children, className, inline, language, style, ...rest} = getProps(
|
|
15
|
+
{size, ...props},
|
|
16
|
+
codeProps,
|
|
17
|
+
)
|
|
18
|
+
/*
|
|
19
|
+
* The span wrapper for inline code is necessary because react-refractor does not
|
|
20
|
+
* support any attributes other than className
|
|
21
|
+
*/
|
|
22
|
+
const Component = inline ? 'span' : 'pre'
|
|
28
23
|
|
|
29
24
|
return (
|
|
30
25
|
<Component className={clsx(codeClassName, className)} style={style} data-ui="Code" {...rest}>
|
|
31
|
-
|
|
32
|
-
<
|
|
33
|
-
|
|
26
|
+
{language ? (
|
|
27
|
+
<Suspense fallback={<code>{children}</code>}>
|
|
28
|
+
<LazyRefractor language={language} value={children} />
|
|
29
|
+
</Suspense>
|
|
30
|
+
) : (
|
|
31
|
+
<code>{children}</code>
|
|
32
|
+
)}
|
|
34
33
|
</Component>
|
|
35
34
|
)
|
|
36
35
|
}
|
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
import {marginProps} from '../../props/margin'
|
|
2
2
|
import {type TypographyProps, typographyProps} from '../../props/typography'
|
|
3
|
-
import {CODE_SIZE,
|
|
3
|
+
import {CODE_SIZE, type CodeSize} from '../../types/Code'
|
|
4
4
|
import {type PropDef} from '../../types/PropDef'
|
|
5
5
|
import type {Responsive} from '../../types/Responsive'
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
export interface CodeProps<T extends CodeTag = 'pre'> extends Omit<
|
|
9
|
-
TypographyProps,
|
|
10
|
-
'align' | 'truncate' | 'tone'
|
|
11
|
-
> {
|
|
12
|
-
/**
|
|
13
|
-
* HTML element or component to render.
|
|
14
|
-
* @remarks The defined element wraps an inner `<code>` tag.
|
|
15
|
-
*/
|
|
16
|
-
as?: T
|
|
7
|
+
interface CodeBaseProps extends Omit<TypographyProps, 'align' | 'truncate' | 'tone' | 'weight'> {
|
|
17
8
|
/**
|
|
18
9
|
* Refractor language for syntax highlighting.
|
|
19
10
|
*/
|
|
@@ -24,10 +15,22 @@ export interface CodeProps<T extends CodeTag = 'pre'> extends Omit<
|
|
|
24
15
|
size?: Responsive<CodeSize>
|
|
25
16
|
}
|
|
26
17
|
|
|
18
|
+
/** @public */
|
|
19
|
+
export type CodeProps =
|
|
20
|
+
| (CodeBaseProps & {
|
|
21
|
+
/**
|
|
22
|
+
* Render code inline or as a block.
|
|
23
|
+
* @remarks Block code is wrapped in a `<pre>` tag.
|
|
24
|
+
*/
|
|
25
|
+
inline?: false
|
|
26
|
+
} & Omit<React.ComponentPropsWithRef<'pre'>, keyof CodeBaseProps>)
|
|
27
|
+
| (CodeBaseProps & {
|
|
28
|
+
inline: true
|
|
29
|
+
} & Omit<React.ComponentPropsWithRef<'span'>, keyof CodeBaseProps>)
|
|
30
|
+
|
|
27
31
|
export const codeProps: Record<string, PropDef> = {
|
|
28
|
-
|
|
29
|
-
type: '
|
|
30
|
-
values: CODE_TAG,
|
|
32
|
+
inline: {
|
|
33
|
+
type: 'boolean',
|
|
31
34
|
},
|
|
32
35
|
language: {
|
|
33
36
|
type: 'string',
|
|
@@ -39,6 +42,5 @@ export const codeProps: Record<string, PropDef> = {
|
|
|
39
42
|
},
|
|
40
43
|
muted: typographyProps['muted'] as PropDef,
|
|
41
44
|
trim: typographyProps['trim'] as PropDef,
|
|
42
|
-
weight: typographyProps['weight'] as PropDef,
|
|
43
45
|
...marginProps,
|
|
44
46
|
}
|
|
@@ -66,7 +66,7 @@ function DialogRoot({open = false, size = 0, ...props}: DialogProps) {
|
|
|
66
66
|
>
|
|
67
67
|
<Flex flexShrink={0} justifyContent="space-between" alignItems="center">
|
|
68
68
|
{header ? (
|
|
69
|
-
<Heading trim size={1} id={headerId}>
|
|
69
|
+
<Heading as="h2" trim size={1} id={headerId}>
|
|
70
70
|
{header}
|
|
71
71
|
</Heading>
|
|
72
72
|
) : (
|
|
@@ -10,10 +10,9 @@ const headingClassName = suffixClassName('sui-Heading')
|
|
|
10
10
|
/** @public */
|
|
11
11
|
export function Heading<T extends ElementType = 'h2'>({
|
|
12
12
|
size = 2,
|
|
13
|
-
weight = 'bold',
|
|
14
13
|
...props
|
|
15
14
|
}: HeadingProps & Omit<ComponentPropsWithRef<T>, keyof HeadingProps>) {
|
|
16
|
-
const {as, children, className, style, ...rest} = getProps({size,
|
|
15
|
+
const {as, children, className, style, ...rest} = getProps({size, ...props}, headingProps)
|
|
17
16
|
const Component = as || 'h2'
|
|
18
17
|
|
|
19
18
|
if (props.truncate && props.trim) {
|
|
@@ -30,6 +29,7 @@ export function Heading<T extends ElementType = 'h2'>({
|
|
|
30
29
|
<span
|
|
31
30
|
className={clsx(
|
|
32
31
|
'sui-overflow-hidden',
|
|
32
|
+
'sui-weight-bold',
|
|
33
33
|
props.truncate === 1 ? 'sui-text-overflow' : 'sui-line-clamp',
|
|
34
34
|
)}
|
|
35
35
|
>
|
|
@@ -41,7 +41,12 @@ export function Heading<T extends ElementType = 'h2'>({
|
|
|
41
41
|
|
|
42
42
|
return (
|
|
43
43
|
<Component
|
|
44
|
-
className={clsx(
|
|
44
|
+
className={clsx(
|
|
45
|
+
headingClassName,
|
|
46
|
+
props.truncate && 'sui-overflow-hidden',
|
|
47
|
+
'sui-weight-bold',
|
|
48
|
+
className,
|
|
49
|
+
)}
|
|
45
50
|
style={style}
|
|
46
51
|
data-ui="Heading"
|
|
47
52
|
{...rest}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import {marginProps} from '../../props/margin'
|
|
2
|
+
import {toneProps} from '../../props/tone'
|
|
1
3
|
import {type TypographyProps, typographyProps} from '../../props/typography'
|
|
2
4
|
import {HEADING_SIZE, HEADING_TAG, type HeadingSize, type HeadingTag} from '../../types/Heading'
|
|
3
5
|
import {type PropDef} from '../../types/PropDef'
|
|
4
6
|
import type {Responsive} from '../../types/Responsive'
|
|
5
7
|
|
|
6
8
|
/** @public */
|
|
7
|
-
export interface HeadingProps extends TypographyProps {
|
|
9
|
+
export interface HeadingProps extends Omit<TypographyProps, 'muted' | 'weight'> {
|
|
8
10
|
/**
|
|
9
11
|
* Semantic heading element to render.
|
|
10
|
-
* @remarks Always set this explicitly.
|
|
11
12
|
*/
|
|
12
|
-
as
|
|
13
|
+
as: HeadingTag
|
|
13
14
|
/**
|
|
14
15
|
* Sets font size.
|
|
15
16
|
* @remarks Independent of `as`.
|
|
@@ -27,5 +28,9 @@ export const headingProps: Record<string, PropDef> = {
|
|
|
27
28
|
className: 'text-heading',
|
|
28
29
|
values: HEADING_SIZE,
|
|
29
30
|
},
|
|
30
|
-
|
|
31
|
+
align: typographyProps['align'] as PropDef,
|
|
32
|
+
trim: typographyProps['trim'] as PropDef,
|
|
33
|
+
truncate: typographyProps['truncate'] as PropDef,
|
|
34
|
+
...marginProps,
|
|
35
|
+
...toneProps,
|
|
31
36
|
}
|
|
@@ -1,3 +1,48 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--shadow-outline-color: light-dark(
|
|
3
|
+
rgba(114, 120, 146, 0.3),
|
|
4
|
+
rgba(117, 123, 150, 0.4)
|
|
5
|
+
);
|
|
6
|
+
--shadow-umbra-color: light-dark(
|
|
7
|
+
rgba(114, 120, 146, 0.1),
|
|
8
|
+
rgba(0, 0, 0, 0.2)
|
|
9
|
+
);
|
|
10
|
+
--shadow-penumbra-color: light-dark(
|
|
11
|
+
rgba(114, 120, 146, 0.07),
|
|
12
|
+
rgba(0, 0, 0, 0.14)
|
|
13
|
+
);
|
|
14
|
+
--shadow-ambient-color: light-dark(
|
|
15
|
+
rgba(114, 120, 146, 0.06),
|
|
16
|
+
rgba(0, 0, 0, 0.12)
|
|
17
|
+
);
|
|
18
|
+
--shadow-0: 0px 0px 0px 0px var(--shadow-outline-color);
|
|
19
|
+
--shadow-1:
|
|
20
|
+
0px 0px 0px 0.5px var(--shadow-outline-color),
|
|
21
|
+
0px 0px 0px 0px var(--shadow-umbra-color),
|
|
22
|
+
0px 0px 0px 0px var(--shadow-penumbra-color),
|
|
23
|
+
0px 0px 0px 0px var(--shadow-ambient-color);
|
|
24
|
+
--shadow-2:
|
|
25
|
+
0px 0px 0px 0.5px var(--shadow-outline-color),
|
|
26
|
+
0px 3px 5px -2px var(--shadow-umbra-color),
|
|
27
|
+
0px 6px 10px 0px var(--shadow-penumbra-color),
|
|
28
|
+
0px 1px 18px 1px var(--shadow-ambient-color);
|
|
29
|
+
--shadow-3:
|
|
30
|
+
0px 0px 0px 0.5px var(--shadow-outline-color),
|
|
31
|
+
0px 7px 8px -4px var(--shadow-umbra-color),
|
|
32
|
+
0px 12px 17px 2px var(--shadow-penumbra-color),
|
|
33
|
+
0px 5px 22px 4px var(--shadow-ambient-color);
|
|
34
|
+
--shadow-4:
|
|
35
|
+
0px 0px 0px 0.5px var(--shadow-outline-color),
|
|
36
|
+
0px 9px 11px -5px var(--shadow-umbra-color),
|
|
37
|
+
0px 18px 28px 2px var(--shadow-penumbra-color),
|
|
38
|
+
0px 7px 34px 6px var(--shadow-ambient-color);
|
|
39
|
+
--shadow-5:
|
|
40
|
+
0px 0px 0px 0.5px var(--shadow-outline-color),
|
|
41
|
+
0px 11px 15px -7px var(--shadow-umbra-color),
|
|
42
|
+
0px 24px 38px 3px var(--shadow-penumbra-color),
|
|
43
|
+
0px 9px 46px 8px var(--shadow-ambient-color);
|
|
44
|
+
}
|
|
45
|
+
|
|
1
46
|
.sui-shadow0 { box-shadow: var(--shadow-0); }
|
|
2
47
|
.sui-shadow1 { box-shadow: var(--shadow-1); }
|
|
3
48
|
.sui-shadow2 { box-shadow: var(--shadow-2); }
|
package/src/css/global/reset.css
CHANGED
package/src/types/Code.ts
CHANGED
package/src/version.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// This file is generated by scripts/write-version.js. Do not edit.
|
|
2
|
-
export const VERSION = '
|
|
3
|
-
export const HASH = '
|
|
2
|
+
export const VERSION = '500alpha22'
|
|
3
|
+
export const HASH = '9912f1'
|