@transferwise/components 0.0.0-experimental-d11e9c5 → 0.0.0-experimental-76bb7cd
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/avatar/Avatar.js +0 -3
- package/build/avatar/Avatar.js.map +1 -1
- package/build/avatar/Avatar.mjs +0 -3
- package/build/avatar/Avatar.mjs.map +1 -1
- package/build/avatarWrapper/AvatarWrapper.js +4 -10
- package/build/avatarWrapper/AvatarWrapper.js.map +1 -1
- package/build/avatarWrapper/AvatarWrapper.mjs +4 -10
- package/build/avatarWrapper/AvatarWrapper.mjs.map +1 -1
- package/build/badge/Badge.js +1 -3
- package/build/badge/Badge.js.map +1 -1
- package/build/badge/Badge.mjs +1 -3
- package/build/badge/Badge.mjs.map +1 -1
- package/build/button/Button.js.map +1 -1
- package/build/button/Button.mjs.map +1 -1
- package/build/button/legacyUtils/legacyUtils.js.map +1 -1
- package/build/button/legacyUtils/legacyUtils.mjs.map +1 -1
- package/build/common/circle/Circle.js +1 -17
- package/build/common/circle/Circle.js.map +1 -1
- package/build/common/circle/Circle.mjs +1 -17
- package/build/common/circle/Circle.mjs.map +1 -1
- package/build/index.js +121 -128
- package/build/index.js.map +1 -1
- package/build/index.mjs +29 -33
- package/build/index.mjs.map +1 -1
- package/build/main.css +5 -109
- package/build/styles/badge/Badge.css +5 -6
- package/build/styles/common/circle/Circle.css +0 -32
- package/build/styles/main.css +5 -109
- package/build/types/avatar/Avatar.d.ts +0 -3
- package/build/types/avatar/Avatar.d.ts.map +1 -1
- package/build/types/avatarWrapper/AvatarWrapper.d.ts +0 -3
- package/build/types/avatarWrapper/AvatarWrapper.d.ts.map +1 -1
- package/build/types/badge/Badge.d.ts +1 -5
- package/build/types/badge/Badge.d.ts.map +1 -1
- package/build/types/badge/index.d.ts +0 -2
- package/build/types/badge/index.d.ts.map +1 -1
- package/build/types/button/Button.d.ts +1 -1
- package/build/types/button/Button.d.ts.map +1 -1
- package/build/types/button/legacyUtils/legacyUtils.d.ts +2 -2
- package/build/types/button/legacyUtils/legacyUtils.d.ts.map +1 -1
- package/build/types/common/circle/Circle.d.ts +0 -2
- package/build/types/common/circle/Circle.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -3
- package/build/types/index.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +158 -0
- package/build/types/test-utils/index.d.ts.map +1 -0
- package/build/types/test-utils/jest.setup.d.ts +2 -0
- package/build/types/test-utils/jest.setup.d.ts.map +1 -0
- package/package.json +4 -3
- package/src/avatar/Avatar.tsx +0 -3
- package/src/avatarWrapper/AvatarWrapper.tsx +0 -3
- package/src/badge/Badge.css +5 -6
- package/src/badge/Badge.less +3 -4
- package/src/badge/Badge.tsx +1 -8
- package/src/badge/index.ts +0 -3
- package/src/button/{Button.spec.js → Button.spec.tsx} +3 -2
- package/src/button/Button.tsx +1 -1
- package/src/button/legacyUtils/{legacyUtils.spec.js → legacyUtils.spec.tsx} +1 -1
- package/src/button/legacyUtils/legacyUtils.ts +2 -2
- package/src/common/circle/Circle.css +0 -32
- package/src/common/circle/Circle.less +0 -35
- package/src/common/circle/Circle.tsx +1 -22
- package/src/decision/Decision.story.tsx +46 -10
- package/src/flowNavigation/FlowNavigation.story.tsx +48 -10
- package/src/index.ts +0 -4
- package/src/listItem/ListItem.story.tsx +43 -5
- package/src/main.css +5 -109
- package/src/main.less +0 -2
- package/src/modal/{Modal.rtl.spec.js → Modal.rtl.spec.tsx} +8 -7
- package/src/navigationOption/NavigationOption.story.tsx +65 -14
- package/src/overlayHeader/OverlayHeader.story.tsx +10 -5
- package/src/radio/Radio.story.tsx +5 -5
- package/src/radioGroup/RadioGroup.story.tsx +3 -3
- package/src/selectOption/SelectOption.story.tsx +30 -31
- package/src/slidingPanel/SlidingPanel.spec.js +1 -1
- package/src/ssr.spec.tsx +264 -0
- package/src/test-utils/{index.js → index.tsx} +11 -6
- package/src/test-utils/{jest.setup.js → jest.setup.ts} +13 -8
- package/src/tile/Tile.story.tsx +6 -2
- package/build/avatarView/AvatarView.js +0 -163
- package/build/avatarView/AvatarView.js.map +0 -1
- package/build/avatarView/AvatarView.mjs +0 -161
- package/build/avatarView/AvatarView.mjs.map +0 -1
- package/build/avatarView/NotificationDot.js +0 -59
- package/build/avatarView/NotificationDot.js.map +0 -1
- package/build/avatarView/NotificationDot.mjs +0 -57
- package/build/avatarView/NotificationDot.mjs.map +0 -1
- package/build/badge/BadgeAssets.js +0 -85
- package/build/badge/BadgeAssets.js.map +0 -1
- package/build/badge/BadgeAssets.mjs +0 -83
- package/build/badge/BadgeAssets.mjs.map +0 -1
- package/build/styles/avatarGroup/AvatarGroup.css +0 -29
- package/build/styles/avatarView/AvatarView.css +0 -42
- package/build/styles/avatarView/NotificationDot.css +0 -20
- 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/build/types/avatarView/AvatarView.d.ts +0 -19
- package/build/types/avatarView/AvatarView.d.ts.map +0 -1
- package/build/types/avatarView/NotificationDot.d.ts +0 -8
- package/build/types/avatarView/NotificationDot.d.ts.map +0 -1
- package/build/types/avatarView/index.d.ts +0 -3
- package/build/types/avatarView/index.d.ts.map +0 -1
- package/build/types/badge/BadgeAssets.d.ts +0 -15
- package/build/types/badge/BadgeAssets.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/avatarView/AvatarView.css +0 -42
- package/src/avatarView/AvatarView.less +0 -33
- package/src/avatarView/AvatarView.story.tsx +0 -425
- package/src/avatarView/AvatarView.tsx +0 -141
- package/src/avatarView/NotificationDot.css +0 -20
- package/src/avatarView/NotificationDot.less +0 -24
- package/src/avatarView/NotificationDot.tsx +0 -35
- package/src/avatarView/index.ts +0 -2
- package/src/badge/BadgeAssets.tsx +0 -65
- package/src/ssr.spec.js +0 -256
- /package/src/button/__snapshots__/{Button.spec.js.snap → Button.spec.tsx.snap} +0 -0
- /package/src/dimmer/{Dimmer.rtl.spec.js → Dimmer.rtl.spec.tsx} +0 -0
- /package/src/info/{Info.spec.js → Info.spec.jsx} +0 -0
|
@@ -1,425 +0,0 @@
|
|
|
1
|
-
/* eslint-disable react/jsx-key */
|
|
2
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
3
|
-
import {
|
|
4
|
-
Camera,
|
|
5
|
-
Convert,
|
|
6
|
-
FastFlag,
|
|
7
|
-
Freeze,
|
|
8
|
-
Graph,
|
|
9
|
-
Money,
|
|
10
|
-
Plane,
|
|
11
|
-
PlusCircle,
|
|
12
|
-
QrCode,
|
|
13
|
-
Rewards,
|
|
14
|
-
Target,
|
|
15
|
-
Team,
|
|
16
|
-
Transport,
|
|
17
|
-
Wallet,
|
|
18
|
-
Water,
|
|
19
|
-
} from '@transferwise/icons';
|
|
20
|
-
import AvatarView, { AvatarViewProps } from '.';
|
|
21
|
-
import { Flag } from '@wise/art';
|
|
22
|
-
import { getBrandColorFromSeed, getInitials } from '../common';
|
|
23
|
-
import Display from '../display';
|
|
24
|
-
|
|
25
|
-
export default {
|
|
26
|
-
title: 'Content/AvatarView',
|
|
27
|
-
} satisfies Meta<typeof AvatarView>;
|
|
28
|
-
|
|
29
|
-
type Story = StoryObj<typeof AvatarView>;
|
|
30
|
-
|
|
31
|
-
const profileName1 = 'Wolter White';
|
|
32
|
-
const profileName2 = 'Tyler Durden';
|
|
33
|
-
const sizes: AvatarViewProps['size'][] = [16, 24, 32, 40, 48, 56, 72];
|
|
34
|
-
|
|
35
|
-
export const Selected: Story = {
|
|
36
|
-
tags: ['autodocs'],
|
|
37
|
-
render: () => {
|
|
38
|
-
return (
|
|
39
|
-
<div
|
|
40
|
-
style={{
|
|
41
|
-
gap: '1em',
|
|
42
|
-
display: 'grid',
|
|
43
|
-
justifyContent: 'space-between',
|
|
44
|
-
gridTemplate: `auto auto / repeat(${sizes.length}, min-content)`,
|
|
45
|
-
}}
|
|
46
|
-
>
|
|
47
|
-
{sizes.map((size) => (
|
|
48
|
-
<AvatarView key={size} size={size} selected interactive>
|
|
49
|
-
<Freeze />
|
|
50
|
-
</AvatarView>
|
|
51
|
-
))}
|
|
52
|
-
{sizes.map((size) => (
|
|
53
|
-
<AvatarView
|
|
54
|
-
key={size}
|
|
55
|
-
size={size}
|
|
56
|
-
imgSrc="../avatar-square-dude.webp"
|
|
57
|
-
selected
|
|
58
|
-
interactive
|
|
59
|
-
/>
|
|
60
|
-
))}
|
|
61
|
-
</div>
|
|
62
|
-
);
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export const Notification: Story = {
|
|
67
|
-
tags: ['autodocs'],
|
|
68
|
-
render: () => (
|
|
69
|
-
<div
|
|
70
|
-
style={{
|
|
71
|
-
gap: '1em',
|
|
72
|
-
display: 'grid',
|
|
73
|
-
justifyContent: 'space-between',
|
|
74
|
-
gridTemplate: `auto auto / repeat(${sizes.length}, min-content)`,
|
|
75
|
-
}}
|
|
76
|
-
>
|
|
77
|
-
{sizes.map((size) => (
|
|
78
|
-
<AvatarView key={size} size={size} notification>
|
|
79
|
-
<Freeze />
|
|
80
|
-
</AvatarView>
|
|
81
|
-
))}
|
|
82
|
-
{sizes.map((size) => (
|
|
83
|
-
<AvatarView key={size} size={size} notification interactive>
|
|
84
|
-
<Freeze />
|
|
85
|
-
</AvatarView>
|
|
86
|
-
))}
|
|
87
|
-
{sizes.map((size) => (
|
|
88
|
-
<AvatarView
|
|
89
|
-
key={size}
|
|
90
|
-
size={size}
|
|
91
|
-
imgSrc="../avatar-rectangle-fox.webp"
|
|
92
|
-
notification
|
|
93
|
-
interactive
|
|
94
|
-
/>
|
|
95
|
-
))}
|
|
96
|
-
</div>
|
|
97
|
-
),
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export const Badge: Story = {
|
|
101
|
-
tags: ['autodocs'],
|
|
102
|
-
render: () => {
|
|
103
|
-
const currencies = ['USD', 'EUR', 'GBP', 'AUD', 'CAD', 'JPY', 'CNY'];
|
|
104
|
-
const icons = [
|
|
105
|
-
<Plane />,
|
|
106
|
-
<QrCode />,
|
|
107
|
-
<Target />,
|
|
108
|
-
<Transport />,
|
|
109
|
-
<Wallet />,
|
|
110
|
-
<Water />,
|
|
111
|
-
<Team />,
|
|
112
|
-
];
|
|
113
|
-
return (
|
|
114
|
-
<div
|
|
115
|
-
style={{
|
|
116
|
-
gap: '1em',
|
|
117
|
-
display: 'grid',
|
|
118
|
-
justifyContent: 'space-between',
|
|
119
|
-
gridTemplate: 'auto auto / repeat(7, min-content)',
|
|
120
|
-
}}
|
|
121
|
-
>
|
|
122
|
-
{sizes.map((size, index) => (
|
|
123
|
-
<AvatarView key={size} size={size} badge={{ flagCode: currencies[index] }}>
|
|
124
|
-
{icons[index]}
|
|
125
|
-
</AvatarView>
|
|
126
|
-
))}
|
|
127
|
-
|
|
128
|
-
{sizes.map((size, index) => (
|
|
129
|
-
<AvatarView
|
|
130
|
-
key={size}
|
|
131
|
-
size={size}
|
|
132
|
-
imgSrc="../avatar-rectangle-fox.webp"
|
|
133
|
-
badge={{ imgSrc: '../tapestry-01.png' }}
|
|
134
|
-
/>
|
|
135
|
-
))}
|
|
136
|
-
|
|
137
|
-
{sizes.map((size, index) => (
|
|
138
|
-
<AvatarView
|
|
139
|
-
key={size}
|
|
140
|
-
size={size}
|
|
141
|
-
imgSrc="../avatar-square-dude.webp"
|
|
142
|
-
badge={{ imgSrc: '../tapestry-01.png' }}
|
|
143
|
-
/>
|
|
144
|
-
))}
|
|
145
|
-
|
|
146
|
-
{sizes.map((size, index) => (
|
|
147
|
-
<AvatarView key={size} size={size} badge={{ imgSrc: '../tapestry-01.png' }}>
|
|
148
|
-
{icons[index]}
|
|
149
|
-
</AvatarView>
|
|
150
|
-
))}
|
|
151
|
-
|
|
152
|
-
{sizes.map((size, index) => (
|
|
153
|
-
<AvatarView key={size} size={size} badge={{ status: 'warning' }}>
|
|
154
|
-
{icons[index]}
|
|
155
|
-
</AvatarView>
|
|
156
|
-
))}
|
|
157
|
-
|
|
158
|
-
{sizes.map((size, index) => (
|
|
159
|
-
<AvatarView key={size} size={size} badge={{ status: 'neutral' }}>
|
|
160
|
-
{icons[index]}
|
|
161
|
-
</AvatarView>
|
|
162
|
-
))}
|
|
163
|
-
|
|
164
|
-
{sizes.map((size, index) => (
|
|
165
|
-
<AvatarView key={size} size={size} badge={{ status: 'negative' }}>
|
|
166
|
-
{icons[index]}
|
|
167
|
-
</AvatarView>
|
|
168
|
-
))}
|
|
169
|
-
|
|
170
|
-
{sizes.map((size, index) => (
|
|
171
|
-
<AvatarView key={size} size={size} badge={{ icon: <FastFlag /> }}>
|
|
172
|
-
{icons[index]}
|
|
173
|
-
</AvatarView>
|
|
174
|
-
))}
|
|
175
|
-
|
|
176
|
-
{sizes.map((size, index) => (
|
|
177
|
-
<AvatarView key={size} size={size} badge={{ type: 'reference' }}>
|
|
178
|
-
{icons[index]}
|
|
179
|
-
</AvatarView>
|
|
180
|
-
))}
|
|
181
|
-
|
|
182
|
-
{sizes.map((size, index) => (
|
|
183
|
-
<AvatarView key={size} size={size} badge={{ type: 'action' }}>
|
|
184
|
-
{icons[index]}
|
|
185
|
-
</AvatarView>
|
|
186
|
-
))}
|
|
187
|
-
|
|
188
|
-
{sizes.map((size) => (
|
|
189
|
-
<AvatarView
|
|
190
|
-
key={size}
|
|
191
|
-
size={size}
|
|
192
|
-
imgSrc="../avatar-square-dude.webp"
|
|
193
|
-
badge={{ type: 'action', icon: <Camera /> }}
|
|
194
|
-
/>
|
|
195
|
-
))}
|
|
196
|
-
|
|
197
|
-
{sizes.map((size) => (
|
|
198
|
-
<AvatarView
|
|
199
|
-
key={size}
|
|
200
|
-
size={size}
|
|
201
|
-
imgSrc="../avatar-square-dude.webp"
|
|
202
|
-
badge={{ type: 'reference', icon: <Convert /> }}
|
|
203
|
-
/>
|
|
204
|
-
))}
|
|
205
|
-
|
|
206
|
-
{sizes.map((size) => (
|
|
207
|
-
<AvatarView
|
|
208
|
-
key={size}
|
|
209
|
-
size={size}
|
|
210
|
-
imgSrc="../avatar-square-dude.webp"
|
|
211
|
-
badge={{ icon: <Convert /> }}
|
|
212
|
-
/>
|
|
213
|
-
))}
|
|
214
|
-
</div>
|
|
215
|
-
);
|
|
216
|
-
},
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
export const Images: Story = {
|
|
220
|
-
tags: ['autodocs'],
|
|
221
|
-
render: () => {
|
|
222
|
-
return (
|
|
223
|
-
<div
|
|
224
|
-
style={{
|
|
225
|
-
gap: '1em',
|
|
226
|
-
display: 'grid',
|
|
227
|
-
justifyContent: 'space-between',
|
|
228
|
-
gridTemplate: 'auto auto / repeat(7, min-content)',
|
|
229
|
-
}}
|
|
230
|
-
>
|
|
231
|
-
{sizes.map((size) => (
|
|
232
|
-
<AvatarView
|
|
233
|
-
key={size}
|
|
234
|
-
size={size}
|
|
235
|
-
interactive
|
|
236
|
-
imgSrc="../avatar-square-dude.webp"
|
|
237
|
-
name="Test Name"
|
|
238
|
-
type="business"
|
|
239
|
-
/>
|
|
240
|
-
))}
|
|
241
|
-
{sizes.map((size) => (
|
|
242
|
-
<AvatarView
|
|
243
|
-
key={size}
|
|
244
|
-
size={size}
|
|
245
|
-
imgSrc="../avatar-square-dude.webp"
|
|
246
|
-
name="Test Name"
|
|
247
|
-
type="business"
|
|
248
|
-
/>
|
|
249
|
-
))}
|
|
250
|
-
{sizes.map((size) => (
|
|
251
|
-
<AvatarView key={size} size={size} interactive>
|
|
252
|
-
<Flag code="JPY" intrinsicSize={size} />
|
|
253
|
-
</AvatarView>
|
|
254
|
-
))}
|
|
255
|
-
{sizes.map((size) => (
|
|
256
|
-
<AvatarView key={size} size={size}>
|
|
257
|
-
<Flag code="JPY" intrinsicSize={size} />
|
|
258
|
-
</AvatarView>
|
|
259
|
-
))}
|
|
260
|
-
{sizes.map((size) => (
|
|
261
|
-
<AvatarView key={size} interactive imgSrc="../avatar-rectangle-fox.webp" size={size} />
|
|
262
|
-
))}
|
|
263
|
-
{sizes.map((size) => (
|
|
264
|
-
<AvatarView key={size} size={size} imgSrc="../avatar-rectangle-fox.webp" />
|
|
265
|
-
))}
|
|
266
|
-
</div>
|
|
267
|
-
);
|
|
268
|
-
},
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
export const Profiles: Story = {
|
|
272
|
-
tags: ['autodocs'],
|
|
273
|
-
render: () => {
|
|
274
|
-
return (
|
|
275
|
-
<div
|
|
276
|
-
style={{
|
|
277
|
-
gap: '1em',
|
|
278
|
-
display: 'grid',
|
|
279
|
-
justifyContent: 'space-between',
|
|
280
|
-
gridTemplate: 'auto auto / repeat(7, min-content)',
|
|
281
|
-
}}
|
|
282
|
-
>
|
|
283
|
-
{sizes.map((size) => (
|
|
284
|
-
<AvatarView
|
|
285
|
-
key={size}
|
|
286
|
-
size={size}
|
|
287
|
-
imgSrc="../avatar-square-dude.webp"
|
|
288
|
-
name="Test Name"
|
|
289
|
-
type="business"
|
|
290
|
-
/>
|
|
291
|
-
))}
|
|
292
|
-
|
|
293
|
-
{sizes.map((size) => (
|
|
294
|
-
<AvatarView
|
|
295
|
-
key={size}
|
|
296
|
-
size={size}
|
|
297
|
-
interactive
|
|
298
|
-
imgSrc="../avatar-square-dude.webp"
|
|
299
|
-
name="Test Name"
|
|
300
|
-
type="business"
|
|
301
|
-
/>
|
|
302
|
-
))}
|
|
303
|
-
|
|
304
|
-
{sizes.map((size) => (
|
|
305
|
-
<AvatarView key={size} size={size} name="Test Name" />
|
|
306
|
-
))}
|
|
307
|
-
|
|
308
|
-
{sizes.map((size) => (
|
|
309
|
-
<AvatarView key={size} size={size} interactive name="Test Name" />
|
|
310
|
-
))}
|
|
311
|
-
|
|
312
|
-
{sizes.map((size) => (
|
|
313
|
-
<AvatarView key={size} size={size} type="business" />
|
|
314
|
-
))}
|
|
315
|
-
|
|
316
|
-
{sizes.map((size) => (
|
|
317
|
-
<AvatarView key={size} size={size} interactive type="business" />
|
|
318
|
-
))}
|
|
319
|
-
|
|
320
|
-
{sizes.map((size) => (
|
|
321
|
-
<AvatarView key={size} size={size} />
|
|
322
|
-
))}
|
|
323
|
-
|
|
324
|
-
{sizes.map((size) => (
|
|
325
|
-
<AvatarView key={size} size={size} interactive />
|
|
326
|
-
))}
|
|
327
|
-
</div>
|
|
328
|
-
);
|
|
329
|
-
},
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
export const ProfileBrokenImageFallback: Story = {
|
|
333
|
-
render: () => (
|
|
334
|
-
<>
|
|
335
|
-
<AvatarView imgSrc="../img-wrong-url.lol" />
|
|
336
|
-
<AvatarView imgSrc="../img-wrong-url.lol" type="business" />
|
|
337
|
-
<AvatarView imgSrc="../img-wrong-url.lol" type="business" name="D D" />
|
|
338
|
-
</>
|
|
339
|
-
),
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
export const EdgeInstaces: Story = {
|
|
343
|
-
tags: ['autodocs'],
|
|
344
|
-
render: () => {
|
|
345
|
-
const css = `.custom-variant {
|
|
346
|
-
border: 1px dashed var(--color-border-neutral);
|
|
347
|
-
}`;
|
|
348
|
-
return (
|
|
349
|
-
<div
|
|
350
|
-
style={{
|
|
351
|
-
gap: '1em',
|
|
352
|
-
display: 'grid',
|
|
353
|
-
justifyContent: 'space-between',
|
|
354
|
-
gridTemplate: 'auto auto / repeat(2, min-content)',
|
|
355
|
-
}}
|
|
356
|
-
>
|
|
357
|
-
<style>{css}</style>
|
|
358
|
-
{/* <Body>- Custom colors</Body> */}
|
|
359
|
-
<AvatarView
|
|
360
|
-
interactive
|
|
361
|
-
badge={{ flagCode: 'EU' }}
|
|
362
|
-
style={{ backgroundColor: 'var(--color-bright-orange)' }}
|
|
363
|
-
>
|
|
364
|
-
<Money />
|
|
365
|
-
</AvatarView>
|
|
366
|
-
<AvatarView
|
|
367
|
-
badge={{ flagCode: 'EU' }}
|
|
368
|
-
style={{ backgroundColor: 'var(--color-bright-orange)', border: 'none' }}
|
|
369
|
-
>
|
|
370
|
-
<Money />
|
|
371
|
-
</AvatarView>
|
|
372
|
-
{/* <Body>- Add example with dashed avatar as in shared balances</Body> */}
|
|
373
|
-
<AvatarView interactive className="custom-variant">
|
|
374
|
-
<PlusCircle />
|
|
375
|
-
</AvatarView>
|
|
376
|
-
<AvatarView interactive className="custom-variant">
|
|
377
|
-
{null}
|
|
378
|
-
</AvatarView>
|
|
379
|
-
{/* <Body> - Add example custom backgrounds as in account summary (https://wise.com/account-summary)</Body> */}
|
|
380
|
-
<AvatarView style={{ backgroundColor: 'rgb(203, 217, 195)' }}>
|
|
381
|
-
<span style={{ color: 'rgb(22, 51, 0)' }}>
|
|
382
|
-
<Graph />
|
|
383
|
-
</span>
|
|
384
|
-
</AvatarView>
|
|
385
|
-
<AvatarView interactive style={{ backgroundColor: 'rgb(203, 217, 195)' }}>
|
|
386
|
-
<span style={{ color: 'rgb(22, 51, 0)' }}>
|
|
387
|
-
<Graph />
|
|
388
|
-
</span>
|
|
389
|
-
</AvatarView>
|
|
390
|
-
<AvatarView style={{ backgroundColor: 'rgb(22, 51, 0)' }}>
|
|
391
|
-
<span style={{ color: 'rgb(203, 217, 195)' }}>
|
|
392
|
-
<Rewards />
|
|
393
|
-
</span>
|
|
394
|
-
</AvatarView>
|
|
395
|
-
<AvatarView interactive style={{ backgroundColor: 'rgb(22, 51, 0)' }}>
|
|
396
|
-
<span style={{ color: 'rgb(203, 217, 195)' }}>
|
|
397
|
-
<Rewards />
|
|
398
|
-
</span>
|
|
399
|
-
</AvatarView>
|
|
400
|
-
{/* <Body>- Add example Wise Sand + custom background from hash</Body> */}
|
|
401
|
-
<AvatarView
|
|
402
|
-
badge={{ flagCode: 'EU' }}
|
|
403
|
-
style={{ backgroundColor: getBrandColorFromSeed(profileName1) }}
|
|
404
|
-
>
|
|
405
|
-
<Display>{getInitials(profileName1)}</Display>
|
|
406
|
-
</AvatarView>
|
|
407
|
-
<AvatarView style={{ backgroundColor: getBrandColorFromSeed(profileName1) }}>
|
|
408
|
-
<Display>{getInitials(profileName1)}</Display>
|
|
409
|
-
</AvatarView>
|
|
410
|
-
<AvatarView interactive style={{ backgroundColor: getBrandColorFromSeed(profileName2) }}>
|
|
411
|
-
<Display>{getInitials(profileName1)}</Display>
|
|
412
|
-
</AvatarView>
|
|
413
|
-
<AvatarView
|
|
414
|
-
interactive
|
|
415
|
-
badge={{ flagCode: 'EU' }}
|
|
416
|
-
style={{ backgroundColor: getBrandColorFromSeed(profileName2) }}
|
|
417
|
-
>
|
|
418
|
-
<Display>{getInitials(profileName1)}</Display>
|
|
419
|
-
</AvatarView>
|
|
420
|
-
<AvatarView>9+</AvatarView>
|
|
421
|
-
<AvatarView interactive>5+</AvatarView>
|
|
422
|
-
</div>
|
|
423
|
-
);
|
|
424
|
-
},
|
|
425
|
-
};
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import Badge, { BadgeAssets, BadgeProps, BadgeAssetsProps } from '../badge';
|
|
2
|
-
import NotificationDot from './NotificationDot';
|
|
3
|
-
import Circle from '../common/circle';
|
|
4
|
-
import Image from '../image';
|
|
5
|
-
import { HTMLAttributes, PropsWithChildren, useState } from 'react';
|
|
6
|
-
import { clsx } from 'clsx';
|
|
7
|
-
import { getInitials, Size } from '../common';
|
|
8
|
-
import {
|
|
9
|
-
Briefcase as BusinessProfileIcon,
|
|
10
|
-
Profile as PersonalProfileIcon,
|
|
11
|
-
} from '@transferwise/icons';
|
|
12
|
-
|
|
13
|
-
export type Props = {
|
|
14
|
-
imgSrc?: string | null;
|
|
15
|
-
/**
|
|
16
|
-
* Entity name (person (profile or recipient) or business name), it will be boilded down to 1 or 2 chars (initials)
|
|
17
|
-
*/
|
|
18
|
-
name?: string | null;
|
|
19
|
-
type?: 'personal' | 'business';
|
|
20
|
-
size?: 16 | 24 | 32 | 40 | 48 | 56 | 72;
|
|
21
|
-
notification?: boolean;
|
|
22
|
-
badge?: BadgeAssetsProps;
|
|
23
|
-
interactive?: boolean;
|
|
24
|
-
selected?: boolean;
|
|
25
|
-
style?: Pick<React.CSSProperties, 'border' | 'backgroundColor' | 'color'>;
|
|
26
|
-
} & Pick<
|
|
27
|
-
HTMLAttributes<HTMLDivElement>,
|
|
28
|
-
'className' | 'children' | 'role' | 'aria-label' | 'aria-labelledby' | 'aria-describedby'
|
|
29
|
-
>;
|
|
30
|
-
|
|
31
|
-
function AvatarView({
|
|
32
|
-
children = undefined,
|
|
33
|
-
size = 48,
|
|
34
|
-
selected,
|
|
35
|
-
notification,
|
|
36
|
-
badge,
|
|
37
|
-
interactive = false,
|
|
38
|
-
className,
|
|
39
|
-
style,
|
|
40
|
-
imgSrc,
|
|
41
|
-
type,
|
|
42
|
-
name,
|
|
43
|
-
...restProps
|
|
44
|
-
}: Props) {
|
|
45
|
-
return (
|
|
46
|
-
<Circle
|
|
47
|
-
size={size}
|
|
48
|
-
fixedSize
|
|
49
|
-
className={clsx(
|
|
50
|
-
'np-avatar-view',
|
|
51
|
-
interactive ? 'np-avatar-view-interactive' : 'np-avatar-view-non-interactive',
|
|
52
|
-
{ 'np-avatar-view-selected': selected },
|
|
53
|
-
className,
|
|
54
|
-
)}
|
|
55
|
-
{...restProps}
|
|
56
|
-
>
|
|
57
|
-
<Badges avatar={{ size, notification, selected }} {...badge}>
|
|
58
|
-
<Circle
|
|
59
|
-
size={size}
|
|
60
|
-
fixedSize
|
|
61
|
-
className={clsx('np-avatar-view-content')}
|
|
62
|
-
enableBorder={!interactive || selected}
|
|
63
|
-
style={{
|
|
64
|
-
...(selected && { '--circle-border-color': 'var(--color-interactive-primary)' }),
|
|
65
|
-
...style,
|
|
66
|
-
}}
|
|
67
|
-
>
|
|
68
|
-
{children === undefined ? <Profile {...{ imgSrc, type, name }} /> : children}
|
|
69
|
-
</Circle>
|
|
70
|
-
</Badges>
|
|
71
|
-
</Circle>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/** Size of badge depends on size of avatar */
|
|
76
|
-
const MAP_BADGE_ASSET_SIZE = {
|
|
77
|
-
16: 'sm',
|
|
78
|
-
24: 'sm',
|
|
79
|
-
32: 'sm',
|
|
80
|
-
40: 'sm',
|
|
81
|
-
48: 'sm',
|
|
82
|
-
56: 'lg',
|
|
83
|
-
72: 'lg',
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
/** Certain sizes of AvatarView has a custom offset of Badge */
|
|
87
|
-
const MAP_BADGE_POSITION = {
|
|
88
|
-
24: -6,
|
|
89
|
-
32: -4,
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
type BadgesProps = BadgeAssetsProps &
|
|
93
|
-
PropsWithChildren<{
|
|
94
|
-
avatar: Pick<Props, 'selected' | 'size' | 'notification'>;
|
|
95
|
-
}>;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Adds build-in badges to AvatarView
|
|
99
|
-
*/
|
|
100
|
-
function Badges({ children, avatar, ...badge }: BadgesProps) {
|
|
101
|
-
const { size = 48, selected, notification } = avatar;
|
|
102
|
-
const anyCustomBadge = Object.keys(badge).length > 0;
|
|
103
|
-
if ((anyCustomBadge || selected) && size > 16) {
|
|
104
|
-
const badgeSize: BadgeProps['size'] = MAP_BADGE_ASSET_SIZE[size] ?? Size.SMALL;
|
|
105
|
-
return (
|
|
106
|
-
<Badge
|
|
107
|
-
size={badgeSize}
|
|
108
|
-
badge={<BadgeAssets {...(selected ? { status: 'positive' } : badge)} size={badgeSize} />}
|
|
109
|
-
style={{
|
|
110
|
-
// @ts-expect-error CSS custom props allowed
|
|
111
|
-
'--badge-content-position': `${MAP_BADGE_POSITION[size] ?? 0}px`,
|
|
112
|
-
}}
|
|
113
|
-
>
|
|
114
|
-
{children}
|
|
115
|
-
</Badge>
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
if (notification) {
|
|
119
|
-
return <NotificationDot avatarSize={size}>{children}</NotificationDot>;
|
|
120
|
-
}
|
|
121
|
-
return children;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Common logic for entities (personal & business profiles or recipients)
|
|
126
|
-
*/
|
|
127
|
-
function Profile({ imgSrc, name, type }: Pick<Props, 'imgSrc' | 'name' | 'type'>) {
|
|
128
|
-
const [tryLoadImage, setTryLoadImage] = useState(true);
|
|
129
|
-
if (imgSrc && tryLoadImage) {
|
|
130
|
-
return <Image src={imgSrc} alt="" onError={() => setTryLoadImage(false)} />;
|
|
131
|
-
}
|
|
132
|
-
if (type) {
|
|
133
|
-
return type.toLowerCase() === 'business' ? <BusinessProfileIcon /> : <PersonalProfileIcon />;
|
|
134
|
-
}
|
|
135
|
-
if (name) {
|
|
136
|
-
return getInitials(name);
|
|
137
|
-
}
|
|
138
|
-
return <PersonalProfileIcon />;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export default AvatarView;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
.np-notification-dot {
|
|
2
|
-
--np-notification-dot-size: 14px;
|
|
3
|
-
position: relative;
|
|
4
|
-
display: inline-block;
|
|
5
|
-
}
|
|
6
|
-
.np-notification-dot-mask {
|
|
7
|
-
-webkit-mask-image: radial-gradient(circle at bottom calc(100% - (var(--np-notification-dot-size) / 2)) left calc(100% - (var(--np-notification-dot-size) / 2)), transparent 0, transparent calc(var(--np-notification-dot-size) / 2 + var(--np-notification-dot-offset)), black 0);
|
|
8
|
-
mask-image: radial-gradient(circle at bottom calc(100% - (var(--np-notification-dot-size) / 2)) left calc(100% - (var(--np-notification-dot-size) / 2)), transparent 0, transparent calc(var(--np-notification-dot-size) / 2 + var(--np-notification-dot-offset)), black 0);
|
|
9
|
-
-webkit-mask-image: radial-gradient(circle at bottom calc(100% - calc(var(--np-notification-dot-size) / 2)) left calc(100% - calc(var(--np-notification-dot-size) / 2)), transparent 0, transparent calc(var(--np-notification-dot-size) / 2 + var(--np-notification-dot-offset)), black 0);
|
|
10
|
-
mask-image: radial-gradient(circle at bottom calc(100% - calc(var(--np-notification-dot-size) / 2)) left calc(100% - calc(var(--np-notification-dot-size) / 2)), transparent 0, transparent calc(var(--np-notification-dot-size) / 2 + var(--np-notification-dot-offset)), black 0);
|
|
11
|
-
}
|
|
12
|
-
.np-notification-dot-badge {
|
|
13
|
-
position: absolute;
|
|
14
|
-
width: var(--np-notification-dot-size);
|
|
15
|
-
height: var(--np-notification-dot-size);
|
|
16
|
-
background-color: var(--color-sentiment-negative);
|
|
17
|
-
border-radius: 9999px;
|
|
18
|
-
border-radius: var(--radius-full);
|
|
19
|
-
right: 0;
|
|
20
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
.np-notification-dot {
|
|
2
|
-
--np-notification-dot-size: 14px;
|
|
3
|
-
position: relative;
|
|
4
|
-
display: inline-block;
|
|
5
|
-
|
|
6
|
-
&-mask {
|
|
7
|
-
mask-image: radial-gradient(
|
|
8
|
-
circle at bottom calc(100% - calc(var(--np-notification-dot-size) / 2))
|
|
9
|
-
left calc(100% - calc(var(--np-notification-dot-size) / 2)),
|
|
10
|
-
transparent 0,
|
|
11
|
-
transparent calc(var(--np-notification-dot-size) / 2 + var(--np-notification-dot-offset)),
|
|
12
|
-
black 0
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
&-badge {
|
|
17
|
-
position: absolute;
|
|
18
|
-
width: var(--np-notification-dot-size);
|
|
19
|
-
height: var(--np-notification-dot-size);
|
|
20
|
-
background-color: var(--color-sentiment-negative);
|
|
21
|
-
border-radius: var(--radius-full);
|
|
22
|
-
right: 0;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { HTMLAttributes } from 'react';
|
|
2
|
-
import { Props as AvatarViewProps } from './AvatarView';
|
|
3
|
-
|
|
4
|
-
type Props = Pick<HTMLAttributes<HTMLDivElement>, 'children'> & {
|
|
5
|
-
avatarSize?: AvatarViewProps['size'];
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Depending on avatar size, notifcation dot size and offset are different
|
|
10
|
-
*/
|
|
11
|
-
const MAP_STYLE_CONFIG = {
|
|
12
|
-
16: { size: 6, offset: 1 },
|
|
13
|
-
24: { size: 8, offset: 2 },
|
|
14
|
-
32: { size: 10, offset: 2 },
|
|
15
|
-
40: { size: 10, offset: 2 },
|
|
16
|
-
48: { size: 14, offset: 2 },
|
|
17
|
-
56: { size: 16, offset: 3 },
|
|
18
|
-
72: { size: 20, offset: 3 },
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default function NotificationDot({ children, avatarSize = 48 }: Props) {
|
|
22
|
-
return (
|
|
23
|
-
<div
|
|
24
|
-
className="np-notification-dot"
|
|
25
|
-
style={{
|
|
26
|
-
// @ts-expect-error CSS custom props allowed
|
|
27
|
-
'--np-notification-dot-size': `${MAP_STYLE_CONFIG[avatarSize].size}px`,
|
|
28
|
-
'--np-notification-dot-offset': `${MAP_STYLE_CONFIG[avatarSize].offset}px`,
|
|
29
|
-
}}
|
|
30
|
-
>
|
|
31
|
-
<div className="np-notification-dot-badge" />
|
|
32
|
-
<div className="np-notification-dot-mask">{children}</div>
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
}
|
package/src/avatarView/index.ts
DELETED