@transferwise/components 0.0.0-experimental-8109a86 → 0.0.0-experimental-688d30c
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/build/avatarView/AvatarView.js +5 -5
- package/build/avatarView/AvatarView.js.map +1 -1
- package/build/avatarView/AvatarView.mjs +5 -5
- package/build/avatarView/AvatarView.mjs.map +1 -1
- package/build/common/circle/Circle.js +3 -1
- package/build/common/circle/Circle.js.map +1 -1
- package/build/common/circle/Circle.mjs +3 -1
- package/build/common/circle/Circle.mjs.map +1 -1
- package/build/i18n/zh-HK.json +5 -0
- package/build/i18n/zh-HK.json.js +5 -0
- package/build/i18n/zh-HK.json.js.map +1 -1
- package/build/i18n/zh-HK.json.mjs +5 -0
- package/build/i18n/zh-HK.json.mjs.map +1 -1
- package/build/main.css +0 -35
- package/build/styles/avatarView/AvatarView.css +0 -6
- package/build/styles/main.css +0 -35
- package/build/types/avatarView/AvatarView.d.ts +1 -1
- package/build/types/avatarView/AvatarView.d.ts.map +1 -1
- package/build/types/common/circle/Circle.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/avatarView/AvatarView.css +0 -6
- package/src/avatarView/AvatarView.less +1 -7
- package/src/avatarView/AvatarView.story.tsx +41 -54
- package/src/avatarView/AvatarView.tsx +4 -4
- package/src/avatarWrapper/AvatarWrapper.story.tsx +19 -0
- package/src/circularButton/CircularButton.spec.tsx +0 -36
- package/src/common/circle/Circle.less +2 -2
- package/src/common/circle/Circle.tsx +3 -1
- package/src/flowNavigation/FlowNavigation.story.tsx +16 -11
- package/src/i18n/zh-HK.json +5 -0
- package/src/main.css +0 -35
- package/src/main.less +0 -1
- package/src/overlayHeader/OverlayHeader.story.tsx +2 -5
- package/build/styles/avatarGroup/AvatarGroup.css +0 -29
- package/build/types/avatarGroup/AvatarGroup.d.ts +0 -18
- package/build/types/avatarGroup/AvatarGroup.d.ts.map +0 -1
- package/build/types/avatarGroup/index.d.ts +0 -3
- package/build/types/avatarGroup/index.d.ts.map +0 -1
- package/src/avatarGroup/AvatarGroup.css +0 -29
- package/src/avatarGroup/AvatarGroup.less +0 -42
- package/src/avatarGroup/AvatarGroup.story.tsx +0 -284
- package/src/avatarGroup/AvatarGroup.tsx +0 -117
- package/src/avatarGroup/index.ts +0 -2
- package/src/circularButton/__snapshots__/CircularButton.spec.tsx.snap +0 -381
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import AvatarGroup, { AvatarGroupProps } from '.';
|
|
3
|
-
import { Bank, Briefcase } from '@transferwise/icons';
|
|
4
|
-
import Title from '../title';
|
|
5
|
-
import { Flag } from '@wise/art';
|
|
6
|
-
import { storyConfig } from '../test-utils';
|
|
7
|
-
import RadioOption from '../radioOption';
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
title: 'Content/AvatarGroup',
|
|
11
|
-
} satisfies Meta<typeof AvatarGroup>;
|
|
12
|
-
|
|
13
|
-
type Story = StoryObj<typeof AvatarGroup>;
|
|
14
|
-
|
|
15
|
-
const sizes: AvatarGroupProps['size'][] = [16, 24, 32, 40, 48, 56, 72];
|
|
16
|
-
|
|
17
|
-
export const Diagonal: Story = storyConfig(
|
|
18
|
-
{
|
|
19
|
-
render: () => (
|
|
20
|
-
<div
|
|
21
|
-
style={{
|
|
22
|
-
gap: '1em',
|
|
23
|
-
display: 'grid',
|
|
24
|
-
justifyContent: 'space-between',
|
|
25
|
-
gridTemplate: `auto auto / repeat(${sizes.length}, min-content)`,
|
|
26
|
-
}}
|
|
27
|
-
>
|
|
28
|
-
{sizes.map((size) => (
|
|
29
|
-
<div key={size}>{size}</div>
|
|
30
|
-
))}
|
|
31
|
-
|
|
32
|
-
{sizes.map((size) => (
|
|
33
|
-
<AvatarGroup
|
|
34
|
-
key={size}
|
|
35
|
-
size={size}
|
|
36
|
-
orientation="diagonal"
|
|
37
|
-
avatars={[{ profileName: 'Jay Jay' }, { profileName: 'Amy Amy' }]}
|
|
38
|
-
/>
|
|
39
|
-
))}
|
|
40
|
-
|
|
41
|
-
{sizes.map((size) => (
|
|
42
|
-
<AvatarGroup
|
|
43
|
-
key={size}
|
|
44
|
-
size={size}
|
|
45
|
-
orientation="diagonal"
|
|
46
|
-
interactive
|
|
47
|
-
avatars={[{ profileName: 'Jay Jay' }, { profileName: 'Amy Amy' }]}
|
|
48
|
-
/>
|
|
49
|
-
))}
|
|
50
|
-
|
|
51
|
-
{sizes.map((size) => (
|
|
52
|
-
<AvatarGroup
|
|
53
|
-
key={size}
|
|
54
|
-
size={size}
|
|
55
|
-
orientation="diagonal"
|
|
56
|
-
avatars={[{ asset: <Briefcase size="16" /> }, { asset: <Bank size="16" /> }]}
|
|
57
|
-
/>
|
|
58
|
-
))}
|
|
59
|
-
|
|
60
|
-
{sizes.map((size) => (
|
|
61
|
-
<AvatarGroup
|
|
62
|
-
key={size}
|
|
63
|
-
size={size}
|
|
64
|
-
orientation="diagonal"
|
|
65
|
-
interactive
|
|
66
|
-
avatars={[{ asset: <Briefcase size="16" /> }, { asset: <Bank size="16" /> }]}
|
|
67
|
-
/>
|
|
68
|
-
))}
|
|
69
|
-
|
|
70
|
-
{sizes.map((size) => (
|
|
71
|
-
<AvatarGroup
|
|
72
|
-
key={size}
|
|
73
|
-
size={size}
|
|
74
|
-
orientation="diagonal"
|
|
75
|
-
avatars={[{ asset: <Flag code="EU" /> }, { asset: <Flag code="GB" /> }]}
|
|
76
|
-
/>
|
|
77
|
-
))}
|
|
78
|
-
|
|
79
|
-
{sizes.map((size) => (
|
|
80
|
-
<AvatarGroup
|
|
81
|
-
key={size}
|
|
82
|
-
size={size}
|
|
83
|
-
orientation="diagonal"
|
|
84
|
-
interactive
|
|
85
|
-
avatars={[{ asset: <Flag code="EU" /> }, { asset: <Flag code="GB" /> }]}
|
|
86
|
-
/>
|
|
87
|
-
))}
|
|
88
|
-
|
|
89
|
-
{sizes.map((size) => (
|
|
90
|
-
<AvatarGroup
|
|
91
|
-
key={size}
|
|
92
|
-
size={size}
|
|
93
|
-
orientation="diagonal"
|
|
94
|
-
avatars={[{ imgSrc: './avatar-square-dude.webp' }, { imgSrc: './tapestry-01.png' }]}
|
|
95
|
-
/>
|
|
96
|
-
))}
|
|
97
|
-
|
|
98
|
-
{sizes.map((size) => (
|
|
99
|
-
<AvatarGroup
|
|
100
|
-
key={size}
|
|
101
|
-
size={size}
|
|
102
|
-
orientation="diagonal"
|
|
103
|
-
interactive
|
|
104
|
-
avatars={[{ imgSrc: './avatar-square-dude.webp' }, { imgSrc: './tapestry-01.png' }]}
|
|
105
|
-
/>
|
|
106
|
-
))}
|
|
107
|
-
</div>
|
|
108
|
-
),
|
|
109
|
-
},
|
|
110
|
-
{ variants: ['light', 'dark'] },
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
export const Horizontal: Story = storyConfig(
|
|
114
|
-
{
|
|
115
|
-
render: () => (
|
|
116
|
-
<div
|
|
117
|
-
style={{
|
|
118
|
-
gap: '1em',
|
|
119
|
-
display: 'grid',
|
|
120
|
-
justifyContent: 'space-between',
|
|
121
|
-
gridTemplate: `auto auto / repeat(${sizes.length}, min-content)`,
|
|
122
|
-
}}
|
|
123
|
-
>
|
|
124
|
-
{sizes.map((size) => (
|
|
125
|
-
<div key={size}>{size}</div>
|
|
126
|
-
))}
|
|
127
|
-
|
|
128
|
-
{sizes.map((size) => (
|
|
129
|
-
<AvatarGroup
|
|
130
|
-
key={size}
|
|
131
|
-
size={size}
|
|
132
|
-
orientation="horizontal"
|
|
133
|
-
avatars={[{ profileName: 'Jay Jay' }, { profileName: 'Amy Amy' }]}
|
|
134
|
-
/>
|
|
135
|
-
))}
|
|
136
|
-
|
|
137
|
-
{sizes.map((size) => (
|
|
138
|
-
<AvatarGroup
|
|
139
|
-
key={size}
|
|
140
|
-
size={size}
|
|
141
|
-
orientation="horizontal"
|
|
142
|
-
interactive
|
|
143
|
-
avatars={[{ profileName: 'Jay Jay' }, { profileName: 'Amy Amy' }]}
|
|
144
|
-
/>
|
|
145
|
-
))}
|
|
146
|
-
|
|
147
|
-
{sizes.map((size) => (
|
|
148
|
-
<AvatarGroup
|
|
149
|
-
key={size}
|
|
150
|
-
size={size}
|
|
151
|
-
orientation="horizontal"
|
|
152
|
-
avatars={[{ asset: <Briefcase size="16" /> }, { asset: <Bank size="16" /> }]}
|
|
153
|
-
/>
|
|
154
|
-
))}
|
|
155
|
-
|
|
156
|
-
{sizes.map((size) => (
|
|
157
|
-
<AvatarGroup
|
|
158
|
-
key={size}
|
|
159
|
-
size={size}
|
|
160
|
-
orientation="horizontal"
|
|
161
|
-
interactive
|
|
162
|
-
avatars={[{ asset: <Briefcase size="16" /> }, { asset: <Bank size="16" /> }]}
|
|
163
|
-
/>
|
|
164
|
-
))}
|
|
165
|
-
|
|
166
|
-
{sizes.map((size) => (
|
|
167
|
-
<AvatarGroup
|
|
168
|
-
key={size}
|
|
169
|
-
size={size}
|
|
170
|
-
orientation="horizontal"
|
|
171
|
-
avatars={[{ asset: <Flag code="EU" /> }, { asset: <Flag code="GB" /> }]}
|
|
172
|
-
/>
|
|
173
|
-
))}
|
|
174
|
-
|
|
175
|
-
{sizes.map((size) => (
|
|
176
|
-
<AvatarGroup
|
|
177
|
-
key={size}
|
|
178
|
-
size={size}
|
|
179
|
-
orientation="horizontal"
|
|
180
|
-
interactive
|
|
181
|
-
avatars={[{ asset: <Flag code="EU" /> }, { asset: <Flag code="GB" /> }]}
|
|
182
|
-
/>
|
|
183
|
-
))}
|
|
184
|
-
|
|
185
|
-
{sizes.map((size) => (
|
|
186
|
-
<AvatarGroup
|
|
187
|
-
key={size}
|
|
188
|
-
size={size}
|
|
189
|
-
orientation="horizontal"
|
|
190
|
-
avatars={[{ imgSrc: './avatar-square-dude.webp' }, { imgSrc: './tapestry-01.png' }]}
|
|
191
|
-
/>
|
|
192
|
-
))}
|
|
193
|
-
|
|
194
|
-
{sizes.map((size) => (
|
|
195
|
-
<AvatarGroup
|
|
196
|
-
key={size}
|
|
197
|
-
size={size}
|
|
198
|
-
orientation="horizontal"
|
|
199
|
-
interactive
|
|
200
|
-
avatars={[{ imgSrc: './avatar-square-dude.webp' }, { imgSrc: './tapestry-01.png' }]}
|
|
201
|
-
/>
|
|
202
|
-
))}
|
|
203
|
-
</div>
|
|
204
|
-
),
|
|
205
|
-
},
|
|
206
|
-
{ variants: ['light', 'dark'] },
|
|
207
|
-
);
|
|
208
|
-
|
|
209
|
-
export const Option: Story = storyConfig(
|
|
210
|
-
{
|
|
211
|
-
render: () => (
|
|
212
|
-
<RadioOption
|
|
213
|
-
id="test"
|
|
214
|
-
name="foo"
|
|
215
|
-
title="Personal account"
|
|
216
|
-
showMediaCircle={false}
|
|
217
|
-
media={
|
|
218
|
-
<AvatarGroup
|
|
219
|
-
size={48}
|
|
220
|
-
orientation="diagonal"
|
|
221
|
-
avatars={[{ asset: 'AA' }, { asset: 'BB' }]}
|
|
222
|
-
/>
|
|
223
|
-
}
|
|
224
|
-
onChange={() => {}}
|
|
225
|
-
/>
|
|
226
|
-
),
|
|
227
|
-
},
|
|
228
|
-
{ variants: ['light', 'dark'] },
|
|
229
|
-
);
|
|
230
|
-
|
|
231
|
-
export const EdgeInstances: Story = storyConfig(
|
|
232
|
-
{
|
|
233
|
-
render: () => (
|
|
234
|
-
<>
|
|
235
|
-
<AvatarGroup
|
|
236
|
-
size={72}
|
|
237
|
-
orientation="horizontal"
|
|
238
|
-
avatars={[
|
|
239
|
-
{ asset: <Flag code="br" /> },
|
|
240
|
-
{ asset: <Flag code="eu" /> },
|
|
241
|
-
{ asset: <Flag code="us" /> },
|
|
242
|
-
{ asset: '5+' },
|
|
243
|
-
]}
|
|
244
|
-
/>
|
|
245
|
-
|
|
246
|
-
<br />
|
|
247
|
-
|
|
248
|
-
<AvatarGroup
|
|
249
|
-
size={72}
|
|
250
|
-
orientation="horizontal"
|
|
251
|
-
avatars={[{ asset: <Flag code="gb" /> }, { asset: <Flag code="jp" /> }, { asset: '9+' }]}
|
|
252
|
-
/>
|
|
253
|
-
|
|
254
|
-
<br />
|
|
255
|
-
|
|
256
|
-
<AvatarGroup
|
|
257
|
-
orientation="horizontal"
|
|
258
|
-
interactive
|
|
259
|
-
avatars={[
|
|
260
|
-
{ asset: <Flag code="eu" /> },
|
|
261
|
-
{ asset: '9+', style: { border: '1px dashed var(--color-border-neutral)' } },
|
|
262
|
-
]}
|
|
263
|
-
/>
|
|
264
|
-
|
|
265
|
-
<br />
|
|
266
|
-
|
|
267
|
-
<AvatarGroup
|
|
268
|
-
orientation="horizontal"
|
|
269
|
-
interactive
|
|
270
|
-
avatars={[
|
|
271
|
-
{ imgSrc: '../avatar-squere-dude.webp' },
|
|
272
|
-
{ asset: null, style: { border: '1px dashed var(--color-border-neutral)' } },
|
|
273
|
-
]}
|
|
274
|
-
/>
|
|
275
|
-
</>
|
|
276
|
-
),
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
variants: [
|
|
280
|
-
'light',
|
|
281
|
-
// 'dark'
|
|
282
|
-
],
|
|
283
|
-
},
|
|
284
|
-
);
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
2
|
-
/* eslint-disable react/jsx-key */
|
|
3
|
-
import { clsx } from 'clsx';
|
|
4
|
-
import { CommonProps } from '../common';
|
|
5
|
-
import AvatarView, { AvatarViewProps } from '../avatarView';
|
|
6
|
-
|
|
7
|
-
type AvatarType = { asset?: AvatarViewProps['children'] } & Omit<
|
|
8
|
-
AvatarViewProps,
|
|
9
|
-
'notification' | 'selected' | 'size' | 'badge' | 'action' | 'children'
|
|
10
|
-
>;
|
|
11
|
-
type AvatarGroupOrientation = 'horizontal' | 'diagonal';
|
|
12
|
-
type AvatarGroupDiagonalSize = 24 | 32 | 40 | 48 | 56 | 72;
|
|
13
|
-
type AvatarGroupSize = 16 | AvatarGroupDiagonalSize;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Diagonal avatar groups have custom styles for avatars, icons, and fonts
|
|
17
|
-
*/
|
|
18
|
-
const MAP_DIAGONAL_AVATAR_STYLE = {
|
|
19
|
-
16: { avatar: 0, icon: 0, font: 0 },
|
|
20
|
-
24: { avatar: 15, icon: 11.25, font: 8 },
|
|
21
|
-
32: { avatar: 20, icon: 15, font: 12 },
|
|
22
|
-
40: { avatar: 24, icon: 18, font: 12 },
|
|
23
|
-
48: { avatar: 30, icon: 16.88, font: 14 },
|
|
24
|
-
56: { avatar: 34, icon: 19.13, font: 14 },
|
|
25
|
-
72: { avatar: 44, icon: 22, font: 22 },
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const MAP_DIAGONAL_AVATAR_POSITION = {
|
|
29
|
-
24: 9,
|
|
30
|
-
32: 12,
|
|
31
|
-
40: 16,
|
|
32
|
-
48: 18,
|
|
33
|
-
56: 22,
|
|
34
|
-
72: 28,
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* AvatarGroup size: Avatar position (px)
|
|
39
|
-
*/
|
|
40
|
-
const MAP_HORIZONTAL_AVATAR_POSITION = {
|
|
41
|
-
16: 2,
|
|
42
|
-
24: 2,
|
|
43
|
-
32: 7,
|
|
44
|
-
40: 4,
|
|
45
|
-
48: 4,
|
|
46
|
-
56: 6,
|
|
47
|
-
72: 8,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export type Props = {
|
|
51
|
-
'aria-label'?: string;
|
|
52
|
-
avatars: AvatarType[];
|
|
53
|
-
orientation?: AvatarGroupOrientation;
|
|
54
|
-
size?: AvatarGroupSize;
|
|
55
|
-
interactive?: boolean;
|
|
56
|
-
} & CommonProps;
|
|
57
|
-
|
|
58
|
-
export default function AvatarGroup({
|
|
59
|
-
avatars,
|
|
60
|
-
orientation = 'horizontal',
|
|
61
|
-
size: groupSize = 48,
|
|
62
|
-
'aria-label': ariaLabel,
|
|
63
|
-
className,
|
|
64
|
-
interactive,
|
|
65
|
-
}: Props) {
|
|
66
|
-
const isDiagonal = orientation === 'diagonal';
|
|
67
|
-
const singleAvatarSize = isDiagonal ? MAP_DIAGONAL_AVATAR_STYLE[groupSize]?.avatar : groupSize;
|
|
68
|
-
return (
|
|
69
|
-
<div
|
|
70
|
-
className={clsx('np-avatar-group', `np-avatar-group-${orientation}`, className)}
|
|
71
|
-
style={{
|
|
72
|
-
// @ts-expect-error `--np-avatar-group-size` exsits in styles of AvatarGroup
|
|
73
|
-
'--np-avatar-group-size': `${groupSize}px`,
|
|
74
|
-
'--np-avatar-group-single-size': `${singleAvatarSize}px`,
|
|
75
|
-
}}
|
|
76
|
-
aria-label={ariaLabel}
|
|
77
|
-
>
|
|
78
|
-
{avatars.length < 2 ||
|
|
79
|
-
((groupSize === 16 || avatars.length > 2) && orientation === 'diagonal')
|
|
80
|
-
? null
|
|
81
|
-
: avatars.map((avatar, index) => (
|
|
82
|
-
<div
|
|
83
|
-
className={clsx(
|
|
84
|
-
{ [`np-avatar-group-${orientation}-child`]: index !== 0 },
|
|
85
|
-
{ [`np-avatar-group-${orientation}-mask`]: index !== avatars.length - 1 },
|
|
86
|
-
)}
|
|
87
|
-
style={{
|
|
88
|
-
// @ts-expect-error CSS custom props allowed
|
|
89
|
-
'--np-avatar-group-diagonal-child-position': `${MAP_DIAGONAL_AVATAR_POSITION[groupSize]}px`,
|
|
90
|
-
'--np-avatar-group-horizontal-child-position': `${MAP_HORIZONTAL_AVATAR_POSITION[groupSize]}px`,
|
|
91
|
-
}}
|
|
92
|
-
>
|
|
93
|
-
<AvatarView
|
|
94
|
-
{...avatar}
|
|
95
|
-
// @ts-expect-error AvatarGroup has custom sizes for it's avatars
|
|
96
|
-
size={singleAvatarSize}
|
|
97
|
-
style={{
|
|
98
|
-
...(interactive && {
|
|
99
|
-
'--circle-border-width': 0,
|
|
100
|
-
backgroundColor: 'var(--color-background-neutral)',
|
|
101
|
-
}),
|
|
102
|
-
// diagonal AvatarGroup variant uses custom sizes for it's avatars, icons, and font
|
|
103
|
-
...(isDiagonal && {
|
|
104
|
-
'--circle-size': `${singleAvatarSize}px`,
|
|
105
|
-
'--circle-icon-size': `${MAP_DIAGONAL_AVATAR_STYLE[groupSize].icon}px`,
|
|
106
|
-
'--circle-font-size': `${MAP_DIAGONAL_AVATAR_STYLE[groupSize].font}px`,
|
|
107
|
-
}),
|
|
108
|
-
...avatar.style,
|
|
109
|
-
}}
|
|
110
|
-
>
|
|
111
|
-
{avatar.asset}
|
|
112
|
-
</AvatarView>
|
|
113
|
-
</div>
|
|
114
|
-
))}
|
|
115
|
-
</div>
|
|
116
|
-
);
|
|
117
|
-
}
|
package/src/avatarGroup/index.ts
DELETED