@transferwise/components 0.0.0-experimental-db4013c → 0.0.0-experimental-bd6f8cc

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 (118) hide show
  1. package/build/avatarLayout/AvatarLayout.js +2 -9
  2. package/build/avatarLayout/AvatarLayout.js.map +1 -1
  3. package/build/avatarLayout/AvatarLayout.mjs +2 -9
  4. package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
  5. package/build/button/Button.js +79 -84
  6. package/build/button/Button.js.map +1 -1
  7. package/build/button/Button.mjs +80 -85
  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 +2 -2
  16. package/build/index.mjs +1 -1
  17. package/build/link/Link.js +3 -8
  18. package/build/link/Link.js.map +1 -1
  19. package/build/link/Link.mjs +3 -8
  20. package/build/link/Link.mjs.map +1 -1
  21. package/build/main.css +11 -226
  22. package/build/nudge/Nudge.js.map +1 -1
  23. package/build/nudge/Nudge.mjs.map +1 -1
  24. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +4 -2
  25. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
  26. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +4 -2
  27. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
  28. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +5 -3
  29. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
  30. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +5 -3
  31. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -1
  32. package/build/select/Select.js +2 -2
  33. package/build/select/Select.js.map +1 -1
  34. package/build/select/Select.mjs +1 -1
  35. package/build/styles/avatarLayout/AvatarLayout.css +0 -11
  36. package/build/styles/button/Button.css +15 -207
  37. package/build/styles/main.css +11 -226
  38. package/build/styles/nudge/Nudge.css +11 -0
  39. package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
  40. package/build/types/button/Button.d.ts +23 -2
  41. package/build/types/button/Button.d.ts.map +1 -1
  42. package/build/types/button/index.d.ts +2 -2
  43. package/build/types/button/index.d.ts.map +1 -1
  44. package/build/types/link/Link.d.ts +2 -2
  45. package/build/types/link/Link.d.ts.map +1 -1
  46. package/build/types/nudge/Nudge.d.ts +1 -1
  47. package/build/types/nudge/Nudge.d.ts.map +1 -1
  48. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts.map +1 -1
  49. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts +2 -6
  50. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts.map +1 -1
  51. package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts.map +1 -1
  52. package/build/types/test-utils/story-config.d.ts +1 -1
  53. package/build/types/test-utils/story-config.d.ts.map +1 -1
  54. package/build/upload/steps/completeStep/completeStep.js +2 -2
  55. package/build/upload/steps/completeStep/completeStep.js.map +1 -1
  56. package/build/upload/steps/completeStep/completeStep.mjs +1 -1
  57. package/build/upload/steps/processingStep/processingStep.js +2 -2
  58. package/build/upload/steps/processingStep/processingStep.js.map +1 -1
  59. package/build/upload/steps/processingStep/processingStep.mjs +1 -1
  60. package/build/uploadInput/UploadInput.js +3 -3
  61. package/build/uploadInput/UploadInput.js.map +1 -1
  62. package/build/uploadInput/UploadInput.mjs +1 -1
  63. package/package.json +3 -3
  64. package/src/alert/Alert.tests.story.tsx +1 -1
  65. package/src/avatarLayout/AvatarLayout.css +0 -11
  66. package/src/avatarLayout/AvatarLayout.less +1 -18
  67. package/src/avatarLayout/AvatarLayout.tsx +2 -10
  68. package/src/button/Button.css +15 -207
  69. package/src/button/Button.less +14 -214
  70. package/src/button/Button.spec.tsx +224 -188
  71. package/src/button/Button.story.tsx +135 -701
  72. package/src/button/Button.tsx +131 -97
  73. package/src/button/__snapshots__/Button.spec.tsx.snap +309 -0
  74. package/src/button/index.ts +3 -2
  75. package/src/field/Field.story.tsx +1 -1
  76. package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +2 -1
  77. package/src/inputs/SelectInput.story.tsx +1 -1
  78. package/src/label/Label.story.tsx +1 -1
  79. package/src/link/Link.tsx +6 -15
  80. package/src/main.css +11 -226
  81. package/src/main.less +0 -1
  82. package/src/nudge/Nudge.css +11 -0
  83. package/src/nudge/Nudge.less +3 -0
  84. package/src/nudge/Nudge.story.tsx +10 -0
  85. package/src/nudge/Nudge.tsx +2 -1
  86. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +8 -2
  87. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +2 -7
  88. package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +3 -1
  89. package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +12 -4
  90. package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +13 -16
  91. package/src/test-utils/Parameters.d.ts +1 -9
  92. package/src/test-utils/story-config.ts +1 -10
  93. package/build/button/Button.resolver.js +0 -74
  94. package/build/button/Button.resolver.js.map +0 -1
  95. package/build/button/Button.resolver.mjs +0 -72
  96. package/build/button/Button.resolver.mjs.map +0 -1
  97. package/build/button/LegacyButton.js +0 -114
  98. package/build/button/LegacyButton.js.map +0 -1
  99. package/build/button/LegacyButton.mjs +0 -112
  100. package/build/button/LegacyButton.mjs.map +0 -1
  101. package/build/styles/button/Button.vars.css +0 -46
  102. package/build/styles/button/LegacyButton.css +0 -23
  103. package/build/types/button/Button.resolver.d.ts +0 -33
  104. package/build/types/button/Button.resolver.d.ts.map +0 -1
  105. package/build/types/button/Button.types.d.ts +0 -67
  106. package/build/types/button/Button.types.d.ts.map +0 -1
  107. package/build/types/button/LegacyButton.d.ts +0 -30
  108. package/build/types/button/LegacyButton.d.ts.map +0 -1
  109. package/src/button/Button.resolver.tsx +0 -73
  110. package/src/button/Button.tests.story.tsx +0 -27
  111. package/src/button/Button.types.ts +0 -94
  112. package/src/button/Button.vars.css +0 -46
  113. package/src/button/Button.vars.less +0 -60
  114. package/src/button/LegacyButton.css +0 -23
  115. package/src/button/LegacyButton.less +0 -24
  116. package/src/button/LegacyButton.spec.tsx +0 -147
  117. package/src/button/LegacyButton.story.tsx +0 -220
  118. package/src/button/LegacyButton.tsx +0 -160
