@transferwise/components 46.111.1 → 46.112.1

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 (69) 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/listItem/useListItemControl.js +1 -1
  18. package/build/listItem/useListItemControl.js.map +1 -1
  19. package/build/listItem/useListItemControl.mjs +2 -2
  20. package/build/listItem/useListItemControl.mjs.map +1 -1
  21. package/build/listItem/useListItemMedia.js +1 -1
  22. package/build/listItem/useListItemMedia.js.map +1 -1
  23. package/build/listItem/useListItemMedia.mjs +2 -2
  24. package/build/listItem/useListItemMedia.mjs.map +1 -1
  25. package/build/main.css +17 -11
  26. package/build/styles/avatarView/AvatarView.css +17 -11
  27. package/build/styles/avatarView/Dot.css +26 -0
  28. package/build/styles/main.css +17 -11
  29. package/build/types/avatarLayout/AvatarLayout.d.ts +1 -1
  30. package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
  31. package/build/types/avatarView/AvatarView.d.ts +1 -2
  32. package/build/types/avatarView/AvatarView.d.ts.map +1 -1
  33. package/build/types/avatarView/Dot.d.ts +8 -0
  34. package/build/types/avatarView/Dot.d.ts.map +1 -0
  35. package/build/types/badge/BadgeAssets.d.ts +1 -1
  36. package/build/types/badge/BadgeAssets.d.ts.map +1 -1
  37. package/build/types/inputs/SelectInput.d.ts +20 -1
  38. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  39. package/build/types/withDisplayFormat/WithDisplayFormat.d.ts.map +1 -1
  40. package/build/withDisplayFormat/WithDisplayFormat.js +0 -1
  41. package/build/withDisplayFormat/WithDisplayFormat.js.map +1 -1
  42. package/build/withDisplayFormat/WithDisplayFormat.mjs +0 -1
  43. package/build/withDisplayFormat/WithDisplayFormat.mjs.map +1 -1
  44. package/package.json +10 -3
  45. package/src/avatarLayout/AvatarLayout.tsx +1 -1
  46. package/src/avatarView/AvatarView.css +17 -11
  47. package/src/avatarView/AvatarView.less +1 -1
  48. package/src/avatarView/AvatarView.story.tsx +92 -36
  49. package/src/avatarView/AvatarView.tsx +35 -30
  50. package/src/avatarView/Dot.css +26 -0
  51. package/src/avatarView/Dot.less +31 -0
  52. package/src/avatarView/Dot.tsx +42 -0
  53. package/src/badge/BadgeAssets.tsx +1 -1
  54. package/src/inputs/SelectInput.story.tsx +94 -0
  55. package/src/inputs/SelectInput.tsx +84 -1
  56. package/src/listItem/AvatarView/ListItemAvatarView.story.tsx +89 -25
  57. package/src/listItem/useListItemControl.tsx +2 -2
  58. package/src/listItem/useListItemMedia.tsx +2 -2
  59. package/src/main.css +17 -11
  60. package/src/withDisplayFormat/WithDisplayFormat.spec.js +28 -1
  61. package/src/withDisplayFormat/WithDisplayFormat.tsx +0 -1
  62. package/build/avatarView/NotificationDot.js.map +0 -1
  63. package/build/avatarView/NotificationDot.mjs.map +0 -1
  64. package/build/styles/avatarView/NotificationDot.css +0 -20
  65. package/build/types/avatarView/NotificationDot.d.ts +0 -8
  66. package/build/types/avatarView/NotificationDot.d.ts.map +0 -1
  67. package/src/avatarView/NotificationDot.css +0 -20
  68. package/src/avatarView/NotificationDot.less +0 -24
  69. package/src/avatarView/NotificationDot.tsx +0 -35
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,5 +1,5 @@
1
1
  import React from 'react';
2
- import { userEvent, render, screen, waitFor } from '../test-utils';
2
+ import { userEvent, render, screen, waitFor, fireEvent } from '../test-utils';
3
3
  import { Input } from '../inputs/Input';
4
4
  import WithDisplayFormat from '.';
5
5
 
@@ -22,6 +22,10 @@ describe('InputWithTextFormat (React Testing Library)', () => {
22
22
  onBlur: jest.fn(),
23
23
  };
24
24
 
25
+ beforeEach(() => {
26
+ jest.clearAllMocks();
27
+ });
28
+
25
29
  [
26
30
  { value: '123', expectedValue: '12-3', displayPattern: '**-**-**' },
27
31
  { value: '1234', expectedValue: '12-34', displayPattern: '**-**-**' },
@@ -170,4 +174,27 @@ describe('InputWithTextFormat (React Testing Library)', () => {
170
174
 
171
175
  expect(input).toHaveValue('14-5');
172
176
  });
177
+
178
+ it('calls onFocus when input is focused', () => {
179
+ const onFocus = jest.fn();
180
+ setup({ ...initialProps, onFocus });
181
+
182
+ const input = screen.getByRole('textbox');
183
+ fireEvent.focus(input);
184
+
185
+ expect(initialProps.onBlur).not.toHaveBeenCalled();
186
+ expect(initialProps.onChange).not.toHaveBeenCalled();
187
+ expect(onFocus).toHaveBeenCalled();
188
+ });
189
+
190
+ it('calls onBlur when input is blurred', () => {
191
+ setup(initialProps);
192
+
193
+ const input = screen.getByRole('textbox');
194
+ fireEvent.blur(input);
195
+
196
+ expect(initialProps.onFocus).not.toHaveBeenCalled();
197
+ expect(initialProps.onChange).not.toHaveBeenCalled();
198
+ expect(initialProps.onBlur).toHaveBeenCalled();
199
+ });
173
200
  });
@@ -237,7 +237,6 @@ class WithDisplayFormat<T extends TextElementProps> extends React.Component<
237
237
  handleOnFocus: React.FocusEventHandler<HTMLTextElement> = (event) => {
238
238
  const { displayPattern, onFocus } = this.props;
239
239
  if (onFocus) {
240
- this.handleOnChange(event);
241
240
  onFocus(unformatWithPattern(event.target.value, displayPattern));
242
241
  }
243
242
  };
@@ -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
- }