@sanity/ui 2.0.0-beta.13 → 2.0.0-beta.15
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/index.esm.js +31 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +31 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/core/__workshop__/fontsPlugin.tsx +2 -2
- package/src/core/components/toast/toast.tsx +17 -2
- package/src/core/components/toast/toastProvider.tsx +20 -3
- package/src/core/constants.ts +22 -3
- package/src/core/primitives/popover/popoverCard.tsx +7 -2
- package/src/core/primitives/tooltip/tooltipCard.tsx +9 -3
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ const GlobalStyle = createGlobalStyle`
|
|
|
7
7
|
font-style: normal;
|
|
8
8
|
font-weight: 100 900;
|
|
9
9
|
font-display: swap;
|
|
10
|
-
src: url('https://
|
|
10
|
+
src: url('https://studio-static.sanity.io/InterVariable.ttf') format('ttf');
|
|
11
11
|
font-named-instance: 'Regular';
|
|
12
12
|
}
|
|
13
13
|
@font-face {
|
|
@@ -15,7 +15,7 @@ const GlobalStyle = createGlobalStyle`
|
|
|
15
15
|
font-style: italic;
|
|
16
16
|
font-weight: 100 900;
|
|
17
17
|
font-display: swap;
|
|
18
|
-
src: url('https://
|
|
18
|
+
src: url('https://studio-static.sanity.io/InterVariable-Italic.ttf') format('ttf');
|
|
19
19
|
font-named-instance: 'Italic';
|
|
20
20
|
}
|
|
21
21
|
`
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {CloseIcon} from '@sanity/icons'
|
|
2
2
|
import {ThemeColorToneKey} from '@sanity/ui/theme'
|
|
3
3
|
import styled from 'styled-components'
|
|
4
|
+
import {POPOVER_MOTION_CONTENT_OPACITY_PROPERTY} from '../../constants'
|
|
4
5
|
import {Box, Button, Card, Flex, Stack, Text} from '../../primitives'
|
|
6
|
+
import type {ButtonTone} from '../../types'
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* @public
|
|
@@ -20,17 +22,28 @@ const STATUS_CARD_TONE: {[key: string]: ThemeColorToneKey} = {
|
|
|
20
22
|
warning: 'caution',
|
|
21
23
|
success: 'positive',
|
|
22
24
|
info: 'primary',
|
|
23
|
-
}
|
|
25
|
+
} as const
|
|
26
|
+
|
|
27
|
+
const BUTTON_TONE = {
|
|
28
|
+
error: 'critical',
|
|
29
|
+
warning: 'caution',
|
|
30
|
+
success: 'positive',
|
|
31
|
+
info: 'primary',
|
|
32
|
+
} satisfies {[key: string]: ButtonTone}
|
|
24
33
|
|
|
25
34
|
const ROLES = {
|
|
26
35
|
error: 'alert',
|
|
27
36
|
warning: 'alert',
|
|
28
37
|
success: 'alert',
|
|
29
38
|
info: 'alert',
|
|
30
|
-
}
|
|
39
|
+
} as const
|
|
31
40
|
|
|
32
41
|
const Root = styled(Card)`
|
|
33
42
|
pointer-events: all;
|
|
43
|
+
& > * {
|
|
44
|
+
opacity: var(${POPOVER_MOTION_CONTENT_OPACITY_PROPERTY}, 1);
|
|
45
|
+
will-change: opacity;
|
|
46
|
+
}
|
|
34
47
|
`
|
|
35
48
|
|
|
36
49
|
const TextBox = styled(Flex)`
|
|
@@ -49,6 +62,7 @@ export function Toast(
|
|
|
49
62
|
): React.ReactElement {
|
|
50
63
|
const {closable, description, onClose, radius = 3, title, status, ...restProps} = props
|
|
51
64
|
const cardTone = status ? STATUS_CARD_TONE[status] : 'default'
|
|
65
|
+
const buttonTone = status ? BUTTON_TONE[status] : 'default'
|
|
52
66
|
const role = status ? ROLES[status] : 'status'
|
|
53
67
|
|
|
54
68
|
return (
|
|
@@ -84,6 +98,7 @@ export function Toast(
|
|
|
84
98
|
icon={CloseIcon}
|
|
85
99
|
mode="bleed"
|
|
86
100
|
padding={2}
|
|
101
|
+
tone={buttonTone}
|
|
87
102
|
onClick={onClose}
|
|
88
103
|
style={{verticalAlign: 'top'}}
|
|
89
104
|
/>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {AnimatePresence, motion} from 'framer-motion'
|
|
2
2
|
import {useCallback, useEffect, useMemo, useRef, useState, startTransition} from 'react'
|
|
3
3
|
import styled from 'styled-components'
|
|
4
|
+
import {POPOVER_MOTION_CONTENT_OPACITY_PROPERTY} from '../../constants'
|
|
4
5
|
import {useMounted} from '../../hooks/useMounted'
|
|
5
6
|
import {Box} from '../../primitives'
|
|
6
7
|
import {Layer} from '../../utils'
|
|
@@ -132,9 +133,25 @@ export function ToastProvider(props: ToastProviderProps): React.ReactElement {
|
|
|
132
133
|
<AnimatePresence initial={false}>
|
|
133
134
|
{state.map(({dismiss, id, params}) => (
|
|
134
135
|
<motion.div
|
|
135
|
-
animate={{
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
animate={{
|
|
137
|
+
opacity: [0, 1, 1],
|
|
138
|
+
[POPOVER_MOTION_CONTENT_OPACITY_PROPERTY as string]: [0, 0, 1],
|
|
139
|
+
y: 0,
|
|
140
|
+
scale: 1,
|
|
141
|
+
}}
|
|
142
|
+
exit={{
|
|
143
|
+
opacity: [1, 1, 0],
|
|
144
|
+
[POPOVER_MOTION_CONTENT_OPACITY_PROPERTY as string]: [1, 0, 0],
|
|
145
|
+
scale: 0.5,
|
|
146
|
+
transition: {duration: 0.2},
|
|
147
|
+
}}
|
|
148
|
+
initial={{
|
|
149
|
+
opacity: 0,
|
|
150
|
+
[POPOVER_MOTION_CONTENT_OPACITY_PROPERTY as string]: 0,
|
|
151
|
+
y: 32,
|
|
152
|
+
scale: 0.25,
|
|
153
|
+
willChange: 'transform',
|
|
154
|
+
}}
|
|
138
155
|
key={id}
|
|
139
156
|
layout="position"
|
|
140
157
|
transition={{type: 'spring', damping: 30, stiffness: 400}}
|
package/src/core/constants.ts
CHANGED
|
@@ -10,6 +10,11 @@ export const EMPTY_ARRAY: never[] = []
|
|
|
10
10
|
*/
|
|
11
11
|
export const EMPTY_RECORD: Record<string, never> = {}
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export const POPOVER_MOTION_CONTENT_OPACITY_PROPERTY = '--motion-content-opacity'
|
|
17
|
+
|
|
13
18
|
/**
|
|
14
19
|
* Shared `framer-motion` variants used by `Popover` and `Tooltip` components.
|
|
15
20
|
* @internal
|
|
@@ -20,9 +25,23 @@ export const POPOVER_MOTION_PROPS: {
|
|
|
20
25
|
exit: Variant
|
|
21
26
|
transition: Transition
|
|
22
27
|
} = {
|
|
23
|
-
initial: {
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
initial: {
|
|
29
|
+
opacity: 0.5,
|
|
30
|
+
[POPOVER_MOTION_CONTENT_OPACITY_PROPERTY as string]: 0,
|
|
31
|
+
scale: 0.97,
|
|
32
|
+
willChange: 'transform',
|
|
33
|
+
},
|
|
34
|
+
animate: {
|
|
35
|
+
opacity: [null, 1, 1],
|
|
36
|
+
[POPOVER_MOTION_CONTENT_OPACITY_PROPERTY as string]: [null, null, 1],
|
|
37
|
+
scale: 1,
|
|
38
|
+
},
|
|
39
|
+
exit: {
|
|
40
|
+
// @ts-expect-error -- passing null a second time is valid: https://github.com/framer/motion/blob/b9ce4c42914c3916ea523609c5b032dfc72718bb/packages/framer-motion/src/animation/utils/keyframes.ts#L34C22-L34C22
|
|
41
|
+
opacity: [null, null, 0],
|
|
42
|
+
[POPOVER_MOTION_CONTENT_OPACITY_PROPERTY as string]: [null, 0, 0],
|
|
43
|
+
scale: 0.97,
|
|
44
|
+
},
|
|
26
45
|
transition: {duration: 0.4, type: 'spring'},
|
|
27
46
|
}
|
|
28
47
|
|
|
@@ -3,7 +3,7 @@ import {ThemeColorSchemeKey} from '@sanity/ui/theme'
|
|
|
3
3
|
import {MotionProps, motion} from 'framer-motion'
|
|
4
4
|
import React, {CSSProperties, forwardRef, memo, useMemo} from 'react'
|
|
5
5
|
import styled from 'styled-components'
|
|
6
|
-
import {POPOVER_MOTION_PROPS} from '../../constants'
|
|
6
|
+
import {POPOVER_MOTION_CONTENT_OPACITY_PROPERTY, POPOVER_MOTION_PROPS} from '../../constants'
|
|
7
7
|
import {BoxOverflow, CardTone, Placement, PopoverMargins, Radius} from '../../types'
|
|
8
8
|
import {Arrow, useLayer} from '../../utils'
|
|
9
9
|
import {Card, CardProps} from '../card'
|
|
@@ -22,6 +22,10 @@ const MotionCard = styled(motion(Card))`
|
|
|
22
22
|
flex-direction: column;
|
|
23
23
|
width: max-content;
|
|
24
24
|
min-width: min-content;
|
|
25
|
+
& > * {
|
|
26
|
+
opacity: var(${POPOVER_MOTION_CONTENT_OPACITY_PROPERTY}, 1);
|
|
27
|
+
will-change: opacity;
|
|
28
|
+
}
|
|
25
29
|
`
|
|
26
30
|
|
|
27
31
|
/**
|
|
@@ -99,9 +103,10 @@ export const PopoverCard = memo(
|
|
|
99
103
|
top: y,
|
|
100
104
|
width,
|
|
101
105
|
zIndex,
|
|
106
|
+
willChange: animate ? 'transform' : undefined,
|
|
102
107
|
...style,
|
|
103
108
|
}),
|
|
104
|
-
[originX, originY, strategy, style, width, x, y, zIndex],
|
|
109
|
+
[animate, originX, originY, strategy, style, width, x, y, zIndex],
|
|
105
110
|
)
|
|
106
111
|
|
|
107
112
|
const arrowStyle: CSSProperties = useMemo(
|
|
@@ -2,7 +2,7 @@ import {ThemeColorSchemeKey} from '@sanity/ui/theme'
|
|
|
2
2
|
import {MotionProps, motion} from 'framer-motion'
|
|
3
3
|
import React, {CSSProperties, forwardRef, memo, useMemo} from 'react'
|
|
4
4
|
import styled from 'styled-components'
|
|
5
|
-
import {POPOVER_MOTION_PROPS} from '../../constants'
|
|
5
|
+
import {POPOVER_MOTION_CONTENT_OPACITY_PROPERTY, POPOVER_MOTION_PROPS} from '../../constants'
|
|
6
6
|
import {Placement, Radius} from '../../types'
|
|
7
7
|
import {Arrow} from '../../utils'
|
|
8
8
|
import {Card, CardProps} from '../card'
|
|
@@ -12,7 +12,12 @@ import {
|
|
|
12
12
|
DEFAULT_TOOLTIP_ARROW_WIDTH,
|
|
13
13
|
} from './constants'
|
|
14
14
|
|
|
15
|
-
const MotionCard = styled(motion(Card))
|
|
15
|
+
const MotionCard = styled(motion(Card))`
|
|
16
|
+
& > * {
|
|
17
|
+
opacity: var(${POPOVER_MOTION_CONTENT_OPACITY_PROPERTY}, 1);
|
|
18
|
+
will-change: opacity;
|
|
19
|
+
}
|
|
20
|
+
`
|
|
16
21
|
|
|
17
22
|
/**
|
|
18
23
|
* @internal
|
|
@@ -57,9 +62,10 @@ export const TooltipCard = memo(
|
|
|
57
62
|
() => ({
|
|
58
63
|
originX,
|
|
59
64
|
originY,
|
|
65
|
+
willChange: animate ? 'transform' : undefined,
|
|
60
66
|
...style,
|
|
61
67
|
}),
|
|
62
|
-
[originX, originY, style],
|
|
68
|
+
[animate, originX, originY, style],
|
|
63
69
|
)
|
|
64
70
|
|
|
65
71
|
const arrowStyle: CSSProperties = useMemo(
|