@sanity/ui 2.0.0-alpha.21 → 2.0.0-alpha.23
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 +2 -0
- package/dist/index.esm.js +30 -16
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +30 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/autocomplete/autocomplete.tsx +1 -1
- package/src/components/toast/toast.tsx +8 -3
- package/src/primitives/avatar/avatar.tsx +4 -2
- package/src/primitives/avatar/styles.ts +7 -0
- package/src/primitives/badge/styles.ts +3 -1
- package/src/primitives/tooltip/constants.ts +1 -0
- package/src/primitives/tooltip/tooltip.tsx +13 -5
- package/src/theme/studioTheme/theme.ts +3 -3
package/package.json
CHANGED
|
@@ -10,6 +10,7 @@ export interface ToastProps {
|
|
|
10
10
|
closable?: boolean
|
|
11
11
|
description?: React.ReactNode
|
|
12
12
|
onClose?: () => void
|
|
13
|
+
radius?: number | number[]
|
|
13
14
|
title?: React.ReactNode
|
|
14
15
|
status?: 'error' | 'warning' | 'success' | 'info'
|
|
15
16
|
}
|
|
@@ -46,7 +47,7 @@ const TextBox = styled(Flex)`
|
|
|
46
47
|
export function Toast(
|
|
47
48
|
props: ToastProps & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'height' | 'ref' | 'title'>,
|
|
48
49
|
): React.ReactElement {
|
|
49
|
-
const {closable, description, onClose, title, status, ...restProps} = props
|
|
50
|
+
const {closable, description, onClose, radius = 3, title, status, ...restProps} = props
|
|
50
51
|
const cardTone = status ? STATUS_CARD_TONE[status] : 'default'
|
|
51
52
|
const role = status ? ROLES[status] : 'status'
|
|
52
53
|
|
|
@@ -56,14 +57,18 @@ export function Toast(
|
|
|
56
57
|
role={role}
|
|
57
58
|
{...restProps}
|
|
58
59
|
marginTop={3}
|
|
59
|
-
radius={
|
|
60
|
+
radius={radius}
|
|
60
61
|
shadow={2}
|
|
61
62
|
tone={cardTone}
|
|
62
63
|
>
|
|
63
64
|
<Flex align="flex-start">
|
|
64
65
|
<TextBox flex={1} padding={3}>
|
|
65
66
|
<Stack space={3}>
|
|
66
|
-
{title &&
|
|
67
|
+
{title && (
|
|
68
|
+
<Text size={1} weight="medium">
|
|
69
|
+
{title}
|
|
70
|
+
</Text>
|
|
71
|
+
)}
|
|
67
72
|
{description && (
|
|
68
73
|
<Text muted size={1}>
|
|
69
74
|
{description}
|
|
@@ -42,6 +42,8 @@ const Stroke = styled.ellipse(avatarStyle.stroke)
|
|
|
42
42
|
|
|
43
43
|
const Initials = styled.div(avatarStyle.initials)
|
|
44
44
|
|
|
45
|
+
const Image = styled.svg(avatarStyle.image)
|
|
46
|
+
|
|
45
47
|
/**
|
|
46
48
|
* Avatars are used to represent people and other agents (e.g. bots).
|
|
47
49
|
*
|
|
@@ -131,7 +133,7 @@ export const Avatar = forwardRef(function Avatar(
|
|
|
131
133
|
</Arrow>
|
|
132
134
|
|
|
133
135
|
{!imageFailed && src && (
|
|
134
|
-
<
|
|
136
|
+
<Image viewBox={`0 0 ${_sizeRem} ${_sizeRem}`} fill="none">
|
|
135
137
|
<defs>
|
|
136
138
|
<pattern id={imageId} patternContentUnits="objectBoundingBox" width="1" height="1">
|
|
137
139
|
<image
|
|
@@ -162,7 +164,7 @@ export const Avatar = forwardRef(function Avatar(
|
|
|
162
164
|
stroke={color}
|
|
163
165
|
vectorEffect="non-scaling-stroke"
|
|
164
166
|
/>
|
|
165
|
-
</
|
|
167
|
+
</Image>
|
|
166
168
|
)}
|
|
167
169
|
|
|
168
170
|
{(imageFailed || !src) && initials && (
|
|
@@ -9,6 +9,7 @@ export const avatarStyle = {
|
|
|
9
9
|
bgStroke: avatarBgStrokeStyle,
|
|
10
10
|
stroke: avatarStrokeStyle,
|
|
11
11
|
initials: avatarInitialsStyle,
|
|
12
|
+
image: avatarImageStyle,
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
function avatarArrowStyle(): CSSObject {
|
|
@@ -123,6 +124,12 @@ export function responsiveAvatarSizeStyle(
|
|
|
123
124
|
})
|
|
124
125
|
}
|
|
125
126
|
|
|
127
|
+
export function avatarImageStyle(): CSSObject {
|
|
128
|
+
return {
|
|
129
|
+
position: 'relative',
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
126
133
|
export function avatarInitialsStyle(props: ThemeProps): CSSObject {
|
|
127
134
|
const {theme} = props
|
|
128
135
|
const {base} = theme.sanity.color
|
|
@@ -8,7 +8,9 @@ export function badgeStyle(props: BadgeStyleProps & ThemeProps): CSSObject {
|
|
|
8
8
|
const color = palette[$tone] || palette.default
|
|
9
9
|
|
|
10
10
|
return {
|
|
11
|
-
|
|
11
|
+
'--card-fg-color': color.enabled.fg,
|
|
12
|
+
|
|
13
|
+
backgroundColor: color.enabled.bg2,
|
|
12
14
|
color: color.enabled.fg,
|
|
13
15
|
boxShadow: `inset 0 0 0 1px ${color.enabled.border}`,
|
|
14
16
|
cursor: 'default',
|
|
@@ -30,7 +30,11 @@ import {Placement} from '../../types'
|
|
|
30
30
|
import {Layer, LayerProps, Portal, useBoundaryElement, usePortal} from '../../utils'
|
|
31
31
|
import {Card} from '../card'
|
|
32
32
|
import {Delay} from '../types'
|
|
33
|
-
import {
|
|
33
|
+
import {
|
|
34
|
+
DEFAULT_FALLBACK_PLACEMENTS,
|
|
35
|
+
DEFAULT_TOOLTIP_DISTANCE,
|
|
36
|
+
DEFAULT_TOOLTIP_PADDING,
|
|
37
|
+
} from './constants'
|
|
34
38
|
import {TooltipArrow} from './tooltipArrow'
|
|
35
39
|
import {useTooltipDelayGroup} from './tooltipDelayGroup'
|
|
36
40
|
|
|
@@ -40,6 +44,7 @@ import {useTooltipDelayGroup} from './tooltipDelayGroup'
|
|
|
40
44
|
export interface TooltipProps extends Omit<LayerProps, 'as'> {
|
|
41
45
|
/** @deprecated Use `fallbackPlacements` instead. */
|
|
42
46
|
allowedAutoPlacements?: Placement[]
|
|
47
|
+
arrow?: boolean
|
|
43
48
|
boundaryElement?: HTMLElement | null
|
|
44
49
|
children?: React.ReactElement
|
|
45
50
|
content?: React.ReactNode
|
|
@@ -78,6 +83,7 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
78
83
|
const boundaryElementContext = useBoundaryElement()
|
|
79
84
|
const theme = useTheme()
|
|
80
85
|
const {
|
|
86
|
+
arrow: arrowProp = true,
|
|
81
87
|
boundaryElement = boundaryElementContext?.element,
|
|
82
88
|
children: childProp,
|
|
83
89
|
content,
|
|
@@ -129,7 +135,7 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
129
135
|
)
|
|
130
136
|
|
|
131
137
|
// Define distance between reference and floating element
|
|
132
|
-
ret.push(offset({mainAxis:
|
|
138
|
+
ret.push(offset({mainAxis: DEFAULT_TOOLTIP_DISTANCE}))
|
|
133
139
|
|
|
134
140
|
// Shift the tooltip so its sits with the boundary element
|
|
135
141
|
ret.push(
|
|
@@ -141,10 +147,12 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
141
147
|
)
|
|
142
148
|
|
|
143
149
|
// Place arrow
|
|
144
|
-
|
|
150
|
+
if (arrowProp) {
|
|
151
|
+
ret.push(arrow({element: arrowRef, padding: 2}))
|
|
152
|
+
}
|
|
145
153
|
|
|
146
154
|
return ret
|
|
147
|
-
}, [boundaryElement, fallbackPlacements])
|
|
155
|
+
}, [arrowProp, boundaryElement, fallbackPlacements])
|
|
148
156
|
|
|
149
157
|
const {floatingStyles, placement, middlewareData, refs, update} = useFloating({
|
|
150
158
|
middleware,
|
|
@@ -384,7 +392,7 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
384
392
|
shadow={shadow}
|
|
385
393
|
>
|
|
386
394
|
{content}
|
|
387
|
-
<TooltipArrow ref={setArrow} style={arrowStyle} />
|
|
395
|
+
{arrowProp && <TooltipArrow ref={setArrow} style={arrowStyle} />}
|
|
388
396
|
</Card>
|
|
389
397
|
</Root>
|
|
390
398
|
)
|
|
@@ -8,9 +8,9 @@ import {fonts} from './fonts'
|
|
|
8
8
|
export const studioTheme: RootTheme = {
|
|
9
9
|
avatar: {
|
|
10
10
|
sizes: [
|
|
11
|
-
{distance: -3, size:
|
|
12
|
-
{distance: -6, size:
|
|
13
|
-
{distance: -9, size:
|
|
11
|
+
{distance: -3, size: 19},
|
|
12
|
+
{distance: -6, size: 31},
|
|
13
|
+
{distance: -9, size: 51},
|
|
14
14
|
],
|
|
15
15
|
focusRing: {offset: 0, width: 1},
|
|
16
16
|
},
|