@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ui",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.2",
4
4
  "sideEffects": false,
5
5
  "types": "./dist/index.d.ts",
6
6
  "source": "./exports/index.ts",
@@ -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 (default)': 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, 0, 'Props')
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, 0, 'Props')
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 = 0,
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(() => size.map((s) => (s === 0 ? 0 : s * 2)), [size])
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 {Text} from '../text'
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 = 0} = props
70
+ const {count, size: sizeProp = 1} = props
71
71
  const size = useArrayProp(sizeProp)
72
- const counterSize = useMemo(() => size.map((s) => (s === 0 ? 0 : s + 1)), [size])
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
- <Text as="span" size={counterSize} weight="medium">
87
+ <Label as="span" size={fontSize} weight="medium">
77
88
  {count}
78
- </Text>
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 = 0,
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 = 3,
108
+ padding = 2,
109
109
  placement: placementProp = 'bottom',
110
110
  portal: portalProp,
111
111
  radius = 2,
@@ -6,7 +6,7 @@ export type AvatarPosition = 'top' | 'bottom' | 'inside'
6
6
  /**
7
7
  * @public
8
8
  */
9
- export type AvatarSize = 0 | 1 | 2
9
+ export type AvatarSize = 0 | 1 | 2 | 3
10
10
 
11
11
  /**
12
12
  * @public
@@ -7,6 +7,7 @@ export const defaultThemeConfig: Omit<RootTheme_v2, 'color' | 'font'> = {
7
7
  _version: 2,
8
8
  avatar: {
9
9
  sizes: [
10
+ {distance: -4, size: 19},
10
11
  {distance: -4, size: 25},
11
12
  {distance: -8, size: 33},
12
13
  {distance: -12, size: 49},
@@ -125,7 +125,15 @@ export const defaultThemeFonts: ThemeFonts = {
125
125
  {
126
126
  ascenderHeight: 2,
127
127
  descenderHeight: 2,
128
- fontSize: 9.8,
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: 11.25,
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.75,
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: 14,
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.5,
168
+ fontSize: 15,
161
169
  iconSize: 23,
162
170
  lineHeight: 15,
163
171
  letterSpacing: 0.5,