@transferwise/components 0.0.0-experimental-58ab0d7 → 0.0.0-experimental-4530892

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 (179) 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/avatarView/AvatarView.js +12 -1
  6. package/build/avatarView/AvatarView.js.map +1 -1
  7. package/build/avatarView/AvatarView.mjs +12 -1
  8. package/build/avatarView/AvatarView.mjs.map +1 -1
  9. package/build/button/Button.js +79 -78
  10. package/build/button/Button.js.map +1 -1
  11. package/build/button/Button.mjs +80 -79
  12. package/build/button/Button.mjs.map +1 -1
  13. package/build/circularButton/CircularButton.js +18 -21
  14. package/build/circularButton/CircularButton.js.map +1 -1
  15. package/build/circularButton/CircularButton.mjs +19 -22
  16. package/build/circularButton/CircularButton.mjs.map +1 -1
  17. package/build/criticalBanner/CriticalCommsBanner.js +2 -2
  18. package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
  19. package/build/criticalBanner/CriticalCommsBanner.mjs +1 -1
  20. package/build/definitionList/DefinitionList.js.map +1 -1
  21. package/build/definitionList/DefinitionList.mjs.map +1 -1
  22. package/build/header/Header.js +2 -2
  23. package/build/header/Header.js.map +1 -1
  24. package/build/header/Header.mjs +1 -1
  25. package/build/i18n/de.json +1 -0
  26. package/build/i18n/de.json.js +1 -0
  27. package/build/i18n/de.json.js.map +1 -1
  28. package/build/i18n/de.json.mjs +1 -0
  29. package/build/i18n/de.json.mjs.map +1 -1
  30. package/build/i18n/it.json +1 -0
  31. package/build/i18n/it.json.js +1 -0
  32. package/build/i18n/it.json.js.map +1 -1
  33. package/build/i18n/it.json.mjs +1 -0
  34. package/build/i18n/it.json.mjs.map +1 -1
  35. package/build/i18n/ja.json +1 -0
  36. package/build/i18n/ja.json.js +1 -0
  37. package/build/i18n/ja.json.js.map +1 -1
  38. package/build/i18n/ja.json.mjs +1 -0
  39. package/build/i18n/ja.json.mjs.map +1 -1
  40. package/build/i18n/pt.json +1 -0
  41. package/build/i18n/pt.json.js +1 -0
  42. package/build/i18n/pt.json.js.map +1 -1
  43. package/build/i18n/pt.json.mjs +1 -0
  44. package/build/i18n/pt.json.mjs.map +1 -1
  45. package/build/i18n/ru.json +1 -0
  46. package/build/i18n/ru.json.js +1 -0
  47. package/build/i18n/ru.json.js.map +1 -1
  48. package/build/i18n/ru.json.mjs +1 -0
  49. package/build/i18n/ru.json.mjs.map +1 -1
  50. package/build/i18n/th.json +1 -0
  51. package/build/i18n/th.json.js +1 -0
  52. package/build/i18n/th.json.js.map +1 -1
  53. package/build/i18n/th.json.mjs +1 -0
  54. package/build/i18n/th.json.mjs.map +1 -1
  55. package/build/i18n/zh-HK.json +1 -0
  56. package/build/i18n/zh-HK.json.js +1 -0
  57. package/build/i18n/zh-HK.json.js.map +1 -1
  58. package/build/i18n/zh-HK.json.mjs +1 -0
  59. package/build/i18n/zh-HK.json.mjs.map +1 -1
  60. package/build/index.js +2 -2
  61. package/build/index.mjs +1 -1
  62. package/build/link/Link.js +3 -8
  63. package/build/link/Link.js.map +1 -1
  64. package/build/link/Link.mjs +3 -8
  65. package/build/link/Link.mjs.map +1 -1
  66. package/build/main.css +17 -419
  67. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +3 -1
  68. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
  69. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +3 -1
  70. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
  71. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +4 -1
  72. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
  73. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +4 -1
  74. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -1
  75. package/build/select/Select.js +3 -5
  76. package/build/select/Select.js.map +1 -1
  77. package/build/select/Select.mjs +2 -4
  78. package/build/select/Select.mjs.map +1 -1
  79. package/build/styles/avatarLayout/AvatarLayout.css +0 -11
  80. package/build/styles/button/Button.css +16 -243
  81. package/build/styles/circularButton/CircularButton.css +17 -158
  82. package/build/styles/main.css +17 -419
  83. package/build/types/avatarLayout/AvatarLayout.d.ts +2 -1
  84. package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
  85. package/build/types/avatarLayout/index.d.ts +0 -1
  86. package/build/types/avatarLayout/index.d.ts.map +1 -1
  87. package/build/types/avatarView/AvatarView.d.ts.map +1 -1
  88. package/build/types/button/Button.d.ts +23 -1
  89. package/build/types/button/Button.d.ts.map +1 -1
  90. package/build/types/button/index.d.ts +2 -2
  91. package/build/types/button/index.d.ts.map +1 -1
  92. package/build/types/circularButton/CircularButton.d.ts +11 -4
  93. package/build/types/circularButton/CircularButton.d.ts.map +1 -1
  94. package/build/types/definitionList/DefinitionList.d.ts +1 -2
  95. package/build/types/definitionList/DefinitionList.d.ts.map +1 -1
  96. package/build/types/link/Link.d.ts +2 -2
  97. package/build/types/link/Link.d.ts.map +1 -1
  98. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts.map +1 -1
  99. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts +1 -1
  100. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts.map +1 -1
  101. package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts.map +1 -1
  102. package/build/types/select/Select.d.ts.map +1 -1
  103. package/build/upload/steps/completeStep/completeStep.js +2 -2
  104. package/build/upload/steps/completeStep/completeStep.js.map +1 -1
  105. package/build/upload/steps/completeStep/completeStep.mjs +1 -1
  106. package/build/upload/steps/processingStep/processingStep.js +2 -2
  107. package/build/upload/steps/processingStep/processingStep.js.map +1 -1
  108. package/build/upload/steps/processingStep/processingStep.mjs +1 -1
  109. package/build/uploadInput/UploadInput.js +3 -3
  110. package/build/uploadInput/UploadInput.js.map +1 -1
  111. package/build/uploadInput/UploadInput.mjs +1 -1
  112. package/package.json +3 -3
  113. package/src/avatarLayout/AvatarLayout.css +0 -11
  114. package/src/avatarLayout/AvatarLayout.less +1 -18
  115. package/src/avatarLayout/AvatarLayout.tsx +3 -11
  116. package/src/avatarLayout/index.ts +0 -1
  117. package/src/avatarView/AvatarView.tsx +15 -1
  118. package/src/button/Button.css +16 -243
  119. package/src/button/Button.less +14 -212
  120. package/src/button/Button.spec.tsx +231 -54
  121. package/src/button/Button.story.tsx +137 -644
  122. package/src/button/Button.tsx +132 -98
  123. package/src/button/__snapshots__/Button.spec.tsx.snap +309 -0
  124. package/src/button/index.ts +3 -2
  125. package/src/circularButton/CircularButton.css +17 -158
  126. package/src/circularButton/CircularButton.less +22 -91
  127. package/src/circularButton/CircularButton.story.tsx +45 -24
  128. package/src/circularButton/CircularButton.tsx +38 -25
  129. package/src/dateInput/DateInput.spec.tsx +45 -26
  130. package/src/definitionList/DefinitionList.story.tsx +57 -57
  131. package/src/definitionList/DefinitionList.tsx +1 -1
  132. package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +1 -1
  133. package/src/i18n/de.json +1 -0
  134. package/src/i18n/it.json +1 -0
  135. package/src/i18n/ja.json +1 -0
  136. package/src/i18n/pt.json +1 -0
  137. package/src/i18n/ru.json +1 -0
  138. package/src/i18n/th.json +1 -0
  139. package/src/i18n/zh-HK.json +1 -0
  140. package/src/iconButton/IconButton.story.tsx +6 -6
  141. package/src/inputs/SelectInput.story.tsx +1 -1
  142. package/src/link/Link.tsx +6 -15
  143. package/src/main.css +17 -419
  144. package/src/main.less +0 -1
  145. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +7 -1
  146. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +1 -1
  147. package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +3 -1
  148. package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +8 -1
  149. package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +5 -2
  150. package/src/select/Select.tsx +0 -1
  151. package/src/slidingPanel/SlidingPanel.spec.tsx +69 -0
  152. package/build/button/Button.resolver.js +0 -78
  153. package/build/button/Button.resolver.js.map +0 -1
  154. package/build/button/Button.resolver.mjs +0 -76
  155. package/build/button/Button.resolver.mjs.map +0 -1
  156. package/build/button/LegacyButton.js +0 -114
  157. package/build/button/LegacyButton.js.map +0 -1
  158. package/build/button/LegacyButton.mjs +0 -112
  159. package/build/button/LegacyButton.mjs.map +0 -1
  160. package/build/styles/button/Button.vars.css +0 -55
  161. package/build/styles/button/LegacyButton.css +0 -23
  162. package/build/types/button/Button.resolver.d.ts +0 -31
  163. package/build/types/button/Button.resolver.d.ts.map +0 -1
  164. package/build/types/button/Button.types.d.ts +0 -70
  165. package/build/types/button/Button.types.d.ts.map +0 -1
  166. package/build/types/button/LegacyButton.d.ts +0 -30
  167. package/build/types/button/LegacyButton.d.ts.map +0 -1
  168. package/src/button/Button.resolver.tsx +0 -120
  169. package/src/button/Button.types.ts +0 -93
  170. package/src/button/Button.vars.css +0 -55
  171. package/src/button/Button.vars.less +0 -69
  172. package/src/button/LegacyButton.css +0 -23
  173. package/src/button/LegacyButton.less +0 -24
  174. package/src/button/LegacyButton.spec.tsx +0 -146
  175. package/src/button/LegacyButton.story.tsx +0 -224
  176. package/src/button/LegacyButton.tsx +0 -161
  177. package/src/circularButton/_button-label-states.less +0 -34
  178. package/src/definitionList/DefinitionList.spec.js +0 -91
  179. package/src/slidingPanel/SlidingPanel.spec.js +0 -56
