@transferwise/components 0.0.0-experimental-bb32303 → 0.0.0-experimental-d11e9c5
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 +3 -0
- package/build/avatar/Avatar.js.map +1 -1
- package/build/avatar/Avatar.mjs +3 -0
- package/build/avatar/Avatar.mjs.map +1 -1
- package/build/avatarView/AvatarView.js +163 -0
- package/build/avatarView/AvatarView.js.map +1 -0
- package/build/avatarView/AvatarView.mjs +161 -0
- package/build/avatarView/AvatarView.mjs.map +1 -0
- package/build/avatarView/NotificationDot.js +59 -0
- package/build/avatarView/NotificationDot.js.map +1 -0
- package/build/avatarView/NotificationDot.mjs +57 -0
- package/build/avatarView/NotificationDot.mjs.map +1 -0
- package/build/avatarWrapper/AvatarWrapper.js +10 -4
- package/build/avatarWrapper/AvatarWrapper.js.map +1 -1
- package/build/avatarWrapper/AvatarWrapper.mjs +10 -4
- package/build/avatarWrapper/AvatarWrapper.mjs.map +1 -1
- package/build/badge/Badge.js +3 -1
- package/build/badge/Badge.js.map +1 -1
- package/build/badge/Badge.mjs +3 -1
- package/build/badge/Badge.mjs.map +1 -1
- package/build/badge/BadgeAssets.js +85 -0
- package/build/badge/BadgeAssets.js.map +1 -0
- package/build/badge/BadgeAssets.mjs +83 -0
- package/build/badge/BadgeAssets.mjs.map +1 -0
- 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 +17 -1
- package/build/common/circle/Circle.js.map +1 -1
- package/build/common/circle/Circle.mjs +17 -1
- package/build/common/circle/Circle.mjs.map +1 -1
- package/build/i18n/th.json +5 -0
- package/build/i18n/th.json.js +5 -0
- package/build/i18n/th.json.js.map +1 -1
- package/build/i18n/th.json.mjs +5 -0
- package/build/i18n/th.json.mjs.map +1 -1
- package/build/index.js +128 -121
- package/build/index.js.map +1 -1
- package/build/index.mjs +33 -29
- package/build/index.mjs.map +1 -1
- package/build/main.css +109 -5
- package/build/styles/avatarGroup/AvatarGroup.css +29 -0
- package/build/styles/avatarView/AvatarView.css +42 -0
- package/build/styles/avatarView/NotificationDot.css +20 -0
- package/build/styles/badge/Badge.css +6 -5
- package/build/styles/common/circle/Circle.css +32 -0
- package/build/styles/main.css +109 -5
- package/build/types/avatar/Avatar.d.ts +3 -0
- package/build/types/avatar/Avatar.d.ts.map +1 -1
- package/build/types/avatarGroup/AvatarGroup.d.ts +18 -0
- package/build/types/avatarGroup/AvatarGroup.d.ts.map +1 -0
- package/build/types/avatarGroup/index.d.ts +3 -0
- package/build/types/avatarGroup/index.d.ts.map +1 -0
- package/build/types/avatarView/AvatarView.d.ts +19 -0
- package/build/types/avatarView/AvatarView.d.ts.map +1 -0
- package/build/types/avatarView/NotificationDot.d.ts +8 -0
- package/build/types/avatarView/NotificationDot.d.ts.map +1 -0
- package/build/types/avatarView/index.d.ts +3 -0
- package/build/types/avatarView/index.d.ts.map +1 -0
- package/build/types/avatarWrapper/AvatarWrapper.d.ts +3 -0
- package/build/types/avatarWrapper/AvatarWrapper.d.ts.map +1 -1
- package/build/types/badge/Badge.d.ts +5 -1
- package/build/types/badge/Badge.d.ts.map +1 -1
- package/build/types/badge/BadgeAssets.d.ts +15 -0
- package/build/types/badge/BadgeAssets.d.ts.map +1 -0
- package/build/types/badge/index.d.ts +2 -0
- 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 +2 -0
- package/build/types/common/circle/Circle.d.ts.map +1 -1
- package/build/types/index.d.ts +3 -1
- package/build/types/index.d.ts.map +1 -1
- package/package.json +3 -4
- package/src/avatar/Avatar.tsx +3 -0
- package/src/avatarGroup/AvatarGroup.css +29 -0
- package/src/avatarGroup/AvatarGroup.less +42 -0
- package/src/avatarGroup/AvatarGroup.story.tsx +284 -0
- package/src/avatarGroup/AvatarGroup.tsx +117 -0
- package/src/avatarGroup/index.ts +2 -0
- package/src/avatarView/AvatarView.css +42 -0
- package/src/avatarView/AvatarView.less +33 -0
- package/src/avatarView/AvatarView.story.tsx +425 -0
- package/src/avatarView/AvatarView.tsx +141 -0
- package/src/avatarView/NotificationDot.css +20 -0
- package/src/avatarView/NotificationDot.less +24 -0
- package/src/avatarView/NotificationDot.tsx +35 -0
- package/src/avatarView/index.ts +2 -0
- package/src/avatarWrapper/AvatarWrapper.tsx +3 -0
- package/src/badge/Badge.css +6 -5
- package/src/badge/Badge.less +4 -3
- package/src/badge/Badge.tsx +8 -1
- package/src/badge/BadgeAssets.tsx +65 -0
- package/src/badge/index.ts +3 -0
- package/src/button/{Button.spec.tsx → Button.spec.js} +2 -3
- package/src/button/Button.tsx +1 -1
- package/src/button/legacyUtils/{legacyUtils.spec.tsx → legacyUtils.spec.js} +1 -1
- package/src/button/legacyUtils/legacyUtils.ts +2 -2
- package/src/common/circle/Circle.css +32 -0
- package/src/common/circle/Circle.less +35 -0
- package/src/common/circle/Circle.tsx +22 -1
- package/src/decision/Decision.story.tsx +10 -46
- package/src/flowNavigation/FlowNavigation.story.tsx +10 -48
- package/src/i18n/th.json +5 -0
- package/src/index.ts +4 -0
- package/src/listItem/ListItem.story.tsx +5 -43
- package/src/main.css +109 -5
- package/src/main.less +2 -0
- package/src/modal/{Modal.rtl.spec.tsx → Modal.rtl.spec.js} +7 -8
- package/src/navigationOption/NavigationOption.story.tsx +14 -65
- package/src/overlayHeader/OverlayHeader.story.tsx +5 -10
- package/src/radio/Radio.story.tsx +5 -5
- package/src/radioGroup/RadioGroup.story.tsx +3 -3
- package/src/selectOption/SelectOption.story.tsx +31 -30
- package/src/slidingPanel/SlidingPanel.spec.js +1 -1
- package/src/ssr.spec.js +256 -0
- package/src/test-utils/{index.tsx → index.js} +6 -11
- package/src/test-utils/{jest.setup.ts → jest.setup.js} +8 -13
- package/src/tile/Tile.story.tsx +2 -6
- package/build/types/test-utils/index.d.ts +0 -158
- package/build/types/test-utils/index.d.ts.map +0 -1
- package/build/types/test-utils/jest.setup.d.ts +0 -2
- package/build/types/test-utils/jest.setup.d.ts.map +0 -1
- package/src/ssr.spec.tsx +0 -264
- /package/src/button/__snapshots__/{Button.spec.tsx.snap → Button.spec.js.snap} +0 -0
- /package/src/dimmer/{Dimmer.rtl.spec.tsx → Dimmer.rtl.spec.js} +0 -0
- /package/src/info/{Info.spec.jsx → Info.spec.js} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-d11e9c5",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -72,7 +72,6 @@
|
|
|
72
72
|
"@tsconfig/recommended": "^1.0.7",
|
|
73
73
|
"@types/babel__core": "^7.20.5",
|
|
74
74
|
"@types/commonmark": "^0.27.9",
|
|
75
|
-
"@types/enzyme": "^3.10.18",
|
|
76
75
|
"@types/jest": "^29.5.12",
|
|
77
76
|
"@types/lodash": "4.17.6",
|
|
78
77
|
"@types/lodash.clamp": "^4.0.9",
|
|
@@ -93,12 +92,12 @@
|
|
|
93
92
|
"rollup-preserve-directives": "^1.1.1",
|
|
94
93
|
"storybook": "^8.2.2",
|
|
95
94
|
"@transferwise/less-config": "3.1.0",
|
|
96
|
-
"@transferwise/neptune-css": "
|
|
95
|
+
"@transferwise/neptune-css": "14.20.0",
|
|
97
96
|
"@wise/components-theming": "1.6.1"
|
|
98
97
|
},
|
|
99
98
|
"peerDependencies": {
|
|
100
99
|
"@transferwise/icons": "^3.13.1",
|
|
101
|
-
"@transferwise/neptune-css": "
|
|
100
|
+
"@transferwise/neptune-css": "^14.9.6",
|
|
102
101
|
"@wise/art": "^2.16",
|
|
103
102
|
"@wise/components-theming": "^1.0.0",
|
|
104
103
|
"react": ">=18",
|
package/src/avatar/Avatar.tsx
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.np-avatar-group {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
position: relative;
|
|
4
|
+
}
|
|
5
|
+
.np-avatar-group-diagonal {
|
|
6
|
+
width: var(--np-avatar-group-size);
|
|
7
|
+
height: var(--np-avatar-group-size);
|
|
8
|
+
}
|
|
9
|
+
.np-avatar-group-diagonal-mask {
|
|
10
|
+
-webkit-mask-image: radial-gradient(circle at bottom calc(100% - var(--np-avatar-group-size) / 1.5) right calc(100% - var(--np-avatar-group-size) / 1.5), transparent 0, transparent calc(var(--np-avatar-group-single-size) / 2 + 0.5px), black 0);
|
|
11
|
+
mask-image: radial-gradient(circle at bottom calc(100% - var(--np-avatar-group-size) / 1.5) right calc(100% - var(--np-avatar-group-size) / 1.5), transparent 0, transparent calc(var(--np-avatar-group-single-size) / 2 + 0.5px), black 0);
|
|
12
|
+
}
|
|
13
|
+
.np-avatar-group-diagonal-child {
|
|
14
|
+
position: absolute;
|
|
15
|
+
top: var(--np-avatar-group-diagonal-child-position);
|
|
16
|
+
right: 0;
|
|
17
|
+
}
|
|
18
|
+
.np-avatar-group-horizontal {
|
|
19
|
+
height: var(--np-avatar-group-size);
|
|
20
|
+
}
|
|
21
|
+
.np-avatar-group-horizontal-mask {
|
|
22
|
+
-webkit-mask-image: radial-gradient(circle at top calc(100% - var(--np-avatar-group-single-size) / 2) right calc((100% - var(--np-avatar-group-single-size) / 1.5) * -1), transparent 0, transparent calc((var(--np-avatar-group-single-size) / 2.5) + var(--np-avatar-group-horizontal-child-position)), black 0);
|
|
23
|
+
mask-image: radial-gradient(circle at top calc(100% - var(--np-avatar-group-single-size) / 2) right calc((100% - var(--np-avatar-group-single-size) / 1.5) * -1), transparent 0, transparent calc((var(--np-avatar-group-single-size) / 2.5) + var(--np-avatar-group-horizontal-child-position)), black 0);
|
|
24
|
+
-webkit-mask-image: radial-gradient(circle at top calc(100% - var(--np-avatar-group-single-size) / 2) right calc(calc(100% - var(--np-avatar-group-single-size) / 1.5) * -1), transparent 0, transparent calc(calc(var(--np-avatar-group-single-size) / 2.5) + var(--np-avatar-group-horizontal-child-position)), black 0);
|
|
25
|
+
mask-image: radial-gradient(circle at top calc(100% - var(--np-avatar-group-single-size) / 2) right calc(calc(100% - var(--np-avatar-group-single-size) / 1.5) * -1), transparent 0, transparent calc(calc(var(--np-avatar-group-single-size) / 2.5) + var(--np-avatar-group-horizontal-child-position)), black 0);
|
|
26
|
+
}
|
|
27
|
+
.np-avatar-group-horizontal-child {
|
|
28
|
+
margin-left: calc(var(--np-avatar-group-horizontal-child-position) * -1);
|
|
29
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
.np-avatar-group {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
position: relative;
|
|
4
|
+
|
|
5
|
+
&-diagonal {
|
|
6
|
+
width: var(--np-avatar-group-size);
|
|
7
|
+
height: var(--np-avatar-group-size);
|
|
8
|
+
|
|
9
|
+
&-mask {
|
|
10
|
+
mask-image: radial-gradient(
|
|
11
|
+
circle at bottom calc(100% - var(--np-avatar-group-size) / 1.5)
|
|
12
|
+
right calc(100% - var(--np-avatar-group-size) / 1.5),
|
|
13
|
+
transparent 0,
|
|
14
|
+
transparent calc(var(--np-avatar-group-single-size) / 2 + 0.5px),
|
|
15
|
+
black 0
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&-child {
|
|
20
|
+
position: absolute;
|
|
21
|
+
top: var(--np-avatar-group-diagonal-child-position);
|
|
22
|
+
right: 0;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&-horizontal {
|
|
27
|
+
height: var(--np-avatar-group-size);
|
|
28
|
+
|
|
29
|
+
&-mask {
|
|
30
|
+
mask-image: radial-gradient(
|
|
31
|
+
circle at top calc(100% - var(--np-avatar-group-single-size) / 2)
|
|
32
|
+
right calc(calc(100% - var(--np-avatar-group-single-size) / 1.5) * -1),
|
|
33
|
+
transparent 0,
|
|
34
|
+
transparent calc(calc(var(--np-avatar-group-single-size) / 2.5) + var(--np-avatar-group-horizontal-child-position)),
|
|
35
|
+
black 0);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&-child {
|
|
39
|
+
margin-left: calc(var(--np-avatar-group-horizontal-child-position) * -1);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,284 @@
|
|
|
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={[{ name: 'Jay Jay' }, { name: 'Amy Amy' }]}
|
|
38
|
+
/>
|
|
39
|
+
))}
|
|
40
|
+
|
|
41
|
+
{sizes.map((size) => (
|
|
42
|
+
<AvatarGroup
|
|
43
|
+
key={size}
|
|
44
|
+
size={size}
|
|
45
|
+
orientation="diagonal"
|
|
46
|
+
interactive
|
|
47
|
+
avatars={[{ name: 'Jay Jay' }, { name: '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={[{ name: 'Jay Jay' }, { name: 'Amy Amy' }]}
|
|
134
|
+
/>
|
|
135
|
+
))}
|
|
136
|
+
|
|
137
|
+
{sizes.map((size) => (
|
|
138
|
+
<AvatarGroup
|
|
139
|
+
key={size}
|
|
140
|
+
size={size}
|
|
141
|
+
orientation="horizontal"
|
|
142
|
+
interactive
|
|
143
|
+
avatars={[{ name: 'Jay Jay' }, { name: '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
|
+
);
|
|
@@ -0,0 +1,117 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
}
|
|
21
|
+
.np-avatar-view .np-avatar-view-content {
|
|
22
|
+
color: var(--color-interactive-primary);
|
|
23
|
+
}
|
|
24
|
+
.np-avatar-view-interactive {
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
}
|
|
27
|
+
.np-avatar-view-interactive .np-circle {
|
|
28
|
+
background-color: rgba(134,167,189,0.10196);
|
|
29
|
+
background-color: var(--color-background-neutral);
|
|
30
|
+
}
|
|
31
|
+
.np-avatar-view-interactive:hover {
|
|
32
|
+
background-color: var(--color-background-neutral-hover);
|
|
33
|
+
}
|
|
34
|
+
.np-avatar-view-interactive:active {
|
|
35
|
+
background-color: var(--color-background-neutral-active);
|
|
36
|
+
}
|
|
37
|
+
.np-avatar-view-non-interactive .np-circle {
|
|
38
|
+
background-color: transparent;
|
|
39
|
+
}
|
|
40
|
+
.np-avatar-view-non-interactive .np-avatar-view-content .wds-flag {
|
|
41
|
+
box-shadow: none;
|
|
42
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
@import './NotificationDot.less';
|
|
2
|
+
|
|
3
|
+
.np-avatar-view {
|
|
4
|
+
.np-avatar-view-content {
|
|
5
|
+
color: var(--color-interactive-primary);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
&-interactive {
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
.np-circle {
|
|
11
|
+
background-color: var(--color-background-neutral);
|
|
12
|
+
}
|
|
13
|
+
&:hover {
|
|
14
|
+
background-color: var(--color-background-neutral-hover);
|
|
15
|
+
}
|
|
16
|
+
&:active {
|
|
17
|
+
background-color: var(--color-background-neutral-active);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&-non-interactive {
|
|
22
|
+
.np-circle {
|
|
23
|
+
background-color: transparent;
|
|
24
|
+
}
|
|
25
|
+
.np-avatar-view-content {
|
|
26
|
+
// dismiss broken shadow on Flag component (DS-6309)
|
|
27
|
+
// https://github.com/transferwise/web-art/blob/main/src/flags/Flag.css#L2
|
|
28
|
+
.wds-flag {
|
|
29
|
+
box-shadow: none;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|