@transferwise/components 0.0.0-experimental-3868cf1 → 0.0.0-experimental-69a95e1

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