@transferwise/components 46.168.1 → 46.169.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/CardWidget/CardWidgetAction.js +7 -4
- package/build/CardWidget/CardWidgetAction.js.map +1 -1
- package/build/CardWidget/CardWidgetAction.mjs +7 -4
- package/build/CardWidget/CardWidgetAction.mjs.map +1 -1
- package/build/ListItem/ListItem.js +32 -2
- package/build/ListItem/ListItem.js.map +1 -1
- package/build/ListItem/ListItem.mjs +33 -3
- package/build/ListItem/ListItem.mjs.map +1 -1
- package/build/Prompt/Snackbar/Snackbar.js +7 -2
- package/build/Prompt/Snackbar/Snackbar.js.map +1 -1
- package/build/Prompt/Snackbar/Snackbar.mjs +3 -1
- package/build/Prompt/Snackbar/Snackbar.mjs.map +1 -1
- package/build/Prompt/Snackbar/SnackbarProvider.js +2 -2
- package/build/Prompt/Snackbar/SnackbarProvider.js.map +1 -1
- package/build/Prompt/Snackbar/SnackbarProvider.mjs +2 -2
- package/build/Prompt/Snackbar/SnackbarProvider.mjs.map +1 -1
- package/build/i18n/de.json +1 -0
- package/build/i18n/de.json.js +1 -0
- package/build/i18n/de.json.js.map +1 -1
- package/build/i18n/de.json.mjs +1 -0
- package/build/i18n/de.json.mjs.map +1 -1
- package/build/i18n/hu.json +1 -0
- package/build/i18n/hu.json.js +1 -0
- package/build/i18n/hu.json.js.map +1 -1
- package/build/i18n/hu.json.mjs +1 -0
- package/build/i18n/hu.json.mjs.map +1 -1
- package/build/i18n/it.json +1 -0
- package/build/i18n/it.json.js +1 -0
- package/build/i18n/it.json.js.map +1 -1
- package/build/i18n/it.json.mjs +1 -0
- package/build/i18n/it.json.mjs.map +1 -1
- package/build/i18n/nl.json +1 -1
- package/build/i18n/nl.json.js +1 -1
- package/build/i18n/nl.json.mjs +1 -1
- package/build/i18n/pl.json +1 -0
- package/build/i18n/pl.json.js +1 -0
- package/build/i18n/pl.json.js.map +1 -1
- package/build/i18n/pl.json.mjs +1 -0
- package/build/i18n/pl.json.mjs.map +1 -1
- package/build/i18n/th.json +1 -0
- package/build/i18n/th.json.js +1 -0
- package/build/i18n/th.json.js.map +1 -1
- package/build/i18n/th.json.mjs +1 -0
- package/build/i18n/th.json.mjs.map +1 -1
- package/build/main.css +39 -16
- package/build/styles/CardContainer/CardContainer.css +23 -0
- package/build/styles/CardWidget/CardWidget.css +5 -0
- package/build/styles/Prompt/ActionPrompt/ActionPrompt.css +10 -2
- package/build/styles/Prompt/CriticalBanner/CriticalBanner.css +1 -5
- package/build/styles/Prompt/PrimitivePrompt/PrimitivePrompt.css +0 -9
- package/build/styles/Prompt/PrimitivePrompt/PrimitivePrompt.vars.css +0 -0
- package/build/styles/main.css +39 -16
- package/build/types/CardContainer/CardContainer.types.d.ts +4 -3
- package/build/types/CardContainer/CardContainer.types.d.ts.map +1 -1
- package/build/types/CardWidget/CardWidget.types.d.ts +3 -1
- package/build/types/CardWidget/CardWidget.types.d.ts.map +1 -1
- package/build/types/CardWidget/CardWidgetAction.d.ts +10 -3
- package/build/types/CardWidget/CardWidgetAction.d.ts.map +1 -1
- package/build/types/ListItem/ListItem.d.ts +2 -0
- package/build/types/ListItem/ListItem.d.ts.map +1 -1
- package/build/types/Prompt/Snackbar/Snackbar.d.ts +2 -1
- package/build/types/Prompt/Snackbar/Snackbar.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/CardContainer/CardContainer.css +23 -0
- package/src/CardContainer/CardContainer.less +32 -0
- package/src/CardContainer/CardContainer.types.ts +4 -3
- package/src/CardContainer/_stories/CardContainer.story.tsx +25 -2
- package/src/CardWidget/CardWidget.css +5 -0
- package/src/CardWidget/CardWidget.less +8 -0
- package/src/CardWidget/CardWidget.test.tsx +16 -0
- package/src/CardWidget/CardWidget.types.ts +3 -1
- package/src/CardWidget/CardWidgetAction.tsx +14 -3
- package/src/CardWidget/_stories/CardWidget.story.tsx +57 -2
- package/src/CardWidget/_stories/CardWidget.test.story.tsx +20 -1
- package/src/ListItem/ListItem.ssr.test.tsx +115 -0
- package/src/ListItem/ListItem.test.tsx +42 -0
- package/src/ListItem/ListItem.tsx +23 -2
- package/src/Prompt/ActionPrompt/ActionPrompt.css +10 -2
- package/src/Prompt/ActionPrompt/ActionPrompt.less +17 -2
- package/src/Prompt/ActionPrompt/_stories/ActionPrompt.test.story.tsx +29 -29
- package/src/Prompt/CriticalBanner/CriticalBanner.css +1 -5
- package/src/Prompt/CriticalBanner/CriticalBanner.less +3 -6
- package/src/Prompt/CriticalBanner/CriticalBanner.vars.less +3 -3
- package/src/Prompt/PrimitivePrompt/PrimitivePrompt.css +0 -9
- package/src/Prompt/PrimitivePrompt/PrimitivePrompt.less +0 -9
- package/src/Prompt/PrimitivePrompt/PrimitivePrompt.vars.css +0 -0
- package/src/Prompt/PrimitivePrompt/PrimitivePrompt.vars.less +2 -0
- package/src/Prompt/Snackbar/Snackbar.tsx +2 -1
- package/src/Prompt/Snackbar/SnackbarProvider.tsx +2 -2
- package/src/i18n/de.json +1 -0
- package/src/i18n/hu.json +1 -0
- package/src/i18n/it.json +1 -0
- package/src/i18n/nl.json +1 -1
- package/src/i18n/pl.json +1 -0
- package/src/i18n/th.json +1 -0
- package/src/main.css +39 -16
- package/build/Prompt/Snackbar/SnackbarPortal.js +0 -12
- package/build/Prompt/Snackbar/SnackbarPortal.js.map +0 -1
- package/build/Prompt/Snackbar/SnackbarPortal.mjs +0 -8
- package/build/Prompt/Snackbar/SnackbarPortal.mjs.map +0 -1
- package/build/types/Prompt/Snackbar/SnackbarPortal.d.ts +0 -4
- package/build/types/Prompt/Snackbar/SnackbarPortal.d.ts.map +0 -1
- package/src/Prompt/Snackbar/SnackbarPortal.tsx +0 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plus, Settings } from '@transferwise/icons';
|
|
1
|
+
import { Cog, Email, Plus, Settings } from '@transferwise/icons';
|
|
2
2
|
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
3
3
|
|
|
4
4
|
import {
|
|
@@ -97,7 +97,8 @@ export const TitleLink: Story = {
|
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
* An action object with a `label` renders a small button, and one with only an `icon` a 32px icon
|
|
100
|
-
* button, which requires an `aria-label`.
|
|
100
|
+
* button, which requires an `aria-label`. A labelled action's icon follows its label, or leads
|
|
101
|
+
* it with `iconPosition: 'start'`. `actionSecondary` renders before `action` at a lower
|
|
101
102
|
* emphasis; two actions is the maximum, to keep the title legible. When the header is 360px wide
|
|
102
103
|
* or narrower, the actions move under a title that doesn't fit beside them on one line.
|
|
103
104
|
*/
|
|
@@ -121,6 +122,25 @@ export const Actions: Story = {
|
|
|
121
122
|
<SampleContent />
|
|
122
123
|
</CardWidget>
|
|
123
124
|
</div>
|
|
125
|
+
|
|
126
|
+
<CardWidget
|
|
127
|
+
header={{
|
|
128
|
+
...header,
|
|
129
|
+
action: { label: 'Forward to email', icon: <Email size={16} />, iconPosition: 'start' },
|
|
130
|
+
}}
|
|
131
|
+
>
|
|
132
|
+
<SampleContent />
|
|
133
|
+
</CardWidget>
|
|
134
|
+
|
|
135
|
+
<CardWidget
|
|
136
|
+
header={{
|
|
137
|
+
...header,
|
|
138
|
+
action: { 'aria-label': 'Order card', icon: <Plus size={16} /> },
|
|
139
|
+
actionSecondary: { label: 'Manage', icon: <Cog size={16} />, iconPosition: 'start' },
|
|
140
|
+
}}
|
|
141
|
+
>
|
|
142
|
+
<SampleContent />
|
|
143
|
+
</CardWidget>
|
|
124
144
|
</div>
|
|
125
145
|
);
|
|
126
146
|
},
|
|
@@ -184,6 +204,41 @@ export const WithList: Story = {
|
|
|
184
204
|
),
|
|
185
205
|
};
|
|
186
206
|
|
|
207
|
+
/**
|
|
208
|
+
* A widget stretched to a fixed-height container, with a footer of small print after its content.
|
|
209
|
+
* The content fills the rest of the card's height, so the footer's `margin-top: auto` pushes it to
|
|
210
|
+
* the bottom of the card.
|
|
211
|
+
*/
|
|
212
|
+
export const FixedHeight: Story = {
|
|
213
|
+
parameters: { controls: { disable: true } },
|
|
214
|
+
render: () => (
|
|
215
|
+
<div
|
|
216
|
+
style={{
|
|
217
|
+
display: 'grid',
|
|
218
|
+
height: '400px',
|
|
219
|
+
maxWidth: '480px',
|
|
220
|
+
}}
|
|
221
|
+
>
|
|
222
|
+
<CardWidget
|
|
223
|
+
spotlight="active"
|
|
224
|
+
header={{
|
|
225
|
+
title: 'Balance',
|
|
226
|
+
titleAction: { href: '#balance' },
|
|
227
|
+
action: { label: 'Add money', icon: <Plus size={16} />, iconPosition: 'start' },
|
|
228
|
+
}}
|
|
229
|
+
>
|
|
230
|
+
<Body type={Typography.BODY_LARGE_BOLD}>10,250.00 GBP</Body>
|
|
231
|
+
<Body>Your money is held with our partner banks.</Body>
|
|
232
|
+
<footer style={{ marginTop: 'auto', paddingTop: 'var(--size-16)' }}>
|
|
233
|
+
<Body style={{ color: 'var(--color-content-secondary)' }}>
|
|
234
|
+
Interest rates are variable and can change. Capital at risk. Terms and conditions apply.
|
|
235
|
+
</Body>
|
|
236
|
+
</footer>
|
|
237
|
+
</CardWidget>
|
|
238
|
+
</div>
|
|
239
|
+
),
|
|
240
|
+
};
|
|
241
|
+
|
|
187
242
|
/**
|
|
188
243
|
* The card shows as hovered or pressed while the title link is, and as hovered while the link has
|
|
189
244
|
* keyboard focus. Hovering or pressing the rest of
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Card, Jar, Plus, Settings, Travel } from '@transferwise/icons';
|
|
1
|
+
import { Card, Cog, Email, Jar, Plus, Settings, Travel } from '@transferwise/icons';
|
|
2
2
|
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
3
3
|
import { useTheme } from '@wise/components-theming';
|
|
4
4
|
|
|
@@ -101,6 +101,15 @@ export const HeaderCombinations: Story = {
|
|
|
101
101
|
<Body>Content</Body>
|
|
102
102
|
</CardWidget>
|
|
103
103
|
|
|
104
|
+
<CardWidget
|
|
105
|
+
header={{
|
|
106
|
+
title: 'Icon at the start of the label',
|
|
107
|
+
action: { label: 'Forward to email', icon: <Email size={16} />, iconPosition: 'start' },
|
|
108
|
+
}}
|
|
109
|
+
>
|
|
110
|
+
<Body>Content</Body>
|
|
111
|
+
</CardWidget>
|
|
112
|
+
|
|
104
113
|
<CardWidget
|
|
105
114
|
header={{
|
|
106
115
|
title: 'Both actions, icon only',
|
|
@@ -111,6 +120,16 @@ export const HeaderCombinations: Story = {
|
|
|
111
120
|
<Body>Content</Body>
|
|
112
121
|
</CardWidget>
|
|
113
122
|
|
|
123
|
+
<CardWidget
|
|
124
|
+
header={{
|
|
125
|
+
title: 'Labelled secondary action, icon-only action',
|
|
126
|
+
action: { 'aria-label': 'Add', icon: <Plus size={16} /> },
|
|
127
|
+
actionSecondary: { label: 'Manage', icon: <Cog size={16} />, iconPosition: 'start' },
|
|
128
|
+
}}
|
|
129
|
+
>
|
|
130
|
+
<Body>Content</Body>
|
|
131
|
+
</CardWidget>
|
|
132
|
+
|
|
114
133
|
<CardWidget
|
|
115
134
|
header={{
|
|
116
135
|
title: 'A title long enough to wrap onto more than a single line next to its actions',
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { renderToString } from 'react-dom/server';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { Edit } from '@transferwise/icons';
|
|
4
|
+
import { mockMatchMedia, within } from '../test-utils';
|
|
5
|
+
import Provider from '../Provider';
|
|
6
|
+
import en from '../i18n/en.json';
|
|
7
|
+
import { ListItem } from './ListItem';
|
|
8
|
+
|
|
9
|
+
mockMatchMedia();
|
|
10
|
+
|
|
11
|
+
describe('ListItem server rendering and hydration', () => {
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
jest.spyOn(console, 'error').mockImplementation((message: string) => {
|
|
14
|
+
// React 18 warns about the existing layout effects when rendering on the server.
|
|
15
|
+
if (!message.startsWith('Warning: useLayoutEffect does nothing on the server')) {
|
|
16
|
+
throw new Error(message);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
jest.restoreAllMocks();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const controls = [
|
|
26
|
+
{ name: 'navigation link', control: <ListItem.Navigation href="/payments" /> },
|
|
27
|
+
{ name: 'navigation button', control: <ListItem.Navigation /> },
|
|
28
|
+
{
|
|
29
|
+
name: 'navigation without indicator',
|
|
30
|
+
control: <ListItem.Navigation href="/payments" hideIndicator />,
|
|
31
|
+
},
|
|
32
|
+
{ name: 'button', control: <ListItem.Button>Pay</ListItem.Button> },
|
|
33
|
+
{ name: 'button link', control: <ListItem.Button href="/payments">Pay</ListItem.Button> },
|
|
34
|
+
{
|
|
35
|
+
name: 'icon button',
|
|
36
|
+
control: (
|
|
37
|
+
<ListItem.IconButton aria-label="Edit">
|
|
38
|
+
<Edit />
|
|
39
|
+
</ListItem.IconButton>
|
|
40
|
+
),
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'icon button link',
|
|
44
|
+
control: (
|
|
45
|
+
<ListItem.IconButton href="/payments" aria-label="Edit">
|
|
46
|
+
<Edit />
|
|
47
|
+
</ListItem.IconButton>
|
|
48
|
+
),
|
|
49
|
+
},
|
|
50
|
+
{ name: 'checkbox', control: <ListItem.Checkbox /> },
|
|
51
|
+
{ name: 'radio', control: <ListItem.Radio name="payment" /> },
|
|
52
|
+
{ name: 'switch', control: <ListItem.Switch onClick={jest.fn()} /> },
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
describe.each(['active', 'inactive'] as const)('%s spotlight', (spotlight) => {
|
|
56
|
+
it.each(controls)(
|
|
57
|
+
'is present before hydration and unchanged afterwards for $name',
|
|
58
|
+
({ control }) => {
|
|
59
|
+
const element = (
|
|
60
|
+
<Provider i18n={{ locale: 'en-GB', messages: en }}>
|
|
61
|
+
<ListItem title="Payments" spotlight={spotlight} control={control} />
|
|
62
|
+
</Provider>
|
|
63
|
+
);
|
|
64
|
+
const container = document.createElement('div');
|
|
65
|
+
container.innerHTML = renderToString(element);
|
|
66
|
+
const item = within(container).getByRole('listitem');
|
|
67
|
+
expect(item).toHaveClass(
|
|
68
|
+
'wds-list-item-interactive',
|
|
69
|
+
'wds-list-item-spotlight',
|
|
70
|
+
`wds-list-item-spotlight-${spotlight}`,
|
|
71
|
+
);
|
|
72
|
+
expect(item.querySelector('.wds-list-item-spotlight__border') !== null).toBe(
|
|
73
|
+
spotlight === 'inactive',
|
|
74
|
+
);
|
|
75
|
+
const serverMarkup = container.innerHTML;
|
|
76
|
+
|
|
77
|
+
render(element, { container, hydrate: true });
|
|
78
|
+
|
|
79
|
+
expect(within(container).getByRole('listitem')).toBe(item);
|
|
80
|
+
expect(container.innerHTML).toBe(serverMarkup);
|
|
81
|
+
},
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
it.each([
|
|
85
|
+
{ name: 'no control', control: undefined },
|
|
86
|
+
{
|
|
87
|
+
name: 'partial button',
|
|
88
|
+
control: <ListItem.Button partiallyInteractive>Pay</ListItem.Button>,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'partial icon button',
|
|
92
|
+
control: (
|
|
93
|
+
<ListItem.IconButton partiallyInteractive aria-label="Edit">
|
|
94
|
+
<Edit />
|
|
95
|
+
</ListItem.IconButton>
|
|
96
|
+
),
|
|
97
|
+
},
|
|
98
|
+
])('is absent before and after hydration for $name', ({ control }) => {
|
|
99
|
+
const element = (
|
|
100
|
+
<Provider i18n={{ locale: 'en-GB', messages: en }}>
|
|
101
|
+
<ListItem title="Payments" spotlight={spotlight} control={control} />
|
|
102
|
+
</Provider>
|
|
103
|
+
);
|
|
104
|
+
const container = document.createElement('div');
|
|
105
|
+
container.innerHTML = renderToString(element);
|
|
106
|
+
expect(within(container).getByRole('listitem')).not.toHaveClass('wds-list-item-spotlight');
|
|
107
|
+
expect(container.querySelector('.wds-list-item-spotlight__border')).toBeNull();
|
|
108
|
+
const serverMarkup = container.innerHTML;
|
|
109
|
+
|
|
110
|
+
render(element, { container, hydrate: true });
|
|
111
|
+
|
|
112
|
+
expect(container.innerHTML).toBe(serverMarkup);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
});
|
|
@@ -1480,6 +1480,48 @@ describe('ListItem', () => {
|
|
|
1480
1480
|
});
|
|
1481
1481
|
|
|
1482
1482
|
describe('spotlight', () => {
|
|
1483
|
+
it('updates spotlight when the control changes or is removed', () => {
|
|
1484
|
+
const { rerender } = render(
|
|
1485
|
+
<ListItem
|
|
1486
|
+
title="Test Title"
|
|
1487
|
+
spotlight="inactive"
|
|
1488
|
+
control={<ListItem.Button>Pay</ListItem.Button>}
|
|
1489
|
+
/>,
|
|
1490
|
+
);
|
|
1491
|
+
expect(screen.getByRole('listitem')).toHaveClass('wds-list-item-spotlight-inactive');
|
|
1492
|
+
|
|
1493
|
+
rerender(
|
|
1494
|
+
<ListItem
|
|
1495
|
+
title="Test Title"
|
|
1496
|
+
spotlight="inactive"
|
|
1497
|
+
control={<ListItem.Button partiallyInteractive>Pay</ListItem.Button>}
|
|
1498
|
+
/>,
|
|
1499
|
+
);
|
|
1500
|
+
expect(screen.getByRole('listitem')).not.toHaveClass('wds-list-item-spotlight');
|
|
1501
|
+
expect(screen.getByRole('listitem')).toHaveClass('wds-list-item-partially-interactive');
|
|
1502
|
+
|
|
1503
|
+
rerender(
|
|
1504
|
+
<ListItem
|
|
1505
|
+
title="Test Title"
|
|
1506
|
+
spotlight="active"
|
|
1507
|
+
control={<ListItem.Switch onClick={cb} />}
|
|
1508
|
+
/>,
|
|
1509
|
+
);
|
|
1510
|
+
expect(screen.getByRole('listitem')).toHaveClass('wds-list-item-spotlight-active');
|
|
1511
|
+
|
|
1512
|
+
rerender(<ListItem title="Test Title" spotlight="inactive" />);
|
|
1513
|
+
const listItem = screen.getByRole('listitem');
|
|
1514
|
+
expect(listItem).toHaveClass('wds-list-item-non-interactive');
|
|
1515
|
+
expect(listItem).not.toHaveClass('wds-list-item-spotlight');
|
|
1516
|
+
expect(listItem.querySelector('.wds-list-item-spotlight__border')).toBeNull();
|
|
1517
|
+
});
|
|
1518
|
+
|
|
1519
|
+
it('preserves client-side registration for wrapped controls', () => {
|
|
1520
|
+
const WrappedControl = () => <ListItem.Switch onClick={cb} />;
|
|
1521
|
+
render(<ListItem title="Test Title" spotlight="inactive" control={<WrappedControl />} />);
|
|
1522
|
+
expect(screen.getByRole('listitem')).toHaveClass('wds-list-item-spotlight-inactive');
|
|
1523
|
+
});
|
|
1524
|
+
|
|
1483
1525
|
it('only fully interactive variant can have spotlight:active', () => {
|
|
1484
1526
|
render(<ListItem title="Test Title" spotlight="active" control={<ListItem.Navigation />} />);
|
|
1485
1527
|
const listItem = screen.getByRole('listitem');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
isValidElement,
|
|
2
3
|
useContext,
|
|
3
4
|
useId,
|
|
4
5
|
useMemo,
|
|
@@ -38,6 +39,15 @@ export type ListItemControlProps =
|
|
|
38
39
|
| ListItemRadioProps
|
|
39
40
|
| ListItemSwitchProps;
|
|
40
41
|
|
|
42
|
+
const LIST_ITEM_CONTROLS = [
|
|
43
|
+
{ component: Navigation, type: 'navigation' },
|
|
44
|
+
{ component: Button, type: 'button' },
|
|
45
|
+
{ component: IconButton, type: 'icon-button' },
|
|
46
|
+
{ component: Checkbox, type: 'checkbox' },
|
|
47
|
+
{ component: Radio, type: 'radio' },
|
|
48
|
+
{ component: Switch, type: 'switch' },
|
|
49
|
+
] as const;
|
|
50
|
+
|
|
41
51
|
export type ListItemProps = {
|
|
42
52
|
/** @default 'li' */
|
|
43
53
|
as?: 'li' | 'div';
|
|
@@ -57,6 +67,8 @@ export type ListItemProps = {
|
|
|
57
67
|
disabledPromptMessage?: ReactNode;
|
|
58
68
|
/**
|
|
59
69
|
* Highlights the list item as an action to be taken or already taken. <br />
|
|
70
|
+
* Only applies to fully interactive items. Pass a supported ListItem control directly
|
|
71
|
+
* to include spotlight styles in server-rendered markup.
|
|
60
72
|
*/
|
|
61
73
|
spotlight?: 'active' | 'inactive';
|
|
62
74
|
/**
|
|
@@ -128,10 +140,19 @@ export const ListItem = ({
|
|
|
128
140
|
id,
|
|
129
141
|
}: ListItemProps) => {
|
|
130
142
|
const idPrefix = useId();
|
|
131
|
-
const [
|
|
132
|
-
const [
|
|
143
|
+
const [registeredControlProps, setControlProps] = useState<ListItemControlProps>({});
|
|
144
|
+
const [registeredControlType, setControlType] = useState<ListItemTypes>('non-interactive');
|
|
133
145
|
const [mediaSize, setMediaSize] = useState<ListItemMediaSize | undefined>();
|
|
134
146
|
|
|
147
|
+
// Resolve supported controls during SSR; retain registration for wrapped controls.
|
|
148
|
+
const controlElement = isValidElement<ListItemControlProps>(control) ? control : undefined;
|
|
149
|
+
const directControlType = LIST_ITEM_CONTROLS.find(
|
|
150
|
+
({ component }) => component === controlElement?.type,
|
|
151
|
+
)?.type;
|
|
152
|
+
const controlType = control ? (directControlType ?? registeredControlType) : 'non-interactive';
|
|
153
|
+
const controlProps =
|
|
154
|
+
directControlType && controlElement ? controlElement.props : registeredControlProps;
|
|
155
|
+
|
|
135
156
|
const ids: ListItemContextData['ids'] = {
|
|
136
157
|
title: `${idPrefix}_title`,
|
|
137
158
|
...(subtitle ? { subtitle: `${idPrefix}_subtitle` } : {}),
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
--Prompt-actions-gap: var(--size-8);
|
|
5
5
|
--Prompt-gap: var(--size-10) var(--size-16);
|
|
6
6
|
--Prompt-border-radius: var(--radius-large);
|
|
7
|
+
container: wds-action-prompt / inline-size;
|
|
7
8
|
}
|
|
8
9
|
.wds-action-prompt--media-image {
|
|
9
10
|
inline-size: var(--size-48);
|
|
@@ -11,12 +12,19 @@
|
|
|
11
12
|
-o-object-fit: contain;
|
|
12
13
|
object-fit: contain;
|
|
13
14
|
}
|
|
14
|
-
@
|
|
15
|
+
@container wds-action-prompt (width < 600px) {
|
|
16
|
+
.wds-action-prompt .wds-prompt__actions-wrapper {
|
|
17
|
+
grid-column: span 2;
|
|
18
|
+
inline-size: 100%;
|
|
19
|
+
}
|
|
20
|
+
.wds-action-prompt .wds-prompt__content-wrapper--with-dismiss .wds-prompt__actions-wrapper {
|
|
21
|
+
grid-column: span 3;
|
|
22
|
+
}
|
|
15
23
|
.wds-action-prompt .wds-action-prompt__action {
|
|
16
24
|
inline-size: 100%;
|
|
17
25
|
}
|
|
18
26
|
}
|
|
19
|
-
@
|
|
27
|
+
@container wds-action-prompt (width < 600px) {
|
|
20
28
|
.wds-action-prompt--with-two-actions .wds-action-prompt__action {
|
|
21
29
|
flex: 1 1 calc(50% - (var(--Prompt-actions-gap) / 2));
|
|
22
30
|
min-inline-size: -moz-fit-content;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@import (reference) "../PrimitivePrompt/PrimitivePrompt.vars.less";
|
|
2
|
+
|
|
1
3
|
.wds-action-prompt {
|
|
2
4
|
--Prompt-padding-x: var(--size-16);
|
|
3
5
|
--Prompt-padding-y: var(--size-16);
|
|
@@ -5,20 +7,33 @@
|
|
|
5
7
|
--Prompt-gap: var(--size-10) var(--size-16);
|
|
6
8
|
--Prompt-border-radius: var(--radius-large);
|
|
7
9
|
|
|
10
|
+
// Responsive to the prompt's own width rather than the viewport, so it adapts to narrow
|
|
11
|
+
// containers. Named so ancestor containers can't intercept the queries.
|
|
12
|
+
container: wds-action-prompt / inline-size;
|
|
13
|
+
|
|
8
14
|
&--media-image {
|
|
9
15
|
width: var(--size-48);
|
|
10
16
|
height: var(--size-48);
|
|
11
17
|
object-fit: contain;
|
|
12
18
|
}
|
|
13
19
|
|
|
14
|
-
@
|
|
20
|
+
@container wds-action-prompt (width < @wds-prompt-actions-full-width-max) {
|
|
21
|
+
.wds-prompt__actions-wrapper {
|
|
22
|
+
grid-column: span 2;
|
|
23
|
+
width: 100%;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.wds-prompt__content-wrapper--with-dismiss .wds-prompt__actions-wrapper {
|
|
27
|
+
grid-column: span 3;
|
|
28
|
+
}
|
|
29
|
+
|
|
15
30
|
.wds-action-prompt__action {
|
|
16
31
|
width: 100%;
|
|
17
32
|
}
|
|
18
33
|
}
|
|
19
34
|
|
|
20
35
|
&--with-two-actions {
|
|
21
|
-
@
|
|
36
|
+
@container wds-action-prompt (width < @wds-prompt-actions-full-width-max) {
|
|
22
37
|
.wds-action-prompt__action {
|
|
23
38
|
flex: 1 1 calc(50% - (var(--Prompt-actions-gap) / 2));
|
|
24
39
|
min-width: fit-content;
|
|
@@ -232,37 +232,37 @@ export const TinyScreen: Story = {
|
|
|
232
232
|
};
|
|
233
233
|
|
|
234
234
|
/**
|
|
235
|
-
* ActionPrompt adapts its layout
|
|
236
|
-
*
|
|
235
|
+
* ActionPrompt adapts its layout to its own width (container queries), not the viewport.
|
|
236
|
+
* Below a 600px content width the buttons go full width, otherwise they sit side by side.
|
|
237
237
|
*/
|
|
238
238
|
export const Responsiveness: Story = {
|
|
239
|
-
render: (
|
|
240
|
-
<div
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
239
|
+
render: () => (
|
|
240
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
|
|
241
|
+
{[
|
|
242
|
+
{ width: 320, layout: 'Full width' },
|
|
243
|
+
{ width: 480, layout: 'Full width' },
|
|
244
|
+
{ width: 800, layout: 'Side by side' },
|
|
245
|
+
].map(({ width, layout }) => (
|
|
246
|
+
<div key={width} style={{ width }}>
|
|
247
|
+
<ActionPrompt
|
|
248
|
+
sentiment="proposition"
|
|
249
|
+
title={`${layout} (${width}px)`}
|
|
250
|
+
description={lorem10}
|
|
251
|
+
media={{ avatar: { asset: <Suitcase /> } }}
|
|
252
|
+
action={{ label: 'Primary action', onClick: fn() }}
|
|
253
|
+
actionSecondary={{ label: 'Secondary', onClick: fn() }}
|
|
254
|
+
onDismiss={fn()}
|
|
255
|
+
/>
|
|
256
|
+
</div>
|
|
257
|
+
))}
|
|
258
|
+
<div style={{ width: 320 }}>
|
|
259
|
+
<ActionPrompt
|
|
260
|
+
sentiment="neutral"
|
|
261
|
+
title="Single action, full width (320px)"
|
|
262
|
+
description={lorem10}
|
|
263
|
+
action={{ label: 'Primary action', onClick: fn() }}
|
|
264
|
+
/>
|
|
265
|
+
</div>
|
|
266
266
|
</div>
|
|
267
267
|
),
|
|
268
268
|
parameters: {
|
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
position: relative;
|
|
12
12
|
--critical-banner-easing: cubic-bezier(0.9, 0, 0.7, 1);
|
|
13
13
|
--critical-banner-duration: 150ms;
|
|
14
|
-
/* Override PrimitivePrompt's --screen-sm-max actions behaviour:
|
|
15
|
-
actions only go full-width below mobile-max token (container query) */
|
|
16
14
|
}
|
|
17
15
|
.wds-critical-banner.wds-prompt--neutral {
|
|
18
16
|
--critical-banner-background-base: var(--color-background-elevated);
|
|
@@ -91,13 +89,11 @@
|
|
|
91
89
|
}
|
|
92
90
|
}
|
|
93
91
|
.wds-critical-banner .wds-prompt__actions-wrapper {
|
|
94
|
-
grid-column-start: 2;
|
|
95
|
-
grid-column-end: 3;
|
|
96
92
|
max-block-size: 200px;
|
|
97
93
|
opacity: 1;
|
|
98
94
|
overflow: visible;
|
|
99
95
|
}
|
|
100
|
-
@container (
|
|
96
|
+
@container (width < 600px) {
|
|
101
97
|
.wds-critical-banner .wds-prompt__actions-wrapper {
|
|
102
98
|
grid-column: span 3;
|
|
103
99
|
inline-size: 100%;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
@import (reference) "@transferwise/neptune-tokens/breakpoints.less";
|
|
2
|
+
@import (reference) "../PrimitivePrompt/PrimitivePrompt.vars.less";
|
|
2
3
|
@import (reference) "./CriticalBanner.vars.less";
|
|
3
4
|
|
|
4
5
|
.wds-critical-banner {
|
|
@@ -114,16 +115,12 @@
|
|
|
114
115
|
}
|
|
115
116
|
}
|
|
116
117
|
|
|
117
|
-
/* Override PrimitivePrompt's --screen-sm-max actions behaviour:
|
|
118
|
-
actions only go full-width below mobile-max token (container query) */
|
|
119
118
|
.wds-prompt__actions-wrapper {
|
|
120
|
-
grid-column-start: 2;
|
|
121
|
-
grid-column-end: 3;
|
|
122
119
|
max-height: 200px;
|
|
123
120
|
opacity: 1;
|
|
124
121
|
overflow: visible;
|
|
125
122
|
|
|
126
|
-
@container (
|
|
123
|
+
@container (width < @wds-prompt-actions-full-width-max) {
|
|
127
124
|
grid-column: span 3;
|
|
128
125
|
width: 100%;
|
|
129
126
|
|
|
@@ -142,7 +139,7 @@
|
|
|
142
139
|
}
|
|
143
140
|
|
|
144
141
|
&--with-two-actions .wds-prompt__actions-wrapper {
|
|
145
|
-
@container (max-width: @wds-
|
|
142
|
+
@container (max-width: @wds-prompt-actions-full-width-max) {
|
|
146
143
|
.wds-Button {
|
|
147
144
|
flex: 1 1 calc(50% - (var(--Prompt-actions-gap) / 2));
|
|
148
145
|
min-width: fit-content;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// CriticalBanner has 2 layout modes managed through container queries:
|
|
2
|
-
// * buttons are full width below
|
|
3
|
-
// * collapse toggle is visible below collapsible-max token
|
|
2
|
+
// * buttons are full width below @wds-prompt-actions-full-width-max
|
|
3
|
+
// * collapse toggle is visible below @wds-critical-banner-collapsible-max token
|
|
4
4
|
// At some point in the not too distant future hopefully these two value will be the same but because of launchpad quirks, for now they'll be different
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
@wds-critical-banner-mobile-overhang-max: 600px;
|
|
7
7
|
@wds-critical-banner-collapsible-max: 768px;
|
|
@@ -35,15 +35,6 @@
|
|
|
35
35
|
grid-column-start: 2;
|
|
36
36
|
grid-column-end: 3;
|
|
37
37
|
}
|
|
38
|
-
@media (max-width: 599.98px) {
|
|
39
|
-
.wds-prompt__actions-wrapper {
|
|
40
|
-
grid-column: span 2;
|
|
41
|
-
inline-size: 100%;
|
|
42
|
-
}
|
|
43
|
-
.wds-prompt__content-wrapper--with-dismiss .wds-prompt__actions-wrapper {
|
|
44
|
-
grid-column: span 3;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
38
|
.wds-prompt__dismiss {
|
|
48
39
|
position: relative;
|
|
49
40
|
}
|
|
@@ -37,15 +37,6 @@
|
|
|
37
37
|
gap: var(--Prompt-actions-gap, var(--size-8));
|
|
38
38
|
grid-column-start: 2;
|
|
39
39
|
grid-column-end: 3;
|
|
40
|
-
|
|
41
|
-
@media (--screen-xs-max) {
|
|
42
|
-
grid-column: span 2;
|
|
43
|
-
width: 100%;
|
|
44
|
-
|
|
45
|
-
.wds-prompt__content-wrapper--with-dismiss & {
|
|
46
|
-
grid-column: span 3;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
40
|
}
|
|
50
41
|
|
|
51
42
|
&__dismiss {
|
|
File without changes
|
|
@@ -11,6 +11,7 @@ import { PrimitivePrompt } from '../PrimitivePrompt';
|
|
|
11
11
|
import ProcessIndicator from '../../ProcessIndicator';
|
|
12
12
|
import type { Sentiment } from '../../SentimentSurface';
|
|
13
13
|
import StatusIcon from '../../StatusIcon';
|
|
14
|
+
import withNextPortal from '../../WithNextPortal/WithNextPortal';
|
|
14
15
|
|
|
15
16
|
import { SNACKBAR_ENTER_DURATION, SNACKBAR_EXIT_DURATION } from './constants';
|
|
16
17
|
import messages from './Snackbar.messages';
|
|
@@ -240,4 +241,4 @@ export const Snackbar = ({
|
|
|
240
241
|
);
|
|
241
242
|
};
|
|
242
243
|
|
|
243
|
-
export default Snackbar;
|
|
244
|
+
export default withNextPortal(Snackbar);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import Snackbar from './Snackbar';
|
|
4
4
|
import { SnackbarContext } from './SnackbarContext';
|
|
5
5
|
import useSnackbarManager from './useSnackbarManager';
|
|
6
6
|
|
|
@@ -24,7 +24,7 @@ export default function SnackbarProvider({ timeout, children }: SnackbarProvider
|
|
|
24
24
|
return (
|
|
25
25
|
<SnackbarContext.Provider value={contextValue}>
|
|
26
26
|
{active ? (
|
|
27
|
-
<
|
|
27
|
+
<Snackbar
|
|
28
28
|
// Each instance gets a fresh appear transition and live-region announcement.
|
|
29
29
|
key={active.id}
|
|
30
30
|
{...active.props}
|
package/src/i18n/de.json
CHANGED
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"neptune.PhoneNumberInput.phoneNumberPrefix": "Vorwahl",
|
|
39
39
|
"neptune.Select.searchPlaceholder": "Wird gesucht...",
|
|
40
40
|
"neptune.SelectInput.noResultsFound": "Keine Ergebnisse gefunden",
|
|
41
|
+
"neptune.Snackbar.escapeDismissHint": "Drück die Escape-Taste zum Schließen.",
|
|
41
42
|
"neptune.StatusIcon.iconLabel.error": "Fehler:",
|
|
42
43
|
"neptune.StatusIcon.iconLabel.information": "Auskünfte:",
|
|
43
44
|
"neptune.StatusIcon.iconLabel.pending": "Ausstehend:",
|
package/src/i18n/hu.json
CHANGED
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"neptune.PhoneNumberInput.phoneNumberPrefix": "Előtag",
|
|
39
39
|
"neptune.Select.searchPlaceholder": "Keresés...",
|
|
40
40
|
"neptune.SelectInput.noResultsFound": "Nincs találat",
|
|
41
|
+
"neptune.Snackbar.escapeDismissHint": "Az Escape gomb lenyomásával bezárhatod.",
|
|
41
42
|
"neptune.StatusIcon.iconLabel.error": "Hiba:",
|
|
42
43
|
"neptune.StatusIcon.iconLabel.information": "Információ:",
|
|
43
44
|
"neptune.StatusIcon.iconLabel.pending": "Függőben:",
|
package/src/i18n/it.json
CHANGED
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"neptune.PhoneNumberInput.phoneNumberPrefix": "Prefisso",
|
|
39
39
|
"neptune.Select.searchPlaceholder": "Cerca...",
|
|
40
40
|
"neptune.SelectInput.noResultsFound": "Nessun risultato trovato",
|
|
41
|
+
"neptune.Snackbar.escapeDismissHint": "Premi Esc per ignorare.",
|
|
41
42
|
"neptune.StatusIcon.iconLabel.error": "Errore:",
|
|
42
43
|
"neptune.StatusIcon.iconLabel.information": "Informazioni:",
|
|
43
44
|
"neptune.StatusIcon.iconLabel.pending": "In attesa:",
|
package/src/i18n/nl.json
CHANGED
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"neptune.PhoneNumberInput.phoneNumberPrefix": "Voorvoegsel",
|
|
39
39
|
"neptune.Select.searchPlaceholder": "Zoeken...",
|
|
40
40
|
"neptune.SelectInput.noResultsFound": "Geen resultaten gevonden",
|
|
41
|
-
"neptune.Snackbar.escapeDismissHint": "Druk op
|
|
41
|
+
"neptune.Snackbar.escapeDismissHint": "Druk op Esc om te sluiten.",
|
|
42
42
|
"neptune.StatusIcon.iconLabel.error": "Fout:",
|
|
43
43
|
"neptune.StatusIcon.iconLabel.information": "Informatie:",
|
|
44
44
|
"neptune.StatusIcon.iconLabel.pending": "In behandeling:",
|