@@ -1,670 +1,163 @@
1
1
  import { Meta, StoryObj } from '@storybook/react';
2
- import { fn } from '@storybook/test';
3
- import { Freeze, ArrowRight, Bank } from '@transferwise/icons';
4
- import { Flag } from '@wise/art';
5
- import Button from './Button.resolver';
6
- import type { ButtonProps } from './Button.types';
7
- import AvatarLayout from '../avatarLayout';
2
+ import { userEvent, within, fn } from '@storybook/test';
8
3
 
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
- );
4
+ import { ControlType, Priority } from '../common';
5
+ import { storyConfig } from '../test-utils';
36
6
 
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
- });
7
+ import Button from './Button';
72
8
 
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;
120
-
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
- };
128
-
129
- return [
130
- props,
131
- {
132
- avatars: previewAvatars,
133
- iconStart: previewIconStart,
134
- iconEnd: previewIconEnd,
135
- },
136
- ];
137
- };
138
-
139
- const meta: Meta<typeof Button> = {
9
+ export default {
140
10
  component: Button,
141
11
  title: 'Actions/Button',
12
+ args: {
13
+ children: 'Button text',
14
+ loading: false,
15
+ onClick: fn(),
16
+ onBlur: fn(),
17
+ onFocus: fn(),
18
+ },
142
19
  argTypes: {
143
- v2: {
144
- table: {
145
- readonly: true,
146
- },
147
- },
148
20
  as: {
149
- table: {
150
- defaultValue: { summary: 'button' },
151
- },
152
- },
153
- size: {
154
- type: {
155
- name: 'enum',
156
- value: ['lg', 'md', 'sm'],
157
- },
158
- table: {
159
- type: {
160
- summary: 'ButtonSize',
161
- },
162
- },
163
- },
164
- priority: {
165
21
  type: {
166
22
  name: 'enum',
167
- value: ['primary', 'secondary', 'tertiary', 'minimal'],
168
- },
169
- table: {
170
- type: {
171
- summary: 'ButtonPriority',
172
- },
173
- },
174
- },
175
- sentiment: {
176
- type: {
177
- name: 'enum',
178
- value: ['default', 'negative'],
179
- },
180
- table: {
181
- type: {
182
- summary: 'ButtonSentiment',
183
- },
184
- },
185
- },
186
- disabled: {
187
- table: {
188
- defaultValue: { summary: 'false' },
189
- },
190
- },
191
- loading: {
192
- table: {
193
- defaultValue: { summary: 'false' },
194
- },
195
- },
196
- block: {
197
- table: {
198
- defaultValue: { summary: 'false' },
199
- },
200
- },
201
- href: {
202
- type: {
203
- name: 'string',
204
- },
205
- },
206
- iconStart: {
207
- control: 'object',
208
- },
209
- iconEnd: {
210
- control: 'object',
211
- },
212
- avatars: {
213
- control: 'object',
214
- },
215
- type: {
216
- table: {
217
- disable: true,
218
- },
219
- },
220
- htmlType: {
221
- table: {
222
- disable: true,
223
- },
224
- },
225
- 'data-testid': {
226
- table: {
227
- disable: true,
23
+ value: ['button', 'a'],
228
24
  },
229
25
  },
230
26
  },
231
- args: {
232
- v2: true,
233
- as: undefined,
234
- size: undefined,
235
- priority: undefined,
236
- sentiment: undefined,
237
- disabled: false,
238
- loading: false,
239
- block: false,
240
- iconStart: undefined,
241
- iconEnd: undefined,
242
- avatars: undefined,
243
- href: undefined,
244
- target: undefined,
245
- type: undefined,
246
- testId: undefined,
247
- className: '',
248
- onClick: fn(),
249
- children: 'Button text',
250
- },
251
27
  tags: ['autodocs'],
252
- decorators: [withContainer],
253
- };
254
-
255
- export default meta;
28
+ } satisfies Meta<typeof Button>;
256
29
 
