@transferwise/components 46.133.0 → 46.133.1
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 +4 -4
- package/build/styles/listItem/ListItem.css +4 -4
- package/build/styles/listItem/ListItem.grid.css +3 -3
- package/build/styles/main.css +4 -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/package.json +3 -3
- 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 +4 -4
- package/src/switch/Switch.story.tsx +64 -42
- package/src/switch/Switch.test.story.tsx +123 -0
|
@@ -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
|
|