@sanity/ui 2.0.0-beta.1 → 2.0.0-beta.2
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 +1 -1
- package/dist/index.esm.js +92 -80
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +92 -80
- package/dist/index.js.map +1 -1
- package/dist/theme.esm.js +15 -5
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +15 -5
- package/dist/theme.js.map +1 -1
- package/package.json +1 -1
- package/src/core/__workshop__/constants.ts +3 -2
- package/src/core/primitives/avatar/__workshop__/asButton.tsx +1 -1
- package/src/core/primitives/avatar/__workshop__/stack.tsx +1 -1
- package/src/core/primitives/avatar/avatar.tsx +14 -4
- package/src/core/primitives/avatar/avatarCounter.tsx +16 -5
- package/src/core/primitives/avatar/avatarStack.tsx +2 -2
- package/src/core/primitives/tooltip/tooltip.tsx +1 -1
- package/src/core/types/avatar.ts +1 -1
- package/src/theme/defaults/config.ts +1 -0
- package/src/theme/defaults/fonts.ts +13 -5
package/package.json
CHANGED
|
@@ -17,9 +17,10 @@ import {
|
|
|
17
17
|
import {ThemeColorSpotKey, ThemeColorToneKey, ThemeFontWeightKey} from '@sanity/ui/theme'
|
|
18
18
|
|
|
19
19
|
export const WORKSHOP_AVATAR_SIZE_OPTIONS: {[key: string]: AvatarSize} = {
|
|
20
|
-
'0
|
|
21
|
-
'1': 1,
|
|
20
|
+
'0': 0,
|
|
21
|
+
'1 (default)': 1,
|
|
22
22
|
'2': 2,
|
|
23
|
+
'3': 3,
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export const WORKSHOP_BADGE_MODE_OPTIONS: {[key: string]: BadgeMode} = {
|
|
@@ -3,7 +3,7 @@ import {useSelect} from '@sanity/ui-workshop'
|
|
|
3
3
|
import {WORKSHOP_AVATAR_SIZE_OPTIONS} from '../../../__workshop__/constants'
|
|
4
4
|
|
|
5
5
|
export default function AsButtonStory() {
|
|
6
|
-
const size = useSelect('Size', WORKSHOP_AVATAR_SIZE_OPTIONS,
|
|
6
|
+
const size = useSelect('Size', WORKSHOP_AVATAR_SIZE_OPTIONS, 1, 'Props')
|
|
7
7
|
|
|
8
8
|
return (
|
|
9
9
|
<Flex align="center" height="fill" justify="center">
|
|
@@ -3,7 +3,7 @@ import {useSelect} from '@sanity/ui-workshop'
|
|
|
3
3
|
import {WORKSHOP_AVATAR_SIZE_OPTIONS} from '../../../__workshop__/constants'
|
|
4
4
|
|
|
5
5
|
export default function StackStory() {
|
|
6
|
-
const size = useSelect('Size', WORKSHOP_AVATAR_SIZE_OPTIONS,
|
|
6
|
+
const size = useSelect('Size', WORKSHOP_AVATAR_SIZE_OPTIONS, 1, 'Props')
|
|
7
7
|
|
|
8
8
|
return (
|
|
9
9
|
<Flex align="center" height="fill" justify="center">
|
|
@@ -69,12 +69,12 @@ export const Avatar = forwardRef(function Avatar(
|
|
|
69
69
|
arrowPosition: arrowPositionProp,
|
|
70
70
|
animateArrowFrom,
|
|
71
71
|
status = 'online',
|
|
72
|
-
size: sizeProp =
|
|
72
|
+
size: sizeProp = 1,
|
|
73
73
|
...restProps
|
|
74
74
|
} = props
|
|
75
|
+
const {avatar} = useTheme_v2()
|
|
75
76
|
const as = ReactIs.isValidElementType(asProp) ? asProp : 'div'
|
|
76
77
|
const size = useArrayProp(sizeProp)
|
|
77
|
-
const {avatar} = useTheme_v2()
|
|
78
78
|
|
|
79
79
|
// @todo: remove this
|
|
80
80
|
const avatarSize = avatar.sizes[size[0]] || avatar.sizes[0]
|
|
@@ -111,7 +111,17 @@ export const Avatar = forwardRef(function Avatar(
|
|
|
111
111
|
}
|
|
112
112
|
}, [onImageLoadError])
|
|
113
113
|
|
|
114
|
-
const initialsSize = useMemo(
|
|
114
|
+
const initialsSize = useMemo(
|
|
115
|
+
() =>
|
|
116
|
+
size.map((s) => {
|
|
117
|
+
if (s === 1) return 1
|
|
118
|
+
if (s === 2) return 3
|
|
119
|
+
if (s === 3) return 5
|
|
120
|
+
|
|
121
|
+
return 0
|
|
122
|
+
}),
|
|
123
|
+
[size],
|
|
124
|
+
)
|
|
115
125
|
|
|
116
126
|
return (
|
|
117
127
|
<Root
|
|
@@ -175,7 +185,7 @@ export const Avatar = forwardRef(function Avatar(
|
|
|
175
185
|
{(imageFailed || !src) && initials && (
|
|
176
186
|
<>
|
|
177
187
|
<Initials>
|
|
178
|
-
<InitialsLabel forwardedAs="span" size={initialsSize}>
|
|
188
|
+
<InitialsLabel forwardedAs="span" size={initialsSize} weight="medium">
|
|
179
189
|
{initials}
|
|
180
190
|
</InitialsLabel>
|
|
181
191
|
</Initials>
|
|
@@ -5,7 +5,7 @@ import {EMPTY_RECORD} from '../../constants'
|
|
|
5
5
|
import {useArrayProp} from '../../hooks'
|
|
6
6
|
import {rem, _responsive, ThemeProps} from '../../styles'
|
|
7
7
|
import {AvatarSize} from '../../types'
|
|
8
|
-
import {
|
|
8
|
+
import {Label} from '../label'
|
|
9
9
|
|
|
10
10
|
function _responsiveAvatarCounterSizeStyle(props: {$size: AvatarSize[]} & ThemeProps) {
|
|
11
11
|
const {avatar, media} = getTheme_v2(props.theme)
|
|
@@ -67,15 +67,26 @@ export const AvatarCounter = forwardRef(function AvatarCounter(
|
|
|
67
67
|
props: AvatarCounterProps,
|
|
68
68
|
ref: React.Ref<HTMLDivElement>,
|
|
69
69
|
) {
|
|
70
|
-
const {count, size: sizeProp =
|
|
70
|
+
const {count, size: sizeProp = 1} = props
|
|
71
71
|
const size = useArrayProp(sizeProp)
|
|
72
|
-
|
|
72
|
+
|
|
73
|
+
const fontSize = useMemo(
|
|
74
|
+
() =>
|
|
75
|
+
size.map((s) => {
|
|
76
|
+
if (s === 1) return 1
|
|
77
|
+
if (s === 2) return 3
|
|
78
|
+
if (s === 3) return 5
|
|
79
|
+
|
|
80
|
+
return 0
|
|
81
|
+
}),
|
|
82
|
+
[size],
|
|
83
|
+
)
|
|
73
84
|
|
|
74
85
|
return (
|
|
75
86
|
<Root $size={size} data-ui="AvatarCounter" ref={ref}>
|
|
76
|
-
<
|
|
87
|
+
<Label as="span" size={fontSize} weight="medium">
|
|
77
88
|
{count}
|
|
78
|
-
</
|
|
89
|
+
</Label>
|
|
79
90
|
</Root>
|
|
80
91
|
)
|
|
81
92
|
})
|
|
@@ -63,7 +63,7 @@ export const AvatarStack = forwardRef(function AvatarStack(
|
|
|
63
63
|
const {
|
|
64
64
|
children: childrenProp,
|
|
65
65
|
maxLength: maxLengthProp = 4,
|
|
66
|
-
size: sizeProp =
|
|
66
|
+
size: sizeProp = 1,
|
|
67
67
|
...restProps
|
|
68
68
|
} = props
|
|
69
69
|
const children = childrenToElementArray(childrenProp).filter(
|
|
@@ -81,7 +81,7 @@ export const AvatarStack = forwardRef(function AvatarStack(
|
|
|
81
81
|
<Root data-ui="AvatarStack" {...restProps} ref={ref} $size={size}>
|
|
82
82
|
{len === 0 && (
|
|
83
83
|
<div>
|
|
84
|
-
<AvatarCounter count={len} />
|
|
84
|
+
<AvatarCounter count={len} size={size} />
|
|
85
85
|
</div>
|
|
86
86
|
)}
|
|
87
87
|
|
|
@@ -105,7 +105,7 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
105
105
|
disabled,
|
|
106
106
|
fallbackPlacements: fallbackPlacementsProp = props.fallbackPlacements ??
|
|
107
107
|
DEFAULT_FALLBACK_PLACEMENTS[props.placement ?? 'bottom'],
|
|
108
|
-
padding =
|
|
108
|
+
padding = 2,
|
|
109
109
|
placement: placementProp = 'bottom',
|
|
110
110
|
portal: portalProp,
|
|
111
111
|
radius = 2,
|
package/src/core/types/avatar.ts
CHANGED
|
@@ -125,7 +125,15 @@ export const defaultThemeFonts: ThemeFonts = {
|
|
|
125
125
|
{
|
|
126
126
|
ascenderHeight: 2,
|
|
127
127
|
descenderHeight: 2,
|
|
128
|
-
fontSize:
|
|
128
|
+
fontSize: 8.1,
|
|
129
|
+
iconSize: 13,
|
|
130
|
+
lineHeight: 10,
|
|
131
|
+
letterSpacing: 0.5,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
ascenderHeight: 2,
|
|
135
|
+
descenderHeight: 2,
|
|
136
|
+
fontSize: 9.5,
|
|
129
137
|
iconSize: 15,
|
|
130
138
|
lineHeight: 11,
|
|
131
139
|
letterSpacing: 0.5,
|
|
@@ -133,7 +141,7 @@ export const defaultThemeFonts: ThemeFonts = {
|
|
|
133
141
|
{
|
|
134
142
|
ascenderHeight: 2,
|
|
135
143
|
descenderHeight: 2,
|
|
136
|
-
fontSize:
|
|
144
|
+
fontSize: 10.8,
|
|
137
145
|
iconSize: 17,
|
|
138
146
|
lineHeight: 12,
|
|
139
147
|
letterSpacing: 0.5,
|
|
@@ -141,7 +149,7 @@ export const defaultThemeFonts: ThemeFonts = {
|
|
|
141
149
|
{
|
|
142
150
|
ascenderHeight: 2,
|
|
143
151
|
descenderHeight: 2,
|
|
144
|
-
fontSize: 12.
|
|
152
|
+
fontSize: 12.25,
|
|
145
153
|
iconSize: 19,
|
|
146
154
|
lineHeight: 13,
|
|
147
155
|
letterSpacing: 0.5,
|
|
@@ -149,7 +157,7 @@ export const defaultThemeFonts: ThemeFonts = {
|
|
|
149
157
|
{
|
|
150
158
|
ascenderHeight: 2,
|
|
151
159
|
descenderHeight: 2,
|
|
152
|
-
fontSize:
|
|
160
|
+
fontSize: 13.6,
|
|
153
161
|
iconSize: 21,
|
|
154
162
|
lineHeight: 14,
|
|
155
163
|
letterSpacing: 0.5,
|
|
@@ -157,7 +165,7 @@ export const defaultThemeFonts: ThemeFonts = {
|
|
|
157
165
|
{
|
|
158
166
|
ascenderHeight: 2,
|
|
159
167
|
descenderHeight: 2,
|
|
160
|
-
fontSize: 15
|
|
168
|
+
fontSize: 15,
|
|
161
169
|
iconSize: 23,
|
|
162
170
|
lineHeight: 15,
|
|
163
171
|
letterSpacing: 0.5,
|