@@ -1,729 +1,163 @@
1
1
  import { Meta, StoryObj } from '@storybook/react';
2
- import { fn } from '@storybook/test';
3
- import {
4
- Freeze,
5
- ArrowRight,
6
- ArrowLeft,
7
- ArrowDiagonalDown,
8
- ArrowDiagonalUp,
9
- ChevronRight,
10
- ChevronLeft,
11
- } from '@transferwise/icons';
12
- import { Flag } from '@wise/art';
13
- import Button from './Button.resolver';
14
- import type { ButtonProps, ButtonPriority } from './Button.types';
15
- import { storyConfig } from '../test-utils';
16
-
17
- const withContainer = (Story: any) => (
18
- <div style={{ display: 'flex', justifyContent: 'center' }}>
19
- <Story />
20
- <Button v2 addonStart={{ icon: Freeze, avatars: [{ profileName: 'Test Test' }] }}>
21
- Button
22
- </Button>
23
-
24
- <Button v2 addonEnd={{ icon: Freeze }}>
25
- Button
26
- </Button>
27
- </div>
28
- );
29
-
30
- /**
31
- * Used for showing multiple components within a Canvas.
32
- * @decorator
33
- */
34
- const withComponentGrid =
35
- (maxWidth = 'auto') =>
36
- (Story: any) => (
37
- <div
38
- style={{
39
- width: '100%',
40
- placeItems: 'center',
41
- justifyContent: 'center',
42
- display: 'flex',
43
- flexWrap: 'wrap',
44
- gap: '2rem',
45
- maxWidth,
46
- }}
47
- >
48
- <Story />
49
- </div>
50
- );
51
-
52
- /**
53
- * Not all stories need access to all controls as it causes unnecessary UI noise.
54
- */
55
- const hideControls = (args: string[]) => {
56
- const hidden = [
57
- 'avatars',
58
- 'iconStart',
59
- 'iconEnd',
60
- 'onClick',
61
- 'onBlur',
62
- 'onFocus',
63
- 'onKeyDown',
64
- 'onMouseEnter',
65
- 'onMouseLeave',
66
- ...args,
67
- ];
68
-
69
- return Object.fromEntries(hidden.map((item) => [item, { table: { disable: true } }]));
70
- };
71
-
72
- /**
73
- * SB code generation is often not ideal, rendering confusing source.
74
- * This helper makes icon values more understandable for the stories below.
75
- */
76
- const augmentIconProps = ({ start = 'Freeze', end = 'ArrowRight' } = {}) => ({
77
- docs: {
78
- source: {
79
- transform(value: string): string {
80
- return value
81
- .replace(/iconStart=.*?\}+/g, `iconStart={${start}}`)
82
- .replace(/iconEnd=.*?\}+/g, `iconEnd={${end}}`);
83
- },
84
- },
85
- },
86
- });
2
+ import { userEvent, within, fn } from '@storybook/test';
87
3
 
