@transferwise/components 0.0.0-experimental-a656242 → 0.0.0-experimental-887f2e6

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