257
30
  type Story = StoryObj<typeof Button>;
258
31
 
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
- onBlur: fn(),
267
- 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
- },
395
- 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
- export const Test: StoryObj<PreviewStoryArgs> = {
408
- render: function Render(args: PreviewStoryArgs) {
409
- return (
410
- <div>
411
- <Button
412
- v2
413
- size="sm"
414
- startMedia={<AvatarLayout size={24} avatars={[{ profileName: 'Test Test' }]} />}
415
- endMedia={<Bank />}
416
- >
417
- Button as anchor
418
- </Button>
419
- <Button
420
- v2
421
- size="md"
422
- startMedia={<AvatarLayout size={24} avatars={[{ profileName: 'Test Test' }]} />}
423
- endMedia={<Bank />}
424
- >
425
- Button as anchor
426
- </Button>
427
- <Button
428
- v2
429
- size="lg"
430
- startMedia={<AvatarLayout size={24} avatars={[{ profileName: 'Test Test' }]} />}
431
- endMedia={<Bank size={24} />}
432
- >
433
- Button as anchor
434
- </Button>
435
- </div>
436
- );
437
- },
438
- };
439
-
440
- /**
441
- * A Button rendered as an anchor element.
442
- */
443
- export const AsAnchor: StoryObj<PreviewStoryArgs> = {
444
- render: function Render(args: PreviewStoryArgs) {
445
- const [props, previewProps] = getPropsForPreview(args);
446
-
447
- return (
448
- <Button {...props} {...previewProps}>
449
- Button as anchor
450
- </Button>
451
- );
452
- },
453
- argTypes: {
454
- ...hideControls(['block']),
455
- ...previewArgTypes,
456
- },
457
- args: {
458
- as: 'a',
459
- href: 'https://wise.com',
460
- previewIconStart: false,
461
- previewIconEnd: false,
462
- previewAvatars: false,
463
- onClick: undefined,
464
- },
465
- };
466
-
467
- export const Disabled: StoryObj<PreviewStoryArgs> = {
468
- render: function Render(args: PreviewStoryArgs) {
469
- const [props, previewProps] = getPropsForPreview(args);
470
-
471
- return (
472
- <Button {...props} {...previewProps}>
473
- Disabled button
474
- </Button>
475
- );
476
- },
477
- argTypes: {
478
- ...hideControls(['block']),
479
- ...previewArgTypes,
480
- },
481
- args: {
482
- disabled: true,
483
- previewIconStart: false,
484
- previewIconEnd: false,
485
- previewAvatars: false,
486
- },
487
- };
488
-
489
- export const Loading: StoryObj<PreviewStoryArgs> = {
490
- render: function Render(args: PreviewStoryArgs) {
491
- const [props, previewProps] = getPropsForPreview(args);
32
+ export const Basic: Story = {};
492
33
 
493
- return (
494
- <Button {...props} {...previewProps}>
495
- Button as anchor
496
- </Button>
497
- );
498
- },
499
- argTypes: {
500
- ...hideControls(['block']),
501
- ...previewArgTypes,
502
- },
503
- args: {
504
- loading: true,
505
- previewIconStart: false,
506
- previewIconEnd: false,
507
- previewAvatars: false,
508
- },
509
- };
510
-
511
- /**
512
- * A Button that takes up the full width of its container (`display: block`).
513
- */
514
- export const DisplayBlock: StoryObj<PreviewStoryArgs> = {
515
- render: function Render(args: PreviewStoryArgs) {
516
- const [props, previewProps] = getPropsForPreview(args);
517
-
518
- return (
519
- <Button {...props} {...previewProps}>
520
- Full-width button
521
- </Button>
522
- );
523
- },
524
- argTypes: {
525
- ...hideControls([
526
- 'href',
527
- 'target',
528
- 'priority',
529
- 'sentiment',
530
- 'as',
531
- 'disabled',
532
- 'children',
533
- 'testId',
534
- ]),
535
- ...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
+ },
536
45
  },