88
- /**
89
- * Convenience controls for previewing rich markup,
90
- * not otherwise possible via Storybook
91
- */
92
- type PreviewStoryArgs = Parameters<typeof Button>[0] & {
93
- previewAvatars: boolean | ButtonProps['avatars'];
94
- previewIconStart: boolean | ButtonProps['iconStart'];
95
- previewIconEnd: boolean | ButtonProps['iconEnd'];
96
- };
97
- const previewArgTypes = {
98
- previewIconStart: {
99
- control: 'boolean',
100
- name: 'Show with `iconStart`',
101
- mapping: {
102
- true: Freeze,
103
- },
104
- table: {
105
- category: 'Preview options',
106
- },
107
- },
108
- previewIconEnd: {
109
- control: 'boolean',
110
- name: 'Show with `iconEnd`',
111
- mapping: {
112
- true: ArrowRight,
113
- },
114
- table: {
115
- category: 'Preview options',
116
- },
117
- },
118
- previewAvatars: {
119
- control: 'select',
120
- options: ['undefined', 'flag', 'initials', 'icon', 'image', 'double'],
121
- name: 'Show with Avatar',
122
- mapping: {
123
- undefined,
124
- flag: [{ asset: <Flag code="pl" /> }],
125
- initials: [{ profileName: 'Jay Jay' }],
126
- icon: [{ asset: <Freeze /> }],
127
- image: [{ imgSrc: '../avatar-square-dude.webp' }],
128
- double: [{ asset: <Flag code="gb" /> }, { imgSrc: '../avatar-square-dude.webp' }],
129
- },
130
- table: {
131
- category: 'Preview options',
132
- },
133
- },
134
- } as const;
135
-
136
- const getPropsForPreview = (args: PreviewStoryArgs) => {
137
- const { previewAvatars, previewIconStart, previewIconEnd, ...props } = args as {
138
- previewAvatars: ButtonProps['avatars'];
139
- previewIconStart: ButtonProps['iconStart'];
140
- previewIconEnd: ButtonProps['iconEnd'];
141
- props: typeof Button;
142
- };
4
+ import { ControlType, Priority } from '../common';
5
+ import { storyConfig } from '../test-utils';
143
6
 
144
- return [
145
- props,
146
- {
147
- avatars: previewAvatars,
148
- iconStart: previewIconStart,
149
- iconEnd: previewIconEnd,
150
- },
151
- ];
152
- };
7
+ import Button from './Button';
153
8
 
