@transferwise/components 0.0.0-experimental-696128b → 0.0.0-experimental-328f2cc

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 (159) hide show
  1. package/build/avatarLayout/AvatarLayout.js +4 -10
  2. package/build/avatarLayout/AvatarLayout.js.map +1 -1
  3. package/build/avatarLayout/AvatarLayout.mjs +4 -10
  4. package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
  5. package/build/button/Button.js +79 -81
  6. package/build/button/Button.js.map +1 -1
  7. package/build/button/Button.mjs +80 -82
  8. package/build/button/Button.mjs.map +1 -1
  9. package/build/criticalBanner/CriticalCommsBanner.js +2 -2
  10. package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
  11. package/build/criticalBanner/CriticalCommsBanner.mjs +1 -1
  12. package/build/header/Header.js +2 -2
  13. package/build/header/Header.js.map +1 -1
  14. package/build/header/Header.mjs +1 -1
  15. package/build/index.js +4 -2
  16. package/build/index.js.map +1 -1
  17. package/build/index.mjs +2 -1
  18. package/build/index.mjs.map +1 -1
  19. package/build/link/Link.js +3 -8
  20. package/build/link/Link.js.map +1 -1
  21. package/build/link/Link.mjs +3 -8
  22. package/build/link/Link.mjs.map +1 -1
  23. package/build/main.css +13 -224
  24. package/build/nudge/Nudge.js.map +1 -1
  25. package/build/nudge/Nudge.mjs.map +1 -1
  26. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +3 -1
  27. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
  28. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +3 -1
  29. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
  30. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +4 -1
  31. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
  32. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +4 -1
  33. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -1
  34. package/build/select/Select.js +2 -2
  35. package/build/select/Select.js.map +1 -1
  36. package/build/select/Select.mjs +1 -1
  37. package/build/styles/avatarLayout/AvatarLayout.css +2 -12
  38. package/build/styles/button/Button.css +15 -204
  39. package/build/styles/main.css +13 -224
  40. package/build/styles/nudge/Nudge.css +11 -0
  41. package/build/table/Table.js +166 -0
  42. package/build/table/Table.js.map +1 -0
  43. package/build/table/Table.messages.js +24 -0
  44. package/build/table/Table.messages.js.map +1 -0
  45. package/build/table/Table.messages.mjs +22 -0
  46. package/build/table/Table.messages.mjs.map +1 -0
  47. package/build/table/Table.mjs +164 -0
  48. package/build/table/Table.mjs.map +1 -0
  49. package/build/table/TableCell.js +86 -0
  50. package/build/table/TableCell.js.map +1 -0
  51. package/build/table/TableCell.mjs +84 -0
  52. package/build/table/TableCell.mjs.map +1 -0
  53. package/build/table/TableHeader.js +57 -0
  54. package/build/table/TableHeader.js.map +1 -0
  55. package/build/table/TableHeader.mjs +55 -0
  56. package/build/table/TableHeader.mjs.map +1 -0
  57. package/build/table/TableRow.js +85 -0
  58. package/build/table/TableRow.js.map +1 -0
  59. package/build/table/TableRow.mjs +83 -0
  60. package/build/table/TableRow.mjs.map +1 -0
  61. package/build/table/TableStatusText.js +54 -0
  62. package/build/table/TableStatusText.js.map +1 -0
  63. package/build/table/TableStatusText.mjs +52 -0
  64. package/build/table/TableStatusText.mjs.map +1 -0
  65. package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
  66. package/build/types/button/Button.d.ts +23 -2
  67. package/build/types/button/Button.d.ts.map +1 -1
  68. package/build/types/button/index.d.ts +2 -2
  69. package/build/types/button/index.d.ts.map +1 -1
  70. package/build/types/index.d.ts +2 -0
  71. package/build/types/index.d.ts.map +1 -1
  72. package/build/types/link/Link.d.ts +2 -2
  73. package/build/types/link/Link.d.ts.map +1 -1
  74. package/build/types/nudge/Nudge.d.ts +1 -1
  75. package/build/types/nudge/Nudge.d.ts.map +1 -1
  76. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts.map +1 -1
  77. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts +2 -6
  78. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts.map +1 -1
  79. package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts.map +1 -1
  80. package/build/types/test-utils/story-config.d.ts +1 -1
  81. package/build/types/test-utils/story-config.d.ts.map +1 -1
  82. package/build/types/uploadInput/uploadButton/getAllowedFileTypes.d.ts.map +1 -1
  83. package/build/upload/steps/completeStep/completeStep.js +2 -2
  84. package/build/upload/steps/completeStep/completeStep.js.map +1 -1
  85. package/build/upload/steps/completeStep/completeStep.mjs +1 -1
  86. package/build/upload/steps/processingStep/processingStep.js +2 -2
  87. package/build/upload/steps/processingStep/processingStep.js.map +1 -1
  88. package/build/upload/steps/processingStep/processingStep.mjs +1 -1
  89. package/build/uploadInput/UploadInput.js +3 -3
  90. package/build/uploadInput/UploadInput.js.map +1 -1
  91. package/build/uploadInput/UploadInput.mjs +1 -1
  92. package/build/uploadInput/uploadButton/getAllowedFileTypes.js +23 -3
  93. package/build/uploadInput/uploadButton/getAllowedFileTypes.js.map +1 -1
  94. package/build/uploadInput/uploadButton/getAllowedFileTypes.mjs +23 -3
  95. package/build/uploadInput/uploadButton/getAllowedFileTypes.mjs.map +1 -1
  96. package/package.json +3 -3
  97. package/src/alert/Alert.tests.story.tsx +1 -1
  98. package/src/avatarLayout/AvatarLayout.css +2 -12
  99. package/src/avatarLayout/AvatarLayout.less +2 -19
  100. package/src/avatarLayout/AvatarLayout.tsx +3 -10
  101. package/src/button/Button.css +15 -204
  102. package/src/button/Button.less +14 -211
  103. package/src/button/Button.spec.tsx +227 -75
  104. package/src/button/Button.story.tsx +135 -728
  105. package/src/button/Button.tsx +131 -94
  106. package/src/button/__snapshots__/Button.spec.tsx.snap +309 -0
  107. package/src/button/index.ts +3 -2
  108. package/src/drawer/Drawer.spec.tsx +93 -0
  109. package/src/field/Field.story.tsx +1 -1
  110. package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +1 -1
  111. package/src/index.ts +12 -0
  112. package/src/inputs/SelectInput.story.tsx +1 -1
  113. package/src/label/Label.story.tsx +1 -1
  114. package/src/link/Link.tsx +6 -15
  115. package/src/main.css +13 -224
  116. package/src/main.less +0 -1
  117. package/src/nudge/Nudge.css +11 -0
  118. package/src/nudge/Nudge.less +3 -0
  119. package/src/nudge/Nudge.story.tsx +10 -0
  120. package/src/nudge/Nudge.tsx +2 -1
  121. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +7 -1
  122. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +2 -7
  123. package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +3 -1
  124. package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +8 -1
  125. package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +5 -2
  126. package/src/test-utils/Parameters.d.ts +1 -9
  127. package/src/test-utils/story-config.ts +1 -10
  128. package/src/uploadInput/UploadInput.tests.story.tsx +5 -5
  129. package/src/uploadInput/uploadButton/getAllowedFileTypes.spec.ts +12 -0
  130. package/src/uploadInput/uploadButton/getAllowedFileTypes.ts +33 -7
  131. package/build/button/Button.resolver.js +0 -74
  132. package/build/button/Button.resolver.js.map +0 -1
  133. package/build/button/Button.resolver.mjs +0 -72
  134. package/build/button/Button.resolver.mjs.map +0 -1
  135. package/build/button/LegacyButton.js +0 -114
  136. package/build/button/LegacyButton.js.map +0 -1
  137. package/build/button/LegacyButton.mjs +0 -112
  138. package/build/button/LegacyButton.mjs.map +0 -1
  139. package/build/styles/button/Button.vars.css +0 -39
  140. package/build/styles/button/LegacyButton.css +0 -23
  141. package/build/types/button/Button.resolver.d.ts +0 -33
  142. package/build/types/button/Button.resolver.d.ts.map +0 -1
  143. package/build/types/button/Button.types.d.ts +0 -58
  144. package/build/types/button/Button.types.d.ts.map +0 -1
  145. package/build/types/button/LegacyButton.d.ts +0 -30
  146. package/build/types/button/LegacyButton.d.ts.map +0 -1
  147. package/src/button/Button.resolver.tsx +0 -73
  148. package/src/button/Button.tests.story.tsx +0 -27
  149. package/src/button/Button.types.ts +0 -74
  150. package/src/button/Button.vars.css +0 -39
  151. package/src/button/Button.vars.less +0 -50
  152. package/src/button/LegacyButton.css +0 -23
  153. package/src/button/LegacyButton.less +0 -24
  154. package/src/button/LegacyButton.spec.tsx +0 -147
  155. package/src/button/LegacyButton.story.tsx +0 -225
  156. package/src/button/LegacyButton.tsx +0 -160
  157. package/src/drawer/Drawer.rtl.spec.tsx +0 -59
  158. package/src/drawer/Drawer.spec.js +0 -101
  159. package/src/drawer/__snapshots__/Drawer.rtl.spec.tsx.snap +0 -55
