@transferwise/components 0.0.0-experimental-87a405e → 0.0.0-experimental-6b7c8fd
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/avatarLayout/AvatarLayout.js.map +1 -1
- package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
- package/build/avatarView/AvatarView.js +8 -4
- package/build/avatarView/AvatarView.js.map +1 -1
- package/build/avatarView/AvatarView.mjs +8 -4
- package/build/avatarView/AvatarView.mjs.map +1 -1
- package/build/avatarView/{NotificationDot.js → Dot.js} +14 -12
- package/build/avatarView/Dot.js.map +1 -0
- package/build/avatarView/{NotificationDot.mjs → Dot.mjs} +14 -12
- package/build/avatarView/Dot.mjs.map +1 -0
- package/build/main.css +17 -11
- package/build/styles/avatarView/AvatarView.css +17 -11
- package/build/styles/avatarView/Dot.css +26 -0
- package/build/styles/main.css +17 -11
- package/build/types/avatarLayout/AvatarLayout.d.ts +1 -1
- package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
- package/build/types/avatarView/AvatarView.d.ts +4 -1
- package/build/types/avatarView/AvatarView.d.ts.map +1 -1
- package/build/types/avatarView/Dot.d.ts +8 -0
- package/build/types/avatarView/Dot.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/avatarLayout/AvatarLayout.tsx +1 -1
- package/src/avatarView/AvatarView.css +17 -11
- package/src/avatarView/AvatarView.less +1 -1
- package/src/avatarView/AvatarView.story.tsx +39 -3
- package/src/avatarView/AvatarView.tsx +13 -6
- package/src/avatarView/Dot.css +26 -0
- package/src/avatarView/Dot.less +31 -0
- package/src/avatarView/Dot.tsx +42 -0
- package/src/listItem/AvatarView/ListItemAvatarView.story.tsx +46 -15
- package/src/main.css +17 -11
- package/build/avatarView/NotificationDot.js.map +0 -1
- package/build/avatarView/NotificationDot.mjs.map +0 -1
- package/build/styles/avatarView/NotificationDot.css +0 -20
- package/build/types/avatarView/NotificationDot.d.ts +0 -8
- package/build/types/avatarView/NotificationDot.d.ts.map +0 -1
- package/src/avatarView/NotificationDot.css +0 -20
- package/src/avatarView/NotificationDot.less +0 -24
- package/src/avatarView/NotificationDot.tsx +0 -35
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
import { Props as AvatarViewProps } from './AvatarView';
|
|
3
|
+
export type DotProps = Pick<HTMLAttributes<HTMLDivElement>, 'children'> & {
|
|
4
|
+
avatarSize?: AvatarViewProps['size'];
|
|
5
|
+
variant?: 'notification' | 'online';
|
|
6
|
+
};
|
|
7
|
+
export default function Dot({ children, avatarSize, variant }: DotProps): import("react").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=Dot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dot.d.ts","sourceRoot":"","sources":["../../../src/avatarView/Dot.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,KAAK,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAGxD,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC,GAAG;IACxE,UAAU,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,cAAc,GAAG,QAAQ,CAAC;CACrC,CAAC;AAeF,MAAM,CAAC,OAAO,UAAU,GAAG,CAAC,EAAE,QAAQ,EAAE,UAAe,EAAE,OAAwB,EAAE,EAAE,QAAQ,+BAmB5F"}
|
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-6b7c8fd",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -83,10 +83,10 @@
|
|
|
83
83
|
"storybook": "^9.1.3",
|
|
84
84
|
"storybook-addon-tag-badges": "^2.0.2",
|
|
85
85
|
"storybook-addon-test-codegen": "^2.0.1",
|
|
86
|
-
"@
|
|
86
|
+
"@transferwise/less-config": "3.1.2",
|
|
87
87
|
"@transferwise/neptune-css": "14.25.0",
|
|
88
|
-
"@wise/
|
|
89
|
-
"@
|
|
88
|
+
"@wise/components-theming": "1.7.0",
|
|
89
|
+
"@wise/wds-configs": "0.0.0"
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|
|
92
92
|
"@transferwise/icons": "^3.22.4",
|
|
@@ -4,7 +4,7 @@ import { useDirection } from '../common/hooks';
|
|
|
4
4
|
|
|
5
5
|
type SingleAvatarType = { asset?: AvatarViewProps['children'] } & Omit<
|
|
6
6
|
AvatarViewProps,
|
|
7
|
-
'notification' | 'selected' | 'size' | 'badge' | 'children' | 'interactive'
|
|
7
|
+
'notification' | 'selected' | 'size' | 'badge' | 'children' | 'interactive' | 'dot'
|
|
8
8
|
>;
|
|
9
9
|
|
|
10
10
|
export type Props = {
|
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
.np-
|
|
2
|
-
--np-
|
|
1
|
+
.np-dot {
|
|
2
|
+
--np-dot-size: 14px;
|
|
3
3
|
position: relative;
|
|
4
4
|
display: inline-block;
|
|
5
5
|
}
|
|
6
|
-
.np-
|
|
7
|
-
-webkit-mask-image: radial-gradient(circle at bottom calc(100% - (var(--np-
|
|
8
|
-
mask-image: radial-gradient(circle at bottom calc(100% - (var(--np-
|
|
9
|
-
-webkit-mask-image: radial-gradient(circle at bottom calc(100% - calc(var(--np-
|
|
10
|
-
mask-image: radial-gradient(circle at bottom calc(100% - calc(var(--np-
|
|
6
|
+
.np-dot-mask {
|
|
7
|
+
-webkit-mask-image: radial-gradient(circle at bottom calc(100% - (var(--np-dot-size) / 2)) left calc(100% - (var(--np-dot-size) / 2)), transparent 0, transparent calc(var(--np-dot-size) / 2 + var(--np-dot-offset)), black 0);
|
|
8
|
+
mask-image: radial-gradient(circle at bottom calc(100% - (var(--np-dot-size) / 2)) left calc(100% - (var(--np-dot-size) / 2)), transparent 0, transparent calc(var(--np-dot-size) / 2 + var(--np-dot-offset)), black 0);
|
|
9
|
+
-webkit-mask-image: radial-gradient(circle at bottom calc(100% - calc(var(--np-dot-size) / 2)) left calc(100% - calc(var(--np-dot-size) / 2)), transparent 0, transparent calc(var(--np-dot-size) / 2 + var(--np-dot-offset)), black 0);
|
|
10
|
+
mask-image: radial-gradient(circle at bottom calc(100% - calc(var(--np-dot-size) / 2)) left calc(100% - calc(var(--np-dot-size) / 2)), transparent 0, transparent calc(var(--np-dot-size) / 2 + var(--np-dot-offset)), black 0);
|
|
11
11
|
}
|
|
12
|
-
.np-
|
|
12
|
+
.np-dot-badge {
|
|
13
13
|
position: absolute;
|
|
14
|
-
width: var(--np-
|
|
15
|
-
height: var(--np-
|
|
16
|
-
background-color: var(--color-sentiment-negative);
|
|
14
|
+
width: var(--np-dot-size);
|
|
15
|
+
height: var(--np-dot-size);
|
|
17
16
|
border-radius: 9999px;
|
|
18
17
|
border-radius: var(--radius-full);
|
|
19
18
|
right: 0;
|
|
20
19
|
}
|
|
20
|
+
.np-dot-badge-notification {
|
|
21
|
+
background-color: var(--color-sentiment-negative);
|
|
22
|
+
}
|
|
23
|
+
.np-dot-badge-online {
|
|
24
|
+
background-color: #00a2dd;
|
|
25
|
+
background-color: var(--color-interactive-accent);
|
|
26
|
+
}
|
|
21
27
|
.np-avatar-view .np-avatar-view-content {
|
|
22
28
|
color: #37517e;
|
|
23
29
|
color: var(--color-content-primary);
|
|
@@ -81,12 +81,12 @@ export const Notification: Story = {
|
|
|
81
81
|
<Body type="body-large-bold">{size}</Body>
|
|
82
82
|
))}
|
|
83
83
|
{sizes.map((size) => (
|
|
84
|
-
<AvatarView key={size} size={size} notification>
|
|
84
|
+
<AvatarView key={size} size={size} dot="notification">
|
|
85
85
|
<Freeze />
|
|
86
86
|
</AvatarView>
|
|
87
87
|
))}
|
|
88
88
|
{sizes.map((size) => (
|
|
89
|
-
<AvatarView key={size} size={size} notification interactive>
|
|
89
|
+
<AvatarView key={size} size={size} dot="notification" interactive>
|
|
90
90
|
<Freeze />
|
|
91
91
|
</AvatarView>
|
|
92
92
|
))}
|
|
@@ -95,7 +95,43 @@ export const Notification: Story = {
|
|
|
95
95
|
key={size}
|
|
96
96
|
size={size}
|
|
97
97
|
imgSrc="../avatar-rectangle-fox.webp"
|
|
98
|
-
notification
|
|
98
|
+
dot="notification"
|
|
99
|
+
interactive
|
|
100
|
+
/>
|
|
101
|
+
))}
|
|
102
|
+
</div>
|
|
103
|
+
),
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export const Online: Story = {
|
|
107
|
+
render: () => (
|
|
108
|
+
<div
|
|
109
|
+
style={{
|
|
110
|
+
gap: '1em',
|
|
111
|
+
display: 'grid',
|
|
112
|
+
justifyContent: 'space-between',
|
|
113
|
+
gridTemplate: `auto auto / repeat(${sizes.length}, min-content)`,
|
|
114
|
+
}}
|
|
115
|
+
>
|
|
116
|
+
{sizes.map((size) => (
|
|
117
|
+
<Body type="body-large-bold">{size}</Body>
|
|
118
|
+
))}
|
|
119
|
+
{sizes.map((size) => (
|
|
120
|
+
<AvatarView key={size} size={size} dot="online">
|
|
121
|
+
<Freeze />
|
|
122
|
+
</AvatarView>
|
|
123
|
+
))}
|
|
124
|
+
{sizes.map((size) => (
|
|
125
|
+
<AvatarView key={size} size={size} dot="online" interactive>
|
|
126
|
+
<Freeze />
|
|
127
|
+
</AvatarView>
|
|
128
|
+
))}
|
|
129
|
+
{sizes.map((size) => (
|
|
130
|
+
<AvatarView
|
|
131
|
+
key={size}
|
|
132
|
+
size={size}
|
|
133
|
+
imgSrc="../avatar-rectangle-fox.webp"
|
|
134
|
+
dot="online"
|
|
99
135
|
interactive
|
|
100
136
|
/>
|
|
101
137
|
))}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Badge, { BadgeAssets, BadgeProps, BadgeAssetsProps } from '../badge';
|
|
2
|
-
import
|
|
2
|
+
import Dot, { DotProps } from './Dot';
|
|
3
3
|
import Circle from '../common/circle';
|
|
4
4
|
import Image from '../image';
|
|
5
5
|
import { HTMLAttributes, PropsWithChildren, useState } from 'react';
|
|
@@ -26,7 +26,9 @@ export type Props = {
|
|
|
26
26
|
profileName?: string | null;
|
|
27
27
|
profileType?: ProfileTypeBusiness | ProfileTypePersonal;
|
|
28
28
|
size?: 16 | 24 | 32 | 40 | 48 | 56 | 72;
|
|
29
|
+
/** @deprecated Use `dot` instead. */
|
|
29
30
|
notification?: boolean;
|
|
31
|
+
dot?: DotProps['variant'];
|
|
30
32
|
badge?: AvatarViewBadgeProps;
|
|
31
33
|
interactive?: boolean;
|
|
32
34
|
selected?: boolean;
|
|
@@ -41,6 +43,7 @@ function AvatarView({
|
|
|
41
43
|
size = 48,
|
|
42
44
|
selected,
|
|
43
45
|
notification,
|
|
46
|
+
dot,
|
|
44
47
|
badge,
|
|
45
48
|
interactive = false,
|
|
46
49
|
className,
|
|
@@ -62,7 +65,7 @@ function AvatarView({
|
|
|
62
65
|
)}
|
|
63
66
|
{...restProps}
|
|
64
67
|
>
|
|
65
|
-
<Badges avatar={{ size, notification, selected }} {...badge}>
|
|
68
|
+
<Badges avatar={{ size, notification, dot, selected }} {...badge}>
|
|
66
69
|
<Circle
|
|
67
70
|
size={size}
|
|
68
71
|
fixedSize
|
|
@@ -115,7 +118,7 @@ const MAP_BADGE_POSITION = {
|
|
|
115
118
|
|
|
116
119
|
type BadgesProps = AvatarViewBadgeProps &
|
|
117
120
|
PropsWithChildren<{
|
|
118
|
-
avatar: Pick<Props, 'selected' | 'size' | 'notification'>;
|
|
121
|
+
avatar: Pick<Props, 'selected' | 'size' | 'notification' | 'dot'>;
|
|
119
122
|
}>;
|
|
120
123
|
|
|
121
124
|
/**
|
|
@@ -128,7 +131,7 @@ function Badges({
|
|
|
128
131
|
asset: customBadge,
|
|
129
132
|
...badgeAssets
|
|
130
133
|
}: BadgesProps) {
|
|
131
|
-
const { size = 48, selected, notification } = avatar;
|
|
134
|
+
const { size = 48, selected, notification, dot } = avatar;
|
|
132
135
|
const anyBadge = Object.values({ customBadge, ...badgeAssets }).filter(Boolean).length > 0;
|
|
133
136
|
if ((anyBadge || selected) && size > 16) {
|
|
134
137
|
const badgeSize: BadgeAssetsProps['size'] = MAP_BADGE_ASSET_SIZE[size];
|
|
@@ -154,8 +157,12 @@ function Badges({
|
|
|
154
157
|
</Badge>
|
|
155
158
|
);
|
|
156
159
|
}
|
|
157
|
-
if (notification) {
|
|
158
|
-
return
|
|
160
|
+
if (notification || dot) {
|
|
161
|
+
return (
|
|
162
|
+
<Dot avatarSize={size} variant={dot}>
|
|
163
|
+
{children}
|
|
164
|
+
</Dot>
|
|
165
|
+
);
|
|
159
166
|
}
|
|
160
167
|
return children;
|
|
161
168
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.np-dot {
|
|
2
|
+
--np-dot-size: 14px;
|
|
3
|
+
position: relative;
|
|
4
|
+
display: inline-block;
|
|
5
|
+
}
|
|
6
|
+
.np-dot-mask {
|
|
7
|
+
-webkit-mask-image: radial-gradient(circle at bottom calc(100% - (var(--np-dot-size) / 2)) left calc(100% - (var(--np-dot-size) / 2)), transparent 0, transparent calc(var(--np-dot-size) / 2 + var(--np-dot-offset)), black 0);
|
|
8
|
+
mask-image: radial-gradient(circle at bottom calc(100% - (var(--np-dot-size) / 2)) left calc(100% - (var(--np-dot-size) / 2)), transparent 0, transparent calc(var(--np-dot-size) / 2 + var(--np-dot-offset)), black 0);
|
|
9
|
+
-webkit-mask-image: radial-gradient(circle at bottom calc(100% - calc(var(--np-dot-size) / 2)) left calc(100% - calc(var(--np-dot-size) / 2)), transparent 0, transparent calc(var(--np-dot-size) / 2 + var(--np-dot-offset)), black 0);
|
|
10
|
+
mask-image: radial-gradient(circle at bottom calc(100% - calc(var(--np-dot-size) / 2)) left calc(100% - calc(var(--np-dot-size) / 2)), transparent 0, transparent calc(var(--np-dot-size) / 2 + var(--np-dot-offset)), black 0);
|
|
11
|
+
}
|
|
12
|
+
.np-dot-badge {
|
|
13
|
+
position: absolute;
|
|
14
|
+
width: var(--np-dot-size);
|
|
15
|
+
height: var(--np-dot-size);
|
|
16
|
+
border-radius: 9999px;
|
|
17
|
+
border-radius: var(--radius-full);
|
|
18
|
+
right: 0;
|
|
19
|
+
}
|
|
20
|
+
.np-dot-badge-notification {
|
|
21
|
+
background-color: var(--color-sentiment-negative);
|
|
22
|
+
}
|
|
23
|
+
.np-dot-badge-online {
|
|
24
|
+
background-color: #00a2dd;
|
|
25
|
+
background-color: var(--color-interactive-accent);
|
|
26
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
.np-dot {
|
|
2
|
+
--np-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-dot-size) / 2))
|
|
9
|
+
left calc(100% - calc(var(--np-dot-size) / 2)),
|
|
10
|
+
transparent 0,
|
|
11
|
+
transparent calc(var(--np-dot-size) / 2 + var(--np-dot-offset)),
|
|
12
|
+
black 0
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&-badge {
|
|
17
|
+
position: absolute;
|
|
18
|
+
width: var(--np-dot-size);
|
|
19
|
+
height: var(--np-dot-size);
|
|
20
|
+
border-radius: var(--radius-full);
|
|
21
|
+
right: 0;
|
|
22
|
+
|
|
23
|
+
&-notification {
|
|
24
|
+
background-color: var(--color-sentiment-negative);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&-online {
|
|
28
|
+
background-color: var(--color-interactive-accent);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
import { Props as AvatarViewProps } from './AvatarView';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
|
|
5
|
+
export type DotProps = Pick<HTMLAttributes<HTMLDivElement>, 'children'> & {
|
|
6
|
+
avatarSize?: AvatarViewProps['size'];
|
|
7
|
+
variant?: 'notification' | 'online';
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Depending on avatar size, dot size and offset are different
|
|
12
|
+
*/
|
|
13
|
+
const MAP_STYLE_CONFIG = {
|
|
14
|
+
16: { size: 6, offset: 1 },
|
|
15
|
+
24: { size: 8, offset: 2 },
|
|
16
|
+
32: { size: 10, offset: 2 },
|
|
17
|
+
40: { size: 10, offset: 2 },
|
|
18
|
+
48: { size: 14, offset: 2 },
|
|
19
|
+
56: { size: 16, offset: 3 },
|
|
20
|
+
72: { size: 20, offset: 3 },
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default function Dot({ children, avatarSize = 48, variant = 'notification' }: DotProps) {
|
|
24
|
+
return (
|
|
25
|
+
<div
|
|
26
|
+
className="np-dot"
|
|
27
|
+
style={{
|
|
28
|
+
// @ts-expect-error CSS custom props allowed
|
|
29
|
+
'--np-dot-size': `${MAP_STYLE_CONFIG[avatarSize].size}px`,
|
|
30
|
+
'--np-dot-offset': `${MAP_STYLE_CONFIG[avatarSize].offset}px`,
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
<div
|
|
34
|
+
className={clsx('np-dot-badge', {
|
|
35
|
+
'np-dot-badge-notification': variant === 'notification',
|
|
36
|
+
'np-dot-badge-online': variant === 'online',
|
|
37
|
+
})}
|
|
38
|
+
/>
|
|
39
|
+
<div className="np-dot-mask">{children}</div>
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
@@ -61,7 +61,7 @@ export default {
|
|
|
61
61
|
size: 48,
|
|
62
62
|
selected: false,
|
|
63
63
|
badge: { type: 'action' },
|
|
64
|
-
|
|
64
|
+
dot: undefined,
|
|
65
65
|
profileName: undefined,
|
|
66
66
|
profileType: undefined,
|
|
67
67
|
imgSrc: undefined,
|
|
@@ -88,9 +88,10 @@ export default {
|
|
|
88
88
|
type: { summary: 'ProfileType' },
|
|
89
89
|
},
|
|
90
90
|
},
|
|
91
|
-
|
|
92
|
-
control: '
|
|
93
|
-
|
|
91
|
+
dot: {
|
|
92
|
+
control: 'select',
|
|
93
|
+
options: ['notification', 'online'],
|
|
94
|
+
description: 'Dot variant',
|
|
94
95
|
},
|
|
95
96
|
selected: {
|
|
96
97
|
control: 'boolean',
|
|
@@ -257,14 +258,44 @@ export const Notification: Story = {
|
|
|
257
258
|
args: {
|
|
258
259
|
badge: undefined,
|
|
259
260
|
},
|
|
260
|
-
argTypes: hideControls([
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
261
|
+
argTypes: hideControls(['profileName', 'imgSrc', 'profileType', 'size', 'dot', 'selected']),
|
|
262
|
+
render: (args) => {
|
|
263
|
+
return (
|
|
264
|
+
<List>
|
|
265
|
+
{SIZES.map((size) => (
|
|
266
|
+
<ListItem
|
|
267
|
+
key={size}
|
|
268
|
+
title={`Size ${size}`}
|
|
269
|
+
subtitle={lorem10}
|
|
270
|
+
media={
|
|
271
|
+
<ListItem.AvatarView {...args} size={size} dot="notification">
|
|
272
|
+
<Taxi />
|
|
273
|
+
</ListItem.AvatarView>
|
|
274
|
+
}
|
|
275
|
+
control={CONTROLS.iconButton}
|
|
276
|
+
/>
|
|
277
|
+
))}
|
|
278
|
+
</List>
|
|
279
|
+
);
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Similarly, AvatarView also support an online dot, which also adjusts to the Avatar's size. <br />
|
|
285
|
+
* **NB:** You cannot use online and badge at the same time – badge will always take precedence over online.
|
|
286
|
+
*/
|
|
287
|
+
export const Online: Story = {
|
|
288
|
+
parameters: {
|
|
289
|
+
docs: {
|
|
290
|
+
canvas: {
|
|
291
|
+
sourceState: 'hidden',
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
args: {
|
|
296
|
+
badge: undefined,
|
|
297
|
+
},
|
|
298
|
+
argTypes: hideControls(['profileName', 'imgSrc', 'profileType', 'size', 'dot', 'selected']),
|
|
268
299
|
render: (args) => {
|
|
269
300
|
return (
|
|
270
301
|
<List>
|
|
@@ -274,7 +305,7 @@ export const Notification: Story = {
|
|
|
274
305
|
title={`Size ${size}`}
|
|
275
306
|
subtitle={lorem10}
|
|
276
307
|
media={
|
|
277
|
-
<ListItem.AvatarView {...args} size={size}
|
|
308
|
+
<ListItem.AvatarView {...args} size={size} dot="online">
|
|
278
309
|
<Taxi />
|
|
279
310
|
</ListItem.AvatarView>
|
|
280
311
|
}
|
|
@@ -294,7 +325,7 @@ export const Badges: Story = {
|
|
|
294
325
|
args: {
|
|
295
326
|
imgSrc: '../avatar-square-dude.webp',
|
|
296
327
|
},
|
|
297
|
-
argTypes: hideControls(['profileName', 'imgSrc', 'profileType', '
|
|
328
|
+
argTypes: hideControls(['profileName', 'imgSrc', 'profileType', 'dot', 'selected']),
|
|
298
329
|
parameters: {
|
|
299
330
|
docs: {
|
|
300
331
|
canvas: {
|
|
@@ -323,7 +354,7 @@ export const Badges: Story = {
|
|
|
323
354
|
* AvatarView supports selected state for interactive contexts.
|
|
324
355
|
*/
|
|
325
356
|
export const Selected: Story = {
|
|
326
|
-
argTypes: hideControls(['profileName', 'imgSrc', 'profileType', '
|
|
357
|
+
argTypes: hideControls(['profileName', 'imgSrc', 'profileType', 'dot', 'selected']),
|
|
327
358
|
render: (args) => {
|
|
328
359
|
return (
|
|
329
360
|
<List>
|
package/src/main.css
CHANGED
|
@@ -433,26 +433,32 @@
|
|
|
433
433
|
.np-theme-personal .tw-avatar--outlined:not(.disabled):not(:disabled):hover {
|
|
434
434
|
border-color: var(--color-interactive-primary-hover);
|
|
435
435
|
}
|
|
436
|
-
.np-
|
|
437
|
-
--np-
|
|
436
|
+
.np-dot {
|
|
437
|
+
--np-dot-size: 14px;
|
|
438
438
|
position: relative;
|
|
439
439
|
display: inline-block;
|
|
440
440
|
}
|
|
441
|
-
.np-
|
|
442
|
-
-webkit-mask-image: radial-gradient(circle at bottom calc(100% - (var(--np-
|
|
443
|
-
mask-image: radial-gradient(circle at bottom calc(100% - (var(--np-
|
|
444
|
-
-webkit-mask-image: radial-gradient(circle at bottom calc(100% - calc(var(--np-
|
|
445
|
-
mask-image: radial-gradient(circle at bottom calc(100% - calc(var(--np-
|
|
441
|
+
.np-dot-mask {
|
|
442
|
+
-webkit-mask-image: radial-gradient(circle at bottom calc(100% - (var(--np-dot-size) / 2)) left calc(100% - (var(--np-dot-size) / 2)), transparent 0, transparent calc(var(--np-dot-size) / 2 + var(--np-dot-offset)), black 0);
|
|
443
|
+
mask-image: radial-gradient(circle at bottom calc(100% - (var(--np-dot-size) / 2)) left calc(100% - (var(--np-dot-size) / 2)), transparent 0, transparent calc(var(--np-dot-size) / 2 + var(--np-dot-offset)), black 0);
|
|
444
|
+
-webkit-mask-image: radial-gradient(circle at bottom calc(100% - calc(var(--np-dot-size) / 2)) left calc(100% - calc(var(--np-dot-size) / 2)), transparent 0, transparent calc(var(--np-dot-size) / 2 + var(--np-dot-offset)), black 0);
|
|
445
|
+
mask-image: radial-gradient(circle at bottom calc(100% - calc(var(--np-dot-size) / 2)) left calc(100% - calc(var(--np-dot-size) / 2)), transparent 0, transparent calc(var(--np-dot-size) / 2 + var(--np-dot-offset)), black 0);
|
|
446
446
|
}
|
|
447
|
-
.np-
|
|
447
|
+
.np-dot-badge {
|
|
448
448
|
position: absolute;
|
|
449
|
-
width: var(--np-
|
|
450
|
-
height: var(--np-
|
|
451
|
-
background-color: var(--color-sentiment-negative);
|
|
449
|
+
width: var(--np-dot-size);
|
|
450
|
+
height: var(--np-dot-size);
|
|
452
451
|
border-radius: 9999px;
|
|
453
452
|
border-radius: var(--radius-full);
|
|
454
453
|
right: 0;
|
|
455
454
|
}
|
|
455
|
+
.np-dot-badge-notification {
|
|
456
|
+
background-color: var(--color-sentiment-negative);
|
|
457
|
+
}
|
|
458
|
+
.np-dot-badge-online {
|
|
459
|
+
background-color: #00a2dd;
|
|
460
|
+
background-color: var(--color-interactive-accent);
|
|
461
|
+
}
|
|
456
462
|
.np-avatar-view .np-avatar-view-content {
|
|
457
463
|
color: #37517e;
|
|
458
464
|
color: var(--color-content-primary);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationDot.js","sources":["../../src/avatarView/NotificationDot.tsx"],"sourcesContent":["import { HTMLAttributes } from 'react';\nimport { Props as AvatarViewProps } from './AvatarView';\n\ntype Props = Pick<HTMLAttributes<HTMLDivElement>, 'children'> & {\n avatarSize?: AvatarViewProps['size'];\n};\n\n/**\n * Depending on avatar size, notifcation dot size and offset are different\n */\nconst MAP_STYLE_CONFIG = {\n 16: { size: 6, offset: 1 },\n 24: { size: 8, offset: 2 },\n 32: { size: 10, offset: 2 },\n 40: { size: 10, offset: 2 },\n 48: { size: 14, offset: 2 },\n 56: { size: 16, offset: 3 },\n 72: { size: 20, offset: 3 },\n};\n\nexport default function NotificationDot({ children, avatarSize = 48 }: Props) {\n return (\n <div\n className=\"np-notification-dot\"\n style={{\n // @ts-expect-error CSS custom props allowed\n '--np-notification-dot-size': `${MAP_STYLE_CONFIG[avatarSize].size}px`,\n '--np-notification-dot-offset': `${MAP_STYLE_CONFIG[avatarSize].offset}px`,\n }}\n >\n <div className=\"np-notification-dot-badge\" />\n <div className=\"np-notification-dot-mask\">{children}</div>\n </div>\n );\n}\n"],"names":["MAP_STYLE_CONFIG","size","offset","NotificationDot","children","avatarSize","_jsxs","className","style","_jsx"],"mappings":";;;;;;AAOA;;AAEG;AACH,MAAMA,gBAAgB,GAAG;AACvB,EAAA,EAAE,EAAE;AAAEC,IAAAA,IAAI,EAAE,CAAC;AAAEC,IAAAA,MAAM,EAAE;GAAG;AAC1B,EAAA,EAAE,EAAE;AAAED,IAAAA,IAAI,EAAE,CAAC;AAAEC,IAAAA,MAAM,EAAE;GAAG;AAC1B,EAAA,EAAE,EAAE;AAAED,IAAAA,IAAI,EAAE,EAAE;AAAEC,IAAAA,MAAM,EAAE;GAAG;AAC3B,EAAA,EAAE,EAAE;AAAED,IAAAA,IAAI,EAAE,EAAE;AAAEC,IAAAA,MAAM,EAAE;GAAG;AAC3B,EAAA,EAAE,EAAE;AAAED,IAAAA,IAAI,EAAE,EAAE;AAAEC,IAAAA,MAAM,EAAE;GAAG;AAC3B,EAAA,EAAE,EAAE;AAAED,IAAAA,IAAI,EAAE,EAAE;AAAEC,IAAAA,MAAM,EAAE;GAAG;AAC3B,EAAA,EAAE,EAAE;AAAED,IAAAA,IAAI,EAAE,EAAE;AAAEC,IAAAA,MAAM,EAAE;AAAC;CAC1B;AAEa,SAAUC,eAAeA,CAAC;EAAEC,QAAQ;AAAEC,EAAAA,UAAU,GAAG;AAAE,CAAS,EAAA;AAC1E,EAAA,oBACEC,eAAA,CAAA,KAAA,EAAA;AACEC,IAAAA,SAAS,EAAC,qBAAqB;AAC/BC,IAAAA,KAAK,EAAE;AACL;MACA,4BAA4B,EAAE,GAAGR,gBAAgB,CAACK,UAAU,CAAC,CAACJ,IAAI,CAAA,EAAA,CAAI;AACtE,MAAA,8BAA8B,EAAE,CAAA,EAAGD,gBAAgB,CAACK,UAAU,CAAC,CAACH,MAAM,CAAA,EAAA;KACtE;AAAAE,IAAAA,QAAA,gBAEFK,cAAA,CAAA,KAAA,EAAA;AAAKF,MAAAA,SAAS,EAAC;KAA2B,CAC1C,eAAAE,cAAA,CAAA,KAAA,EAAA;AAAKF,MAAAA,SAAS,EAAC,0BAA0B;AAAAH,MAAAA,QAAA,EAAEA;AAAQ,KAAM,CAC3D;AAAA,GAAK,CAAC;AAEV;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationDot.mjs","sources":["../../src/avatarView/NotificationDot.tsx"],"sourcesContent":["import { HTMLAttributes } from 'react';\nimport { Props as AvatarViewProps } from './AvatarView';\n\ntype Props = Pick<HTMLAttributes<HTMLDivElement>, 'children'> & {\n avatarSize?: AvatarViewProps['size'];\n};\n\n/**\n * Depending on avatar size, notifcation dot size and offset are different\n */\nconst MAP_STYLE_CONFIG = {\n 16: { size: 6, offset: 1 },\n 24: { size: 8, offset: 2 },\n 32: { size: 10, offset: 2 },\n 40: { size: 10, offset: 2 },\n 48: { size: 14, offset: 2 },\n 56: { size: 16, offset: 3 },\n 72: { size: 20, offset: 3 },\n};\n\nexport default function NotificationDot({ children, avatarSize = 48 }: Props) {\n return (\n <div\n className=\"np-notification-dot\"\n style={{\n // @ts-expect-error CSS custom props allowed\n '--np-notification-dot-size': `${MAP_STYLE_CONFIG[avatarSize].size}px`,\n '--np-notification-dot-offset': `${MAP_STYLE_CONFIG[avatarSize].offset}px`,\n }}\n >\n <div className=\"np-notification-dot-badge\" />\n <div className=\"np-notification-dot-mask\">{children}</div>\n </div>\n );\n}\n"],"names":["MAP_STYLE_CONFIG","size","offset","NotificationDot","children","avatarSize","_jsxs","className","style","_jsx"],"mappings":";;AAOA;;AAEG;AACH,MAAMA,gBAAgB,GAAG;AACvB,EAAA,EAAE,EAAE;AAAEC,IAAAA,IAAI,EAAE,CAAC;AAAEC,IAAAA,MAAM,EAAE;GAAG;AAC1B,EAAA,EAAE,EAAE;AAAED,IAAAA,IAAI,EAAE,CAAC;AAAEC,IAAAA,MAAM,EAAE;GAAG;AAC1B,EAAA,EAAE,EAAE;AAAED,IAAAA,IAAI,EAAE,EAAE;AAAEC,IAAAA,MAAM,EAAE;GAAG;AAC3B,EAAA,EAAE,EAAE;AAAED,IAAAA,IAAI,EAAE,EAAE;AAAEC,IAAAA,MAAM,EAAE;GAAG;AAC3B,EAAA,EAAE,EAAE;AAAED,IAAAA,IAAI,EAAE,EAAE;AAAEC,IAAAA,MAAM,EAAE;GAAG;AAC3B,EAAA,EAAE,EAAE;AAAED,IAAAA,IAAI,EAAE,EAAE;AAAEC,IAAAA,MAAM,EAAE;GAAG;AAC3B,EAAA,EAAE,EAAE;AAAED,IAAAA,IAAI,EAAE,EAAE;AAAEC,IAAAA,MAAM,EAAE;AAAC;CAC1B;AAEa,SAAUC,eAAeA,CAAC;EAAEC,QAAQ;AAAEC,EAAAA,UAAU,GAAG;AAAE,CAAS,EAAA;AAC1E,EAAA,oBACEC,IAAA,CAAA,KAAA,EAAA;AACEC,IAAAA,SAAS,EAAC,qBAAqB;AAC/BC,IAAAA,KAAK,EAAE;AACL;MACA,4BAA4B,EAAE,GAAGR,gBAAgB,CAACK,UAAU,CAAC,CAACJ,IAAI,CAAA,EAAA,CAAI;AACtE,MAAA,8BAA8B,EAAE,CAAA,EAAGD,gBAAgB,CAACK,UAAU,CAAC,CAACH,MAAM,CAAA,EAAA;KACtE;AAAAE,IAAAA,QAAA,gBAEFK,GAAA,CAAA,KAAA,EAAA;AAAKF,MAAAA,SAAS,EAAC;KAA2B,CAC1C,eAAAE,GAAA,CAAA,KAAA,EAAA;AAAKF,MAAAA,SAAS,EAAC,0BAA0B;AAAAH,MAAAA,QAAA,EAAEA;AAAQ,KAAM,CAC3D;AAAA,GAAK,CAAC;AAEV;;;;"}
|
|
@@ -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,8 +0,0 @@
|
|
|
1
|
-
import { HTMLAttributes } from 'react';
|
|
2
|
-
import { Props as AvatarViewProps } from './AvatarView';
|
|
3
|
-
type Props = Pick<HTMLAttributes<HTMLDivElement>, 'children'> & {
|
|
4
|
-
avatarSize?: AvatarViewProps['size'];
|
|
5
|
-
};
|
|
6
|
-
export default function NotificationDot({ children, avatarSize }: Props): import("react").JSX.Element;
|
|
7
|
-
export {};
|
|
8
|
-
//# sourceMappingURL=NotificationDot.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationDot.d.ts","sourceRoot":"","sources":["../../../src/avatarView/NotificationDot.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,KAAK,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAExD,KAAK,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC,GAAG;IAC9D,UAAU,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;CACtC,CAAC;AAeF,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EAAE,QAAQ,EAAE,UAAe,EAAE,EAAE,KAAK,+BAc3E"}
|
|
@@ -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
|
-
}
|