@transferwise/components 46.166.0 → 46.168.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 (246) hide show
  1. package/README.md +1 -1
  2. package/build/CardContainer/CardContainer.js +34 -0
  3. package/build/CardContainer/CardContainer.js.map +1 -0
  4. package/build/CardContainer/CardContainer.mjs +30 -0
  5. package/build/CardContainer/CardContainer.mjs.map +1 -0
  6. package/build/CardWidget/CardWidget.js +98 -0
  7. package/build/CardWidget/CardWidget.js.map +1 -0
  8. package/build/CardWidget/CardWidget.mjs +94 -0
  9. package/build/CardWidget/CardWidget.mjs.map +1 -0
  10. package/build/CardWidget/CardWidgetAction.js +73 -0
  11. package/build/CardWidget/CardWidgetAction.js.map +1 -0
  12. package/build/CardWidget/CardWidgetAction.mjs +68 -0
  13. package/build/CardWidget/CardWidgetAction.mjs.map +1 -0
  14. package/build/Link/Link.js.map +1 -1
  15. package/build/Link/Link.mjs.map +1 -1
  16. package/build/ListItem/ListItem.js +2 -0
  17. package/build/ListItem/ListItem.js.map +1 -1
  18. package/build/ListItem/ListItem.mjs +2 -0
  19. package/build/ListItem/ListItem.mjs.map +1 -1
  20. package/build/Loader/Loader.js.map +1 -1
  21. package/build/Loader/Loader.mjs.map +1 -1
  22. package/build/Prompt/PrimitivePrompt/PrimitivePrompt.js +2 -1
  23. package/build/Prompt/PrimitivePrompt/PrimitivePrompt.js.map +1 -1
  24. package/build/Prompt/PrimitivePrompt/PrimitivePrompt.mjs +2 -1
  25. package/build/Prompt/PrimitivePrompt/PrimitivePrompt.mjs.map +1 -1
  26. package/build/Prompt/Snackbar/Snackbar.js +205 -0
  27. package/build/Prompt/Snackbar/Snackbar.js.map +1 -0
  28. package/build/Prompt/Snackbar/Snackbar.messages.js +14 -0
  29. package/build/Prompt/Snackbar/Snackbar.messages.js.map +1 -0
  30. package/build/Prompt/Snackbar/Snackbar.messages.mjs +10 -0
  31. package/build/Prompt/Snackbar/Snackbar.messages.mjs.map +1 -0
  32. package/build/Prompt/Snackbar/Snackbar.mjs +203 -0
  33. package/build/Prompt/Snackbar/Snackbar.mjs.map +1 -0
  34. package/build/Prompt/Snackbar/SnackbarContext.js.map +1 -0
  35. package/build/Prompt/Snackbar/SnackbarContext.mjs.map +1 -0
  36. package/build/Prompt/Snackbar/SnackbarPortal.js +12 -0
  37. package/build/Prompt/Snackbar/SnackbarPortal.js.map +1 -0
  38. package/build/Prompt/Snackbar/SnackbarPortal.mjs +8 -0
  39. package/build/Prompt/Snackbar/SnackbarPortal.mjs.map +1 -0
  40. package/build/Prompt/Snackbar/SnackbarProvider.js +42 -0
  41. package/build/Prompt/Snackbar/SnackbarProvider.js.map +1 -0
  42. package/build/Prompt/Snackbar/SnackbarProvider.mjs +38 -0
  43. package/build/Prompt/Snackbar/SnackbarProvider.mjs.map +1 -0
  44. package/build/Prompt/Snackbar/constants.js +17 -0
  45. package/build/Prompt/Snackbar/constants.js.map +1 -0
  46. package/build/Prompt/Snackbar/constants.mjs +11 -0
  47. package/build/Prompt/Snackbar/constants.mjs.map +1 -0
  48. package/build/Prompt/Snackbar/useSnackbar.js.map +1 -0
  49. package/build/Prompt/Snackbar/useSnackbar.mjs.map +1 -0
  50. package/build/Prompt/Snackbar/useSnackbarAutoDismiss.js +66 -0
  51. package/build/Prompt/Snackbar/useSnackbarAutoDismiss.js.map +1 -0
  52. package/build/Prompt/Snackbar/useSnackbarAutoDismiss.mjs +62 -0
  53. package/build/Prompt/Snackbar/useSnackbarAutoDismiss.mjs.map +1 -0
  54. package/build/Prompt/Snackbar/useSnackbarManager.js +153 -0
  55. package/build/Prompt/Snackbar/useSnackbarManager.js.map +1 -0
  56. package/build/Prompt/Snackbar/useSnackbarManager.mjs +149 -0
  57. package/build/Prompt/Snackbar/useSnackbarManager.mjs.map +1 -0
  58. package/build/Prompt/Snackbar/useSnackbarSwipeDismiss.js +135 -0
  59. package/build/Prompt/Snackbar/useSnackbarSwipeDismiss.js.map +1 -0
  60. package/build/Prompt/Snackbar/useSnackbarSwipeDismiss.mjs +131 -0
  61. package/build/Prompt/Snackbar/useSnackbarSwipeDismiss.mjs.map +1 -0
  62. package/build/Section/Section.js.map +1 -1
  63. package/build/Section/Section.mjs.map +1 -1
  64. package/build/_deprecated/Select/Select.js +1 -1
  65. package/build/_deprecated/Select/Select.js.map +1 -1
  66. package/build/_deprecated/Select/Select.mjs +1 -1
  67. package/build/_deprecated/Select/Select.mjs.map +1 -1
  68. package/build/common/BottomSheet/BottomSheet.js +1 -3
  69. package/build/common/BottomSheet/BottomSheet.js.map +1 -1
  70. package/build/common/BottomSheet/BottomSheet.mjs +1 -3
  71. package/build/common/BottomSheet/BottomSheet.mjs.map +1 -1
  72. package/build/i18n/en.json +1 -0
  73. package/build/i18n/en.json.js +1 -0
  74. package/build/i18n/en.json.js.map +1 -1
  75. package/build/i18n/en.json.mjs +1 -0
  76. package/build/i18n/en.json.mjs.map +1 -1
  77. package/build/index.js +7 -3
  78. package/build/index.js.map +1 -1
  79. package/build/index.mjs +5 -3
  80. package/build/index.mjs.map +1 -1
  81. package/build/main.css +331 -75
  82. package/build/styles/CardContainer/CardContainer.css +108 -0
  83. package/build/styles/CardWidget/CardWidget.css +78 -0
  84. package/build/styles/IconButton/IconButton.css +3 -4
  85. package/build/styles/ListItem/ListItem.css +8 -0
  86. package/build/styles/Prompt/Snackbar/Snackbar.css +134 -0
  87. package/build/styles/main.css +331 -75
  88. package/build/types/Body/Body.d.ts +2 -2
  89. package/build/types/CardContainer/CardContainer.d.ts +8 -0
  90. package/build/types/CardContainer/CardContainer.d.ts.map +1 -0
  91. package/build/types/CardContainer/CardContainer.types.d.ts +55 -0
  92. package/build/types/CardContainer/CardContainer.types.d.ts.map +1 -0
  93. package/build/types/CardContainer/_stories/helpers.d.ts +3 -0
  94. package/build/types/CardContainer/_stories/helpers.d.ts.map +1 -0
  95. package/build/types/CardContainer/index.d.ts +3 -0
  96. package/build/types/CardContainer/index.d.ts.map +1 -0
  97. package/build/types/CardWidget/CardWidget.d.ts +10 -0
  98. package/build/types/CardWidget/CardWidget.d.ts.map +1 -0
  99. package/build/types/CardWidget/CardWidget.types.d.ts +55 -0
  100. package/build/types/CardWidget/CardWidget.types.d.ts.map +1 -0
  101. package/build/types/CardWidget/CardWidgetAction.d.ts +54 -0
  102. package/build/types/CardWidget/CardWidgetAction.d.ts.map +1 -0
  103. package/build/types/CardWidget/index.d.ts +4 -0
  104. package/build/types/CardWidget/index.d.ts.map +1 -0
  105. package/build/types/IconButton/IconButton.d.ts +1 -1
  106. package/build/types/Link/Link.d.ts +1 -1
  107. package/build/types/ListItem/ListItem.d.ts +1 -1
  108. package/build/types/ListItem/ListItem.d.ts.map +1 -1
  109. package/build/types/Loader/Loader.d.ts +1 -1
  110. package/build/types/MoneyInput/MoneyInput.d.ts +1 -1
  111. package/build/types/MoneyInput/MoneyInput.d.ts.map +1 -1
  112. package/build/types/Prompt/PrimitivePrompt/PrimitivePrompt.d.ts +11 -0
  113. package/build/types/Prompt/PrimitivePrompt/PrimitivePrompt.d.ts.map +1 -1
  114. package/build/types/Prompt/Snackbar/Snackbar.d.ts +62 -0
  115. package/build/types/Prompt/Snackbar/Snackbar.d.ts.map +1 -0
  116. package/build/types/Prompt/Snackbar/Snackbar.messages.d.ts +9 -0
  117. package/build/types/Prompt/Snackbar/Snackbar.messages.d.ts.map +1 -0
  118. package/build/types/Prompt/Snackbar/Snackbar.types.d.ts +12 -0
  119. package/build/types/Prompt/Snackbar/Snackbar.types.d.ts.map +1 -0
  120. package/build/types/{Snackbar → Prompt/Snackbar}/SnackbarContext.d.ts +2 -2
  121. package/build/types/Prompt/Snackbar/SnackbarContext.d.ts.map +1 -0
  122. package/build/types/Prompt/Snackbar/SnackbarPortal.d.ts +4 -0
  123. package/build/types/Prompt/Snackbar/SnackbarPortal.d.ts.map +1 -0
  124. package/build/types/Prompt/Snackbar/SnackbarProvider.d.ts +13 -0
  125. package/build/types/Prompt/Snackbar/SnackbarProvider.d.ts.map +1 -0
  126. package/build/types/Prompt/Snackbar/constants.d.ts +9 -0
  127. package/build/types/Prompt/Snackbar/constants.d.ts.map +1 -0
  128. package/build/types/{Snackbar → Prompt/Snackbar}/index.d.ts +1 -1
  129. package/build/types/Prompt/Snackbar/index.d.ts.map +1 -0
  130. package/build/types/Prompt/Snackbar/useSnackbar.d.ts +3 -0
  131. package/build/types/Prompt/Snackbar/useSnackbar.d.ts.map +1 -0
  132. package/build/types/Prompt/Snackbar/useSnackbarAutoDismiss.d.ts +13 -0
  133. package/build/types/Prompt/Snackbar/useSnackbarAutoDismiss.d.ts.map +1 -0
  134. package/build/types/Prompt/Snackbar/useSnackbarManager.d.ts +20 -0
  135. package/build/types/Prompt/Snackbar/useSnackbarManager.d.ts.map +1 -0
  136. package/build/types/Prompt/Snackbar/useSnackbarSwipeDismiss.d.ts +22 -0
  137. package/build/types/Prompt/Snackbar/useSnackbarSwipeDismiss.d.ts.map +1 -0
  138. package/build/types/Section/Section.d.ts +1 -1
  139. package/build/types/Title/Title.d.ts +2 -2
  140. package/build/types/Upload/Steps/UploadImageStep/UploadImageStep.d.ts +1 -1
  141. package/build/types/UploadInput/UploadItem/UploadItemLink.d.ts +1 -1
  142. package/build/types/_deprecated/Select/Select.d.ts +1 -1
  143. package/build/types/common/BottomSheet/BottomSheet.d.ts +1 -3
  144. package/build/types/common/BottomSheet/BottomSheet.d.ts.map +1 -1
  145. package/build/types/index.d.ts +9 -5
  146. package/build/types/index.d.ts.map +1 -1
  147. package/build/types/test-utils/index.d.ts +2 -0
  148. package/build/types/test-utils/index.d.ts.map +1 -1
  149. package/package.json +4 -4
  150. package/src/CardContainer/CardContainer.css +108 -0
  151. package/src/CardContainer/CardContainer.less +171 -0
  152. package/src/CardContainer/CardContainer.test.tsx +150 -0
  153. package/src/CardContainer/CardContainer.tsx +51 -0
  154. package/src/CardContainer/CardContainer.types.ts +62 -0
  155. package/src/CardContainer/_stories/CardContainer.story.tsx +167 -0
  156. package/src/CardContainer/_stories/CardContainer.test.story.tsx +103 -0
  157. package/src/CardContainer/_stories/helpers.tsx +50 -0
  158. package/src/CardContainer/index.ts +6 -0
  159. package/src/CardWidget/CardWidget.css +78 -0
  160. package/src/CardWidget/CardWidget.less +107 -0
  161. package/src/CardWidget/CardWidget.test.tsx +221 -0
  162. package/src/CardWidget/CardWidget.tsx +78 -0
  163. package/src/CardWidget/CardWidget.types.ts +63 -0
  164. package/src/CardWidget/CardWidgetAction.tsx +128 -0
  165. package/src/CardWidget/_stories/CardWidget.story.tsx +238 -0
  166. package/src/CardWidget/_stories/CardWidget.test.story.tsx +350 -0
  167. package/src/CardWidget/index.ts +3 -0
  168. package/src/IconButton/IconButton.css +3 -4
  169. package/src/IconButton/IconButton.less +14 -1
  170. package/src/Link/Link.tsx +1 -1
  171. package/src/ListItem/AdditionalInfo/_stories/ListItemAdditionalInfo.story.tsx +1 -1
  172. package/src/ListItem/AvatarView/_stories/ListItemAvatarView.story.tsx +3 -3
  173. package/src/ListItem/ListItem.css +8 -0
  174. package/src/ListItem/ListItem.less +8 -0
  175. package/src/ListItem/ListItem.test.tsx +20 -0
  176. package/src/ListItem/ListItem.tsx +3 -1
  177. package/src/ListItem/_stories/ListItem.disabled.story.tsx +1 -1
  178. package/src/ListItem/_stories/ListItem.layout.test.story.tsx +1 -1
  179. package/src/ListItem/_stories/ListItem.scenarios.story.tsx +2 -2
  180. package/src/ListItem/_stories/ListItem.story.tsx +1 -1
  181. package/src/Loader/Loader.tsx +1 -1
  182. package/src/Prompt/CriticalBanner/_stories/CriticalBanner.docs.mdx +122 -0
  183. package/src/Prompt/CriticalBanner/_stories/CriticalBanner.story.tsx +0 -2
  184. package/src/Prompt/PrimitivePrompt/PrimitivePrompt.test.tsx +24 -1
  185. package/src/Prompt/PrimitivePrompt/PrimitivePrompt.tsx +8 -2
  186. package/src/Prompt/Snackbar/Snackbar.css +134 -0
  187. package/src/Prompt/Snackbar/Snackbar.less +159 -0
  188. package/src/Prompt/Snackbar/Snackbar.messages.ts +9 -0
  189. package/src/Prompt/Snackbar/Snackbar.test.tsx +1079 -0
  190. package/src/Prompt/Snackbar/Snackbar.tsx +245 -0
  191. package/src/Prompt/Snackbar/Snackbar.types.ts +17 -0
  192. package/src/{Snackbar → Prompt/Snackbar}/SnackbarContext.ts +2 -2
  193. package/src/Prompt/Snackbar/SnackbarPortal.tsx +8 -0
  194. package/src/Prompt/Snackbar/SnackbarProvider.test.tsx +783 -0
  195. package/src/Prompt/Snackbar/SnackbarProvider.tsx +41 -0
  196. package/src/Prompt/Snackbar/_stories/Snackbar.accessibility.docs.mdx +58 -0
  197. package/src/{Snackbar → Prompt/Snackbar}/_stories/Snackbar.rtl.test.story.tsx +17 -9
  198. package/src/Prompt/Snackbar/_stories/Snackbar.story.tsx +416 -0
  199. package/src/Prompt/Snackbar/_stories/Snackbar.test.story.tsx +263 -0
  200. package/src/Prompt/Snackbar/constants.ts +10 -0
  201. package/src/{Snackbar → Prompt/Snackbar}/index.ts +1 -1
  202. package/src/Prompt/Snackbar/useSnackbarAutoDismiss.ts +74 -0
  203. package/src/Prompt/Snackbar/useSnackbarManager.ts +169 -0
  204. package/src/Prompt/Snackbar/useSnackbarSwipeDismiss.ts +169 -0
  205. package/src/Section/Section.tsx +1 -1
  206. package/src/_deprecated/Select/Select.tsx +1 -1
  207. package/src/_deprecated/Select/_stories/Select.story.tsx +1 -1
  208. package/src/common/BottomSheet/BottomSheet.tsx +1 -3
  209. package/src/i18n/en.json +1 -0
  210. package/src/index.ts +18 -5
  211. package/src/main.css +331 -75
  212. package/src/main.less +3 -1
  213. package/build/Snackbar/Snackbar.js +0 -128
  214. package/build/Snackbar/Snackbar.js.map +0 -1
  215. package/build/Snackbar/Snackbar.mjs +0 -123
  216. package/build/Snackbar/Snackbar.mjs.map +0 -1
  217. package/build/Snackbar/SnackbarContext.js.map +0 -1
  218. package/build/Snackbar/SnackbarContext.mjs.map +0 -1
  219. package/build/Snackbar/SnackbarProvider.js +0 -46
  220. package/build/Snackbar/SnackbarProvider.js.map +0 -1
  221. package/build/Snackbar/SnackbarProvider.mjs +0 -42
  222. package/build/Snackbar/SnackbarProvider.mjs.map +0 -1
  223. package/build/Snackbar/useSnackbar.js.map +0 -1
  224. package/build/Snackbar/useSnackbar.mjs.map +0 -1
  225. package/build/styles/Snackbar/Snackbar.css +0 -71
  226. package/build/types/Snackbar/Snackbar.d.ts +0 -16
  227. package/build/types/Snackbar/Snackbar.d.ts.map +0 -1
  228. package/build/types/Snackbar/SnackbarContext.d.ts.map +0 -1
  229. package/build/types/Snackbar/SnackbarProvider.d.ts +0 -6
  230. package/build/types/Snackbar/SnackbarProvider.d.ts.map +0 -1
  231. package/build/types/Snackbar/index.d.ts.map +0 -1
  232. package/build/types/Snackbar/useSnackbar.d.ts +0 -3
  233. package/build/types/Snackbar/useSnackbar.d.ts.map +0 -1
  234. package/src/FlowNavigation/_stories/FlowNavigation.CriticalBanner.docs.mdx +0 -66
  235. package/src/Snackbar/Snackbar.css +0 -71
  236. package/src/Snackbar/Snackbar.less +0 -80
  237. package/src/Snackbar/Snackbar.test.tsx +0 -206
  238. package/src/Snackbar/Snackbar.tsx +0 -129
  239. package/src/Snackbar/SnackbarProvider.tsx +0 -33
  240. package/src/Snackbar/_stories/Snackbar.story.tsx +0 -89
  241. package/src/Snackbar/_stories/Snackbar.test.story.tsx +0 -139
  242. /package/build/{Snackbar → Prompt/Snackbar}/SnackbarContext.js +0 -0
  243. /package/build/{Snackbar → Prompt/Snackbar}/SnackbarContext.mjs +0 -0
  244. /package/build/{Snackbar → Prompt/Snackbar}/useSnackbar.js +0 -0
  245. /package/build/{Snackbar → Prompt/Snackbar}/useSnackbar.mjs +0 -0
  246. /package/src/{Snackbar → Prompt/Snackbar}/useSnackbar.ts +0 -0