537
- args: {
538
- block: true,
539
- previewIconStart: false,
540
- previewIconEnd: false,
541
- previewAvatars: false,
46
+ {
47
+ variants: ['dark'],
542
48
  },
543
- };
544
-
545
- /**
546
- * Icons are only supported for `sm` and `md` size Buttons. <br />
547
- * [Design documentation](https://wise.design/components/button#accessories)
548
- */
549
- export const WithIcons: StoryObj<PreviewStoryArgs> = {
550
- render: function Render(args: PreviewStoryArgs) {
551
- const [props] = getPropsForPreview(args);
552
-
553
- return (
554
- <>
555
- <Button {...props} iconStart={Freeze}>
556
- With start icon
557
- </Button>
558
-
559
- <Button {...props} iconEnd={ArrowRight}>
560
- With end icon
561
- </Button>
49
+ );
562
50
 
563
- <Button {...props} iconStart={Freeze} iconEnd={ArrowRight}>
564
- With both icons
565
- </Button>
566
- </>
567
- );
568
- },
569
- argTypes: {
570
- ...hideControls([
571
- 'href',
572
- 'target',
573
- 'priority',
574
- 'sentiment',
575
- 'as',
576
- 'disabled',
577
- 'children',
578
- 'testId',
579
- ]),
580
- },
581
- args: {
582
- size: 'md',
583
- },
584
- parameters: augmentIconProps(),
585
- decorators: [withComponentGrid()],
586
- };
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
+ );
587
92
 