@@ -1,756 +1,163 @@
1
1
  import { Meta, StoryObj } from '@storybook/react';
2
- import { fn } from '@storybook/test';
3
- import { Freeze, ArrowRight, ArrowLeft } from '@transferwise/icons';
4
- import { Flag } from '@wise/art';
5
- import Button from './Button.resolver';
6
- import type { ButtonProps, ButtonPriority } from './Button.types';
7
- import { storyConfig } from '../test-utils';
8
-
9
- const withContainer = (Story: any) => (
10
- <div style={{ display: 'flex', justifyContent: 'center' }}>
11
- <Story />
12
- </div>
13
- );
14
-
15
- /**
16
- * Used for showing multiple components within a Canvas.
17
- * @decorator
18
- */
19
- const withComponentGrid =
20
- (maxWidth = 'auto') =>
21
- (Story: any) => (
22
- <div
23
- style={{
24
- width: '100%',
25
- placeItems: 'center',
26
- justifyContent: 'center',
27
- display: 'flex',
28
- flexWrap: 'wrap',
29
- gap: '2rem',
30
- maxWidth,
31
- }}
32
- >
33
- <Story />
34
- </div>
35
- );
36
-
37
- /**
38
- * Not all stories need access to all controls as it causes unnecessary UI noise.
39
- */
40
- const hideControls = (args: string[]) => {
41
- const hidden = [
42
- 'avatars',
43
- 'iconStart',
44
- 'iconEnd',
45
- 'onClick',
46
- 'onBlur',
47
- 'onFocus',
48
- 'onKeyDown',
49
- 'onMouseEnter',
50
- 'onMouseLeave',
51
- ...args,
52
- ];
53
-
54
- return Object.fromEntries(hidden.map((item) => [item, { table: { disable: true } }]));
55
- };
56
-
57
- /**
58
- * SB code generation is often not ideal, rendering confusing source.
59
- * This helper makes icon values more understandable for the stories below.
60
- */
61
- const augmentIconProps = ({ start = 'Freeze', end = 'ArrowRight' } = {}) => ({
62
- docs: {
63
- source: {
64
- transform(value: string): string {
65
- return value
66
- .replace(/iconStart=.*?\}+/g, `iconStart={${start}}`)
67
- .replace(/iconEnd=.*?\}+/g, `iconEnd={${end}}`);
68
- },
69
- },
70
- },
71
- });
72
-
73
- /**
74
- * Convenience controls for previewing rich markup,
75
- * not otherwise possible via Storybook
76
- */
77
- type PreviewStoryArgs = Parameters<typeof Button>[0] & {
78
- previewAvatars: boolean | ButtonProps['avatars'];
79
- previewIconStart: boolean | ButtonProps['iconStart'];
80
- previewIconEnd: boolean | ButtonProps['iconEnd'];
81
- };
82
- const previewArgTypes = {
83
- previewIconStart: {
84
- control: 'boolean',
85
- name: 'Show with `iconStart`',
86
- mapping: {
87
- true: Freeze,
88
- },
89
- table: {
90
- category: 'Preview options',
91
- },
92
- },
93
- previewIconEnd: {
94
- control: 'boolean',
95
- name: 'Show with `iconEnd`',
96
- mapping: {
97
- true: ArrowRight,
98
- },
99
- table: {
100
- category: 'Preview options',
101
- },
102
- },
103
- previewAvatars: {
104
- control: 'select',
105
- options: ['undefined', 'flag', 'initials', 'icon', 'image', 'double'],
106
- name: 'Show with Avatar',
107
- mapping: {
108
- undefined,
109
- flag: [{ asset: <Flag code="pl" /> }],
110
- initials: [{ profileName: 'Jay Jay' }],
111
- icon: [{ asset: <Freeze /> }],
112
- image: [{ imgSrc: '../avatar-square-dude.webp' }],
113
- double: [{ asset: <Flag code="gb" /> }, { imgSrc: '../avatar-square-dude.webp' }],
114
- },
115
- table: {
116
- category: 'Preview options',
117
- },
118
- },
119
- } as const;
2
+ import { userEvent, within, fn } from '@storybook/test';
120
3
 