@@ -0,0 +1,238 @@
1
+ import { Plus, Settings } from '@transferwise/icons';
2
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
3
+
4
+ import {
5
+ createSandboxStory,
6
+ globalScope,
7
+ } from '../../../.storybook/components/sandbox/SandboxEditor';
8
+ import Body from '../../Body';
9
+ import type { CardContainerSpotlight } from '../../CardContainer';
10
+ import { CardsList, SampleContent } from '../../CardContainer/_stories/helpers';
11
+ import { Typography } from '../../common';
12
+ import CardWidget from '..';
13
+
14
+ /**
15
+ * A `CardContainer` with an optional header above its content. The `header` prop takes a `title`,
16
+ * a `titleAction` that turns the title into a link, and up to two actions.
17
+ */
18
+ const meta: Meta<typeof CardWidget> = {
19
+ component: CardWidget,
20
+ title: 'Layouts/CardWidget',
21
+ tags: ['early-access'],
22
+ argTypes: {
23
+ header: {
24
+ control: 'object',
25
+ table: { type: { summary: 'CardWidgetHeader' } },
26
+ },
27
+ spotlight: {
28
+ control: 'radio',
29
+ options: [undefined, 'active', 'inactive'],
30
+ table: {
31
+ defaultValue: { summary: 'undefined' },
32
+ type: { summary: 'CardContainerSpotlight' },
33
+ },
34
+ },
35
+ as: {
36
+ control: 'radio',
37
+ options: ['div', 'section', 'article'],
38
+ table: { defaultValue: { summary: "'div'" }, type: { summary: 'string' } },
39
+ },
40
+ children: {
41
+ control: false,
42
+ table: { type: { summary: 'ReactNode' } },
43
+ },
44
+ className: { control: 'text', table: { type: { summary: 'string' } } },
45
+ 'data-testid': { control: 'text', table: { type: { summary: 'string' } } },
46
+ },
47
+ args: {
48
+ spotlight: 'active',
49
+ as: 'div',
50
+ header: {
51
+ title: 'Cards',
52
+ titleAction: { href: '#cards' },
53
+ action: { label: 'Order card' },
54
+ },
55
+ },
56
+ };
57
+
58
+ export default meta;
59
+
60
+ type Story = StoryObj<typeof CardWidget>;
61
+
62
+ /** Experiment with the widget's props. */
63
+ export const Playground: Story = {
64
+ render: (args) => (
65
+ <div style={{ maxWidth: '480px' }}>
66
+ <CardWidget {...args}>
67
+ <SampleContent />
68
+ </CardWidget>
69
+ </div>
70
+ ),
71
+ };
72
+
73
+ export const Sandbox = createSandboxStory({
74
+ code: `<CardWidget
75
+ spotlight="active"
76
+ header={{
77
+ title: 'Cards',
78
+ titleAction: { href: '#cards' },
79
+ action: { label: 'Order card' },
80
+ }}
81
+ >
82
+ <Body>Your virtual card is ready to use.</Body>
83
+ <Body>Spend in 40+ currencies with the real exchange rate.</Body>
84
+ </CardWidget>`,
85
+ scope: { ...globalScope, CardWidget },
86
+ });
87
+
88
+ /** `titleAction` turns the title into a link to the widget's own screen and appends a chevron. */
89
+ export const TitleLink: Story = {
90
+ parameters: { controls: { disable: true } },
91
+ render: () => (
92
+ <CardWidget header={{ title: 'Cards', titleAction: { href: '#cards' } }}>
93
+ <SampleContent />
94
+ </CardWidget>
95
+ ),
96
+ };
97
+
98
+ /**
99
+ * An action object with a `label` renders a small button, and one with only an `icon` a 32px icon
100
+ * button, which requires an `aria-label`. `actionSecondary` renders before `action` at a lower
101
+ * emphasis; two actions is the maximum, to keep the title legible. When the header is 360px wide
102
+ * or narrower, the actions move under a title that doesn't fit beside them on one line.
103
+ */
104
+ export const Actions: Story = {
105
+ parameters: { controls: { disable: true } },
106
+ render: () => {
107
+ const header = {
108
+ title: 'Cards',
109
+ titleAction: { href: '#cards' },
110
+ action: { label: 'Order card', icon: <Plus size={16} /> },
111
+ actionSecondary: { 'aria-label': 'Card settings', icon: <Settings size={16} /> },
112
+ };
113
+ return (
114
+ <div style={{ display: 'flex', flexDirection: 'column', gap: '24px', maxWidth: '480px' }}>
115
+ <CardWidget header={header}>
116
+ <SampleContent />
117
+ </CardWidget>
118
+
119
+ <div style={{ width: '320px' }}>
120
+ <CardWidget header={header}>
121
+ <SampleContent />
122
+ </CardWidget>
123
+ </div>
124
+ </div>
125
+ );
126
+ },
127
+ };
128
+
129
+ /** A title too long for its line wraps. A linked title keeps its chevron after its last word. */
130
+ export const LongTitle: Story = {
131
+ parameters: { controls: { disable: true } },
132
+ render: () => (
133
+ <div style={{ display: 'flex', flexDirection: 'column', gap: '24px', maxWidth: '480px' }}>
134
+ <CardWidget header={{ title: 'Cards, accounts and everything else you hold with us' }}>
135
+ <SampleContent />
136
+ </CardWidget>
137
+
138
+ <CardWidget
139
+ header={{
140
+ title: 'Cards, accounts and everything else you hold with us',
141
+ titleAction: { href: '#cards' },
142
+ action: { label: 'Order card', icon: <Plus size={16} /> },
143
+ actionSecondary: { 'aria-label': 'Card settings', icon: <Settings size={16} /> },
144
+ }}
145
+ >
146
+ <SampleContent />
147
+ </CardWidget>
148
+ </div>
149
+ ),
150
+ };
151
+
152
+ /** The action slots also take any node, for content the button actions do not cover. */
153
+ export const CustomAction: Story = {
154
+ parameters: { controls: { disable: true } },
155
+ render: () => (
156
+ <CardWidget
157
+ header={{
158
+ title: 'Balance',
159
+ action: (
160
+ <Body as="span" type={Typography.BODY_DEFAULT_BOLD}>
161
+ £1,240.00
162
+ </Body>
163
+ ),
164
+ }}
165
+ >
166
+ <SampleContent />
167
+ </CardWidget>
168
+ ),
169
+ };
170
+
171
+ /** A header followed by a list, as in a dashboard's cards module. */
172
+ export const WithList: Story = {
173
+ parameters: { controls: { disable: true } },
174
+ render: () => (
175
+ <CardWidget
176
+ header={{
177
+ title: 'Cards',
178
+ titleAction: { href: '#cards' },
179
+ action: { label: 'New card', icon: <Plus size={16} /> },
180
+ }}
181
+ >
182
+ <CardsList />
183
+ </CardWidget>
184
+ ),
185
+ };
186
+
187
+ /**
188
+ * The card shows as hovered or pressed while the title link is, and as hovered while the link has
189
+ * keyboard focus. Hovering or pressing the rest of
190
+ * the card, or its actions, leaves it at rest.
191
+ */
192
+ export const Interactive: Story = {
193
+ parameters: { controls: { disable: true } },
194
+ render: () => (
195
+ <div style={{ display: 'flex', flexDirection: 'column', gap: '24px', maxWidth: '480px' }}>
196
+ {([undefined, 'active', 'inactive'] as (CardContainerSpotlight | undefined)[]).map(
197
+ (spotlight) => (
198
+ <CardWidget
199
+ key={spotlight ?? 'none'}
200
+ spotlight={spotlight}
201
+ header={{
202
+ title: `Spotlight: ${spotlight ?? 'not set'}`,
203
+ titleAction: { href: '#cards' },
204
+ action: { label: 'Order card', icon: <Plus size={16} /> },
205
+ actionSecondary: { 'aria-label': 'Card settings', icon: <Settings size={16} /> },
206
+ }}
207
+ >
208
+ <Body>Your virtual card is ready to use.</Body>
209
+ </CardWidget>
210
+ ),
211
+ )}
212
+ </div>
213
+ ),
214
+ };
215
+
216
+ /** The same header on each spotlight. */
217
+ export const Spotlight: Story = {
218
+ parameters: { controls: { disable: true } },
219
+ render: () => (
220
+ <div style={{ display: 'flex', flexDirection: 'column', gap: '24px', maxWidth: '480px' }}>
221
+ {([undefined, 'active', 'inactive'] as (CardContainerSpotlight | undefined)[]).map(
222
+ (spotlight) => (
223
+ <CardWidget
224
+ key={spotlight ?? 'none'}
225
+ spotlight={spotlight}
226
+ header={{
227
+ title: `Spotlight: ${spotlight ?? 'not set'}`,
228
+ titleAction: { href: '#cards' },
229
+ action: { label: 'Order card', icon: <Plus size={16} /> },
230
+ }}
231
+ >
232
+ <SampleContent />
233
+ </CardWidget>
234
+ ),
235
+ )}
236
+ </div>
237
+ ),
238
+ };
@@ -0,0 +1,350 @@
1
+ import { Card, Jar, Plus, Settings, Travel } from '@transferwise/icons';
2
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
3
+ import { useTheme } from '@wise/components-theming';
4
+
5
+ import { useRtlDiffI18n, withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
6
+ import { withVariantConfig } from '../../../.storybook/helpers';
7
+ import Body from '../../Body';
8
+ import type { CardContainerSpotlight } from '../../CardContainer';
9
+ import List from '../../List';
10
+ import ListItem from '../../ListItem';
11
+ import type { ListItemProps } from '../../ListItem';
12
+ import Title from '../../Title';
13
+ import CardWidget from '..';
14
+ import type { CardWidgetProps } from '..';
15
+
16
+ const meta: Meta<typeof CardWidget> = {
17
+ component: CardWidget,
18
+ tags: ['!autodocs', '!manifest'],
19
+ title: 'Layouts/CardWidget/Tests',
20
+ };
21
+ export default meta;
22
+ type Story = StoryObj<CardWidgetProps>;
23
+
24
+ const SPOTLIGHTS: (CardContainerSpotlight | undefined)[] = [undefined, 'active', 'inactive'];
25
+
26
+ const ACTIONS = {
27
+ action: { label: 'Order card', icon: <Plus size={16} /> },
28
+ actionSecondary: { 'aria-label': 'Settings', icon: <Settings size={16} /> },
29
+ };
30
+
31
+ const ThemeTitle = () => {
32
+ const { theme, screenMode } = useTheme();
33
+ return (
34
+ <Title type="title-subsection">
35
+ {theme} / {screenMode}
36
+ </Title>
37
+ );
38
+ };
39
+
40
+ /** A full header on every spotlight against every theme. */
41
+ export const AllVariants: Story = {
42
+ ...withVariantConfig([
43
+ 'default',
44
+ 'dark',
45
+ 'bright-green',
46
+ 'forest-green',
47
+ 'business',
48
+ 'business--bright-green',
49
+ 'business--forest-green',
50
+ 'platform',
51
+ 'platform--forest-green',
52
+ ]),
53
+ render: () => (
54
+ <div style={{ display: 'flex', flexDirection: 'column', gap: '24px', maxWidth: '420px' }}>
55
+ <ThemeTitle />
56
+ {SPOTLIGHTS.map((spotlight) => (
57
+ <CardWidget
58
+ key={spotlight ?? 'none'}
59
+ spotlight={spotlight}
60
+ header={{
61
+ title: `Spotlight: ${spotlight ?? 'not set'}`,
62
+ titleAction: { href: '#target' },
63
+ ...ACTIONS,
64
+ }}
65
+ >
66
+ <Body>First line of content.</Body>
67
+ <Body>Second line, to show the content stacks flush.</Body>
68
+ </CardWidget>
69
+ ))}
70
+ </div>
71
+ ),
72
+ };
73
+
74
+ /** Every combination of title link and the two action slots. */
75
+ export const HeaderCombinations: Story = {
76
+ render: () => (
77
+ <div style={{ display: 'flex', flexDirection: 'column', gap: '24px', maxWidth: '420px' }}>
78
+ <CardWidget header={{ title: 'Title only' }}>
79
+ <Body>Content</Body>
80
+ </CardWidget>
81
+
82
+ <CardWidget header={{ title: 'Title as link', titleAction: { href: '#target' } }}>
83
+ <Body>Content</Body>
84
+ </CardWidget>
85
+
86
+ <CardWidget
87
+ header={{
88
+ title:
89
+ 'A title link long enough to wrap onto a second line, with its chevron after the last word',
90
+ titleAction: { href: '#target' },
91
+ }}
92
+ >
93
+ <Body>Content</Body>
94
+ </CardWidget>
95
+
96
+ <CardWidget header={{ title: 'Leading action only', action: { label: 'Order card' } }}>
97
+ <Body>Content</Body>
98
+ </CardWidget>
99
+
100
+ <CardWidget header={{ title: 'Secondary action only', actionSecondary: { label: 'Manage' } }}>
101
+ <Body>Content</Body>
102
+ </CardWidget>
103
+
104
+ <CardWidget
105
+ header={{
106
+ title: 'Both actions, icon only',
107
+ action: { 'aria-label': 'Add', icon: <Plus size={16} /> },
108
+ actionSecondary: ACTIONS.actionSecondary,
109
+ }}
110
+ >
111
+ <Body>Content</Body>
112
+ </CardWidget>
113
+
114
+ <CardWidget
115
+ header={{
116
+ title: 'A title long enough to wrap onto more than a single line next to its actions',
117
+ titleAction: { href: '#target' },
118
+ ...ACTIONS,
119
+ }}
120
+ >
121
+ <Body>Content</Body>
122
+ </CardWidget>
123
+
124
+ <CardWidget header={{ title: 'Header only', action: { label: 'Order card' } }} />
125
+
126
+ <CardWidget>
127
+ <Body>No header — the content starts at the card&apos;s top padding.</Body>
128
+ </CardWidget>
129
+ </div>
130
+ ),
131
+ };
132
+
133
+ const LIST_ITEMS = [
134
+ { title: '•••• 1582', subtitle: 'Current account', icon: <Card /> },
135
+ { title: '•••• 9982', subtitle: 'Jar', icon: <Jar /> },
136
+ { title: '•••• 5507', subtitle: 'Travel', icon: <Travel /> },
137
+ ];
138
+
139
+ const CardListItem = ({
140
+ index,
141
+ spotlight,
142
+ }: {
143
+ index: number;
144
+ spotlight?: ListItemProps['spotlight'];
145
+ }) => {
146
+ const { title, subtitle, icon } = LIST_ITEMS[index];
147
+ return (
148
+ <ListItem
149
+ title={title}
150
+ subtitle={subtitle}
151
+ spotlight={spotlight}
152
+ media={<ListItem.AvatarView>{icon}</ListItem.AvatarView>}
153
+ control={<ListItem.Navigation href={`#item-${index}`} />}
154
+ />
155
+ );
156
+ };
157
+
158
+ /**
159
+ * A `List` with every mix of spotlight and non-spotlight items. Non-spotlight items draw their
160
+ * hover and focus backgrounds 8px out of bounds, into the card's padding.
161
+ */
162
+ export const ListCombinations: Story = {
163
+ render: () => (
164
+ <div style={{ display: 'flex', flexDirection: 'column', gap: '24px', maxWidth: '420px' }}>
165
+ <CardWidget header={{ title: 'Non-spotlight items', titleAction: { href: '#target' } }}>
166
+ <List>
167
+ <CardListItem index={0} />
168
+ <CardListItem index={1} />
169
+ <CardListItem index={2} />
170
+ </List>
171
+ </CardWidget>
172
+
173
+ <CardWidget header={{ title: 'Active spotlight items' }}>
174
+ <List>
175
+ <CardListItem index={0} spotlight="active" />
176
+ <CardListItem index={1} spotlight="active" />
177
+ </List>
178
+ </CardWidget>
179
+
180
+ <CardWidget header={{ title: 'Inactive spotlight items' }}>
181
+ <List>
182
+ <CardListItem index={0} spotlight="inactive" />
183
+ <CardListItem index={1} spotlight="inactive" />
184
+ </List>
185
+ </CardWidget>
186
+
187
+ <CardWidget header={{ title: 'Active and inactive spotlight items' }}>
188
+ <List>
189
+ <CardListItem index={0} spotlight="active" />
190
+ <CardListItem index={1} spotlight="inactive" />
191
+ </List>
192
+ </CardWidget>
193
+
194
+ <CardWidget header={{ title: 'Spotlight and non-spotlight items', action: ACTIONS.action }}>
195
+ <List>
196
+ <CardListItem index={0} spotlight="active" />
197
+ <CardListItem index={1} />
198
+ <CardListItem index={2} />
199
+ </List>
200
+ </CardWidget>
201
+
202
+ <CardWidget
203
+ spotlight="active"
204
+ header={{ title: 'Single non-spotlight item in an active card' }}
205
+ >
206
+ <List>
207
+ <CardListItem index={0} />
208
+ </List>
209
+ </CardWidget>
210
+
211
+ <CardWidget
212
+ spotlight="inactive"
213
+ header={{ title: 'Single spotlight item in an inactive card' }}
214
+ >
215
+ <List>
216
+ <CardListItem index={0} spotlight="active" />
217
+ </List>
218
+ </CardWidget>
219
+
220
+ <CardWidget>
221
+ <List>
222
+ <CardListItem index={0} />
223
+ <CardListItem index={1} />
224
+ </List>
225
+ </CardWidget>
226
+ </div>
227
+ ),
228
+ };
229
+
230
+ /**
231
+ * Two spotlighted widgets side by side: one with a title-only header and text, the other with
232
+ * action buttons and a `List`. Each header is at least as tall as the 32px action buttons, so the
233
+ * first line of content starts at the same height in both.
234
+ */
235
+ export const SideBySide: Story = {
236
+ render: () => (
237
+ <div style={{ display: 'flex', gap: '24px', maxWidth: '900px' }}>
238
+ <div style={{ flex: 1 }}>
239
+ <CardWidget spotlight="active" header={{ title: 'Balance' }}>
240
+ <Body>Your virtual card is ready to use.</Body>
241
+ <Body>Spend in 40+ currencies with the real exchange rate.</Body>
242
+ </CardWidget>
243
+ </div>
244
+ <div style={{ flex: 1 }}>
245
+ <CardWidget
246
+ spotlight="active"
247
+ header={{ title: 'Cards', titleAction: { href: '#target' }, ...ACTIONS }}
248
+ >
249
+ <List>
250
+ <CardListItem index={0} />
251
+ <CardListItem index={1} />
252
+ <CardListItem index={2} />
253
+ </List>
254
+ </CardWidget>
255
+ </div>
256
+ </div>
257
+ ),
258
+ };
259
+
260
+ /**
261
+ * When the header is 360px wide or narrower, its action corner stays beside a title that fits on
262
+ * one line next to it, and moves under a longer title. Above that width, a long title wraps beside
263
+ * the actions instead.
264
+ */
265
+ export const NarrowHeader: Story = {
266
+ render: () => (
267
+ <div style={{ display: 'flex', flexDirection: 'column', gap: '24px' }}>
268
+ {[320, 394, 420].map((width) => (
269
+ <div key={width} style={{ display: 'flex', flexDirection: 'column', gap: '16px', width }}>
270
+ {['Cards', `A longer title in a card ${width}px wide`].map((title) => (
271
+ <CardWidget
272
+ key={title}
273
+ spotlight="active"
274
+ header={{ title, titleAction: { href: '#target' }, ...ACTIONS }}
275
+ >
276
+ <Body>Content</Body>
277
+ </CardWidget>
278
+ ))}
279
+ </div>
280
+ ))}
281
+ </div>
282
+ ),
283
+ };
284
+
285
+ /**
286
+ * In RTL the action cluster should move to the left and the title's trailing chevron should point
287
+ * left. The `actionSecondary` slot must stay on the inline-start side of `action` in both
288
+ * directions.
289
+ *
290
+ * Every widget is rendered wide (480px, actions beside the title) and narrow (320px). At 320px the
291
+ * short titles keep their actions beside them, and the long title's actions stack under it,
292
+ * aligned to the inline end. The long title wraps, so its chevron should follow the last word on
293
+ * the inline-end side in both directions.
294
+ */
295
+ export const RTLDiff: Story = {
296
+ render: () => {
297
+ const i18n = useRtlDiffI18n();
298
+ const actions = {
299
+ action: { label: i18n.orderCard, icon: <Plus size={16} /> },
300
+ actionSecondary: { 'aria-label': i18n.settings, icon: <Settings size={16} /> },
301
+ };
302
+ const widgets = (
303
+ <>
304
+ <CardWidget header={{ title: i18n.cards, titleAction: { href: '#target' } }}>
305
+ <Body>{i18n.content}</Body>
306
+ </CardWidget>
307
+
308
+ <CardWidget header={{ title: i18n.cards, ...actions }}>
309
+ <Body>{i18n.content}</Body>
310
+ </CardWidget>
311
+
312
+ <CardWidget
313
+ spotlight="active"
314
+ header={{ title: i18n.longTitle, titleAction: { href: '#target' }, ...actions }}
315
+ >
316
+ <Body>{i18n.content}</Body>
317
+ </CardWidget>
318
+
319
+ <CardWidget spotlight="inactive" header={{ title: i18n.cards }}>
320
+ <Body>{i18n.content}</Body>
321
+ </CardWidget>
322
+ </>
323
+ );
324
+
325
+ return (
326
+ <div style={{ display: 'flex', flexDirection: 'column', gap: '40px' }}>
327
+ {[480, 320].map((width) => (
328
+ <div key={width} style={{ display: 'flex', flexDirection: 'column', gap: '24px', width }}>
329
+ {widgets}
330
+ </div>
331
+ ))}
332
+ </div>
333
+ );
334
+ },
335
+ ...withRTLDiff({
336
+ i18n: {
337
+ cards: { en: 'Cards', ar: 'البطاقات' },
338
+ content: {
339
+ en: 'Your virtual card is ready to use.',
340
+ ar: 'بطاقتك الافتراضية جاهزة للاستخدام.',
341
+ },
342
+ orderCard: { en: 'Order card', ar: 'اطلب بطاقة' },
343
+ settings: { en: 'Card settings', ar: 'إعدادات البطاقة' },
344
+ longTitle: {
345
+ en: 'Cards, accounts and everything else you hold with us',
346
+ ar: 'البطاقات والحسابات وكل ما تحتفظ به لدينا',
347
+ },
348
+ },
349
+ }),
350
+ };
@@ -0,0 +1,3 @@
1
+ export { default } from './CardWidget';
2
+ export type { CardWidgetProps, CardWidgetHeader, CardWidgetTitleAction } from './CardWidget.types';
3
+ export type { CardWidgetActionButton } from './CardWidgetAction';
@@ -35,15 +35,14 @@
35
35
  color: var(--color-white);
36
36
  }