154
- const meta: Meta<typeof Button> = {
9
+ export default {
155
10
  component: Button,
156
11
  title: 'Actions/Button',
157
- argTypes: {
158
- v2: {
159
- table: {
160
- readonly: true,
161
- },
162
- },
163
- size: {
164
- type: {
165
- name: 'enum',
166
- value: ['lg', 'md', 'sm'],
167
- },
168
- table: {
169
- type: {
170
- summary: 'ButtonSize',
171
- },
172
- },
173
- },
174
- priority: {
175
- type: {
176
- name: 'enum',
177
- value: ['primary', 'secondary', 'tertiary', 'minimal'],
178
- },
179
- table: {
180
- type: {
181
- summary: 'ButtonPriority',
182
- },
183
- },
184
- },
185
- sentiment: {
186
- type: {
187
- name: 'enum',
188
- value: ['default', 'negative'],
189
- },
190
- table: {
191
- type: {
192
- summary: 'ButtonSentiment',
193
- },
194
- },
195
- },
196
- disabled: {
197
- description: 'Toggles the disabled state',
198
- table: {
199
- defaultValue: { summary: 'false' },
200
- },
201
- },
202
- loading: {
203
- description: 'Toggles the loading state',
204
- table: {
205
- defaultValue: { summary: 'false' },
206
- },
207
- },
208
- as: {
209
- table: {
210
- defaultValue: { summary: 'button' },
211
- },
212
- },
213
- block: {
214
- table: {
215
- defaultValue: { summary: 'false' },
216
- },
217
- },
218
- href: {
219
- type: {
220
- name: 'string',
221
- },
222
- description: 'If set, the component will render as an HTML anchor.',
223
- },
224
- iconStart: {
225
- control: 'object',
226
- },
227
- iconEnd: {
228
- control: 'object',
229
- },
230
- avatars: {
231
- control: 'object',
232
- },
233
- type: {
234
- table: {
235
- disable: true,
236
- },
237
- },
238
- htmlType: {
239
- table: {
240
- disable: true,
241
- },
242
- },
243
- },
244
12
  args: {
245
- v2: true,
246
- size: undefined,
247
- priority: undefined,
248
- sentiment: undefined,
249
- disabled: false,
13
+ children: 'Button text',
250
14
  loading: false,
251
- block: false,
252
- href: undefined,
253
- as: undefined,
254
- type: undefined,
255
- iconStart: undefined,
256
- iconEnd: undefined,
257
- avatars: undefined,
258
- className: undefined,
259
15
  onClick: fn(),
260
- children: 'Button text',
261
- },
262
- tags: ['autodocs'],
263
- decorators: [withContainer],
264
- };
265
-
266
- export default meta;
267
-
268
- type Story = StoryObj<typeof Button>;
269
-
270
- export const Playground: StoryObj<PreviewStoryArgs> = {
271
- render: function Render(args: PreviewStoryArgs) {
272
- const [props, previewProps] = getPropsForPreview(args);
273
-
274
- return <Button {...props} {...previewProps} v2 />;
275
- },
276
- args: {
277
16
  onBlur: fn(),
278
17
  onFocus: fn(),
279
- onKeyDown: fn(),
280
- onMouseEnter: fn(),
281
- onMouseLeave: fn(),
282
- previewIconStart: false,
283
- previewIconEnd: false,
284
- previewAvatars: false,
285
- },
286
- argTypes: {
287
- onClick: { table: { disable: true } },
288
- onBlur: { table: { disable: true } },
289
- onFocus: { table: { disable: true } },
290
- onKeyDown: { table: { disable: true } },
291
- onMouseEnter: { table: { disable: true } },
292
- onMouseLeave: { table: { disable: true } },
293
- ...previewArgTypes,
294
- },
295
- };
296
-
297
- /**
298
- * There are two different types of button that, default and negative,
299
- * these designed to emphasise the nature of the action. <br />
300
- * **NB:** Sentiment only applies to `primary` and `secondary` priorities. <br />
301
- * [Design documentation](https://wise.design/components/button#types)
302
- */
303
- export const Sentiment: StoryObj<PreviewStoryArgs> = {
304
- render: function Render(args: PreviewStoryArgs) {
305
- const [props, previewProps] = getPropsForPreview(args);
306
-
307
- return (
308
- <>
309
- <Button {...props} {...previewProps} v2>
310
- Default Sentiment
311
- </Button>
312
- <Button {...props} {...previewProps} v2 sentiment="negative">
313
- Negative Sentiment
314
- </Button>
315
- <Button {...props} {...previewProps} v2 priority="secondary">
316
- Default Sentiment
317
- </Button>
318
- <Button {...props} {...previewProps} v2 priority="secondary" sentiment="negative">
319
- Negative Sentiment
320
- </Button>
321
- </>
322
- );
323
- },
324
- argTypes: {
325
- ...hideControls(['sentiment', 'priority', 'block', 'href', 'target', 'as', 'children']),
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']),
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
18
  },
397
19
  argTypes: {
398
- ...hideControls(['size', 'block', 'href', 'target', 'as', 'children']),
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(['href', 'target', 'priority', 'sentiment', 'as', 'disabled', 'children']),
495
- ...previewArgTypes,
496
- },
497
- args: {
498
- block: true,
499
- previewIconStart: false,
500
- previewIconEnd: false,
501
- previewAvatars: false,
20
+ as: {
21
+ type: {
22
+ name: 'enum',
23
+ value: ['button', 'a'],
24
+ },
25
+ },
502
26
  },
503
- };
504
-
505
- /**
506
- * Icons are only supported for `sm` and `md` size Buttons. <br />
507
- * [Design documentation](https://wise.design/components/button#accessories)
508
- */
509
- export const WithIcons: StoryObj<PreviewStoryArgs> = {
510
- render: function Render(args: PreviewStoryArgs) {
511
- const [props] = getPropsForPreview(args);
27
+ tags: ['autodocs'],
28
+ } satisfies Meta<typeof Button>;
512
29
 
513
- return (
514
- <>
515
- <Button {...props} iconStart={Freeze}>
516
- With start icon
517
- </Button>
30
+ type Story = StoryObj<typeof Button>;
518
31
 
519
- <Button {...props} iconEnd={ArrowRight}>
520
- With end icon
521
- </Button>
32
+ export const Basic: Story = {};
522
33
 
523
- <Button {...props} iconStart={Freeze} iconEnd={ArrowRight}>
524
- With both icons
525
- </Button>
526
- </>
527
- );
528
- },
529
- argTypes: {
530
- ...hideControls(['href', 'target', 'priority', 'sentiment', 'as', 'disabled', 'children']),
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
+ },
531
45
  },
