@transferwise/components 46.80.0 → 46.82.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 (137) hide show
  1. package/build/avatar/Avatar.js +3 -0
  2. package/build/avatar/Avatar.js.map +1 -1
  3. package/build/avatar/Avatar.mjs +3 -0
  4. package/build/avatar/Avatar.mjs.map +1 -1
  5. package/build/avatarView/AvatarView.js +175 -0
  6. package/build/avatarView/AvatarView.js.map +1 -0
  7. package/build/avatarView/AvatarView.mjs +173 -0
  8. package/build/avatarView/AvatarView.mjs.map +1 -0
  9. package/build/avatarView/NotificationDot.js +59 -0
  10. package/build/avatarView/NotificationDot.js.map +1 -0
  11. package/build/avatarView/NotificationDot.mjs +57 -0
  12. package/build/avatarView/NotificationDot.mjs.map +1 -0
  13. package/build/avatarWrapper/AvatarWrapper.js +10 -4
  14. package/build/avatarWrapper/AvatarWrapper.js.map +1 -1
  15. package/build/avatarWrapper/AvatarWrapper.mjs +10 -4
  16. package/build/avatarWrapper/AvatarWrapper.mjs.map +1 -1
  17. package/build/badge/Badge.js +16 -4
  18. package/build/badge/Badge.js.map +1 -1
  19. package/build/badge/Badge.mjs +15 -3
  20. package/build/badge/Badge.mjs.map +1 -1
  21. package/build/badge/BadgeAssets.js +60 -0
  22. package/build/badge/BadgeAssets.js.map +1 -0
  23. package/build/badge/BadgeAssets.mjs +58 -0
  24. package/build/badge/BadgeAssets.mjs.map +1 -0
  25. package/build/common/circle/Circle.js +19 -1
  26. package/build/common/circle/Circle.js.map +1 -1
  27. package/build/common/circle/Circle.mjs +19 -1
  28. package/build/common/circle/Circle.mjs.map +1 -1
  29. package/build/i18n/en.json +5 -0
  30. package/build/i18n/en.json.js +5 -0
  31. package/build/i18n/en.json.js.map +1 -1
  32. package/build/i18n/en.json.mjs +5 -0
  33. package/build/i18n/en.json.mjs.map +1 -1
  34. package/build/i18n/zh-HK.json +5 -0
  35. package/build/i18n/zh-HK.json.js +5 -0
  36. package/build/i18n/zh-HK.json.js.map +1 -1
  37. package/build/i18n/zh-HK.json.mjs +5 -0
  38. package/build/i18n/zh-HK.json.mjs.map +1 -1
  39. package/build/index.js +18 -13
  40. package/build/index.js.map +1 -1
  41. package/build/index.mjs +10 -7
  42. package/build/index.mjs.map +1 -1
  43. package/build/main.css +348 -5
  44. package/build/money/Money.js +5 -2
  45. package/build/money/Money.js.map +1 -1
  46. package/build/money/Money.mjs +5 -2
  47. package/build/money/Money.mjs.map +1 -1
  48. package/build/styles/avatarView/AvatarView.css +36 -0
  49. package/build/styles/avatarView/NotificationDot.css +20 -0
  50. package/build/styles/badge/Badge.css +6 -5
  51. package/build/styles/common/circle/Circle.css +32 -0
  52. package/build/styles/main.css +348 -5
  53. package/build/styles/table/Table.css +274 -0
  54. package/build/types/avatar/Avatar.d.ts +3 -0
  55. package/build/types/avatar/Avatar.d.ts.map +1 -1
  56. package/build/types/avatarView/AvatarView.d.ts +26 -0
  57. package/build/types/avatarView/AvatarView.d.ts.map +1 -0
  58. package/build/types/avatarView/NotificationDot.d.ts +8 -0
  59. package/build/types/avatarView/NotificationDot.d.ts.map +1 -0
  60. package/build/types/avatarView/index.d.ts +3 -0
  61. package/build/types/avatarView/index.d.ts.map +1 -0
  62. package/build/types/avatarWrapper/AvatarWrapper.d.ts +3 -0
  63. package/build/types/avatarWrapper/AvatarWrapper.d.ts.map +1 -1
  64. package/build/types/badge/Badge.d.ts +9 -4
  65. package/build/types/badge/Badge.d.ts.map +1 -1
  66. package/build/types/badge/BadgeAssets.d.ts +14 -0
  67. package/build/types/badge/BadgeAssets.d.ts.map +1 -0
  68. package/build/types/badge/index.d.ts +2 -0
  69. package/build/types/badge/index.d.ts.map +1 -1
  70. package/build/types/common/circle/Circle.d.ts +2 -0
  71. package/build/types/common/circle/Circle.d.ts.map +1 -1
  72. package/build/types/index.d.ts +3 -1
  73. package/build/types/index.d.ts.map +1 -1
  74. package/build/types/money/Money.d.ts +2 -1
  75. package/build/types/money/Money.d.ts.map +1 -1
  76. package/build/types/table/Table.d.ts +23 -0
  77. package/build/types/table/Table.d.ts.map +1 -0
  78. package/build/types/table/Table.messages.d.ts +24 -0
  79. package/build/types/table/Table.messages.d.ts.map +1 -0
  80. package/build/types/table/TableCell.d.ts +40 -0
  81. package/build/types/table/TableCell.d.ts.map +1 -0
  82. package/build/types/table/TableHeader.d.ts +13 -0
  83. package/build/types/table/TableHeader.d.ts.map +1 -0
  84. package/build/types/table/TableRow.d.ts +17 -0
  85. package/build/types/table/TableRow.d.ts.map +1 -0
  86. package/build/types/table/TableStatusText.d.ts +10 -0
  87. package/build/types/table/TableStatusText.d.ts.map +1 -0
  88. package/build/types/table/index.d.ts +6 -0
  89. package/build/types/table/index.d.ts.map +1 -0
  90. package/build/types/test-utils/index.d.ts +10 -0
  91. package/build/types/test-utils/index.d.ts.map +1 -1
  92. package/package.json +3 -3
  93. package/src/avatar/Avatar.tsx +3 -0
  94. package/src/avatarView/AvatarView.css +36 -0
  95. package/src/avatarView/AvatarView.less +27 -0
  96. package/src/avatarView/AvatarView.story.tsx +467 -0
  97. package/src/avatarView/AvatarView.tsx +171 -0
  98. package/src/avatarView/NotificationDot.css +20 -0
  99. package/src/avatarView/NotificationDot.less +24 -0
  100. package/src/avatarView/NotificationDot.tsx +35 -0
  101. package/src/avatarView/index.ts +2 -0
  102. package/src/avatarWrapper/AvatarWrapper.story.tsx +19 -0
  103. package/src/avatarWrapper/AvatarWrapper.tsx +3 -0
  104. package/src/badge/Badge.css +6 -5
  105. package/src/badge/Badge.less +4 -3
  106. package/src/badge/Badge.tsx +20 -6
  107. package/src/badge/BadgeAssets.tsx +61 -0
  108. package/src/badge/index.ts +3 -0
  109. package/src/circularButton/CircularButton.spec.tsx +0 -36
  110. package/src/common/circle/Circle.css +32 -0
  111. package/src/common/circle/Circle.less +35 -0
  112. package/src/common/circle/Circle.tsx +24 -1
  113. package/src/flowNavigation/FlowNavigation.story.tsx +19 -52
  114. package/src/i18n/en.json +5 -0
  115. package/src/i18n/zh-HK.json +5 -0
  116. package/src/index.ts +3 -0
  117. package/src/listItem/ListItem.story.tsx +5 -47
  118. package/src/main.css +348 -5
  119. package/src/main.less +2 -0
  120. package/src/money/Money.tsx +9 -2
  121. package/src/overlayHeader/OverlayHeader.story.tsx +6 -14
  122. package/src/table/Table.css +274 -0
  123. package/src/table/Table.less +334 -0
  124. package/src/table/Table.messages.ts +24 -0
  125. package/src/table/Table.spec.tsx +82 -0
  126. package/src/table/Table.story.tsx +356 -0
  127. package/src/table/Table.tsx +167 -0
  128. package/src/table/TableCell.spec.tsx +298 -0
  129. package/src/table/TableCell.tsx +149 -0
  130. package/src/table/TableHeader.spec.tsx +50 -0
  131. package/src/table/TableHeader.tsx +74 -0
  132. package/src/table/TableRow.spec.tsx +112 -0
  133. package/src/table/TableRow.tsx +70 -0
  134. package/src/table/TableStatusText.spec.tsx +53 -0
  135. package/src/table/TableStatusText.tsx +40 -0
  136. package/src/table/index.ts +11 -0
  137. package/src/circularButton/__snapshots__/CircularButton.spec.tsx.snap +0 -381