37
37
  .np-icon-button-minimal-default {
38
- color: var(--color-interactive-primary);
39
- background-color: var(--color-background-screen);
38
+ color: var(--color-sentiment-content-primary, var(--color-interactive-primary));
40
39
  background-color: transparent;
41
40
  }
42
41
  .np-icon-button-minimal-default:not(.disabled):not(:disabled):hover {
43
- background-color: var(--color-background-screen-hover);
42
+ background-color: var(--color-sentiment-interactive-secondary-neutral-hover, var(--color-background-screen-hover));
44
43
  }
45
44
  .np-icon-button-minimal-default:not(.disabled):not(:disabled):active {
46
- background-color: var(--color-background-screen-active);
45
+ background-color: var(--color-sentiment-interactive-secondary-neutral-active, var(--color-background-screen-active));
47
46
  }
48
47
  .np-icon-button-secondary-default {
49
48
  color: var(--color-sentiment-content-primary, var(--color-interactive-primary));
@@ -31,8 +31,21 @@
31
31
  }
32
32
 
33
33
  &-minimal-default {
34
- .colors(--color-interactive-primary, --color-background-screen);
34
+ color: var(--color-sentiment-content-primary, var(--color-interactive-primary));
35
35
  background-color: transparent;
36
+
37
+ &:not(.disabled, :disabled):hover {
38
+ background-color: var(
39
+ --color-sentiment-interactive-secondary-neutral-hover,
40
+ var(--color-background-screen-hover)
41
+ );
42
+ }
43
+ &:not(.disabled, :disabled):active {
44
+ background-color: var(
45
+ --color-sentiment-interactive-secondary-neutral-active,
46
+ var(--color-background-screen-active)
47
+ );
48
+ }
36
49
  }