532
- args: {
533
- size: 'md',
46
+ {
47
+ variants: ['dark'],
534
48
  },
535
- parameters: augmentIconProps(),
536
- decorators: [withComponentGrid()],
537
- };
538
-
539
- /**
540
- * Avatars are only supported for `md` size Buttons. <br />
541
- * [Design documentation](https://wise.design/components/button#accessories)
542
- */
543
- export const WithAvatars: StoryObj<PreviewStoryArgs> = {
544
- render: function Render(args: PreviewStoryArgs) {
545
- const [props] = getPropsForPreview(args);
546
-
547
- return (
548
- <>
549
- <Button {...props} avatars={[{ asset: <Freeze /> }]}>
550
- With single avatar
551
- </Button>
552
-
553
- <Button {...props} avatars={[{ asset: <Flag code="br" /> }, { asset: <Flag code="jp" /> }]}>
554
- With double avatar
555
- </Button>
556
-
557
- <Button {...props} avatars={[{ profileName: 'John Doe' }]}>
558
- With initials
559
- </Button>
49
+ );
560
50
 
561
- <Button {...props} avatars={[{ imgSrc: '../avatar-square-dude.webp' }]}>
562
- With an image
563
- </Button>
564
- </>
565
- );
566
- },
567
- argTypes: hideControls(['href', 'target', 'priority', 'sentiment', 'as', 'disabled', 'children']),
568
- args: {
569
- size: 'md',
570
- avatars: [],
571
- },
572
- parameters: {
573
- docs: {
574
- source: {
575
- code: `
576
- <>
577
- <Button v2 size="md" avatars={[{ asset: <Freeze /> }]}>
578
- With single avatar
579
- </Button>
580
-
581
- <Button v2 size="md" avatars={[{ asset: <Flag code="br" /> }, { asset: <Flag code="jp" /> }]}>
582
- With double avatar
583
- </Button>
584
-
585
- <Button v2 size="md" avatars={[{ profileName: 'John Doe' }]}>
586
- With initials
587
- </Button>
588
-
589
- <Button v2 size="md" avatars={[{ imgSrc: '../avatar-square-dude.webp' }]}>
590
- With image Avatar
591
- </Button>
592
- </>
593
- `,
594
- },
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
+ );
595
88
  },
596
89
  },
597
- decorators: [withComponentGrid()],
598
- };
90
+ { variants: ['default', 'dark', 'rtl'] },
91
+ );
599
92
 
600
93
  /**
601
- * 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.
602
103
  */
