@transferwise/components 0.0.0-experimental-3d57e31 → 0.0.0-experimental-0315684
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 +4 -2
- package/build/index.js.map +1 -1
- package/build/index.mjs +2 -1
- package/build/index.mjs.map +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 -223
- 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 +2 -2
- package/build/select/Select.js.map +1 -1
- package/build/select/Select.mjs +1 -1
- package/build/styles/avatarLayout/AvatarLayout.css +0 -11
- package/build/styles/button/Button.css +15 -204
- package/build/styles/main.css +0 -223
- package/build/table/Table.js +166 -0
- package/build/table/Table.js.map +1 -0
- package/build/table/Table.messages.js +24 -0
- package/build/table/Table.messages.js.map +1 -0
- package/build/table/Table.messages.mjs +22 -0
- package/build/table/Table.messages.mjs.map +1 -0
- package/build/table/Table.mjs +164 -0
- package/build/table/Table.mjs.map +1 -0
- package/build/table/TableCell.js +86 -0
- package/build/table/TableCell.js.map +1 -0
- package/build/table/TableCell.mjs +84 -0
- package/build/table/TableCell.mjs.map +1 -0
- package/build/table/TableHeader.js +57 -0
- package/build/table/TableHeader.js.map +1 -0
- package/build/table/TableHeader.mjs +55 -0
- package/build/table/TableHeader.mjs.map +1 -0
- package/build/table/TableRow.js +85 -0
- package/build/table/TableRow.js.map +1 -0
- package/build/table/TableRow.mjs +83 -0
- package/build/table/TableRow.mjs.map +1 -0
- package/build/table/TableStatusText.js +54 -0
- package/build/table/TableStatusText.js.map +1 -0
- package/build/table/TableStatusText.mjs +52 -0
- package/build/table/TableStatusText.mjs.map +1 -0
- package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
- package/build/types/button/Button.d.ts +23 -2
- 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/index.d.ts +2 -0
- package/build/types/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 +2 -6
- 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/primitives/PrimitiveButton/src/PrimitiveButton.types.d.ts +0 -1
- package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.types.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 +2 -10
- package/src/button/Button.css +15 -204
- package/src/button/Button.less +14 -211
- package/src/button/Button.spec.tsx +227 -75
- package/src/button/Button.story.tsx +138 -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/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +1 -1
- package/src/index.ts +12 -0
- package/src/inputs/SelectInput.story.tsx +1 -1
- package/src/link/Link.tsx +6 -15
- package/src/main.css +0 -223
- package/src/main.less +0 -1
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +7 -1
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +2 -7
- package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +3 -1
- package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +8 -1
- package/src/primitives/PrimitiveButton/src/PrimitiveButton.types.ts +0 -2
- package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +5 -2
- package/build/button/Button.resolver.js +0 -75
- package/build/button/Button.resolver.js.map +0 -1
- package/build/button/Button.resolver.mjs +0 -73
- 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 -39
- package/build/styles/button/LegacyButton.css +0 -23
- package/build/types/button/Button.resolver.d.ts +0 -33
- package/build/types/button/Button.resolver.d.ts.map +0 -1
- package/build/types/button/Button.types.d.ts +0 -54
- 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 -75
- package/src/button/Button.tests.story.tsx +0 -27
- package/src/button/Button.types.ts +0 -68
- package/src/button/Button.vars.css +0 -39
- package/src/button/Button.vars.less +0 -50
- 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 -225
- package/src/button/LegacyButton.tsx +0 -161
|
@@ -1,637 +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',
|
|
141
|
-
argTypes: {
|
|
142
|
-
v2: {
|
|
143
|
-
table: {
|
|
144
|
-
readonly: true,
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
size: {
|
|
148
|
-
type: {
|
|
149
|
-
name: 'enum',
|
|
150
|
-
value: ['lg', 'md', 'sm'],
|
|
151
|
-
},
|
|
152
|
-
table: {
|
|
153
|
-
type: {
|
|
154
|
-
summary: 'ButtonSize',
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
priority: {
|
|
159
|
-
type: {
|
|
160
|
-
name: 'enum',
|
|
161
|
-
value: ['primary', 'secondary', 'tertiary', 'minimal'],
|
|
162
|
-
},
|
|
163
|
-
table: {
|
|
164
|
-
type: {
|
|
165
|
-
summary: 'ButtonPriority',
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
sentiment: {
|
|
170
|
-
type: {
|
|
171
|
-
name: 'enum',
|
|
172
|
-
value: ['default', 'negative'],
|
|
173
|
-
},
|
|
174
|
-
table: {
|
|
175
|
-
type: {
|
|
176
|
-
summary: 'ButtonSentiment',
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
disabled: {
|
|
181
|
-
description: 'Toggles the disabled state',
|
|
182
|
-
table: {
|
|
183
|
-
defaultValue: { summary: 'false' },
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
loading: {
|
|
187
|
-
description: 'Toggles the loading state',
|
|
188
|
-
table: {
|
|
189
|
-
defaultValue: { summary: 'false' },
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
as: {
|
|
193
|
-
table: {
|
|
194
|
-
defaultValue: { summary: 'button' },
|
|
195
|
-
},
|
|
196
|
-
},
|
|
197
|
-
block: {
|
|
198
|
-
table: {
|
|
199
|
-
defaultValue: { summary: 'false' },
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
href: {
|
|
203
|
-
type: {
|
|
204
|
-
name: 'string',
|
|
205
|
-
},
|
|
206
|
-
description: 'If set, the component will render as an HTML anchor.',
|
|
207
|
-
},
|
|
208
|
-
iconStart: {
|
|
209
|
-
control: 'object',
|
|
210
|
-
},
|
|
211
|
-
iconEnd: {
|
|
212
|
-
control: 'object',
|
|
213
|
-
},
|
|
214
|
-
avatars: {
|
|
215
|
-
control: 'object',
|
|
216
|
-
},
|
|
217
|
-
type: {
|
|
218
|
-
table: {
|
|
219
|
-
disable: true,
|
|
220
|
-
},
|
|
221
|
-
},
|
|
222
|
-
htmlType: {
|
|
223
|
-
table: {
|
|
224
|
-
disable: true,
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
'data-testid': {
|
|
228
|
-
table: {
|
|
229
|
-
disable: true,
|
|
230
|
-
},
|
|
231
|
-
},
|
|
232
|
-
},
|
|
233
12
|
args: {
|
|
234
|
-
|
|
235
|
-
size: undefined,
|
|
236
|
-
priority: undefined,
|
|
237
|
-
sentiment: undefined,
|
|
238
|
-
disabled: false,
|
|
13
|
+
children: 'Button text',
|
|
239
14
|
loading: false,
|
|
240
|
-
block: false,
|
|
241
|
-
as: undefined,
|
|
242
|
-
type: undefined,
|
|
243
|
-
iconStart: undefined,
|
|
244
|
-
iconEnd: undefined,
|
|
245
|
-
avatars: undefined,
|
|
246
|
-
testId: undefined,
|
|
247
|
-
className: undefined,
|
|
248
15
|
onClick: fn(),
|
|
249
|
-
children: 'Button text',
|
|
250
|
-
},
|
|
251
|
-
tags: ['autodocs'],
|
|
252
|
-
decorators: [withContainer],
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
export default meta;
|
|
256
|
-
|
|
257
|
-
type Story = StoryObj<typeof Button>;
|
|
258
|
-
|
|
259
|
-
export const Playground: StoryObj<PreviewStoryArgs> = {
|
|
260
|
-
render: function Render(args: PreviewStoryArgs) {
|
|
261
|
-
const [props, previewProps] = getPropsForPreview(args);
|
|
262
|
-
|
|
263
|
-
return <Button {...props} {...previewProps} v2 />;
|
|
264
|
-
},
|
|
265
|
-
args: {
|
|
266
16
|
onBlur: fn(),
|
|
267
17
|
onFocus: fn(),
|
|
268
|
-
onKeyDown: fn(),
|
|
269
|
-
onMouseEnter: fn(),
|
|
270
|
-
onMouseLeave: fn(),
|
|
271
|
-
previewIconStart: false,
|
|
272
|
-
previewIconEnd: false,
|
|
273
|
-
previewAvatars: false,
|
|
274
|
-
},
|
|
275
|
-
argTypes: {
|
|
276
|
-
onClick: { table: { disable: true } },
|
|
277
|
-
onBlur: { table: { disable: true } },
|
|
278
|
-
onFocus: { table: { disable: true } },
|
|
279
|
-
onKeyDown: { table: { disable: true } },
|
|
280
|
-
onMouseEnter: { table: { disable: true } },
|
|
281
|
-
onMouseLeave: { table: { disable: true } },
|
|
282
|
-
...previewArgTypes,
|
|
283
|
-
},
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* There are two different types of button that, default and negative,
|
|
288
|
-
* these designed to emphasise the nature of the action. <br />
|
|
289
|
-
* **NB:** Sentiment only applies to `primary` and `secondary` priorities. <br />
|
|
290
|
-
* [Design documentation](https://wise.design/components/button#types)
|
|
291
|
-
*/
|
|
292
|
-
export const Sentiment: StoryObj<PreviewStoryArgs> = {
|
|
293
|
-
render: function Render(args: PreviewStoryArgs) {
|
|
294
|
-
const [props, previewProps] = getPropsForPreview(args);
|
|
295
|
-
|
|
296
|
-
return (
|
|
297
|
-
<>
|
|
298
|
-
<Button {...props} {...previewProps} v2>
|
|
299
|
-
Default Sentiment
|
|
300
|
-
</Button>
|
|
301
|
-
<Button {...props} {...previewProps} v2 sentiment="negative">
|
|
302
|
-
Negative Sentiment
|
|
303
|
-
</Button>
|
|
304
|
-
<Button {...props} {...previewProps} v2 priority="secondary">
|
|
305
|
-
Default Sentiment
|
|
306
|
-
</Button>
|
|
307
|
-
<Button {...props} {...previewProps} v2 priority="secondary" sentiment="negative">
|
|
308
|
-
Negative Sentiment
|
|
309
|
-
</Button>
|
|
310
|
-
</>
|
|
311
|
-
);
|
|
312
|
-
},
|
|
313
|
-
argTypes: {
|
|
314
|
-
...hideControls([
|
|
315
|
-
'sentiment',
|
|
316
|
-
'priority',
|
|
317
|
-
'block',
|
|
318
|
-
'href',
|
|
319
|
-
'target',
|
|
320
|
-
'as',
|
|
321
|
-
'children',
|
|
322
|
-
'testId',
|
|
323
|
-
]),
|
|
324
|
-
...previewArgTypes,
|
|
325
|
-
},
|
|
326
|
-
args: {
|
|
327
|
-
previewIconStart: false,
|
|
328
|
-
previewIconEnd: false,
|
|
329
|
-
previewAvatars: false,
|
|
330
|
-
},
|
|
331
|
-
decorators: [withComponentGrid('30rem')],
|
|
332
|
-
parameters: augmentIconProps(),
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* Priorities set a visual hierarchy amongst the buttons displayed on the
|
|
337
|
-
* screen to help more important buttons to take precedence over others. <br />
|
|
338
|
-
* [Design documentation](https://wise.design/components/button#priorities)
|
|
339
|
-
*/
|
|
340
|
-
export const Priority: StoryObj<PreviewStoryArgs> = {
|
|
341
|
-
render: function Render(args: PreviewStoryArgs) {
|
|
342
|
-
const [props, previewProps] = getPropsForPreview(args);
|
|
343
|
-
|
|
344
|
-
return (
|
|
345
|
-
<>
|
|
346
|
-
<Button {...props} {...previewProps} v2>
|
|
347
|
-
Primary Priority (default)
|
|
348
|
-
</Button>
|
|
349
|
-
<Button {...props} {...previewProps} v2 priority="secondary">
|
|
350
|
-
Secondary Priority
|
|
351
|
-
</Button>
|
|
352
|
-
<Button {...props} {...previewProps} v2 priority="tertiary">
|
|
353
|
-
Tertiary Priority
|
|
354
|
-
</Button>
|
|
355
|
-
<Button {...props} {...previewProps} v2 priority="minimal">
|
|
356
|
-
Minimal Priority
|
|
357
|
-
</Button>
|
|
358
|
-
</>
|
|
359
|
-
);
|
|
360
|
-
},
|
|
361
|
-
argTypes: {
|
|
362
|
-
...hideControls(['priority', 'block', 'href', 'target', 'as', 'children', 'testId']),
|
|
363
|
-
...previewArgTypes,
|
|
364
|
-
},
|
|
365
|
-
args: {
|
|
366
|
-
previewIconStart: false,
|
|
367
|
-
previewIconEnd: false,
|
|
368
|
-
previewAvatars: false,
|
|
369
|
-
},
|
|
370
|
-
decorators: [withComponentGrid()],
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* There are three different button sizes – small (`sm`), medium (`md`) and large (`lg`) – each used for different purposes. <br />
|
|
375
|
-
* [Design documentation](https://wise.design/components/button#sizes)
|
|
376
|
-
*/
|
|
377
|
-
export const Size: StoryObj<PreviewStoryArgs> = {
|
|
378
|
-
render: function Render(args: PreviewStoryArgs) {
|
|
379
|
-
const [props, previewProps] = getPropsForPreview(args);
|
|
380
|
-
|
|
381
|
-
return (
|
|
382
|
-
<>
|
|
383
|
-
<Button {...props} {...previewProps}>
|
|
384
|
-
Large button (default)
|
|
385
|
-
</Button>
|
|
386
|
-
<Button {...props} {...previewProps} size="md">
|
|
387
|
-
Medium button
|
|
388
|
-
</Button>
|
|
389
|
-
<Button {...props} {...previewProps} size="sm">
|
|
390
|
-
Small button
|
|
391
|
-
</Button>
|
|
392
|
-
</>
|
|
393
|
-
);
|
|
394
18
|
},
|
|
395
19
|
argTypes: {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
previewAvatars: false,
|
|
403
|
-
},
|
|
404
|
-
decorators: [withComponentGrid()],
|
|
405
|
-
};
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* A Button rendered as an anchor element.
|
|
409
|
-
*/
|
|
410
|
-
export const AsAnchor: StoryObj<PreviewStoryArgs> = {
|
|
411
|
-
render: function Render(args: PreviewStoryArgs) {
|
|
412
|
-
const [props, previewProps] = getPropsForPreview(args);
|
|
413
|
-
|
|
414
|
-
return (
|
|
415
|
-
<Button {...props} {...previewProps}>
|
|
416
|
-
Button as anchor
|
|
417
|
-
</Button>
|
|
418
|
-
);
|
|
419
|
-
},
|
|
420
|
-
argTypes: {
|
|
421
|
-
...hideControls(['block']),
|
|
422
|
-
...previewArgTypes,
|
|
423
|
-
},
|
|
424
|
-
args: {
|
|
425
|
-
as: 'a',
|
|
426
|
-
href: 'https://wise.com',
|
|
427
|
-
previewIconStart: false,
|
|
428
|
-
previewIconEnd: false,
|
|
429
|
-
previewAvatars: false,
|
|
430
|
-
onClick: undefined,
|
|
431
|
-
},
|
|
432
|
-
};
|
|
433
|
-
|
|
434
|
-
export const Disabled: StoryObj<PreviewStoryArgs> = {
|
|
435
|
-
render: function Render(args: PreviewStoryArgs) {
|
|
436
|
-
const [props, previewProps] = getPropsForPreview(args);
|
|
437
|
-
|
|
438
|
-
return (
|
|
439
|
-
<Button {...props} {...previewProps}>
|
|
440
|
-
Disabled button
|
|
441
|
-
</Button>
|
|
442
|
-
);
|
|
443
|
-
},
|
|
444
|
-
argTypes: {
|
|
445
|
-
...hideControls(['block']),
|
|
446
|
-
...previewArgTypes,
|
|
447
|
-
},
|
|
448
|
-
args: {
|
|
449
|
-
disabled: true,
|
|
450
|
-
previewIconStart: false,
|
|
451
|
-
previewIconEnd: false,
|
|
452
|
-
previewAvatars: false,
|
|
20
|
+
as: {
|
|
21
|
+
type: {
|
|
22
|
+
name: 'enum',
|
|
23
|
+
value: ['button', 'a'],
|
|
24
|
+
},
|
|
25
|
+
},
|
|
453
26
|
},
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
export const Loading: StoryObj<PreviewStoryArgs> = {
|
|
457
|
-
render: function Render(args: PreviewStoryArgs) {
|
|
458
|
-
const [props, previewProps] = getPropsForPreview(args);
|
|
27
|
+
tags: ['autodocs'],
|
|
28
|
+
} satisfies Meta<typeof Button>;
|
|
459
29
|
|
|
460
|
-
|
|
461
|
-
<Button {...props} {...previewProps}>
|
|
462
|
-
Button as anchor
|
|
463
|
-
</Button>
|
|
464
|
-
);
|
|
465
|
-
},
|
|
466
|
-
argTypes: {
|
|
467
|
-
...hideControls(['block']),
|
|
468
|
-
...previewArgTypes,
|
|
469
|
-
},
|
|
470
|
-
args: {
|
|
471
|
-
loading: true,
|
|
472
|
-
previewIconStart: false,
|
|
473
|
-
previewIconEnd: false,
|
|
474
|
-
previewAvatars: false,
|
|
475
|
-
},
|
|
476
|
-
};
|
|
30
|
+
type Story = StoryObj<typeof Button>;
|
|
477
31
|
|
|
478
|
-
|
|
479
|
-
* A Button that takes up the full width of its container (`display: block`).
|
|
480
|
-
*/
|
|
481
|
-
export const DisplayBlock: StoryObj<PreviewStoryArgs> = {
|
|
482
|
-
render: function Render(args: PreviewStoryArgs) {
|
|
483
|
-
const [props, previewProps] = getPropsForPreview(args);
|
|
32
|
+
export const Basic: Story = {};
|
|
484
33
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
'
|
|
495
|
-
|
|
496
|
-
'sentiment',
|
|
497
|
-
'as',
|
|
498
|
-
'disabled',
|
|
499
|
-
'children',
|
|
500
|
-
'testId',
|
|
501
|
-
]),
|
|
502
|
-
...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
|
+
},
|
|
503
45
|
},
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
previewIconStart: false,
|
|
507
|
-
previewIconEnd: false,
|
|
508
|
-
previewAvatars: false,
|
|
46
|
+
{
|
|
47
|
+
variants: ['dark'],
|
|
509
48
|
},
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* Icons are only supported for `sm` and `md` size Buttons. <br />
|
|
514
|
-
* [Design documentation](https://wise.design/components/button#accessories)
|
|
515
|
-
*/
|
|
516
|
-
export const WithIcons: StoryObj<PreviewStoryArgs> = {
|
|
517
|
-
render: function Render(args: PreviewStoryArgs) {
|
|
518
|
-
const [props] = getPropsForPreview(args);
|
|
519
|
-
|
|
520
|
-
return (
|
|
521
|
-
<>
|
|
522
|
-
<Button {...props} iconStart={Freeze}>
|
|
523
|
-
With start icon
|
|
524
|
-
</Button>
|
|
525
|
-
|
|
526
|
-
<Button {...props} iconEnd={ArrowRight}>
|
|
527
|
-
With end icon
|
|
528
|
-
</Button>
|
|
49
|
+
);
|
|
529
50
|
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
}
|
|
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
|
+
);
|
|
554
92
|
|
|
555
93
|
/**
|
|
556
|
-
*
|
|
557
|
-
*
|
|
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.
|
|
558
103
|
*/
|
|
559
|
-
export const
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
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
|
+
);
|
|
576
123
|
|
|
577
|
-
|
|
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
|
-
<Button v2 size="md" avatars={[{ imgSrc: '../avatar-square-dude.webp' }]}>
|
|
615
|
-
With image Avatar
|
|
616
|
-
</Button>
|
|
617
|
-
</>
|
|
618
|
-
`,
|
|
619
|
-
},
|
|
620
|
-
},
|
|
621
|
-
},
|
|
622
|
-
decorators: [withComponentGrid()],
|
|
623
|
-
};
|
|
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
|
+
);
|
|
624
160
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
export const WithAvatarAndIcon: Story = {
|
|
629
|
-
args: {
|
|
630
|
-
size: 'md',
|
|
631
|
-
iconStart: Freeze,
|
|
632
|
-
avatars: [{ profileName: 'John Doe' }],
|
|
633
|
-
iconEnd: ArrowRight,
|
|
634
|
-
},
|
|
635
|
-
argTypes: hideControls(['href', 'target', 'as', 'children', 'testId']),
|
|
636
|
-
parameters: augmentIconProps(),
|
|
637
|
-
};
|
|
161
|
+
export const SocialMediaMobile = storyConfig<Story>(SocialMedia, {
|
|
162
|
+
variants: ['default', 'dark', 'rtl', 'mobile'],
|
|
163
|
+
});
|