588
93
  /**
589
- * Avatars are only supported for `md` size Buttons. <br />
590
- * [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.
591
103
  */
592
- export const WithAvatars: StoryObj<PreviewStoryArgs> = {
593
- render: function Render(args: PreviewStoryArgs) {
594
- const [props] = getPropsForPreview(args);
595
-
596
- return (
597
- <>
598
- <Button {...props} avatars={[{ asset: <Freeze /> }]}>
599
- With single avatar
600
- </Button>
601
-
602
- <Button {...props} avatars={[{ asset: <Flag code="br" /> }, { asset: <Flag code="jp" /> }]}>
603
- With double avatar
604
- </Button>
605
-
606
- <Button {...props} avatars={[{ profileName: 'John Doe' }]}>
607
- With initials
608
- </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
+ );
609
123
 
610
- <Button {...props} avatars={[{ imgSrc: '../avatar-square-dude.webp' }]}>
611
- With an image
612
- </Button>
613
- </>
614
- );
615
- },
616
- argTypes: hideControls([
617
- 'href',
618
- 'target',
619
- 'priority',
620
- 'sentiment',
621
- 'as',
622
- 'disabled',
623
- 'children',
624
- 'testId',
625
- ]),
626
- args: {
627
- size: 'md',
628
- avatars: [],
629
- },
630
- parameters: {
631
- docs: {
632
- source: {
633
- code: `
634
- <>
635
- <Button v2 size="md" avatars={[{ asset: <Freeze /> }]}>
636
- With single avatar
637
- </Button>
638
-
639
- <Button v2 size="md" avatars={[{ asset: <Flag code="br" /> }, { asset: <Flag code="jp" /> }]}>
640
- With double avatar
641
- </Button>
642
-
643
- <Button v2 size="md" avatars={[{ profileName: 'John Doe' }]}>
644
- With initials
645
- </Button>
646
-
647
- <Button v2 size="md" avatars={[{ imgSrc: '../avatar-square-dude.webp' }]}>
648
- With image Avatar
649
- </Button>
650
- </>
651
- `,
652
- },
653
- },
654
- },
655
- decorators: [withComponentGrid()],
656
- };
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
+ );
657
160
 
658
- /**
659
- * Avatar will always take precedence over `iconStart`
660
- */
661
- export const WithAvatarAndIcon: Story = {
662
- args: {
663
- size: 'md',
664
- iconStart: Freeze,
665
- avatars: [{ profileName: 'John Doe' }],
666
- iconEnd: ArrowRight,
667
- },
668
- argTypes: hideControls(['href', 'target', 'as', 'children', 'testId']),
669
- parameters: augmentIconProps(),
670
- };
161
+ export const SocialMediaMobile = storyConfig<Story>(SocialMedia, {
162
+ variants: ['default', 'dark', 'rtl', 'mobile'],
163
+ });