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