@transferwise/components 0.0.0-experimental-4c79cff → 0.0.0-experimental-28a3dd5

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