@transferwise/components 0.0.0-experimental-4c79cff → 0.0.0-experimental-3d434b1

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