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