@transferwise/components 0.0.0-experimental-3d57e31 → 0.0.0-experimental-0315684

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