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