@sanity/ui 0.37.21 → 0.37.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/lib/dts/src/primitives/spinner/spinner.d.ts +1 -1
- package/lib/dts/src/primitives/spinner/spinner.d.ts.map +1 -1
- package/lib/dts/src/primitives/spinner/styles.d.ts +9 -0
- package/lib/dts/src/primitives/spinner/styles.d.ts.map +1 -0
- package/lib/sanity-ui.js +59 -19
- package/lib/sanity-ui.js.map +1 -1
- package/lib/sanity-ui.modern.js +71 -27
- package/lib/sanity-ui.modern.js.map +1 -1
- package/lib/sanity-ui.module.js +59 -19
- package/lib/sanity-ui.module.js.map +1 -1
- package/package.json +2 -2
- package/src/primitives/button/__workshop__/props.tsx +2 -0
- package/src/primitives/spinner/spinner.tsx +8 -19
- package/src/primitives/spinner/styles.ts +43 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/ui",
|
|
3
|
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.22",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"exports": {
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"publishConfig": {
|
|
73
73
|
"access": "public"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "1b732dbd4ff36714d5c920b942aa6023168588de"
|
|
76
76
|
}
|
|
@@ -18,6 +18,7 @@ export default function ButtonStory() {
|
|
|
18
18
|
const icon = useSelect('Icon', WORKSHOP_ICON_SYMBOL_OPTIONS, 'add-circle', 'Props')
|
|
19
19
|
const iconRight = useSelect('Icon (right)', WORKSHOP_ICON_SYMBOL_OPTIONS, '', 'Props')
|
|
20
20
|
const justify = useSelect('Justify', WORKSHOP_FLEX_JUSTIFY_OPTIONS, 'center', 'Props')
|
|
21
|
+
const loading = useBoolean('Loading')
|
|
21
22
|
const mode = useSelect('Mode', WORKSHOP_BUTTON_MODE_OPTIONS, 'default', 'Props')
|
|
22
23
|
const paddingX = useSelect('Padding X', WORKSHOP_SPACE_OPTIONS, 3, 'Props')
|
|
23
24
|
const paddingY = useSelect('Padding Y', WORKSHOP_SPACE_OPTIONS, 3, 'Props')
|
|
@@ -36,6 +37,7 @@ export default function ButtonStory() {
|
|
|
36
37
|
icon={icon && icons[icon]}
|
|
37
38
|
iconRight={iconRight && icons[iconRight]}
|
|
38
39
|
justify={justify}
|
|
40
|
+
loading={loading}
|
|
39
41
|
mode={mode}
|
|
40
42
|
onClick={useAction('onClick')}
|
|
41
43
|
paddingX={paddingX}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {SpinnerIcon} from '@sanity/icons'
|
|
2
|
-
import React, {forwardRef} from 'react'
|
|
3
|
-
import styled
|
|
4
|
-
import {
|
|
2
|
+
import React, {forwardRef, useMemo} from 'react'
|
|
3
|
+
import styled from 'styled-components'
|
|
4
|
+
import {spinnerSizeStyle, spinnerStyle} from './styles'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @public
|
|
@@ -11,21 +11,7 @@ export interface SpinnerProps {
|
|
|
11
11
|
size?: number | number[]
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
from {
|
|
16
|
-
transform: rotate(0deg);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
to {
|
|
20
|
-
transform: rotate(360deg);
|
|
21
|
-
}
|
|
22
|
-
`
|
|
23
|
-
|
|
24
|
-
const Root = styled(Text)`
|
|
25
|
-
& > span > svg {
|
|
26
|
-
animation: ${rotate} 500ms linear infinite;
|
|
27
|
-
}
|
|
28
|
-
`
|
|
14
|
+
const Root = styled.div<{$muted?: boolean; $size: number[]}>(spinnerStyle, spinnerSizeStyle)
|
|
29
15
|
|
|
30
16
|
/**
|
|
31
17
|
* @public
|
|
@@ -34,8 +20,11 @@ export const Spinner = forwardRef(function Spinner(
|
|
|
34
20
|
props: SpinnerProps & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'size'>,
|
|
35
21
|
ref: React.ForwardedRef<HTMLDivElement>
|
|
36
22
|
) {
|
|
23
|
+
const {muted, size = 2, ...restProps} = props
|
|
24
|
+
const $size = useMemo(() => (Array.isArray(size) ? size : [size]), [size])
|
|
25
|
+
|
|
37
26
|
return (
|
|
38
|
-
<Root data-ui="Spinner" {...
|
|
27
|
+
<Root data-ui="Spinner" {...restProps} $muted={muted} $size={$size} ref={ref}>
|
|
39
28
|
<SpinnerIcon />
|
|
40
29
|
</Root>
|
|
41
30
|
)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {css, CSSObject, FlattenSimpleInterpolation, keyframes} from 'styled-components'
|
|
2
|
+
import {rem, responsive, ThemeProps} from '../../styles'
|
|
3
|
+
|
|
4
|
+
const rotate = keyframes`
|
|
5
|
+
from {
|
|
6
|
+
transform: rotate(0deg);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
to {
|
|
10
|
+
transform: rotate(360deg);
|
|
11
|
+
}
|
|
12
|
+
`
|
|
13
|
+
|
|
14
|
+
export function spinnerStyle(props: {$muted?: boolean} & ThemeProps): FlattenSimpleInterpolation {
|
|
15
|
+
const {$muted} = props
|
|
16
|
+
|
|
17
|
+
return css`
|
|
18
|
+
animation: ${rotate} 500ms linear infinite;
|
|
19
|
+
color: ${$muted ? 'var(--card-muted-fg-color)' : 'var(--card-fg-color)'};
|
|
20
|
+
`
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function spinnerSizeStyle(props: {$size: number[]} & ThemeProps): CSSObject[] {
|
|
24
|
+
const {$size} = props
|
|
25
|
+
const {fonts, media} = props.theme.sanity
|
|
26
|
+
|
|
27
|
+
return responsive(media, $size, (size) => {
|
|
28
|
+
const {ascenderHeight, descenderHeight, lineHeight, iconSize} = fonts.text.sizes[size]
|
|
29
|
+
const capHeight = lineHeight - ascenderHeight - descenderHeight
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
width: rem(capHeight),
|
|
33
|
+
height: rem(capHeight),
|
|
34
|
+
|
|
35
|
+
'& > svg': {
|
|
36
|
+
display: 'block',
|
|
37
|
+
width: rem(iconSize),
|
|
38
|
+
height: rem(iconSize),
|
|
39
|
+
margin: (capHeight - iconSize) / 2,
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
}
|