603
- export const WithAvatarAndIcon: Story = {
604
- args: {
605
- size: 'md',
606
- iconStart: Freeze,
607
- avatars: [{ profileName: 'John Doe' }],
608
- iconEnd: ArrowRight,
609
- },
610
- argTypes: hideControls(['href', 'target', 'as', 'children']),
611
- parameters: augmentIconProps(),
612
- };
613
-
614
- const buttonPriorities = ['primary', 'secondary', 'tertiary', 'minimal'] as const;
615
- 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
+ );
616
123
 
617
- export const AllVariants = storyConfig(
124
+ export const SocialMedia = storyConfig<Story>(
618
125
  {
619
- tags: ['!autodocs'],
620
- parameters: {
621
- padding: '0',
622
- },
623
- render: () => (
624
- <div
625
- className="button-variants"
626
- style={{ display: 'flex', flexWrap: 'wrap', gap: '16px', maxWidth: '1200px' }}
627
- >
628
- {buttonPriorities.map((priority) =>
629
- buttonSizes.map((size) => (
630
- <div
631
- key={`${priority}-default-${size}`}
632
- style={{ flex: '1 0 30%', marginBottom: '16px', justifyContent: 'space-between' }}
633
- >
634
- <Button
635
- v2
636
- priority={priority as ButtonPriority}
637
- size={size}
638
- iconStart={ArrowLeft}
639
- iconEnd={ArrowRight}
640
- avatars={[{ asset: <Freeze /> }]}
641
- block
642
- href="https://wise.com"
643
- target="_blank"
644
- >
645
- {`${priority} default ${size}`}
646
- </Button>
647
- <Button
648
- className="m-t-1 m-b-1"
649
- v2
650
- priority={priority as ButtonPriority}
651
- size={size}
652
- iconStart={ArrowLeft}
653
- iconEnd={ArrowRight}
654
- avatars={[{ asset: <Freeze /> }, { asset: <Freeze /> }]}
655
- block
656
- disabled
657
- >
658
- {`${priority} default ${size} Disabled`}
659
- </Button>
660
- <Button
661
- v2
662
- priority={priority as ButtonPriority}
663
- size={size}
664
- iconStart={ArrowLeft}
665
- iconEnd={ArrowRight}
666
- avatars={[{ asset: <Freeze /> }]}
667
- block
668
- loading
669
- >
670
- {`${priority} default ${size} Loading`}
671
- </Button>
672
- </div>
673
- )),
674
- )}
675
- {['primary', 'secondary'].map((priority) =>
676
- buttonSizes.map((size) => (
677
- <div
678
- key={`${priority}-negative-${size}`}
679
- style={{ flex: '1 0 30%', marginBottom: '16px', justifyContent: 'space-between' }}
680
- >
681
- <Button
682
- v2
683
- sentiment="negative"
684
- priority={priority as ButtonPriority}
685
- size={size}
686
- iconStart={ChevronLeft}
687
- iconEnd={ChevronRight}
688
- avatars={[{ asset: <Freeze /> }]}
689
- block
690
- href="https://wise.com"
691
- target="_blank"
692
- >
693
- {`${priority} negative ${size}`}
694
- </Button>
695
- <Button
696
- className="m-t-1 m-b-1"
697
- v2
698
- sentiment="negative"
699
- priority={priority as ButtonPriority}
700
- size={size}
701
- iconStart={ChevronLeft}
702
- iconEnd={ChevronRight}
703
- avatars={[{ asset: <Freeze /> }]}
704
- block
705
- disabled
706
- >
707
- {`${priority} negative ${size} Disabled`}
708
- </Button>
709
- <Button
710
- v2
711
- sentiment="negative"
712
- priority={priority as ButtonPriority}
713
- size={size}
714
- iconStart={ChevronLeft}
715
- iconEnd={ChevronRight}
716
- avatars={[{ asset: <Freeze /> }]}
717
- block
718
- loading
719
- >
720
- {`${priority} negative ${size} Loading`}
721
- </Button>
722
- </div>
723
- )),
724
- )}
725
- </div>
726
- ),
727
- },
728
- { variants: ['default', 'dark', 'bright-green', 'forest-green', 'rtl'] },
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'] },
729
159
  );
160
+
161
+ export const SocialMediaMobile = storyConfig<Story>(SocialMedia, {
162
+ variants: ['default', 'dark', 'rtl', 'mobile'],
163
+ });