@transferwise/components 46.133.0 → 46.134.0
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/chips/Chips.js.map +1 -1
- package/build/chips/Chips.mjs.map +1 -1
- package/build/label/Label.js +1 -1
- package/build/label/Label.js.map +1 -1
- package/build/label/Label.mjs +1 -1
- package/build/label/Label.mjs.map +1 -1
- package/build/logo/Logo.js +6 -0
- package/build/logo/Logo.js.map +1 -1
- package/build/logo/Logo.mjs +6 -0
- package/build/logo/Logo.mjs.map +1 -1
- package/build/main.css +47 -9
- package/build/moneyInput/MoneyInput.js +28 -12
- package/build/moneyInput/MoneyInput.js.map +1 -1
- package/build/moneyInput/MoneyInput.mjs +30 -14
- package/build/moneyInput/MoneyInput.mjs.map +1 -1
- package/build/moneyInput/currencyFormatting.js +8 -2
- package/build/moneyInput/currencyFormatting.js.map +1 -1
- package/build/moneyInput/currencyFormatting.mjs +5 -4
- package/build/moneyInput/currencyFormatting.mjs.map +1 -1
- package/build/statusIcon/StatusIcon.js +1 -12
- package/build/statusIcon/StatusIcon.js.map +1 -1
- package/build/statusIcon/StatusIcon.mjs +1 -12
- package/build/statusIcon/StatusIcon.mjs.map +1 -1
- package/build/styles/listItem/ListItem.css +4 -4
- package/build/styles/listItem/ListItem.grid.css +3 -3
- package/build/styles/main.css +47 -9
- package/build/styles/sentimentSurface/SentimentSurface.css +1 -1
- package/build/styles/statusIcon/StatusIcon.css +35 -4
- package/build/types/chips/Chips.d.ts +1 -1
- package/build/types/chips/Chips.d.ts.map +1 -1
- package/build/types/common/commonProps.d.ts +0 -6
- package/build/types/common/commonProps.d.ts.map +1 -1
- package/build/types/label/Label.d.ts.map +1 -1
- package/build/types/logo/Logo.d.ts +10 -1
- package/build/types/logo/Logo.d.ts.map +1 -1
- package/build/types/moneyInput/MoneyInput.d.ts +6 -0
- package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
- package/build/types/moneyInput/currencyFormatting.d.ts +4 -3
- package/build/types/moneyInput/currencyFormatting.d.ts.map +1 -1
- package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/button/_stories/Button.story.tsx +15 -5
- package/src/checkboxButton/CheckboxButton.story.tsx +125 -44
- package/src/checkboxButton/CheckboxButton.test.story.tsx +236 -0
- package/src/chips/Chips.story.tsx +141 -102
- package/src/chips/Chips.test.story.tsx +177 -0
- package/src/chips/Chips.tsx +1 -1
- package/src/circularButton/CircularButton.story.tsx +261 -49
- package/src/circularButton/CircularButton.test.story.tsx +192 -2
- package/src/common/commonProps.ts +0 -6
- package/src/iconButton/IconButton.story.tsx +315 -110
- package/src/iconButton/IconButton.test.story.tsx +217 -44
- package/src/label/Label.tsx +1 -2
- package/src/listItem/ListItem.css +4 -4
- package/src/listItem/ListItem.grid.css +3 -3
- package/src/listItem/ListItem.grid.less +5 -3
- package/src/listItem/ListItem.less +1 -1
- package/src/listItem/ListItem.vars.less +2 -2
- package/src/listItem/_stories/ListItem.layout.test.story.tsx +55 -0
- package/src/logo/Logo.story.tsx +181 -21
- package/src/logo/Logo.test.story.tsx +40 -7
- package/src/logo/Logo.tsx +10 -1
- package/src/main.css +47 -9
- package/src/moneyInput/MoneyInput.story.tsx +10 -1
- package/src/moneyInput/MoneyInput.test.story.tsx +141 -1
- package/src/moneyInput/MoneyInput.test.tsx +45 -0
- package/src/moneyInput/MoneyInput.tsx +27 -3
- package/src/moneyInput/currencyFormatting.ts +11 -5
- package/src/sentimentSurface/SentimentSurface.css +1 -1
- package/src/sentimentSurface/SentimentSurface.less +1 -1
- package/src/statusIcon/StatusIcon.css +35 -4
- package/src/statusIcon/StatusIcon.less +35 -4
- package/src/statusIcon/StatusIcon.story.tsx +119 -79
- package/src/statusIcon/StatusIcon.test.story.tsx +125 -0
- package/src/statusIcon/StatusIcon.test.tsx +16 -23
- package/src/statusIcon/StatusIcon.tsx +2 -16
- package/src/switch/Switch.story.tsx +64 -42
- package/src/switch/Switch.test.story.tsx +123 -0
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import * as Icons from '@transferwise/icons';
|
|
2
2
|
|
|
3
|
-
import { ControlType, Priority } from '../common';
|
|
4
|
-
|
|
5
3
|
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
6
|
-
import
|
|
4
|
+
import { fn } from 'storybook/test';
|
|
5
|
+
import CircularButton, { CircularButtonProps } from './CircularButton';
|
|
7
6
|
import Title from '../title';
|
|
8
|
-
import
|
|
7
|
+
import SentimentSurface from '../sentimentSurface';
|
|
9
8
|
|
|
9
|
+
/**
|
|
10
|
+
* An <a href="?path=/docs/actions-iconbutton--docs">IconButton</a> with a text label below it.
|
|
11
|
+
*
|
|
12
|
+
* **Design guidance**: <a href="https://wise.design/components/circular-button" target="_blank">wise.design/components/circular-button</a>
|
|
13
|
+
*/
|
|
10
14
|
export default {
|
|
11
15
|
component: CircularButton,
|
|
12
16
|
title: 'Actions/CircularButton',
|
|
13
17
|
args: {
|
|
14
18
|
children: 'Button text',
|
|
15
19
|
icon: <Icons.Freeze />,
|
|
20
|
+
onClick: fn(),
|
|
21
|
+
priority: 'primary',
|
|
22
|
+
type: 'default',
|
|
23
|
+
disabled: false,
|
|
16
24
|
},
|
|
17
25
|
argTypes: {
|
|
18
26
|
icon: {
|
|
@@ -21,66 +29,270 @@ export default {
|
|
|
21
29
|
Object.entries(Icons).map(([name, Icon]) => [name, <Icon key={name} />]),
|
|
22
30
|
),
|
|
23
31
|
},
|
|
32
|
+
className: { table: { category: 'Common' } },
|
|
33
|
+
onClick: { table: { category: 'Common', type: { summary: 'function' } } },
|
|
34
|
+
},
|
|
35
|
+
parameters: {
|
|
36
|
+
docs: { toc: true },
|
|
24
37
|
},
|
|
25
38
|
} satisfies Meta<typeof CircularButton>;
|
|
26
39
|
|
|
27
40
|
type Story = StoryObj<typeof CircularButton>;
|
|
28
41
|
|
|
29
|
-
|
|
42
|
+
/** Explore all props via the controls panel. */
|
|
43
|
+
export const Playground: Story = {};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Priorities set a visual hierarchy amongst the buttons displayed on the
|
|
47
|
+
* screen to help more important buttons to take precedence over others. <br />
|
|
48
|
+
* [Design documentation](https://wise.design/components/circular-button#priority)
|
|
49
|
+
*/
|
|
50
|
+
export const Priority: Story = {
|
|
30
51
|
args: {
|
|
31
|
-
priority: 'primary',
|
|
32
52
|
type: 'default',
|
|
33
|
-
disabled: false,
|
|
34
53
|
},
|
|
54
|
+
argTypes: {
|
|
55
|
+
type: {
|
|
56
|
+
control: 'radio',
|
|
57
|
+
options: ['default', 'negative'],
|
|
58
|
+
},
|
|
59
|
+
priority: { table: { disable: true } },
|
|
60
|
+
disabled: { table: { disable: true } },
|
|
61
|
+
icon: { table: { disable: true } },
|
|
62
|
+
children: { table: { disable: true } },
|
|
63
|
+
onClick: { table: { disable: true } },
|
|
64
|
+
},
|
|
65
|
+
decorators: [
|
|
66
|
+
(Story) => (
|
|
67
|
+
<div style={{ display: 'flex', gap: '24px' }}>
|
|
68
|
+
<Story />
|
|
69
|
+
</div>
|
|
70
|
+
),
|
|
71
|
+
],
|
|
72
|
+
render: (args: CircularButtonProps) => (
|
|
73
|
+
<>
|
|
74
|
+
<CircularButton priority="primary" type={args.type} icon={<Icons.Send />} onClick={fn()}>
|
|
75
|
+
Primary
|
|
76
|
+
</CircularButton>
|
|
77
|
+
<CircularButton priority="secondary" type={args.type} icon={<Icons.Plus />} onClick={fn()}>
|
|
78
|
+
Secondary
|
|
79
|
+
</CircularButton>
|
|
80
|
+
</>
|
|
81
|
+
),
|
|
35
82
|
};
|
|
36
83
|
|
|
37
|
-
|
|
84
|
+
/**
|
|
85
|
+
* There are two different types of button – default and negative – designed to emphasise the nature of the action. <br />
|
|
86
|
+
* [Design documentation](https://wise.design/components/circular-button#types)
|
|
87
|
+
*/
|
|
88
|
+
export const Type: Story = {
|
|
38
89
|
args: {
|
|
39
|
-
|
|
90
|
+
priority: 'primary',
|
|
40
91
|
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
92
|
+
argTypes: {
|
|
93
|
+
priority: {
|
|
94
|
+
control: 'radio',
|
|
95
|
+
options: ['primary', 'secondary'],
|
|
96
|
+
},
|
|
97
|
+
type: { table: { disable: true } },
|
|
98
|
+
disabled: { table: { disable: true } },
|
|
99
|
+
icon: { table: { disable: true } },
|
|
100
|
+
children: { table: { disable: true } },
|
|
101
|
+
onClick: { table: { disable: true } },
|
|
102
|
+
},
|
|
103
|
+
decorators: [
|
|
104
|
+
(Story) => (
|
|
105
|
+
<div style={{ display: 'flex', gap: '24px' }}>
|
|
106
|
+
<Story />
|
|
107
|
+
</div>
|
|
108
|
+
),
|
|
109
|
+
],
|
|
110
|
+
render: (args: CircularButtonProps) => (
|
|
111
|
+
<>
|
|
112
|
+
<CircularButton priority={args.priority} type="default" icon={<Icons.Send />} onClick={fn()}>
|
|
113
|
+
Default
|
|
114
|
+
</CircularButton>
|
|
115
|
+
<CircularButton
|
|
116
|
+
priority={args.priority}
|
|
117
|
+
type="negative"
|
|
118
|
+
icon={<Icons.Cross />}
|
|
119
|
+
onClick={fn()}
|
|
120
|
+
>
|
|
121
|
+
Negative
|
|
122
|
+
</CircularButton>
|
|
123
|
+
</>
|
|
124
|
+
),
|
|
125
|
+
};
|
|
53
126
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
127
|
+
/**
|
|
128
|
+
* Disabled buttons cannot be interacted with and are visually distinct.
|
|
129
|
+
*/
|
|
130
|
+
export const Disabled: Story = {
|
|
131
|
+
args: {
|
|
132
|
+
priority: 'primary',
|
|
133
|
+
type: 'default',
|
|
134
|
+
},
|
|
135
|
+
argTypes: {
|
|
136
|
+
priority: {
|
|
137
|
+
control: 'radio',
|
|
138
|
+
options: ['primary', 'secondary'],
|
|
139
|
+
},
|
|
140
|
+
type: {
|
|
141
|
+
control: 'radio',
|
|
142
|
+
options: ['default', 'negative'],
|
|
143
|
+
},
|
|
144
|
+
disabled: { table: { disable: true } },
|
|
145
|
+
icon: { table: { disable: true } },
|
|
146
|
+
children: { table: { disable: true } },
|
|
147
|
+
onClick: { table: { disable: true } },
|
|
148
|
+
},
|
|
149
|
+
decorators: [
|
|
150
|
+
(Story) => (
|
|
151
|
+
<div style={{ display: 'flex', justifyContent: 'center' }}>
|
|
152
|
+
<Story />
|
|
153
|
+
</div>
|
|
154
|
+
),
|
|
155
|
+
],
|
|
156
|
+
render: (args: CircularButtonProps) => (
|
|
157
|
+
<CircularButton disabled priority={args.priority} type={args.type} icon={<Icons.Card />}>
|
|
158
|
+
Disabled
|
|
159
|
+
</CircularButton>
|
|
160
|
+
),
|
|
161
|
+
};
|
|
63
162
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
163
|
+
/**
|
|
164
|
+
* `CircularButton` is sentiment-aware and will automatically adjust its colours if wrapped inside
|
|
165
|
+
* the <a href="?path=/docs/foundations-sentimentsurface--docs">SentimentSurface</a> component. <br />
|
|
166
|
+
* [Design documentation](https://wise.design/components/circular-button)
|
|
167
|
+
*/
|
|
168
|
+
export const SentimentAwareness: Story = {
|
|
169
|
+
render: () => {
|
|
170
|
+
const buttons = [
|
|
171
|
+
{
|
|
172
|
+
priority: 'primary',
|
|
173
|
+
type: 'default',
|
|
174
|
+
icon: <Icons.Send />,
|
|
175
|
+
label: 'primary',
|
|
176
|
+
disabled: false,
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
priority: 'secondary',
|
|
180
|
+
type: 'default',
|
|
181
|
+
icon: <Icons.Plus />,
|
|
182
|
+
label: 'secondary',
|
|
183
|
+
disabled: false,
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
priority: 'primary',
|
|
187
|
+
type: 'negative',
|
|
188
|
+
icon: <Icons.Cross />,
|
|
189
|
+
label: 'neg primary',
|
|
190
|
+
disabled: false,
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
priority: 'secondary',
|
|
194
|
+
type: 'negative',
|
|
195
|
+
icon: <Icons.Edit />,
|
|
196
|
+
label: 'neg secondary',
|
|
197
|
+
disabled: false,
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
priority: 'primary',
|
|
201
|
+
type: 'default',
|
|
202
|
+
icon: <Icons.Card />,
|
|
203
|
+
label: 'disabled',
|
|
204
|
+
disabled: true,
|
|
205
|
+
},
|
|
206
|
+
] as const;
|
|
207
|
+
const sentiments = ['success', 'warning', 'negative', 'neutral', 'proposition'] as const;
|
|
73
208
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
209
|
+
return (
|
|
210
|
+
<div style={{ display: 'flex', flexDirection: 'column' }}>
|
|
211
|
+
{/* Rows for each sentiment with base and elevated emphasis */}
|
|
212
|
+
{sentiments.flatMap((sentiment) => [
|
|
213
|
+
<SentimentSurface
|
|
214
|
+
key={`${sentiment}-base`}
|
|
215
|
+
sentiment={sentiment}
|
|
216
|
+
emphasis="base"
|
|
217
|
+
style={{ display: 'flex', alignItems: 'center', padding: '8px 0', gap: '8px' }}
|
|
218
|
+
>
|
|
219
|
+
<div
|
|
220
|
+
style={{
|
|
221
|
+
width: '120px',
|
|
222
|
+
fontSize: '11px',
|
|
223
|
+
fontWeight: 'bold',
|
|
224
|
+
textAlign: 'left',
|
|
225
|
+
paddingLeft: '8px',
|
|
226
|
+
}}
|
|
227
|
+
>
|
|
228
|
+
{sentiment} (base)
|
|
229
|
+
</div>
|
|
230
|
+
{buttons.map((button) => (
|
|
231
|
+
<div
|
|
232
|
+
key={button.label}
|
|
233
|
+
style={{
|
|
234
|
+
width: '100px',
|
|
235
|
+
display: 'flex',
|
|
236
|
+
justifyContent: 'center',
|
|
237
|
+
}}
|
|
238
|
+
>
|
|
239
|
+
<CircularButton
|
|
240
|
+
priority={button.priority}
|
|
241
|
+
type={button.type}
|
|
242
|
+
icon={button.icon}
|
|
243
|
+
disabled={button.disabled}
|
|
244
|
+
onClick={fn()}
|
|
245
|
+
>
|
|
246
|
+
{button.label}
|
|
247
|
+
</CircularButton>
|
|
248
|
+
</div>
|
|
249
|
+
))}
|
|
250
|
+
</SentimentSurface>,
|
|
251
|
+
<SentimentSurface
|
|
252
|
+
key={`${sentiment}-elevated`}
|
|
253
|
+
sentiment={sentiment}
|
|
254
|
+
emphasis="elevated"
|
|
255
|
+
style={{ display: 'flex', alignItems: 'center', padding: '8px 0', gap: '8px' }}
|
|
256
|
+
>
|
|
257
|
+
<div
|
|
258
|
+
style={{
|
|
259
|
+
width: '120px',
|
|
260
|
+
fontSize: '11px',
|
|
261
|
+
fontWeight: 'bold',
|
|
262
|
+
textAlign: 'left',
|
|
263
|
+
paddingLeft: '8px',
|
|
264
|
+
}}
|
|
265
|
+
>
|
|
266
|
+
{sentiment} (elevated)
|
|
267
|
+
</div>
|
|
268
|
+
{buttons.map((button) => (
|
|
269
|
+
<div
|
|
270
|
+
key={button.label}
|
|
271
|
+
style={{
|
|
272
|
+
width: '100px',
|
|
273
|
+
display: 'flex',
|
|
274
|
+
justifyContent: 'center',
|
|
275
|
+
}}
|
|
276
|
+
>
|
|
277
|
+
<CircularButton
|
|
278
|
+
priority={button.priority}
|
|
279
|
+
type={button.type}
|
|
280
|
+
icon={button.icon}
|
|
281
|
+
disabled={button.disabled}
|
|
282
|
+
onClick={fn()}
|
|
283
|
+
>
|
|
284
|
+
{button.label}
|
|
285
|
+
</CircularButton>
|
|
286
|
+
</div>
|
|
287
|
+
))}
|
|
288
|
+
</SentimentSurface>,
|
|
289
|
+
])}
|
|
290
|
+
</div>
|
|
84
291
|
);
|
|
85
292
|
},
|
|
293
|
+
parameters: {
|
|
294
|
+
docs: {
|
|
295
|
+
canvas: { sourceState: 'hidden' },
|
|
296
|
+
},
|
|
297
|
+
},
|
|
86
298
|
};
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import { Freeze } from '@transferwise/icons';
|
|
1
|
+
import { Freeze, Plus, Send, Convert, Card } from '@transferwise/icons';
|
|
2
2
|
|
|
3
3
|
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
4
|
+
import { expect, fn, userEvent, within } from 'storybook/test';
|
|
5
|
+
import { useState } from 'react';
|
|
4
6
|
import CircularButton from './CircularButton';
|
|
5
7
|
import Title from '../title';
|
|
6
8
|
import Body from '../body';
|
|
7
9
|
import { withVariantConfig } from '../../.storybook/helpers';
|
|
8
10
|
|
|
11
|
+
const wait = async (ms: number) =>
|
|
12
|
+
new Promise<void>((resolve) => {
|
|
13
|
+
setTimeout(resolve, ms);
|
|
14
|
+
});
|
|
15
|
+
|
|
9
16
|
export default {
|
|
10
17
|
component: CircularButton,
|
|
11
18
|
title: 'Actions/CircularButton/Tests',
|
|
@@ -14,6 +21,188 @@ export default {
|
|
|
14
21
|
|
|
15
22
|
type Story = StoryObj<typeof CircularButton>;
|
|
16
23
|
|
|
24
|
+
/** All priorities, types, and states across all themes. */
|
|
25
|
+
export const Variants: Story = {
|
|
26
|
+
render: () => {
|
|
27
|
+
const rowStyle = {
|
|
28
|
+
display: 'grid',
|
|
29
|
+
gridTemplateColumns: 'repeat(4, minmax(0, 100px))',
|
|
30
|
+
gap: '16px',
|
|
31
|
+
textAlign: 'center' as const,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '24px' }}>
|
|
36
|
+
<div style={rowStyle}>
|
|
37
|
+
<CircularButton priority="primary" type="default" icon={<Send />} onClick={fn()}>
|
|
38
|
+
Primary
|
|
39
|
+
</CircularButton>
|
|
40
|
+
<CircularButton priority="secondary" type="default" icon={<Plus />} onClick={fn()}>
|
|
41
|
+
Secondary
|
|
42
|
+
</CircularButton>
|
|
43
|
+
<CircularButton disabled priority="primary" type="default" icon={<Card />}>
|
|
44
|
+
Primary disabled
|
|
45
|
+
</CircularButton>
|
|
46
|
+
<CircularButton disabled priority="secondary" type="default" icon={<Card />}>
|
|
47
|
+
Secondary disabled
|
|
48
|
+
</CircularButton>
|
|
49
|
+
</div>
|
|
50
|
+
<div style={rowStyle}>
|
|
51
|
+
<CircularButton priority="primary" type="negative" icon={<Send />} onClick={fn()}>
|
|
52
|
+
Primary
|
|
53
|
+
</CircularButton>
|
|
54
|
+
<CircularButton priority="secondary" type="negative" icon={<Convert />} onClick={fn()}>
|
|
55
|
+
Secondary
|
|
56
|
+
</CircularButton>
|
|
57
|
+
<CircularButton disabled priority="primary" type="negative" icon={<Card />}>
|
|
58
|
+
Primary disabled
|
|
59
|
+
</CircularButton>
|
|
60
|
+
<CircularButton disabled priority="secondary" type="negative" icon={<Card />}>
|
|
61
|
+
Secondary disabled
|
|
62
|
+
</CircularButton>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
},
|
|
67
|
+
...withVariantConfig(['default', 'dark', 'bright-green', 'forest-green']),
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* `Space` or `Enter` activates when focused. Tab skips disabled buttons.
|
|
72
|
+
*/
|
|
73
|
+
export const KeyboardInteraction: Story = {
|
|
74
|
+
render: () => {
|
|
75
|
+
const onClick = fn();
|
|
76
|
+
return (
|
|
77
|
+
<div style={{ display: 'flex', gap: '24px', padding: '16px' }}>
|
|
78
|
+
<CircularButton priority="primary" type="default" icon={<Send />} onClick={onClick}>
|
|
79
|
+
Send
|
|
80
|
+
</CircularButton>
|
|
81
|
+
<CircularButton priority="secondary" type="default" icon={<Plus />} onClick={onClick}>
|
|
82
|
+
Add funds
|
|
83
|
+
</CircularButton>
|
|
84
|
+
<CircularButton priority="primary" type="negative" icon={<Convert />} onClick={onClick}>
|
|
85
|
+
Convert
|
|
86
|
+
</CircularButton>
|
|
87
|
+
<CircularButton
|
|
88
|
+
priority="primary"
|
|
89
|
+
type="default"
|
|
90
|
+
icon={<Card />}
|
|
91
|
+
disabled
|
|
92
|
+
onClick={onClick}
|
|
93
|
+
>
|
|
94
|
+
Disabled
|
|
95
|
+
</CircularButton>
|
|
96
|
+
</div>
|
|
97
|
+
);
|
|
98
|
+
},
|
|
99
|
+
play: async ({ canvasElement, step }) => {
|
|
100
|
+
const canvas = within(canvasElement);
|
|
101
|
+
const buttons = canvas.getAllByRole('button');
|
|
102
|
+
|
|
103
|
+
await step('tab to Send and press Space', async () => {
|
|
104
|
+
await userEvent.tab();
|
|
105
|
+
await expect(buttons[0]).toHaveFocus();
|
|
106
|
+
await wait(400);
|
|
107
|
+
await userEvent.keyboard(' ');
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
await wait(400);
|
|
111
|
+
|
|
112
|
+
await step('tab to Add funds and press Space', async () => {
|
|
113
|
+
await userEvent.tab();
|
|
114
|
+
await expect(buttons[1]).toHaveFocus();
|
|
115
|
+
await wait(400);
|
|
116
|
+
await userEvent.keyboard(' ');
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
await wait(400);
|
|
120
|
+
|
|
121
|
+
await step('tab to Convert and press Space', async () => {
|
|
122
|
+
await userEvent.tab();
|
|
123
|
+
await expect(buttons[2]).toHaveFocus();
|
|
124
|
+
await wait(400);
|
|
125
|
+
await userEvent.keyboard(' ');
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
await wait(400);
|
|
129
|
+
|
|
130
|
+
await step('tab skips Disabled button', async () => {
|
|
131
|
+
await userEvent.tab();
|
|
132
|
+
// Disabled button should be skipped, focus leaves the component
|
|
133
|
+
await expect(buttons[3]).not.toHaveFocus();
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/** Base variants in right-to-left layout. */
|
|
139
|
+
export const RTL: Story = {
|
|
140
|
+
render: function Render() {
|
|
141
|
+
const [clicks, setClicks] = useState(0);
|
|
142
|
+
const rowStyle = {
|
|
143
|
+
display: 'grid',
|
|
144
|
+
gridTemplateColumns: 'repeat(4, minmax(0, 100px))',
|
|
145
|
+
gap: '16px',
|
|
146
|
+
textAlign: 'center' as const,
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
return (
|
|
150
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '24px', padding: '16px' }}>
|
|
151
|
+
<div style={rowStyle}>
|
|
152
|
+
<CircularButton
|
|
153
|
+
priority="primary"
|
|
154
|
+
type="default"
|
|
155
|
+
icon={<Send />}
|
|
156
|
+
onClick={() => setClicks((c) => c + 1)}
|
|
157
|
+
>
|
|
158
|
+
Primary
|
|
159
|
+
</CircularButton>
|
|
160
|
+
<CircularButton
|
|
161
|
+
priority="secondary"
|
|
162
|
+
type="default"
|
|
163
|
+
icon={<Plus />}
|
|
164
|
+
onClick={() => setClicks((c) => c + 1)}
|
|
165
|
+
>
|
|
166
|
+
Secondary
|
|
167
|
+
</CircularButton>
|
|
168
|
+
<CircularButton disabled priority="primary" type="default" icon={<Card />}>
|
|
169
|
+
Primary disabled
|
|
170
|
+
</CircularButton>
|
|
171
|
+
<CircularButton disabled priority="secondary" type="default" icon={<Card />}>
|
|
172
|
+
Secondary disabled
|
|
173
|
+
</CircularButton>
|
|
174
|
+
</div>
|
|
175
|
+
<div style={rowStyle}>
|
|
176
|
+
<CircularButton
|
|
177
|
+
priority="primary"
|
|
178
|
+
type="negative"
|
|
179
|
+
icon={<Send />}
|
|
180
|
+
onClick={() => setClicks((c) => c + 1)}
|
|
181
|
+
>
|
|
182
|
+
Primary
|
|
183
|
+
</CircularButton>
|
|
184
|
+
<CircularButton
|
|
185
|
+
priority="secondary"
|
|
186
|
+
type="negative"
|
|
187
|
+
icon={<Convert />}
|
|
188
|
+
onClick={() => setClicks((c) => c + 1)}
|
|
189
|
+
>
|
|
190
|
+
Secondary
|
|
191
|
+
</CircularButton>
|
|
192
|
+
<CircularButton disabled priority="primary" type="negative" icon={<Card />}>
|
|
193
|
+
Primary disabled
|
|
194
|
+
</CircularButton>
|
|
195
|
+
<CircularButton disabled priority="secondary" type="negative" icon={<Card />}>
|
|
196
|
+
Secondary disabled
|
|
197
|
+
</CircularButton>
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
);
|
|
201
|
+
},
|
|
202
|
+
...withVariantConfig(['rtl']),
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
/** Long labels are centered beneath the icon. */
|
|
17
206
|
export const CenteredText: Story = {
|
|
18
207
|
render: () => {
|
|
19
208
|
return (
|
|
@@ -79,7 +268,8 @@ const All: Story = {
|
|
|
79
268
|
},
|
|
80
269
|
};
|
|
81
270
|
|
|
82
|
-
|
|
271
|
+
/** All variants at 400% zoom for accessibility testing. */
|
|
272
|
+
export const Zoom400: Story = {
|
|
83
273
|
...All,
|
|
84
274
|
...withVariantConfig(['400%'], All),
|
|
85
275
|
};
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
export type CommonProps = {
|
|
2
|
-
/**
|
|
3
|
-
* Space-separated list of the case-sensitive CSS classes,
|
|
4
|
-
* most would be applied to outermost element inside the component
|
|
5
|
-
*
|
|
6
|
-
* @see https://github.com/transferwise/neptune-web/blob/main/rfc/0001-always-pass-classname.md
|
|
7
|
-
*/
|
|
8
2
|
className?: string;
|
|
9
3
|
};
|
|
10
4
|
|