@transferwise/components 46.111.1 → 46.112.0

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 (52) 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 +27 -29
  4. package/build/avatarView/AvatarView.js.map +1 -1
  5. package/build/avatarView/AvatarView.mjs +27 -29
  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/badge/BadgeAssets.js.map +1 -1
  12. package/build/badge/BadgeAssets.mjs.map +1 -1
  13. package/build/inputs/SelectInput.js +41 -2
  14. package/build/inputs/SelectInput.js.map +1 -1
  15. package/build/inputs/SelectInput.mjs +41 -2
  16. package/build/inputs/SelectInput.mjs.map +1 -1
  17. package/build/main.css +17 -11
  18. package/build/styles/avatarView/AvatarView.css +17 -11
  19. package/build/styles/avatarView/Dot.css +26 -0
  20. package/build/styles/main.css +17 -11
  21. package/build/types/avatarLayout/AvatarLayout.d.ts +1 -1
  22. package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
  23. package/build/types/avatarView/AvatarView.d.ts +1 -2
  24. package/build/types/avatarView/AvatarView.d.ts.map +1 -1
  25. package/build/types/avatarView/Dot.d.ts +8 -0
  26. package/build/types/avatarView/Dot.d.ts.map +1 -0
  27. package/build/types/badge/BadgeAssets.d.ts +1 -1
  28. package/build/types/badge/BadgeAssets.d.ts.map +1 -1
  29. package/build/types/inputs/SelectInput.d.ts +20 -1
  30. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  31. package/package.json +2 -2
  32. package/src/avatarLayout/AvatarLayout.tsx +1 -1
  33. package/src/avatarView/AvatarView.css +17 -11
  34. package/src/avatarView/AvatarView.less +1 -1
  35. package/src/avatarView/AvatarView.story.tsx +92 -36
  36. package/src/avatarView/AvatarView.tsx +35 -30
  37. package/src/avatarView/Dot.css +26 -0
  38. package/src/avatarView/Dot.less +31 -0
  39. package/src/avatarView/Dot.tsx +42 -0
  40. package/src/badge/BadgeAssets.tsx +1 -1
  41. package/src/inputs/SelectInput.story.tsx +94 -0
  42. package/src/inputs/SelectInput.tsx +84 -1
  43. package/src/listItem/AvatarView/ListItemAvatarView.story.tsx +89 -25
  44. package/src/main.css +17 -11
  45. package/build/avatarView/NotificationDot.js.map +0 -1
  46. package/build/avatarView/NotificationDot.mjs.map +0 -1
  47. package/build/styles/avatarView/NotificationDot.css +0 -20
  48. package/build/types/avatarView/NotificationDot.d.ts +0 -8
  49. package/build/types/avatarView/NotificationDot.d.ts.map +0 -1
  50. package/src/avatarView/NotificationDot.css +0 -20
  51. package/src/avatarView/NotificationDot.less +0 -24
  52. package/src/avatarView/NotificationDot.tsx +0 -35
@@ -47,6 +47,8 @@ const BADGES = {
47
47
  </div>
48
48
  ),
49
49
  },
50
+ 'Notification badge': { type: 'notification' },
51
+ 'Online badge': { type: 'online' },
50
52
  } as const;
51
53
 