@@ -0,0 +1,13 @@
1
+ export interface TableHeaderType {
2
+ header?: string;
3
+ className?: string;
4
+ alignment?: 'left' | 'right';
5
+ status?: 'error';
6
+ width?: string;
7
+ }
8
+ export interface TableHeaderProps extends TableHeaderType {
9
+ isActionHeader?: boolean;
10
+ }
11
+ declare const TableHeader: ({ header, className, alignment, status, width, isActionHeader, }: TableHeaderProps) => import("react").JSX.Element;
12
+ export default TableHeader;
13
+ //# sourceMappingURL=TableHeader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableHeader.d.ts","sourceRoot":"","sources":["../../../src/table/TableHeader.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,QAAA,MAAM,WAAW,qEAOd,gBAAgB,gCA+ClB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { TableCellProps } from './TableCell';
3
+ export interface TableRowType {
4
+ cells?: TableCellProps[];
5
+ }
6
+ export interface TableRowClickableType extends TableRowType {
7
+ id: number | string;
8
+ }
9
+ export interface TableRowProps {
10
+ rowData?: TableRowType | TableRowClickableType;
11
+ hasSeparator?: boolean;
12
+ children?: React.ReactNode;
13
+ onRowClick?: (rowData: TableRowType | TableRowClickableType) => void;
14
+ }
15
+ declare const TableRow: ({ rowData, hasSeparator, children, onRowClick }: TableRowProps) => React.JSX.Element;
16
+ export default TableRow;
17
+ //# sourceMappingURL=TableRow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableRow.d.ts","sourceRoot":"","sources":["../../../src/table/TableRow.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAKxD,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAsB,SAAQ,YAAY;IACzD,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,YAAY,GAAG,qBAAqB,CAAC;IAC/C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,GAAG,qBAAqB,KAAK,IAAI,CAAC;CACtE;AAED,QAAA,MAAM,QAAQ,oDAA6D,aAAa,sBA8CvF,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ export interface TableStatusTextProps {
3
+ text: string | React.ReactNode;
4
+ className?: string;
5
+ status?: 'success' | 'error';
6
+ typography?: 'default' | 'default-bold';
7
+ }
8
+ declare const TableStatusText: ({ text, className, status, typography, }: TableStatusTextProps) => React.JSX.Element;
9
+ export default TableStatusText;
10
+ //# sourceMappingURL=TableStatusText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableStatusText.d.ts","sourceRoot":"","sources":["../../../src/table/TableStatusText.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAC7B,UAAU,CAAC,EAAE,SAAS,GAAG,cAAc,CAAC;CACzC;AAED,QAAA,MAAM,eAAe,6CAKlB,oBAAoB,sBAmBtB,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { default } from './Table';
2
+ export type { TableProps } from './Table';
3
+ export type { TableRowType, TableRowClickableType } from './TableRow';
4
+ export type { TableHeaderType } from './TableHeader';
5
+ export type { TableCellLeading, TableCellText, TableCellCurrency, TableCellStatus, TableCellType, } from './TableCell';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/table/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,YAAY,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACtE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,aAAa,GACd,MAAM,aAAa,CAAC"}
@@ -45,6 +45,11 @@ declare function customRender(ui: ReactElement, { locale, messages, ...renderOpt
45
45
  "neptune.Summary.statusDone": string;
46
46
  "neptune.Summary.statusNotDone": string;
47
47
  "neptune.Summary.statusPending": string;
48
+ "neptune.Table.actionHeader": string;
49
+ "neptune.Table.emptyData": string;
50
+ "neptune.Table.loaded": string;
51
+ "neptune.Table.loading": string;
52
+ "neptune.Table.refreshPage": string;
48
53
  "neptune.Upload.csButtonText": string;
49
54
  "neptune.Upload.csFailureText": string;
50
55
  "neptune.Upload.csSuccessText": string;
@@ -119,6 +124,11 @@ declare function customRenderHook(callback: () => unknown, { locale, messages }?
119
124
  "neptune.Summary.statusDone": string;
120
125
  "neptune.Summary.statusNotDone": string;
121
126
  "neptune.Summary.statusPending": string;
127
+ "neptune.Table.actionHeader": string;
128
+ "neptune.Table.emptyData": string;
129
+ "neptune.Table.loaded": string;
130
+ "neptune.Table.loading": string;
131
+ "neptune.Table.refreshPage": string;
122
132
  "neptune.Upload.csButtonText": string;
123
133
  "neptune.Upload.csFailureText": string;
124
134
  "neptune.Upload.csSuccessText": string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/test-utils/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAM,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,MAAM,EAAc,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAMxD;;;;GAIG;AACH,iBAAS,YAAY,CACnB,EAAE,EAAE,YAAY,EAChB,EAAE,MAAuB,EAAE,QAAa,EAAE,GAAG,aAAa,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAK,GAChE,UAAU,CAAC,OAAO,MAAM,CAAC,CAK3B;AAED;;;GAGG;AACH,iBAAS,gBAAgB,CACvB,QAAQ,EAAE,MAAM,OAAO,EACvB,EAAE,MAAuB,EAAE,QAAa,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAK,uEAKhD;AAED,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,gBAAgB,IAAI,UAAU,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/test-utils/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAM,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,MAAM,EAAc,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAMxD;;;;GAIG;AACH,iBAAS,YAAY,CACnB,EAAE,EAAE,YAAY,EAChB,EAAE,MAAuB,EAAE,QAAa,EAAE,GAAG,aAAa,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAK,GAChE,UAAU,CAAC,OAAO,MAAM,CAAC,CAK3B;AAED;;;GAGG;AACH,iBAAS,gBAAgB,CACvB,QAAQ,EAAE,MAAM,OAAO,EACvB,EAAE,MAAuB,EAAE,QAAa,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAK,uEAKhD;AAED,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,gBAAgB,IAAI,UAAU,EAAE,SAAS,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "46.80.0",
3
+ "version": "46.82.0",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -93,8 +93,8 @@
93
93
  "rollup-preserve-directives": "^1.1.1",
94
94
  "storybook": "^8.2.2",
95
95
  "@transferwise/less-config": "3.1.0",
96
- "@transferwise/neptune-css": "14.20.0",
97
- "@wise/components-theming": "1.6.1"
96
+ "@wise/components-theming": "1.6.1",
97
+ "@transferwise/neptune-css": "14.20.0"
98
98
  },
99
99
  "peerDependencies": {
100
100
  "@transferwise/icons": "^3.13.1",
@@ -43,6 +43,9 @@ const backwardsCompatibleSize = (size: AvatarSize): NumericAvatarSize => {
43
43
  }
44
44
  };
45
45
 
46
+ /**
47
+ * @deprecated Use `AvatarView` component instead
48
+ */
46
49
  const Avatar: React.FC<AvatarProps> = ({
47
50
  backgroundColor = null,
48
51
  backgroundColorSeed = null,
@@ -0,0 +1,36 @@
1
+ .np-notification-dot {
2
+ --np-notification-dot-size: 14px;
3
+ position: relative;
4
+ display: inline-block;
5
+ }
6
+ .np-notification-dot-mask {
7
+ -webkit-mask-image: radial-gradient(circle at bottom calc(100% - (var(--np-notification-dot-size) / 2)) left calc(100% - (var(--np-notification-dot-size) / 2)), transparent 0, transparent calc(var(--np-notification-dot-size) / 2 + var(--np-notification-dot-offset)), black 0);
8
+ mask-image: radial-gradient(circle at bottom calc(100% - (var(--np-notification-dot-size) / 2)) left calc(100% - (var(--np-notification-dot-size) / 2)), transparent 0, transparent calc(var(--np-notification-dot-size) / 2 + var(--np-notification-dot-offset)), black 0);
9
+ -webkit-mask-image: radial-gradient(circle at bottom calc(100% - calc(var(--np-notification-dot-size) / 2)) left calc(100% - calc(var(--np-notification-dot-size) / 2)), transparent 0, transparent calc(var(--np-notification-dot-size) / 2 + var(--np-notification-dot-offset)), black 0);
10
+ mask-image: radial-gradient(circle at bottom calc(100% - calc(var(--np-notification-dot-size) / 2)) left calc(100% - calc(var(--np-notification-dot-size) / 2)), transparent 0, transparent calc(var(--np-notification-dot-size) / 2 + var(--np-notification-dot-offset)), black 0);
11
+ }
12
+ .np-notification-dot-badge {
13
+ position: absolute;
14
+ width: var(--np-notification-dot-size);
15
+ height: var(--np-notification-dot-size);
16
+ background-color: var(--color-sentiment-negative);
17
+ border-radius: 9999px;
18
+ border-radius: var(--radius-full);
19
+ right: 0;
20
+ }
21
+ .np-avatar-view .np-avatar-view-content {
22
+ color: var(--color-interactive-primary);
23
+ }
24
+ .np-avatar-view-interactive {
25
+ cursor: pointer;
26
+ }
27
+ .np-avatar-view-interactive .np-circle {
28
+ background-color: rgba(134,167,189,0.10196);
29
+ background-color: var(--color-background-neutral);
30
+ }
31
+ .np-avatar-view-non-interactive .np-circle {
32
+ background-color: transparent;
33
+ }
34
+ .np-avatar-view-non-interactive .np-avatar-view-content .wds-flag {
35
+ box-shadow: none;
36
+ }
@@ -0,0 +1,27 @@
1
+ @import './NotificationDot.less';
2
+
3
+ .np-avatar-view {
4
+ .np-avatar-view-content {
5
+ color: var(--color-interactive-primary);
6
+ }
7
+
8
+ &-interactive {
9
+ cursor: pointer;
10
+ .np-circle {
11
+ background-color: var(--color-background-neutral);
12
+ }
13
+ }
14
+
15
+ &-non-interactive {
16
+ .np-circle {
17
+ background-color: transparent;
18
+ }
19
+ .np-avatar-view-content {
20
+ // dismiss broken shadow on Flag component (DS-6309)
21
+ // https://github.com/transferwise/web-art/blob/main/src/flags/Flag.css#L2
22
+ .wds-flag {
23
+ box-shadow: none;
24
+ }
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,467 @@
1
+ /* eslint-disable react/jsx-key */
2
+ import { Meta, StoryObj } from '@storybook/react';
3
+ import {
4
+ Camera,
5
+ Convert,
6
+ FastFlag,
7
+ Freeze,
8
+ Graph,
9
+ Money,
10
+ Leaf,
11
+ Plane,
12
+ PlusCircle,
13
+ QrCode,
14
+ Rewards,
15
+ Target,
16
+ Team,
17
+ Transport,
18
+ Wallet,
19
+ Water,
20
+ } from '@transferwise/icons';
21
+ import AvatarView, { AvatarViewProps } from '.';
22
+ import { Flag } from '@wise/art';
23
+ import { getBrandColorFromSeed, getInitials, ProfileType } from '../common';
24
+ import Display from '../display';
25
+ import Body from '../body';
26
+
27
+ export default {
28
+ title: 'Content/AvatarView',
29
+ } satisfies Meta<typeof AvatarView>;
30
+
31
+ type Story = StoryObj<typeof AvatarView>;
32
+
33
+ const profileName1 = 'Wolter White';
34
+ const profileName2 = 'Tyler Durden';
35
+ const sizes: AvatarViewProps['size'][] = [16, 24, 32, 40, 48, 56, 72];
36
+
37
+ export const Selected: Story = {
38
+ tags: ['autodocs'],
39
+ render: () => {
40
+ return (
41
+ <div
42
+ style={{
43
+ gap: '1em',
44
+ display: 'grid',
45
+ justifyContent: 'space-between',
46
+ gridTemplate: `auto auto / repeat(${sizes.length}, min-content)`,
47
+ }}
48
+ >
49
+ {sizes.map((size) => (
50
+ <Body type="body-large-bold">{size}</Body>
51
+ ))}
52
+ {sizes.map((size) => (
53
+ <AvatarView key={size} size={size} selected interactive>
54
+ <Freeze />
55
+ </AvatarView>
56
+ ))}
57
+ {sizes.map((size) => (
58
+ <AvatarView
59
+ key={size}
60
+ size={size}
61
+ imgSrc="../avatar-square-dude.webp"
62
+ selected
63
+ interactive
64
+ />
65
+ ))}
66
+ </div>
67
+ );
68
+ },
69
+ };
70
+
71
+ export const Notification: Story = {
72
+ tags: ['autodocs'],
73
+ render: () => (
74
+ <div
75
+ style={{
76
+ gap: '1em',
77
+ display: 'grid',
78
+ justifyContent: 'space-between',
79
+ gridTemplate: `auto auto / repeat(${sizes.length}, min-content)`,
80
+ }}
81
+ >
82
+ {sizes.map((size) => (
83
+ <Body type="body-large-bold">{size}</Body>
84
+ ))}
85
+ {sizes.map((size) => (
86
+ <AvatarView key={size} size={size} notification>
87
+ <Freeze />
88
+ </AvatarView>
89
+ ))}
90
+ {sizes.map((size) => (
91
+ <AvatarView key={size} size={size} notification interactive>
92
+ <Freeze />
93
+ </AvatarView>
94
+ ))}
95
+ {sizes.map((size) => (
96
+ <AvatarView
97
+ key={size}
98
+ size={size}
99
+ imgSrc="../avatar-rectangle-fox.webp"
100
+ notification
101
+ interactive
102
+ />
103
+ ))}
104
+ </div>
105
+ ),
106
+ };
107
+
108
+ export const Badge: Story = {
109
+ tags: ['autodocs'],
110
+ render: () => {
111
+ const currencies = ['USD', 'EUR', 'GBP', 'AUD', 'CAD', 'JPY', 'CNY'];
112
+ const icons = [
113
+ <Plane />,
114
+ <QrCode />,
115
+ <Target />,
116
+ <Transport />,
117
+ <Wallet />,
118
+ <Water />,
119
+ <Team />,
120
+ ];
121
+ return (
122
+ <div
123
+ style={{
124
+ gap: '1em',
125
+ display: 'grid',
126
+ justifyContent: 'space-between',
127
+ gridTemplate: 'auto auto / repeat(7, min-content)',
128
+ }}
129
+ >
130
+ {sizes.map((size) => (
131
+ <Body type="body-large-bold">{size}</Body>
132
+ ))}
133
+ {sizes.map((size, index) => (
134
+ <AvatarView key={size} size={size} badge={{ flagCode: currencies[index] }}>
135
+ {icons[index]}
136
+ </AvatarView>
137
+ ))}
138
+
139
+ {sizes.map((size) => (
140
+ <AvatarView
141
+ key={size}
142
+ size={size}
143
+ imgSrc="../avatar-rectangle-fox.webp"
144
+ badge={{ imgSrc: '../tapestry-01.png' }}
145
+ />
146
+ ))}
147
+
148
+ {sizes.map((size) => (
149
+ <AvatarView
150
+ key={size}
151
+ size={size}
152
+ imgSrc="../avatar-square-dude.webp"
153
+ badge={{ imgSrc: '../tapestry-01.png' }}
154
+ />
155
+ ))}
156
+
157
+ {sizes.map((size, index) => (
158
+ <AvatarView key={size} size={size} badge={{ imgSrc: '../tapestry-01.png' }}>
159
+ {icons[index]}
160
+ </AvatarView>
161
+ ))}
162
+
163
+ {sizes.map((size, index) => (
164
+ <AvatarView key={size} size={size} badge={{ status: 'warning' }}>
165
+ {icons[index]}
166
+ </AvatarView>
167
+ ))}
168
+
169
+ {sizes.map((size, index) => (
170
+ <AvatarView key={size} size={size} badge={{ status: 'neutral' }}>
171
+ {icons[index]}
172
+ </AvatarView>
173
+ ))}
174
+
175
+ {sizes.map((size, index) => (
176
+ <AvatarView key={size} size={size} badge={{ status: 'negative' }}>
177
+ {icons[index]}
178
+ </AvatarView>
179
+ ))}
180
+
181
+ {sizes.map((size, index) => (
182
+ <AvatarView key={size} size={size} badge={{ icon: <FastFlag /> }}>
183
+ {icons[index]}
184
+ </AvatarView>
185
+ ))}
186
+
187
+ {sizes.map((size, index) => (
188
+ <AvatarView key={size} size={size} badge={{ type: 'reference' }}>
189
+ {icons[index]}
190
+ </AvatarView>
191
+ ))}
192
+
193
+ {sizes.map((size, index) => (
194
+ <AvatarView key={size} size={size} badge={{ type: 'action' }}>
195
+ {icons[index]}
196
+ </AvatarView>
197
+ ))}
198
+
199
+ {sizes.map((size) => (
200
+ <AvatarView
201
+ key={size}
202
+ size={size}
203
+ imgSrc="../avatar-square-dude.webp"
204
+ badge={{ type: 'action', icon: <Camera /> }}
205
+ />
206
+ ))}
207
+
208
+ {sizes.map((size) => (
209
+ <AvatarView
210
+ key={size}
211
+ size={size}
212
+ imgSrc="../avatar-square-dude.webp"
213
+ badge={{ type: 'reference', icon: <Convert /> }}
214
+ />
215
+ ))}
216
+
217
+ {sizes.map((size) => (
218
+ <AvatarView
219
+ key={size}
220
+ size={size}
221
+ imgSrc="../avatar-square-dude.webp"
222
+ badge={{ icon: <Convert /> }}
223
+ />
224
+ ))}
225
+ {sizes.map((size) => (
226
+ <AvatarView
227
+ key={size}
228
+ size={size}
229
+ imgSrc="../avatar-square-dude.webp"
230
+ badge={{
231
+ asset: (
232
+ <div
233
+ className="d-flex align-items-center justify-content-center"
234
+ style={{
235
+ backgroundColor: 'var(--color-bright-pink)',
236
+ color: 'var(--color-interactive-primary)',
237
+ width: '100%',
238
+ height: '100%',
239
+ }}
240
+ >
241
+ <Leaf />
242
+ </div>
243
+ ),
244
+ }}
245
+ />
246
+ ))}
247
+ </div>
248
+ );
249
+ },
250
+ };
251
+
252
+ export const Images: Story = {
253
+ tags: ['autodocs'],
254
+ render: () => {
255
+ return (
256
+ <div
257
+ style={{
258
+ gap: '1em',
259
+ display: 'grid',
260
+ justifyContent: 'space-between',
261
+ gridTemplate: 'auto auto / repeat(7, min-content)',
262
+ }}
263
+ >
264
+ {sizes.map((size) => (
265
+ <Body type="body-large-bold">{size}</Body>
266
+ ))}
267
+ {sizes.map((size) => (
268
+ <AvatarView
269
+ key={size}
270
+ size={size}
271
+ interactive
272
+ imgSrc="../avatar-square-dude.webp"
273
+ profileName="Test Name"
274
+ profileType={ProfileType.BUSINESS}
275
+ />
276
+ ))}
277
+ {sizes.map((size) => (
278
+ <AvatarView
279
+ key={size}
280
+ size={size}
281
+ imgSrc="../avatar-square-dude.webp"
282
+ profileName="Test Name"
283
+ profileType={ProfileType.BUSINESS}
284
+ />
285
+ ))}
286
+ {sizes.map((size) => (
287
+ <AvatarView key={size} size={size} interactive>
288
+ <Flag code="JPY" intrinsicSize={size} />
289
+ </AvatarView>
290
+ ))}
291
+ {sizes.map((size) => (
292
+ <AvatarView key={size} size={size}>
293
+ <Flag code="JPY" intrinsicSize={size} />
294
+ </AvatarView>
295
+ ))}
296
+ {sizes.map((size) => (
297
+ <AvatarView key={size} interactive imgSrc="../avatar-rectangle-fox.webp" size={size} />
298
+ ))}
299
+ {sizes.map((size) => (
300
+ <AvatarView key={size} size={size} imgSrc="../avatar-rectangle-fox.webp" />
301
+ ))}
302
+ </div>
303
+ );
304
+ },
305
+ };
306
+
307
+ export const Profiles: Story = {
308
+ tags: ['autodocs'],
309
+ render: () => {
310
+ return (
311
+ <div
312
+ style={{
313
+ gap: '1em',
314
+ display: 'grid',
315
+ justifyContent: 'space-between',
316
+ gridTemplate: 'auto auto / repeat(7, min-content)',
317
+ }}
318
+ >
319
+ {sizes.map((size) => (
320
+ <Body type="body-large-bold">{size}</Body>
321
+ ))}
322
+ {sizes.map((size) => (
323
+ <AvatarView
324
+ key={size}
325
+ size={size}
326
+ imgSrc="../avatar-square-dude.webp"
327
+ profileName="Test Name"
328
+ profileType={ProfileType.BUSINESS}
329
+ />
330
+ ))}
331
+
332
+ {sizes.map((size) => (
333
+ <AvatarView
334
+ key={size}
335
+ size={size}
336
+ interactive
337
+ imgSrc="../avatar-square-dude.webp"
338
+ profileName="Test Name"
339
+ profileType={ProfileType.BUSINESS}
340
+ />
341
+ ))}
342
+
343
+ {sizes.map((size) => (
344
+ <AvatarView key={size} size={size} profileName="Test Name" />
345
+ ))}
346
+
347
+ {sizes.map((size) => (
348
+ <AvatarView key={size} size={size} interactive profileName="Test Name" />
349
+ ))}
350
+
351
+ {sizes.map((size) => (
352
+ <AvatarView key={size} size={size} profileType={ProfileType.BUSINESS} />
353
+ ))}
354
+
355
+ {sizes.map((size) => (
356
+ <AvatarView key={size} size={size} interactive profileType={ProfileType.BUSINESS} />
357
+ ))}
358
+
359
+ {sizes.map((size) => (
360
+ <AvatarView key={size} size={size} />
361
+ ))}
362
+
363
+ {sizes.map((size) => (
364
+ <AvatarView key={size} size={size} interactive />
365
+ ))}
366
+ </div>
367
+ );
368
+ },
369
+ };
370
+
371
+ export const ProfileBrokenImageFallback: Story = {
372
+ parameters: {
373
+ chromatic: {
374
+ delay: 5000,
375
+ },
376
+ },
377
+ render: () => {
378
+ const assetUrl = 'https://test.com/img-wrong-url.test';
379
+ return (
380
+ <>
381
+ <AvatarView />
382
+ <AvatarView imgSrc={assetUrl} />
383
+ <AvatarView imgSrc={assetUrl} profileType={ProfileType.BUSINESS} />
384
+ <AvatarView imgSrc={assetUrl} profileType={ProfileType.BUSINESS} profileName="Test Name" />
385
+ </>
386
+ );
387
+ },
388
+ };
389
+
390
+ export const EdgeInstaces: Story = {
391
+ tags: ['autodocs'],
392
+ render: () => {
393
+ const css = `.custom-variant {
394
+ border: 1px dashed var(--color-border-neutral);
395
+ }`;
396
+ return (
397
+ <div
398
+ style={{
399
+ gap: '1em',
400
+ display: 'grid',
401
+ justifyContent: 'space-between',
402
+ gridTemplate: 'auto auto / repeat(2, min-content)',
403
+ }}
404
+ >
405
+ <style>{css}</style>
406
+ <AvatarView
407
+ interactive
408
+ badge={{ flagCode: 'EU' }}
409
+ style={{ backgroundColor: 'var(--color-bright-orange)' }}
410
+ >
411
+ <Money />
412
+ </AvatarView>
413
+ <AvatarView
414
+ badge={{ flagCode: 'EU' }}
415
+ style={{ backgroundColor: 'var(--color-bright-orange)', border: 'none' }}
416
+ >
417
+ <Money />
418
+ </AvatarView>
419
+ <AvatarView interactive className="custom-variant">
420
+ <PlusCircle />
421
+ </AvatarView>
422
+ <AvatarView interactive className="custom-variant">
423
+ {null}
424
+ </AvatarView>
425
+ <AvatarView style={{ color: 'rgb(22, 51, 0)', backgroundColor: 'rgb(203, 217, 195)' }}>
426
+ <Graph />
427
+ </AvatarView>
428
+ <AvatarView
429
+ interactive
430
+ style={{ color: 'rgb(22, 51, 0)', backgroundColor: 'rgb(203, 217, 195)' }}
431
+ >
432
+ <Graph />
433
+ </AvatarView>
434
+ <AvatarView style={{ color: 'rgb(203, 217, 195)', backgroundColor: 'rgb(22, 51, 0)' }}>
435
+ <Rewards />
436
+ </AvatarView>
437
+ <AvatarView
438
+ interactive
439
+ style={{ color: 'rgb(203, 217, 195)', backgroundColor: 'rgb(22, 51, 0)' }}
440
+ >
441
+ <Rewards />
442
+ </AvatarView>
443
+ <AvatarView
444
+ badge={{ flagCode: 'EU' }}
445
+ style={{ backgroundColor: getBrandColorFromSeed(profileName1) }}
446
+ >
447
+ <Display>{getInitials(profileName1)}</Display>
448
+ </AvatarView>
449
+ <AvatarView style={{ backgroundColor: getBrandColorFromSeed(profileName1) }}>
450
+ <Display>{getInitials(profileName1)}</Display>
451
+ </AvatarView>
452
+ <AvatarView interactive style={{ backgroundColor: getBrandColorFromSeed(profileName2) }}>
453
+ <Display>{getInitials(profileName1)}</Display>
454
+ </AvatarView>
455
+ <AvatarView
456
+ interactive
457
+ badge={{ flagCode: 'EU' }}
458
+ style={{ backgroundColor: getBrandColorFromSeed(profileName2) }}
459
+ >
460
+ <Display>{getInitials(profileName1)}</Display>
461
+ </AvatarView>
462
+ <AvatarView>9+</AvatarView>
463
+ <AvatarView interactive>5+</AvatarView>
464
+ </div>
465
+ );
466
+ },
467
+ };