37
50
 
38
51
  &-secondary-default {
package/src/Link/Link.tsx CHANGED
@@ -14,7 +14,7 @@ export type LinkProps = PrimitiveAnchorProps &
14
14
  /**
15
15
  * Standard Link component with navigate away icon
16
16
  *
17
- * Documentation: https://transferwise.github.io/neptune-web/components/content/Link
17
+ * Documentation: https://storybook.wise.design/?path=/docs/typography-link--docs
18
18
  */
19
19
  const Link = ({
20
20
  className,
@@ -15,7 +15,7 @@ import { action } from 'storybook/actions';
15
15
  /**
16
16
  * Use additional information to add extra details that help make the information clearer for users. Use additional information only after you've used the subtitle.
17
17
  *
18
- * Refer to the [design documentation](https://docs.wise.design/components/list-item#content:~:text=StatusIcon.iconLabel.error-,Additional%20information,-Use%20additional%20information) for more details.
18
+ * Refer to the [design documentation](https://docs.wise.design/components/list-item#additional-information) for more details.
19
19
  */
20
20
  export default {
21
21
  component: ListItem.AdditionalInfo,
@@ -135,7 +135,7 @@ export const Playground: Story = {
135
135
 
136
136
  /**
137
137
  * AvatarView can display different types of content including icons, profile images, and initials. <br />
138
- * Refer to the [design documentation](https://docs.wise.design/components/avatar#:~:text=56%2C%20%E2%80%A8and%2072.-,Media,-There%20are%204) for details.
138
+ * Refer to the [design documentation](https://docs.wise.design/components/avatar#media) for details.
139
139
  */
140
140
  export const ContentTypes: Story = {
141
141
  args: {
@@ -209,7 +209,7 @@ export const ContentTypes: Story = {
209
209
 
210
210
  /**
211
211
  * AvatarView supports 6 sizes to fit different list item contexts: `24`, `32`, `40`, `48`, `56`, `72`. If decorated with a Badge, those will be sized accordingly as well. <br />
212
- * Please refer to the [design documentation](https://docs.wise.design/components/list-item#avatar:~:text=of%20the%20avatar.-,Avatar%20sizes,-List%20item%20supports) for details on when to use which one.
212
+ * Please refer to the [design documentation](https://docs.wise.design/components/list-item#avatar-sizes) for details on when to use which one.
213
213
  */
214
214
  export const Sizes: Story = {
215
215
  parameters: {
@@ -243,7 +243,7 @@ export const Sizes: Story = {
243
243
 
244
244
  /**
245
245
  * AvatarView supports different types of badges for additional context and information. <br />
246
- * Refer to the [design documentation](https://docs.wise.design/components/avatar#:~:text=support%20the%20information.-,With%20badge,-Badges%20contain%20additional) for details.
246
+ * Refer to the [design documentation](https://docs.wise.design/components/avatar#with-badge) for details.
247
247
  */
248
248
  export const Badges: Story = {
249
249
  args: {