121
- const getPropsForPreview = (args: PreviewStoryArgs) => {
122
- const { previewAvatars, previewIconStart, previewIconEnd, ...props } = args as {
123
- previewAvatars: ButtonProps['avatars'];
124
- previewIconStart: ButtonProps['iconStart'];
125
- previewIconEnd: ButtonProps['iconEnd'];
126
- props: typeof Button;
127
- };
4
+ import { ControlType, Priority } from '../common';
5
+ import { storyConfig } from '../test-utils';
128
6
 
129
- return [
130
- props,
131
- {
132
- avatars: previewAvatars,
133
- iconStart: previewIconStart,
134
- iconEnd: previewIconEnd,
135
- },
136
- ];
137
- };
7
+ import Button from './Button';
138
8
 
139
- const meta: Meta<typeof Button> = {
9
+ export default {
140
10
  component: Button,
141
11
  title: 'Actions/Button',
142
- argTypes: {
143
- v2: {
144
- table: {
145
- readonly: true,
146
- },
147
- },
148
- size: {
149
- type: {
150
- name: 'enum',
151
- value: ['lg', 'md', 'sm'],
152
- },
153
- table: {
154
- type: {
155
- summary: 'ButtonSize',
156
- },
157
- },
158
- },
159
- priority: {
160
- type: {
161
- name: 'enum',
162
- value: ['primary', 'secondary', 'tertiary', 'minimal'],
163
- },
164
- table: {
165
- type: {
166
- summary: 'ButtonPriority',
167
- },
168
- },
169
- },
170
- sentiment: {
171
- type: {
172
- name: 'enum',
173
- value: ['default', 'negative'],
174
- },
175
- table: {
176
- type: {
177
- summary: 'ButtonSentiment',
178
- },
179
- },
180
- },
181
- disabled: {
182
- description: 'Toggles the disabled state',
183
- table: {
184
- defaultValue: { summary: 'false' },
185
- },
186
- },
187
- loading: {
188
- description: 'Toggles the loading state',
189
- table: {
190
- defaultValue: { summary: 'false' },
191
- },
192
- },
193
- as: {
194
- table: {
195
- defaultValue: { summary: 'button' },
196
- },
197
- },
198
- block: {
199
- table: {
200
- defaultValue: { summary: 'false' },
201
- },
202
- },
203
- href: {
204
- type: {
205
- name: 'string',
206
- },
207
- description: 'If set, the component will render as an HTML anchor.',
208
- },
209
- iconStart: {
210
- control: 'object',
211
- },
212
- iconEnd: {
213
- control: 'object',
214
- },
215
- avatars: {
216
- control: 'object',
217
- },
218
- type: {
219
- table: {
220
- disable: true,
221
- },
222
- },
223
- htmlType: {
224
- table: {
225
- disable: true,
226
- },
227
- },
228
- 'data-testid': {
229
- table: {
230
- disable: true,
231
- },
232
- },
233
- },
234
12
  args: {
235
- v2: true,
236
- size: undefined,
237
- priority: undefined,
238
- sentiment: undefined,
239
- disabled: false,
13
+ children: 'Button text',
240
14
  loading: false,
241
- block: false,
242
- href: undefined,
243
- as: undefined,
244
- type: undefined,
245
- iconStart: undefined,
246
- iconEnd: undefined,
247
- avatars: undefined,
248
- testId: undefined,
249
- className: undefined,
250
15
  onClick: fn(),
251
- children: 'Button text',
252
- },
253
- tags: ['autodocs'],
254
- decorators: [withContainer],
255
- };
256
-
257
- export default meta;
258
-
259
- type Story = StoryObj<typeof Button>;
260
-
261
- export const Playground: StoryObj<PreviewStoryArgs> = {
262
- render: function Render(args: PreviewStoryArgs) {
263
- const [props, previewProps] = getPropsForPreview(args);
264
-
265
- return <Button {...props} {...previewProps} v2 />;
266
- },
267
- args: {
268
16
  onBlur: fn(),
269
17
  onFocus: fn(),
270
- onKeyDown: fn(),
271
- onMouseEnter: fn(),
272
- onMouseLeave: fn(),
273
- previewIconStart: false,
274
- previewIconEnd: false,
275
- previewAvatars: false,
276
18
  },
277
19
  argTypes: {
278
- onClick: { table: { disable: true } },
279
- onBlur: { table: { disable: true } },
280
- onFocus: { table: { disable: true } },
281
- onKeyDown: { table: { disable: true } },
282
- onMouseEnter: { table: { disable: true } },
283
- onMouseLeave: { table: { disable: true } },
284
- ...previewArgTypes,
285
- },
286
- };
287
-
288
- /**
289
- * There are two different types of button that, default and negative,
290
- * these designed to emphasise the nature of the action. <br />
291
- * **NB:** Sentiment only applies to `primary` and `secondary` priorities. <br />
292
- * [Design documentation](https://wise.design/components/button#types)
293
- */
294
- export const Sentiment: StoryObj<PreviewStoryArgs> = {
295
- render: function Render(args: PreviewStoryArgs) {
296
- const [props, previewProps] = getPropsForPreview(args);
297
-
298
- return (
299
- <>
300
- <Button {...props} {...previewProps} v2>
301
- Default Sentiment
302
- </Button>
303
- <Button {...props} {...previewProps} v2 sentiment="negative">
304
- Negative Sentiment
305
- </Button>
306
- <Button {...props} {...previewProps} v2 priority="secondary">
307
- Default Sentiment
308
- </Button>
309
- <Button {...props} {...previewProps} v2 priority="secondary" sentiment="negative">
310
- Negative Sentiment
311
- </Button>
312
- </>
313
- );
314
- },
315
- argTypes: {
316
- ...hideControls([
317
- 'sentiment',
318
- 'priority',
319
- 'block',
320
- 'href',
321
- 'target',
322
- 'as',
323
- 'children',
324
- 'testId',
325
- ]),
326
- ...previewArgTypes,
327
- },
328
- args: {
329
- previewIconStart: false,
330
- previewIconEnd: false,
331
- previewAvatars: false,
332
- },
333
- decorators: [withComponentGrid('30rem')],
334
- parameters: augmentIconProps(),
335
- };
336
-
337
- /**
338
- * Priorities set a visual hierarchy amongst the buttons displayed on the
339
- * screen to help more important buttons to take precedence over others. <br />
340
- * [Design documentation](https://wise.design/components/button#priorities)
341
- */
342
- export const Priority: StoryObj<PreviewStoryArgs> = {
343
- render: function Render(args: PreviewStoryArgs) {
344
- const [props, previewProps] = getPropsForPreview(args);
345
-
346
- return (
347
- <>
348
- <Button {...props} {...previewProps} v2>
349
- Primary Priority (default)
350
- </Button>
351
- <Button {...props} {...previewProps} v2 priority="secondary">
352
- Secondary Priority
353
- </Button>
354
- <Button {...props} {...previewProps} v2 priority="tertiary">
355
- Tertiary Priority
356
- </Button>
357
- <Button {...props} {...previewProps} v2 priority="minimal">
358
- Minimal Priority
359
- </Button>
360
- </>
361
- );
362
- },
363
- argTypes: {
364
- ...hideControls(['priority', 'block', 'href', 'target', 'as', 'children', 'testId']),
365
- ...previewArgTypes,
366
- },
367
- args: {
368
- previewIconStart: false,
369
- previewIconEnd: false,
370
- previewAvatars: false,
371
- },
372
- decorators: [withComponentGrid()],
373
- };
374
-
375
- /**
376
- * There are three different button sizes – small (`sm`), medium (`md`) and large (`lg`) – each used for different purposes. <br />
377
- * [Design documentation](https://wise.design/components/button#sizes)
378
- */
379
- export const Size: StoryObj<PreviewStoryArgs> = {
380
- render: function Render(args: PreviewStoryArgs) {
381
- const [props, previewProps] = getPropsForPreview(args);
382
-
383
- return (
384
- <>
385
- <Button {...props} {...previewProps}>
386
- Large button (default)
387
- </Button>
388
- <Button {...props} {...previewProps} size="md">
389
- Medium button
390
- </Button>
391
- <Button {...props} {...previewProps} size="sm">
392
- Small button
393
- </Button>
394
- </>
395
- );
396
- },
397
- argTypes: {
398
- ...hideControls(['size', 'block', 'href', 'target', 'as', 'children', 'testId']),
399
- ...previewArgTypes,
400
- },
401
- args: {
402
- previewIconStart: false,
403
- previewIconEnd: false,
404
- previewAvatars: false,
405
- },
406
- decorators: [withComponentGrid()],
407
- };
408
-
409
- /**
410
- * A Button rendered as an anchor element.
411
- */
412
- export const AsAnchor: StoryObj<PreviewStoryArgs> = {
413
- render: function Render(args: PreviewStoryArgs) {
414
- const [props, previewProps] = getPropsForPreview(args);
415
-
416
- return (
417
- <Button {...props} {...previewProps}>
418
- Button as anchor
419
- </Button>
420
- );
421
- },
422
- argTypes: {
423
- ...hideControls(['block']),
424
- ...previewArgTypes,
425
- },
426
- args: {
427
- as: 'a',
428
- href: 'https://wise.com',
429
- previewIconStart: false,
430
- previewIconEnd: false,
431
- previewAvatars: false,
432
- onClick: undefined,
433
- },
434
- };
435
-
436
- export const Disabled: StoryObj<PreviewStoryArgs> = {
437
- render: function Render(args: PreviewStoryArgs) {
438
- const [props, previewProps] = getPropsForPreview(args);
439
-
440
- return (
441
- <Button {...props} {...previewProps}>
442
- Disabled button
443
- </Button>
444
- );
445
- },
446
- argTypes: {
447
- ...hideControls(['block']),
448
- ...previewArgTypes,
449
- },
450
- args: {
451
- disabled: true,
452
- previewIconStart: false,
453
- previewIconEnd: false,
454
- previewAvatars: false,
455
- },
456
- };
457
-
458
- export const Loading: StoryObj<PreviewStoryArgs> = {
459
- render: function Render(args: PreviewStoryArgs) {
460
- const [props, previewProps] = getPropsForPreview(args);
461
-
462
- return (
463
- <Button {...props} {...previewProps}>
464
- Button as anchor
465
- </Button>
466
- );
467
- },
468
- argTypes: {
469
- ...hideControls(['block']),
470
- ...previewArgTypes,
471
- },
472
- args: {
473
- loading: true,
474
- previewIconStart: false,
475
- previewIconEnd: false,
476
- previewAvatars: false,
477
- },
478
- };
479
-
480
- /**
481
- * A Button that takes up the full width of its container (`display: block`).
482
- */
483
- export const DisplayBlock: StoryObj<PreviewStoryArgs> = {
484
- render: function Render(args: PreviewStoryArgs) {
485
- const [props, previewProps] = getPropsForPreview(args);
486
-
487
- return (
488
- <Button {...props} {...previewProps}>
489
- Full-width button
490
- </Button>
491
- );
492
- },
493
- argTypes: {
494
- ...hideControls([
495
- 'href',
496
- 'target',
497
- 'priority',
498
- 'sentiment',
499
- 'as',
500
- 'disabled',
501
- 'children',
502
- 'testId',
503
- ]),
504
- ...previewArgTypes,
505
- },
506
- args: {
507
- block: true,
508
- previewIconStart: false,
509
- previewIconEnd: false,
510
- previewAvatars: false,
20
+ as: {
21
+ type: {
22
+ name: 'enum',
23
+ value: ['button', 'a'],
24
+ },
25
+ },
511
26
  },
512
- };
513
-
514
- /**
515
- * Icons are only supported for `sm` and `md` size Buttons. <br />
516
- * [Design documentation](https://wise.design/components/button#accessories)
517
- */
518
- export const WithIcons: StoryObj<PreviewStoryArgs> = {
519
- render: function Render(args: PreviewStoryArgs) {
520
- const [props] = getPropsForPreview(args);
27
+ tags: ['autodocs'],
28
+ } satisfies Meta<typeof Button>;
521
29
 
522
- return (
523
- <>
524
- <Button {...props} iconStart={Freeze}>
525
- With start icon
526
- </Button>
30
+ type Story = StoryObj<typeof Button>;
527
31
 
528
- <Button {...props} iconEnd={ArrowRight}>
529
- With end icon
530
- </Button>
32
+ export const Basic: Story = {};
531
33
 
532
- <Button {...props} iconStart={Freeze} iconEnd={ArrowRight}>
533
- With both icons
534
- </Button>
535
- </>
536
- );
537
- },
538
- argTypes: {
539
- ...hideControls([
540
- 'href',
541
- 'target',
542
- 'priority',
543
- 'sentiment',
544
- 'as',
545
- 'disabled',
546
- 'children',
547
- 'testId',
548
- ]),
34
+ export const Focused = storyConfig<Story>(
35
+ {
36
+ parameters: {
37
+ chromatic: {
38
+ delay: 1000,
39
+ },
40
+ },
41
+ play: async ({ canvasElement }) => {
42
+ const canvas = within(canvasElement);
43
+ await userEvent.click(canvas.getByRole('button'));
44
+ },
549
45
  },
550
- args: {
551
- size: 'md',
46
+ {
47
+ variants: ['dark'],
552
48
  },
553
- parameters: augmentIconProps(),
554
- decorators: [withComponentGrid()],
555
- };
556
-
557
- /**
558
- * Avatars are only supported for `md` size Buttons. <br />
559
- * [Design documentation](https://wise.design/components/button#accessories)
560
- */
561
- export const WithAvatars: StoryObj<PreviewStoryArgs> = {
562
- render: function Render(args: PreviewStoryArgs) {
563
- const [props] = getPropsForPreview(args);
564
-
565
- return (
566
- <>
567
- <Button {...props} avatars={[{ asset: <Freeze /> }]}>
568
- With single avatar
569
- </Button>
570
-
571
- <Button {...props} avatars={[{ asset: <Flag code="br" /> }, { asset: <Flag code="jp" /> }]}>
572
- With double avatar
573
- </Button>
574
-
575
- <Button {...props} avatars={[{ profileName: 'John Doe' }]}>
576
- With initials
577
- </Button>
49
+ );
578
50
 
579
- <Button {...props} avatars={[{ imgSrc: '../avatar-square-dude.webp' }]}>
580
- With an image
581
- </Button>
582
- </>
583
- );
584
- },
585
- argTypes: hideControls([
586
- 'href',
587
- 'target',
588
- 'priority',
589
- 'sentiment',
590
- 'as',
591
- 'disabled',
592
- 'children',
593
- 'testId',
594
- ]),
595
- args: {
596
- size: 'md',
597
- avatars: [],
598
- },
599
- parameters: {
600
- docs: {
601
- source: {
602
- code: `
603
- <>
604
- <Button v2 size="md" avatars={[{ asset: <Freeze /> }]}>
605
- With single avatar
606
- </Button>
607
-
608
- <Button v2 size="md" avatars={[{ asset: <Flag code="br" /> }, { asset: <Flag code="jp" /> }]}>
609
- With double avatar
610
- </Button>
611
-
612
- <Button v2 size="md" avatars={[{ profileName: 'John Doe' }]}>
613
- With initials
614
- </Button>
615
-
616
- <Button v2 size="md" avatars={[{ imgSrc: '../avatar-square-dude.webp' }]}>
617
- With image Avatar
618
- </Button>
619
- </>
620
- `,
621
- },
51
+ export const Variants = storyConfig<Story>(
52
+ {
53
+ render: (args) => {
54
+ return (
55
+ <>
56
+ <div className="m-b-2">
57
+ <div className="title-4 m-b-1">Accent</div>
58
+ <div className="d-flex flex-wrap" style={{ gap: 'var(--size-16)' }}>
59
+ <Button {...args} priority={Priority.PRIMARY} type={ControlType.ACCENT} />
60
+ <Button {...args} priority={Priority.SECONDARY} type={ControlType.ACCENT} />
61
+ <Button {...args} priority={Priority.TERTIARY} type={ControlType.ACCENT} />
62
+ </div>
63
+ </div>
64
+ <div className="m-b-2">
65
+ <div className="title-4 m-b-1">Positive</div>
66
+ <div className="d-flex flex-wrap" style={{ gap: 'var(--size-16)' }}>
67
+ <Button {...args} priority={Priority.PRIMARY} type={ControlType.POSITIVE} />
68
+ <Button {...args} priority={Priority.SECONDARY} type={ControlType.POSITIVE} />
69
+ </div>
70
+ </div>
71
+ <div className="m-b-2">
72
+ <div className="title-4 m-b-1">Negative</div>
73
+ <div className="d-flex flex-wrap" style={{ gap: 'var(--size-16)' }}>
74
+ <Button {...args} priority={Priority.PRIMARY} type={ControlType.NEGATIVE} />
75
+ <Button {...args} priority={Priority.SECONDARY} type={ControlType.NEGATIVE} />
76
+ </div>
77
+ </div>
78
+ <div className="m-b-2">
79
+ <div className="title-4 m-b-1">Disabled</div>
80
+ <div className="d-flex flex-wrap" style={{ gap: 'var(--size-16)' }}>
81
+ <Button {...args} priority={Priority.PRIMARY} disabled />
82
+ <Button {...args} priority={Priority.SECONDARY} disabled />
83
+ <Button {...args} priority={Priority.TERTIARY} disabled />
84
+ </div>
85
+ </div>
86
+ </>
87
+ );
622
88
  },
623
89
  },
624
- decorators: [withComponentGrid()],
625
- };
90
+ { variants: ['default', 'dark', 'rtl'] },
91
+ );
626
92
 
627
93
  /**
628
- * Avatar will always take precedence over `iconStart`
94
+ * The purpose of the `loading` mode is to convey a message to the
95
+ * user that some asynchronous process has been triggered, likely
96
+ * in response to their previous action.
97
+ *
98
+ * Although it carries some similarities with the `disabled` mode
99
+ * (users cannot activate a loading button), it's not hidden from
100
+ * the keyboard and assistive tech users (users can focus on it,
101
+ * and it's announced by screen readers), and is also much more
102
+ * accessible to sighted users due to its default, high contrast.
629
103
  */
630
- export const WithAvatarAndIcon: Story = {
631
- args: {
632
- size: 'md',
633
- iconStart: Freeze,
634
- avatars: [{ profileName: 'John Doe' }],
635
- iconEnd: ArrowRight,
636
- },
637
- argTypes: hideControls(['href', 'target', 'as', 'children', 'testId']),
638
- parameters: augmentIconProps(),
639
- };
640
-
641
- const buttonPriorities = ['primary', 'secondary', 'tertiary', 'minimal'] as const;
642
- const buttonSizes = ['sm', 'md', 'lg'] as const;
104
+ export const Loading = storyConfig<Story>(
105
+ {
106
+ render: (args) => {
107
+ return (
108
+ <div className="d-flex flex-wrap" style={{ gap: 'var(--size-16)' }}>
109
+ <Button {...args} loading priority={Priority.PRIMARY} />
110
+ <Button {...args} loading priority={Priority.SECONDARY} />
111
+ <Button {...args} loading priority={Priority.TERTIARY} />
112
+ <Button {...args} loading priority={Priority.PRIMARY} type={ControlType.NEGATIVE} />
113
+ <Button {...args} loading priority={Priority.SECONDARY} type={ControlType.NEGATIVE} />
114
+ </div>
115
+ );
116
+ },
117
+ args: {
118
+ loading: true,
119
+ },
120
+ },
121
+ { variants: ['default', 'dark', 'rtl'] },
122
+ );
643
123
 
644
- export const AllVariants = storyConfig(
124
+ export const SocialMedia = storyConfig<Story>(
645
125
  {
646
- tags: ['!autodocs'],
647
- parameters: {
648
- padding: '0',
649
- },
650
- render: () => (
651
- <div
652
- className="button-variants"
653
- style={{ display: 'flex', flexWrap: 'wrap', gap: '16px', maxWidth: '1200px' }}
654
- >
655
- {buttonPriorities.map((priority) =>
656
- buttonSizes.map((size) => (
657
- <div
658
- key={`${priority}-default-${size}`}
659
- style={{ flex: '1 0 30%', marginBottom: '16px', justifyContent: 'space-between' }}
660
- >
661
- <Button
662
- v2
663
- priority={priority as ButtonPriority}
664
- size={size}
665
- iconStart={ArrowLeft}
666
- iconEnd={ArrowRight}
667
- avatars={[{ asset: <Freeze /> }]}
668
- block
669
- href="https://wise.com"
670
- target="_blank"
671
- >
672
- {`${priority} default ${size}`}
673
- </Button>
674
- <Button
675
- className="m-t-1 m-b-1"
676
- v2
677
- priority={priority as ButtonPriority}
678
- size={size}
679
- iconStart={ArrowLeft}
680
- iconEnd={ArrowRight}
681
- avatars={[{ asset: <Freeze /> }, { asset: <Freeze /> }]}
682
- block
683
- disabled
684
- >
685
- {`${priority} default ${size} Disabled`}
686
- </Button>
687
- <Button
688
- v2
689
- priority={priority as ButtonPriority}
690
- size={size}
691
- iconStart={ArrowLeft}
692
- iconEnd={ArrowRight}
693
- avatars={[{ asset: <Freeze /> }]}
694
- block
695
- loading
696
- >
697
- {`${priority} default ${size} Loading`}
698
- </Button>
699
- </div>
700
- )),
701
- )}
702
- {['primary', 'secondary'].map((priority) =>
703
- buttonSizes.map((size) => (
704
- <div
705
- key={`${priority}-negative-${size}`}
706
- style={{ flex: '1 0 30%', marginBottom: '16px', justifyContent: 'space-between' }}
707
- >
708
- <Button
709
- v2
710
- sentiment="negative"
711
- priority={priority as ButtonPriority}
712
- size={size}
713
- iconStart={ArrowLeft}
714
- iconEnd={ArrowRight}
715
- avatars={[{ asset: <Freeze /> }]}
716
- block
717
- href="https://wise.com"
718
- target="_blank"
719
- >
720
- {`${priority} negative ${size}`}
721
- </Button>
722
- <Button
723
- className="m-t-1 m-b-1"
724
- v2
725
- sentiment="negative"
726
- priority={priority as ButtonPriority}
727
- size={size}
728
- iconStart={ArrowLeft}
729
- iconEnd={ArrowRight}
730
- avatars={[{ asset: <Freeze /> }]}
731
- block
732
- disabled
733
- >
734
- {`${priority} negative ${size} Disabled`}
735
- </Button>
736
- <Button
737
- v2
738
- sentiment="negative"
739
- priority={priority as ButtonPriority}
740
- size={size}
741
- iconStart={ArrowLeft}
742
- iconEnd={ArrowRight}
743
- avatars={[{ asset: <Freeze /> }]}
744
- block
745
- loading
746
- >
747
- {`${priority} negative ${size} Loading`}
748
- </Button>
749
- </div>
750
- )),
751
- )}
752
- </div>
753
- ),
754
- },
755
- { variants: ['default', 'dark', 'bright-green', 'forest-green'] },
126
+ render: () => {
127
+ return (
128
+ <>
129
+ <div className="m-b-2">
130
+ <button type="button" className="btn btn-google">
131
+ Login with Google
132
+ </button>
133
+ </div>
134
+ <div className="m-b-2">
135
+ <button type="button" className="btn btn-facebook">
136
+ Login with Facebook
137
+ </button>
138
+ </div>
139
+ <div className="m-b-2">
140
+ <button type="button" className="btn btn-lg btn-facebook">
141
+ Large Button
142
+ </button>
143
+ </div>
144
+ <div className="m-b-2">
145
+ <button type="button" className="btn btn-block btn-facebook">
146
+ Block Button
147
+ </button>
148
+ </div>
149
+ <div className="m-b-2">
150
+ <button type="button" className="btn btn-lg btn-block btn-facebook">
151
+ Large Block Button
152
+ </button>
153
+ </div>
154
+ </>
155
+ );
156
+ },
157
+ },
158
+ { variants: ['default', 'dark', 'rtl'] },
756
159
  );
160
+
161
+ export const SocialMediaMobile = storyConfig<Story>(SocialMedia, {
162
+ variants: ['default', 'dark', 'rtl', 'mobile'],
163
+ });