@transferwise/components 46.168.1 → 46.168.2
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/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/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 +11 -16
- 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 +11 -16
- 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/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/pl.json +1 -0
- package/src/i18n/th.json +1 -0
- package/src/main.css +11 -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
|
@@ -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/pl.json
CHANGED
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"neptune.PhoneNumberInput.phoneNumberPrefix": "Prefiks",
|
|
39
39
|
"neptune.Select.searchPlaceholder": "Wyszukaj...",
|
|
40
40
|
"neptune.SelectInput.noResultsFound": "Nie znaleziono wyników",
|
|
41
|
+
"neptune.Snackbar.escapeDismissHint": "Naciśnij klawisz Esc, żeby zamknąć ono.",
|
|
41
42
|
"neptune.StatusIcon.iconLabel.error": "Błąd:",
|
|
42
43
|
"neptune.StatusIcon.iconLabel.information": "Informacje:",
|
|
43
44
|
"neptune.StatusIcon.iconLabel.pending": "W toku:",
|
package/src/i18n/th.json
CHANGED
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"neptune.PhoneNumberInput.phoneNumberPrefix": "รหัสประเทศ",
|
|
39
39
|
"neptune.Select.searchPlaceholder": "ค้นหา...",
|
|
40
40
|
"neptune.SelectInput.noResultsFound": "ไม่พบผลลัพธ์",
|
|
41
|
+
"neptune.Snackbar.escapeDismissHint": "กด Escape เพื่อปิด",
|
|
41
42
|
"neptune.StatusIcon.iconLabel.error": "ข้อผิดพลาด:",
|
|
42
43
|
"neptune.StatusIcon.iconLabel.information": "ข้อมูล:",
|
|
43
44
|
"neptune.StatusIcon.iconLabel.pending": "รอดำเนินการ:",
|
package/src/main.css
CHANGED
|
@@ -31064,15 +31064,6 @@ button.np-link {
|
|
|
31064
31064
|
grid-column-start: 2;
|
|
31065
31065
|
grid-column-end: 3;
|
|
31066
31066
|
}
|
|
31067
|
-
@media (max-width: 599.98px) {
|
|
31068
|
-
.wds-prompt__actions-wrapper {
|
|
31069
|
-
grid-column: span 2;
|
|
31070
|
-
inline-size: 100%;
|
|
31071
|
-
}
|
|
31072
|
-
.wds-prompt__content-wrapper--with-dismiss .wds-prompt__actions-wrapper {
|
|
31073
|
-
grid-column: span 3;
|
|
31074
|
-
}
|
|
31075
|
-
}
|
|
31076
31067
|
.wds-prompt__dismiss {
|
|
31077
31068
|
position: relative;
|
|
31078
31069
|
}
|
|
@@ -31196,6 +31187,7 @@ button.np-link {
|
|
|
31196
31187
|
--Prompt-actions-gap: var(--size-8);
|
|
31197
31188
|
--Prompt-gap: var(--size-10) var(--size-16);
|
|
31198
31189
|
--Prompt-border-radius: var(--radius-large);
|
|
31190
|
+
container: wds-action-prompt / inline-size;
|
|
31199
31191
|
}
|
|
31200
31192
|
.wds-action-prompt--media-image {
|
|
31201
31193
|
inline-size: var(--size-48);
|
|
@@ -31203,12 +31195,19 @@ button.np-link {
|
|
|
31203
31195
|
-o-object-fit: contain;
|
|
31204
31196
|
object-fit: contain;
|
|
31205
31197
|
}
|
|
31206
|
-
@
|
|
31198
|
+
@container wds-action-prompt (width < 600px) {
|
|
31199
|
+
.wds-action-prompt .wds-prompt__actions-wrapper {
|
|
31200
|
+
grid-column: span 2;
|
|
31201
|
+
inline-size: 100%;
|
|
31202
|
+
}
|
|
31203
|
+
.wds-action-prompt .wds-prompt__content-wrapper--with-dismiss .wds-prompt__actions-wrapper {
|
|
31204
|
+
grid-column: span 3;
|
|
31205
|
+
}
|
|
31207
31206
|
.wds-action-prompt .wds-action-prompt__action {
|
|
31208
31207
|
inline-size: 100%;
|
|
31209
31208
|
}
|
|
31210
31209
|
}
|
|
31211
|
-
@
|
|
31210
|
+
@container wds-action-prompt (width < 600px) {
|
|
31212
31211
|
.wds-action-prompt--with-two-actions .wds-action-prompt__action {
|
|
31213
31212
|
flex: 1 1 calc(50% - (var(--Prompt-actions-gap) / 2));
|
|
31214
31213
|
min-inline-size: -moz-fit-content;
|
|
@@ -31231,8 +31230,6 @@ button.np-link {
|
|
|
31231
31230
|
position: relative;
|
|
31232
31231
|
--critical-banner-easing: cubic-bezier(0.9, 0, 0.7, 1);
|
|
31233
31232
|
--critical-banner-duration: 150ms;
|
|
31234
|
-
/* Override PrimitivePrompt's --screen-sm-max actions behaviour:
|
|
31235
|
-
actions only go full-width below mobile-max token (container query) */
|
|
31236
31233
|
}
|
|
31237
31234
|
.wds-critical-banner.wds-prompt--neutral {
|
|
31238
31235
|
--critical-banner-background-base: var(--color-background-elevated);
|
|
@@ -31311,13 +31308,11 @@ button.np-link {
|
|
|
31311
31308
|
}
|
|
31312
31309
|
}
|
|
31313
31310
|
.wds-critical-banner .wds-prompt__actions-wrapper {
|
|
31314
|
-
grid-column-start: 2;
|
|
31315
|
-
grid-column-end: 3;
|
|
31316
31311
|
max-block-size: 200px;
|
|
31317
31312
|
opacity: 1;
|
|
31318
31313
|
overflow: visible;
|
|
31319
31314
|
}
|
|
31320
|
-
@container (
|
|
31315
|
+
@container (width < 600px) {
|
|
31321
31316
|
.wds-critical-banner .wds-prompt__actions-wrapper {
|
|
31322
31317
|
grid-column: span 3;
|
|
31323
31318
|
inline-size: 100%;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var WithNextPortal = require('../../WithNextPortal/WithNextPortal.js');
|
|
6
|
-
var Snackbar = require('./Snackbar.js');
|
|
7
|
-
|
|
8
|
-
/** Renders the Snackbar into `document.body` after mount, so it's safe for SSR. */
|
|
9
|
-
const SnackbarPortal = WithNextPortal.default(Snackbar.Snackbar);
|
|
10
|
-
|
|
11
|
-
exports.default = SnackbarPortal;
|
|
12
|
-
//# sourceMappingURL=SnackbarPortal.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SnackbarPortal.js","sources":["../../../src/Prompt/Snackbar/SnackbarPortal.tsx"],"sourcesContent":["import withNextPortal from '../../WithNextPortal/WithNextPortal';\n\nimport { Snackbar } from './Snackbar';\n\n/** Renders the Snackbar into `document.body` after mount, so it's safe for SSR. */\nconst SnackbarPortal = withNextPortal(Snackbar);\n\nexport default SnackbarPortal;\n"],"names":["SnackbarPortal","withNextPortal","Snackbar"],"mappings":";;;;;;;AAIA;AACA,MAAMA,cAAc,GAAGC,sBAAc,CAACC,iBAAQ;;"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import withNextPortalWrapper from '../../WithNextPortal/WithNextPortal.mjs';
|
|
2
|
-
import { Snackbar } from './Snackbar.mjs';
|
|
3
|
-
|
|
4
|
-
/** Renders the Snackbar into `document.body` after mount, so it's safe for SSR. */
|
|
5
|
-
const SnackbarPortal = withNextPortalWrapper(Snackbar);
|
|
6
|
-
|
|
7
|
-
export { SnackbarPortal as default };
|
|
8
|
-
//# sourceMappingURL=SnackbarPortal.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SnackbarPortal.mjs","sources":["../../../src/Prompt/Snackbar/SnackbarPortal.tsx"],"sourcesContent":["import withNextPortal from '../../WithNextPortal/WithNextPortal';\n\nimport { Snackbar } from './Snackbar';\n\n/** Renders the Snackbar into `document.body` after mount, so it's safe for SSR. */\nconst SnackbarPortal = withNextPortal(Snackbar);\n\nexport default SnackbarPortal;\n"],"names":["SnackbarPortal","withNextPortal","Snackbar"],"mappings":";;;AAIA;AACA,MAAMA,cAAc,GAAGC,qBAAc,CAACC,QAAQ;;"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/** Renders the Snackbar into `document.body` after mount, so it's safe for SSR. */
|
|
2
|
-
declare const SnackbarPortal: (props: import("./Snackbar").SnackbarProps) => import("react").ReactPortal | null;
|
|
3
|
-
export default SnackbarPortal;
|
|
4
|
-
//# sourceMappingURL=SnackbarPortal.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SnackbarPortal.d.ts","sourceRoot":"","sources":["../../../../src/Prompt/Snackbar/SnackbarPortal.tsx"],"names":[],"mappings":"AAIA,mFAAmF;AACnF,QAAA,MAAM,cAAc,mFAA2B,CAAC;AAEhD,eAAe,cAAc,CAAC"}
|