@transferwise/components 0.0.0-experimental-4aa072a → 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.
Files changed (45) hide show
  1. package/build/avatarLayout/AvatarLayout.js.map +1 -1
  2. package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
  3. package/build/avatarView/AvatarView.js +8 -4
  4. package/build/avatarView/AvatarView.js.map +1 -1
  5. package/build/avatarView/AvatarView.mjs +8 -4
  6. package/build/avatarView/AvatarView.mjs.map +1 -1
  7. package/build/avatarView/{NotificationDot.js → Dot.js} +14 -12
  8. package/build/avatarView/Dot.js.map +1 -0
  9. package/build/avatarView/{NotificationDot.mjs → Dot.mjs} +14 -12
  10. package/build/avatarView/Dot.mjs.map +1 -0
  11. package/build/listItem/ListItem.js +2 -0
  12. package/build/listItem/ListItem.js.map +1 -1
  13. package/build/listItem/ListItem.mjs +2 -0
  14. package/build/listItem/ListItem.mjs.map +1 -1
  15. package/build/main.css +17 -11
  16. package/build/styles/avatarView/AvatarView.css +17 -11
  17. package/build/styles/avatarView/Dot.css +26 -0
  18. package/build/styles/main.css +17 -11
  19. package/build/types/avatarLayout/AvatarLayout.d.ts +1 -1
  20. package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
  21. package/build/types/avatarView/AvatarView.d.ts +4 -1
  22. package/build/types/avatarView/AvatarView.d.ts.map +1 -1
  23. package/build/types/avatarView/Dot.d.ts +8 -0
  24. package/build/types/avatarView/Dot.d.ts.map +1 -0
  25. package/build/types/listItem/ListItem.d.ts.map +1 -1
  26. package/package.json +2 -2
  27. package/src/avatarLayout/AvatarLayout.tsx +1 -1
  28. package/src/avatarView/AvatarView.css +17 -11
  29. package/src/avatarView/AvatarView.less +1 -1
  30. package/src/avatarView/AvatarView.story.tsx +39 -3
  31. package/src/avatarView/AvatarView.tsx +13 -6
  32. package/src/avatarView/Dot.css +26 -0
  33. package/src/avatarView/Dot.less +31 -0
  34. package/src/avatarView/Dot.tsx +42 -0
  35. package/src/listItem/AvatarView/ListItemAvatarView.story.tsx +46 -15
  36. package/src/listItem/ListItem.tsx +2 -0
  37. package/src/main.css +17 -11
  38. package/build/avatarView/NotificationDot.js.map +0 -1
  39. package/build/avatarView/NotificationDot.mjs.map +0 -1
  40. package/build/styles/avatarView/NotificationDot.css +0 -20
  41. package/build/types/avatarView/NotificationDot.d.ts +0 -8
  42. package/build/types/avatarView/NotificationDot.d.ts.map +0 -1
  43. package/src/avatarView/NotificationDot.css +0 -20
  44. package/src/avatarView/NotificationDot.less +0 -24
  45. package/src/avatarView/NotificationDot.tsx +0 -35
@@ -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
- notification: false,
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
- notification: {
92
- control: 'boolean',
93
- description: 'Shows notification dot',
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
- 'profileName',
262
- 'imgSrc',
263
- 'profileType',
264
- 'size',
265
- 'notification',
266
- 'selected',
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} notification>
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', 'notification', 'selected']),
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', 'notification', 'selected']),
357
+ argTypes: hideControls(['profileName', 'imgSrc', 'profileType', 'dot', 'selected']),
327
358
  render: (args) => {
328
359
  return (
329
360
  <List>
@@ -188,6 +188,7 @@ export const ListItem = ({
188
188
  const hasInfo = Boolean(additionalInfo);
189
189
  const hasPrompt = Boolean(prompt) || (disabled && Boolean(disabledPromptMessage));
190
190
 
191
+ /* eslint-disable functional/immutable-data */
191
192
  if (hasMedia && hasControl) {
192
193
  partials.push('wds-list-item-hasMedia-hasControl');
193
194
  }
@@ -216,6 +217,7 @@ export const ListItem = ({
216
217
  if (!hasInfo && !hasPrompt) {
217
218
  partials.push('wds-list-item-noInfo-noPrompt');
218
219
  }
220
+ /* eslint-enable functional/immutable-data */
219
221
 
220
222
  return partials.join(' ');
221
223
  };
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-notification-dot {
437
- --np-notification-dot-size: 14px;
436
+ .np-dot {
437
+ --np-dot-size: 14px;
438
438
  position: relative;
439
439
  display: inline-block;
440
440
  }
441
- .np-notification-dot-mask {
442
- -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);
443
- 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);
444
- -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);
445
- 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);
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-notification-dot-badge {
447
+ .np-dot-badge {
448
448
  position: absolute;
449
- width: var(--np-notification-dot-size);
450
- height: var(--np-notification-dot-size);
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
- }