52
54
  export default {
@@ -61,7 +63,6 @@ export default {
61
63
  size: 48,
62
64
  selected: false,
63
65
  badge: { type: 'action' },
64
- notification: false,
65
66
  profileName: undefined,
66
67
  profileType: undefined,
67
68
  imgSrc: undefined,
@@ -88,20 +89,23 @@ export default {
88
89
  type: { summary: 'ProfileType' },
89
90
  },
90
91
  },
91
- notification: {
92
- control: 'boolean',
93
- description: 'Shows notification dot',
94
- },
95
- selected: {
96
- control: 'boolean',
97
- description: 'Toggles selected state',
98
- },
99
92
  badge: {
100
- description: 'Badge configuration object',
93
+ control: 'select',
94
+ options: ['action', 'notification', 'online'],
95
+ description: 'Badge type',
96
+ mapping: {
97
+ action: { type: 'action' },
98
+ notification: { type: 'notification' },
99
+ online: { type: 'online' },
100
+ },
101
101
  table: {
102
102
  type: { summary: 'AvatarViewBadgeProps' },
103
103
  },
104
104
  },
105
+ selected: {
106
+ control: 'boolean',
107
+ description: 'Toggles selected state',
108
+ },
105
109
  children: {
106
110
  table: {
107
111
  type: { summary: 'ReactNode' },
@@ -243,8 +247,48 @@ export const Sizes: Story = {
243
247
  };
244
248
 
245
249
  /**
246
- * Similarly, AvatarView also support a notification dot, which also adjusts to the Avatar's size. <br />
247
- * **NB:** You cannot use notification and badge at the same time badge will always take precedence over notification.
250
+ * AvatarView supports different types of badges for additional context and information. <br />
251
+ * Refer to the [design documentation](https://wise.design/components/avatar#:~:text=support%20the%20information.-,With%20badge,-Badges%20contain%20additional) for details.
252
+ */
253
+ export const Badges: Story = {
254
+ args: {
255
+ imgSrc: '../avatar-square-dude.webp',
256
+ },
257
+ argTypes: hideControls([
258
+ 'profileName',
259
+ 'imgSrc',
260
+ 'profileType',
261
+ 'notification',
262
+ 'dot',
263
+ 'selected',
264
+ ]),
265
+ parameters: {
266
+ docs: {
267
+ canvas: {
268
+ sourceState: 'hidden',
269
+ },
270
+ },
271
+ },
272
+ render: (args) => {
273
+ return (
274
+ <List>
275
+ {Object.entries(BADGES).map(([title, badge]) => (
276
+ <ListItem
277
+ key={title}
278
+ title={title}
279
+ subtitle={lorem10}
280
+ media={<ListItem.AvatarView {...args} badge={badge} />}
281
+ control={CONTROLS.iconButton}
282
+ />
283
+ ))}
284
+ </List>
285
+ );
286
+ },
287
+ };
288
+
289
+ /**
290
+ * `notification` is a particular `type` of Badge that appears in the top right corner as a red dot. It also adjusts to the Avatar's size. <br />
291
+ * **NB:** You can only choose one badge at a time, so the notification badge cannot be combined with any other badge type.
248
292
  */
249
293
  export const Notification: Story = {
250
294
  parameters: {
@@ -263,6 +307,7 @@ export const Notification: Story = {
263
307
  'profileType',
264
308
  'size',
265
309
  'notification',
310
+ 'dot',
266
311
  'selected',
267
312
  ]),
268
313
  render: (args) => {
@@ -274,7 +319,7 @@ export const Notification: Story = {
274
319
  title={`Size ${size}`}
275
320
  subtitle={lorem10}
276
321
  media={
277
- <ListItem.AvatarView {...args} size={size} notification>
322
+ <ListItem.AvatarView {...args} size={size} badge={{ type: 'notification' }}>
278
323
  <Taxi />
279
324
  </ListItem.AvatarView>
280
325
  }
@@ -287,14 +332,11 @@ export const Notification: Story = {
287
332
  };
288
333
 
289
334
  /**
290
- * AvatarView supports different type of badges for additional context and information. <br />
291
- * Refer to the [design documentation](https://wise.design/components/avatar#:~:text=support%20the%20information.-,With%20badge,-Badges%20contain%20additional) for details.
335
+ * Similarly, Badge also has an `online` `type` which is green and also adjusts to the Avatar's size. <br />
336
+ * **NB:** You can only choose one badge at a time, so the online badge cannot be combined with any other badge type.
292
337
  */
293
- export const Badges: Story = {
294
- args: {
295
- imgSrc: '../avatar-square-dude.webp',
296
- },
297
- argTypes: hideControls(['profileName', 'imgSrc', 'profileType', 'notification', 'selected']),
338
+ export const Online: Story = {
339
+ tags: ['new'],
298
340
  parameters: {
299
341
  docs: {
300
342
  canvas: {
@@ -302,15 +344,30 @@ export const Badges: Story = {
302
344
  },
303
345
  },
304
346
  },
347
+ args: {
348
+ badge: undefined,
349
+ },
350
+ argTypes: hideControls([
351
+ 'profileName',
352
+ 'imgSrc',
353
+ 'profileType',
354
+ 'size',
355
+ 'notification',
356
+ 'selected',
357
+ ]),
305
358
  render: (args) => {
306
359
  return (
307
360
  <List>
308
- {Object.entries(BADGES).map(([title, badge]) => (
361
+ {SIZES.map((size) => (
309
362
  <ListItem
310
- key={title}
311
- title={title}
363
+ key={size}
364
+ title={`Size ${size}`}
312
365
  subtitle={lorem10}
313
- media={<ListItem.AvatarView {...args} badge={badge} />}
366
+ media={
367
+ <ListItem.AvatarView {...args} size={size} badge={{ type: 'online' }}>
368
+ <Taxi />
369
+ </ListItem.AvatarView>
370
+ }
314
371
  control={CONTROLS.iconButton}
315
372
  />
316
373
  ))}
@@ -323,7 +380,14 @@ export const Badges: Story = {
323
380
  * AvatarView supports selected state for interactive contexts.
324
381
  */
325
382
  export const Selected: Story = {
326
- argTypes: hideControls(['profileName', 'imgSrc', 'profileType', 'notification', 'selected']),
383
+ argTypes: hideControls([
384
+ 'profileName',
385
+ 'imgSrc',
386
+ 'profileType',
387
+ 'notification',
388
+ 'dot',
389
+ 'selected',
390
+ ]),
327
391
  render: (args) => {
328
392
  return (
329
393
  <List>
package/src/main.css CHANGED
@@ -586,26 +586,32 @@
586
586
  .wds-inline-prompt.wds-inline-prompt--warning:has(a, button):active {
587
587
  background-color: color-mix(in srgb, var(--color-sentiment-warning-secondary) 84%, var(--color-sentiment-warning-primary));
588
588
  }
589
- .np-notification-dot {
590
- --np-notification-dot-size: 14px;
589
+ .np-dot {
590
+ --np-dot-size: 14px;
591
591
  position: relative;
592
592
  display: inline-block;
593
593
  }
594
- .np-notification-dot-mask {
595
- -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);
596
- 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);
597
- -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);
598
- 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);
594
+ .np-dot-mask {
595
+ -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);
596
+ 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);
597
+ -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);
598
+ 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);
599
599
  }
600
- .np-notification-dot-badge {
600
+ .np-dot-badge {
601
601
  position: absolute;
602
- width: var(--np-notification-dot-size);
603
- height: var(--np-notification-dot-size);
604
- background-color: var(--color-sentiment-negative);
602
+ width: var(--np-dot-size);
603
+ height: var(--np-dot-size);
605
604
  border-radius: 9999px;
606
605
  border-radius: var(--radius-full);
607
606
  right: 0;
608
607
  }
608
+ .np-dot-badge-notification {
609
+ background-color: var(--color-sentiment-negative);
610
+ }
611
+ .np-dot-badge-online {
612
+ background-color: #00a2dd;
613
+ background-color: var(--color-interactive-accent);
614
+ }
609
615
  .np-avatar-view .np-avatar-view-content {
610
616
  color: #37517e;
611
617
  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
- }