@transferwise/components 0.0.0-experimental-303fd87 → 0.0.0-experimental-1aabc72
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/common/panel/Panel.js +1 -0
- package/build/common/panel/Panel.js.map +1 -1
- package/build/common/panel/Panel.mjs +1 -0
- package/build/common/panel/Panel.mjs.map +1 -1
- package/build/common/responsivePanel/ResponsivePanel.js +6 -1
- package/build/common/responsivePanel/ResponsivePanel.js.map +1 -1
- package/build/common/responsivePanel/ResponsivePanel.mjs +6 -1
- package/build/common/responsivePanel/ResponsivePanel.mjs.map +1 -1
- package/build/dateLookup/DateLookup.js +1 -0
- package/build/dateLookup/DateLookup.js.map +1 -1
- package/build/dateLookup/DateLookup.mjs +1 -0
- package/build/dateLookup/DateLookup.mjs.map +1 -1
- package/build/inputs/_BottomSheet.js +0 -10
- package/build/inputs/_BottomSheet.js.map +1 -1
- package/build/inputs/_BottomSheet.mjs +1 -11
- package/build/inputs/_BottomSheet.mjs.map +1 -1
- package/build/main.css +10 -35
- package/build/styles/inputs/SelectInput.css +10 -35
- package/build/styles/main.css +10 -35
- package/build/types/common/panel/Panel.d.ts +2 -0
- package/build/types/common/panel/Panel.d.ts.map +1 -1
- package/build/types/common/responsivePanel/ResponsivePanel.d.ts +1 -0
- package/build/types/common/responsivePanel/ResponsivePanel.d.ts.map +1 -1
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/inputs/_BottomSheet.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/common/panel/Panel.tsx +2 -0
- package/src/common/responsivePanel/ResponsivePanel.tsx +7 -1
- package/src/dateInput/DateInput.spec.tsx +27 -0
- package/src/dateLookup/DateLookup.spec.tsx +16 -0
- package/src/dateLookup/DateLookup.tsx +1 -0
- package/src/inputs/SelectInput.css +10 -35
- package/src/inputs/_BottomSheet.less +8 -34
- package/src/inputs/_BottomSheet.tsx +1 -18
- package/src/main.css +10 -35
- package/src/moneyInput/MoneyInput.spec.tsx +14 -0
- package/src/phoneNumberInput/PhoneNumberInput.spec.tsx +32 -0
- package/src/common/bottomSheet/BottomSheet.test.story.tsx +0 -94
- package/src/inputs/SelectInput.test.story.tsx +0 -83
- package/src/moneyInput/MoneyInput.test.story.tsx +0 -101
|
@@ -10,7 +10,7 @@ import { Transition } from '@headlessui/react';
|
|
|
10
10
|
import { FocusScope } from '@react-aria/focus';
|
|
11
11
|
import { ThemeProvider, useTheme } from '@wise/components-theming';
|
|
12
12
|
import { clsx } from 'clsx';
|
|
13
|
-
import { Fragment,
|
|
13
|
+
import { Fragment, useState } from 'react';
|
|
14
14
|
|
|
15
15
|
import { CloseButton } from '../common/closeButton';
|
|
16
16
|
import { useVirtualKeyboard } from '../common/hooks/useVirtualKeyboard';
|
|
@@ -33,19 +33,6 @@ export interface BottomSheetProps {
|
|
|
33
33
|
onCloseEnd?: () => void;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
/**
|
|
37
|
-
* App pages set scroll-behavior to 'smooth' which causes mobile Safari to
|
|
38
|
-
* slow-scroll and glitch. This function temporarily disables that behaviour
|
|
39
|
-
* while the BottomSheet is open.
|
|
40
|
-
*/
|
|
41
|
-
const freezeScroll = (shouldFreeze = true) => {
|
|
42
|
-
if (shouldFreeze) {
|
|
43
|
-
document.documentElement.classList.add('wds-select-input-scroll-freeze');
|
|
44
|
-
} else {
|
|
45
|
-
document.documentElement.classList.remove('wds-select-input-scroll-freeze');
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
36
|
export function BottomSheet({
|
|
50
37
|
open,
|
|
51
38
|
renderTrigger,
|
|
@@ -67,10 +54,6 @@ export function BottomSheet({
|
|
|
67
54
|
},
|
|
68
55
|
});
|
|
69
56
|
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
freezeScroll(open);
|
|
72
|
-
}, [open]);
|
|
73
|
-
|
|
74
57
|
const dismiss = useDismiss(context);
|
|
75
58
|
const role = useRole(context);
|
|
76
59
|
const { getReferenceProps, getFloatingProps } = useInteractions([dismiss, role]);
|
package/src/main.css
CHANGED
|
@@ -3519,73 +3519,48 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
3519
3519
|
padding-inline-start: 8px;
|
|
3520
3520
|
padding-inline-start: var(--size-8);
|
|
3521
3521
|
}
|
|
3522
|
-
.wds-select-input-scroll-freeze {
|
|
3523
|
-
scroll-behavior: unset !important;
|
|
3524
|
-
height: 100vh;
|
|
3525
|
-
}
|
|
3526
|
-
.wds-select-input-scroll-freeze body {
|
|
3527
|
-
height: 100vh;
|
|
3528
|
-
}
|
|
3529
3522
|
.np-bottom-sheet-v2-container {
|
|
3530
3523
|
position: relative;
|
|
3531
3524
|
z-index: 1060;
|
|
3532
3525
|
}
|
|
3533
3526
|
.np-bottom-sheet-v2-backdrop {
|
|
3534
3527
|
position: fixed;
|
|
3535
|
-
inset:
|
|
3536
|
-
|
|
3537
|
-
background-color:
|
|
3528
|
+
inset: 0px;
|
|
3529
|
+
background-color: #37517e;
|
|
3530
|
+
background-color: var(--color-content-primary);
|
|
3531
|
+
opacity: 0.4;
|
|
3538
3532
|
transition-property: opacity;
|
|
3539
3533
|
transition-timing-function: ease-out;
|
|
3540
3534
|
transition-duration: 300ms;
|
|
3541
|
-
min-height: 100vh;
|
|
3542
|
-
}
|
|
3543
|
-
@supports (color: color-mix(in lch, red, blue)) {
|
|
3544
|
-
.np-bottom-sheet-v2-backdrop {
|
|
3545
|
-
background-color: color-mix(in srgb, var(--color-content-primary) 40%, transparent);
|
|
3546
|
-
}
|
|
3547
3535
|
}
|
|
3548
3536
|
.np-bottom-sheet-v2-backdrop--closed {
|
|
3549
3537
|
opacity: 0;
|
|
3550
3538
|
}
|
|
3551
3539
|
.np-bottom-sheet-v2 {
|
|
3552
3540
|
position: fixed;
|
|
3553
|
-
inset:
|
|
3554
|
-
bottom: env(
|
|
3555
|
-
margin-top: 64px;
|
|
3556
|
-
margin-top: var(--size-64);
|
|
3541
|
+
inset: 0px;
|
|
3542
|
+
bottom: env(keyboard-inset-height, 0px);
|
|
3557
3543
|
margin-left: 8px;
|
|
3558
3544
|
margin-left: var(--size-8);
|
|
3559
3545
|
margin-right: 8px;
|
|
3560
3546
|
margin-right: var(--size-8);
|
|
3547
|
+
margin-top: 64px;
|
|
3548
|
+
margin-top: var(--size-64);
|
|
3561
3549
|
display: flex;
|
|
3562
3550
|
flex-direction: column;
|
|
3563
3551
|
justify-content: flex-end;
|
|
3564
|
-
height: calc(100vh - 64px - 40px);
|
|
3565
|
-
height: calc(100vh - var(--size-64) - 40px);
|
|
3566
|
-
}
|
|
3567
|
-
.np-bottom-sheet-v2:after {
|
|
3568
|
-
content: '';
|
|
3569
|
-
position: fixed;
|
|
3570
|
-
bottom: -74px;
|
|
3571
|
-
width: 100%;
|
|
3572
|
-
background: #ffffff;
|
|
3573
|
-
background: var(--color-background-elevated);
|
|
3574
|
-
height: 32px;
|
|
3575
|
-
z-index: 1500;
|
|
3576
3552
|
}
|
|
3577
3553
|
.np-bottom-sheet-v2-content {
|
|
3578
3554
|
display: flex;
|
|
3579
3555
|
flex-direction: column;
|
|
3580
3556
|
overflow: auto;
|
|
3581
3557
|
border-top-left-radius: 32px;
|
|
3582
|
-
|
|
3558
|
+
/* TODO: Tokenize */
|
|
3583
3559
|
border-top-right-radius: 32px;
|
|
3584
|
-
|
|
3560
|
+
/* TODO: Tokenize */
|
|
3585
3561
|
background-color: #ffffff;
|
|
3586
3562
|
background-color: var(--color-background-elevated);
|
|
3587
3563
|
box-shadow: 0 0 40px rgba(69, 71, 69, 0.2);
|
|
3588
|
-
will-change: transform;
|
|
3589
3564
|
}
|
|
3590
3565
|
.np-bottom-sheet-v2-content:focus {
|
|
3591
3566
|
outline: none;
|
|
@@ -419,6 +419,20 @@ describe('Money Input', () => {
|
|
|
419
419
|
expect(screen.getAllByRole('group')[0]).toHaveAccessibleName(/^Recipient gets/);
|
|
420
420
|
});
|
|
421
421
|
|
|
422
|
+
it('focuses money input when `Field` label is clicked', async () => {
|
|
423
|
+
const label = 'Recipient gets';
|
|
424
|
+
|
|
425
|
+
render(
|
|
426
|
+
<Field label={label}>
|
|
427
|
+
<MoneyInput {...initialProps} />
|
|
428
|
+
</Field>,
|
|
429
|
+
);
|
|
430
|
+
|
|
431
|
+
const input = screen.getByRole('textbox');
|
|
432
|
+
await userEvent.click(screen.getByLabelText(label));
|
|
433
|
+
expect(input).toHaveFocus();
|
|
434
|
+
});
|
|
435
|
+
|
|
422
436
|
describe('ids', () => {
|
|
423
437
|
it('renders Select component with generated id when id is not provided', () => {
|
|
424
438
|
customRender();
|
|
@@ -314,4 +314,36 @@ describe('PhoneNumberInput', () => {
|
|
|
314
314
|
);
|
|
315
315
|
expect(screen.getAllByRole('group')[0]).toHaveAccessibleName(/^Phone number/);
|
|
316
316
|
});
|
|
317
|
+
|
|
318
|
+
it('focuses country code input when `Field` label is clicked', async () => {
|
|
319
|
+
const label = 'Phone number';
|
|
320
|
+
|
|
321
|
+
render(
|
|
322
|
+
<Field label={label}>
|
|
323
|
+
<PhoneNumberInput initialValue="+12345678" onChange={() => {}} />
|
|
324
|
+
</Field>,
|
|
325
|
+
);
|
|
326
|
+
|
|
327
|
+
await userEvent.click(screen.getByText(label, { selector: 'label:not(.sr-only)' })); // Have to use `getByText` due to the way `Field` handles group labelling
|
|
328
|
+
const countryCodeFilterInput = screen.getByRole('combobox');
|
|
329
|
+
expect(countryCodeFilterInput).toHaveFocus();
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
it('focuses number input when `Field` label is clicked and country code is disabled', async () => {
|
|
333
|
+
const label = 'Phone number';
|
|
334
|
+
|
|
335
|
+
render(
|
|
336
|
+
<Field label={label}>
|
|
337
|
+
<PhoneNumberInput
|
|
338
|
+
initialValue="+12345678"
|
|
339
|
+
selectProps={{ disabled: true }}
|
|
340
|
+
onChange={() => {}}
|
|
341
|
+
/>
|
|
342
|
+
</Field>,
|
|
343
|
+
);
|
|
344
|
+
|
|
345
|
+
const phoneNumberInput = screen.getByRole('textbox');
|
|
346
|
+
await userEvent.click(screen.getByText(label, { selector: 'label:not(.sr-only)' })); // Have to use `getByText` due to the way `Field` handles group labelling
|
|
347
|
+
expect(phoneNumberInput).toHaveFocus();
|
|
348
|
+
});
|
|
317
349
|
});
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
3
|
-
import { userEvent, within } from 'storybook/test';
|
|
4
|
-
import { lorem100, lorem500 } from '../../test-utils';
|
|
5
|
-
import { Typography } from '../propsValues/typography';
|
|
6
|
-
import Alert from '../../alert';
|
|
7
|
-
import Body from '../../body';
|
|
8
|
-
import Button from '../../button';
|
|
9
|
-
import Title from '../../title';
|
|
10
|
-
import BottomSheet from './BottomSheet';
|
|
11
|
-
|
|
12
|
-
const wait = async (duration = 500) =>
|
|
13
|
-
new Promise<void>((resolve) => {
|
|
14
|
-
setTimeout(resolve, duration);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
export default {
|
|
18
|
-
component: BottomSheet,
|
|
19
|
-
title: 'Dialogs/BottomSheet/tests',
|
|
20
|
-
tags: ['!autodocs'],
|
|
21
|
-
args: {
|
|
22
|
-
open: false,
|
|
23
|
-
},
|
|
24
|
-
} satisfies Meta<typeof BottomSheet>;
|
|
25
|
-
|
|
26
|
-
type Story = StoryObj<typeof BottomSheet>;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* This test ensures that when the SelectInput is used within a scrollable page,
|
|
30
|
-
* opening the dropdown does not cause any unwanted scrolling or layout shifts.
|
|
31
|
-
* Expected preview should start with green bar at the top, with yellow section
|
|
32
|
-
* not in the viewport.
|
|
33
|
-
*
|
|
34
|
-
* NB: This test is disabled in Chromatic as there's no obvious way to control <html/> element of a snapshot.
|
|
35
|
-
*/
|
|
36
|
-
export const SmoothScrollReset: Story = {
|
|
37
|
-
args: {
|
|
38
|
-
children: (
|
|
39
|
-
<>
|
|
40
|
-
<Title type={Typography.TITLE_SECTION}>Observe the document</Title>
|
|
41
|
-
<Alert className="m-t-2" type="warning">
|
|
42
|
-
Once the <code>BottomSheet</code> opens, the document underneath should be static and
|
|
43
|
-
should not scroll.
|
|
44
|
-
</Alert>
|
|
45
|
-
<Body as="p">{lorem100}</Body>
|
|
46
|
-
<Body as="p">{lorem100}</Body>
|
|
47
|
-
</>
|
|
48
|
-
),
|
|
49
|
-
},
|
|
50
|
-
decorators: [
|
|
51
|
-
(Story) => (
|
|
52
|
-
<>
|
|
53
|
-
<style>{'html { scroll-behavior: smooth; }'}</style>
|
|
54
|
-
<div style={{ maxWidth: 500 }}>
|
|
55
|
-
<Body>
|
|
56
|
-
<p>{lorem100}</p>
|
|
57
|
-
<p>{lorem100}</p>
|
|
58
|
-
</Body>
|
|
59
|
-
<Story />
|
|
60
|
-
<Body as="p" className="m-t-5 disabled">
|
|
61
|
-
{lorem500}
|
|
62
|
-
</Body>
|
|
63
|
-
</div>
|
|
64
|
-
</>
|
|
65
|
-
),
|
|
66
|
-
],
|
|
67
|
-
parameters: {
|
|
68
|
-
chromatic: {
|
|
69
|
-
disableSnapshot: true,
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
play: async ({ canvasElement }) => {
|
|
73
|
-
document.documentElement.scrollTop = 400;
|
|
74
|
-
await wait(500);
|
|
75
|
-
const canvas = within(canvasElement);
|
|
76
|
-
await userEvent.click(canvas.getByRole('button'));
|
|
77
|
-
},
|
|
78
|
-
render: ({ open, ...args }) => {
|
|
79
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
80
|
-
|
|
81
|
-
return (
|
|
82
|
-
<div>
|
|
83
|
-
<Button onClick={() => setIsOpen(true)}>Open BottomSheet</Button>
|
|
84
|
-
<BottomSheet
|
|
85
|
-
{...args}
|
|
86
|
-
open={isOpen}
|
|
87
|
-
onClose={() => {
|
|
88
|
-
setIsOpen(false);
|
|
89
|
-
}}
|
|
90
|
-
/>
|
|
91
|
-
</div>
|
|
92
|
-
);
|
|
93
|
-
},
|
|
94
|
-
};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
-
import { fn, type Mock, userEvent, within } from 'storybook/test';
|
|
3
|
-
import { allModes } from '../../.storybook/modes';
|
|
4
|
-
import { lorem5, lorem500 } from '../test-utils';
|
|
5
|
-
import { Field } from '../field/Field';
|
|
6
|
-
import Body from '../body';
|
|
7
|
-
import { SelectInput, type SelectInputProps } from './SelectInput';
|
|
8
|
-
|
|
9
|
-
const meta = {
|
|
10
|
-
title: 'Forms/SelectInput/tests',
|
|
11
|
-
component: SelectInput,
|
|
12
|
-
args: {
|
|
13
|
-
onFilterChange: fn() satisfies Mock,
|
|
14
|
-
onChange: fn() satisfies Mock,
|
|
15
|
-
onClose: fn() satisfies Mock,
|
|
16
|
-
onOpen: fn() satisfies Mock,
|
|
17
|
-
},
|
|
18
|
-
tags: ['!autodocs'],
|
|
19
|
-
} satisfies Meta<typeof SelectInput>;
|
|
20
|
-
export default meta;
|
|
21
|
-
|
|
22
|
-
type Story<T, M extends boolean = false> = StoryObj<SelectInputProps<T, M>>;
|
|
23
|
-
|
|
24
|
-
const wait = async (duration = 500) =>
|
|
25
|
-
new Promise<void>((resolve) => {
|
|
26
|
-
setTimeout(resolve, duration);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* This test ensures that when the SelectInput is used within a scrollable page,
|
|
31
|
-
* opening the dropdown does not cause any unwanted scrolling or layout shifts.
|
|
32
|
-
* Expected preview should start with green bar at the top, with yellow section
|
|
33
|
-
* not in the viewport.
|
|
34
|
-
*
|
|
35
|
-
* NB: This test is disabled in Chromatic as there's no obvious way to control <html/> element of a snapshot.
|
|
36
|
-
*/
|
|
37
|
-
export const SmoothScrollReset: Story<string> = {
|
|
38
|
-
args: {
|
|
39
|
-
items: Array.from({ length: 15 }).map((_, id) => ({
|
|
40
|
-
type: 'option',
|
|
41
|
-
value: `option ${id + 1}`,
|
|
42
|
-
})),
|
|
43
|
-
placeholder: 'Select option',
|
|
44
|
-
},
|
|
45
|
-
decorators: [
|
|
46
|
-
(Story) => (
|
|
47
|
-
<>
|
|
48
|
-
<style>{`html { scroll-behavior: smooth; }`}</style>
|
|
49
|
-
<div>
|
|
50
|
-
<div
|
|
51
|
-
className="d-flex align-items-center justify-content-center"
|
|
52
|
-
style={{
|
|
53
|
-
backgroundColor: 'var(--color-bright-yellow)',
|
|
54
|
-
height: 400,
|
|
55
|
-
}}
|
|
56
|
-
>
|
|
57
|
-
This block should not be in the viewport.
|
|
58
|
-
</div>
|
|
59
|
-
<div style={{ height: 10, backgroundColor: 'var(--color-bright-green)' }} />
|
|
60
|
-
<Field id="el1" label={lorem5}>
|
|
61
|
-
<Story />
|
|
62
|
-
</Field>
|
|
63
|
-
<Body as="p">{lorem500}</Body>
|
|
64
|
-
</div>
|
|
65
|
-
</>
|
|
66
|
-
),
|
|
67
|
-
],
|
|
68
|
-
play: async ({ canvasElement }) => {
|
|
69
|
-
document.documentElement.scrollTop = 400;
|
|
70
|
-
await wait();
|
|
71
|
-
const canvas = within(canvasElement);
|
|
72
|
-
const triggerButton = canvas.getByRole('combobox');
|
|
73
|
-
await userEvent.click(triggerButton);
|
|
74
|
-
},
|
|
75
|
-
globals: {
|
|
76
|
-
viewport: { value: allModes.largeMobile.viewport, isRotated: false },
|
|
77
|
-
},
|
|
78
|
-
parameters: {
|
|
79
|
-
chromatic: {
|
|
80
|
-
disableSnapshot: true,
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
-
import { fn, type Mock, userEvent, within } from 'storybook/test';
|
|
3
|
-
import { allModes } from '../../.storybook/modes';
|
|
4
|
-
import { lorem500 } from '../test-utils';
|
|
5
|
-
import { Field } from '../field/Field';
|
|
6
|
-
import Body from '../body';
|
|
7
|
-
import MoneyInput from './MoneyInput';
|
|
8
|
-
|
|
9
|
-
const meta = {
|
|
10
|
-
title: 'Forms/MoneyInput/tests',
|
|
11
|
-
component: MoneyInput,
|
|
12
|
-
args: {
|
|
13
|
-
amount: 1000,
|
|
14
|
-
id: 'moneyInput',
|
|
15
|
-
currencies: [
|
|
16
|
-
{
|
|
17
|
-
value: 'EUR',
|
|
18
|
-
label: 'EUR',
|
|
19
|
-
note: 'Euro',
|
|
20
|
-
currency: 'eur',
|
|
21
|
-
searchable: 'Spain, Germany, France, Austria',
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
value: 'GBP',
|
|
25
|
-
label: 'GBP',
|
|
26
|
-
note: 'British pound',
|
|
27
|
-
currency: 'gbp',
|
|
28
|
-
searchable: 'England, Scotland, Wales',
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
selectedCurrency: {
|
|
32
|
-
value: 'EUR',
|
|
33
|
-
label: 'EUR',
|
|
34
|
-
note: 'Euro',
|
|
35
|
-
currency: 'eur',
|
|
36
|
-
searchable: 'Spain, Germany, France, Austria',
|
|
37
|
-
},
|
|
38
|
-
searchPlaceholder: '',
|
|
39
|
-
onAmountChange: () => {},
|
|
40
|
-
onCurrencyChange: () => {},
|
|
41
|
-
},
|
|
42
|
-
tags: ['!autodocs'],
|
|
43
|
-
} satisfies Meta<typeof MoneyInput>;
|
|
44
|
-
export default meta;
|
|
45
|
-
|
|
46
|
-
type Story = StoryObj<typeof MoneyInput>;
|
|
47
|
-
|
|
48
|
-
const wait = async (duration = 500) =>
|
|
49
|
-
new Promise<void>((resolve) => {
|
|
50
|
-
setTimeout(resolve, duration);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* This test ensures that when the SelectInput is used within a scrollable page,
|
|
55
|
-
* opening the dropdown does not cause any unwanted scrolling or layout shifts.
|
|
56
|
-
* Expected preview should start with green bar at the top, with yellow section
|
|
57
|
-
* not in the viewport.
|
|
58
|
-
*
|
|
59
|
-
* NB: This test is disabled in Chromatic as there's no obvious way to control <html/> element of a snapshot.
|
|
60
|
-
*/
|
|
61
|
-
export const SmoothScrollReset: Story = {
|
|
62
|
-
decorators: [
|
|
63
|
-
(Story) => (
|
|
64
|
-
<>
|
|
65
|
-
<style>{`html { scroll-behavior: smooth; }`}</style>
|
|
66
|
-
<div>
|
|
67
|
-
<div
|
|
68
|
-
className="d-flex align-items-center justify-content-center"
|
|
69
|
-
style={{
|
|
70
|
-
backgroundColor: 'var(--color-bright-yellow)',
|
|
71
|
-
height: 400,
|
|
72
|
-
}}
|
|
73
|
-
>
|
|
74
|
-
This block should not be in the viewport.
|
|
75
|
-
</div>
|
|
76
|
-
<div style={{ height: 10, backgroundColor: 'var(--color-bright-green)' }} />
|
|
77
|
-
<Field id="el1" label="Select currency">
|
|
78
|
-
<Story />
|
|
79
|
-
</Field>
|
|
80
|
-
<Body as="p">{lorem500}</Body>
|
|
81
|
-
</div>
|
|
82
|
-
</>
|
|
83
|
-
),
|
|
84
|
-
],
|
|
85
|
-
play: async ({ canvasElement }) => {
|
|
86
|
-
await wait(2000);
|
|
87
|
-
document.documentElement.scrollTop = 400;
|
|
88
|
-
await wait(2000);
|
|
89
|
-
const canvas = within(canvasElement);
|
|
90
|
-
const triggerButton = canvas.getByRole('combobox');
|
|
91
|
-
await userEvent.click(triggerButton);
|
|
92
|
-
},
|
|
93
|
-
globals: {
|
|
94
|
-
viewport: { value: allModes.largeMobile.viewport, isRotated: false },
|
|
95
|
-
},
|
|
96
|
-
parameters: {
|
|
97
|
-
chromatic: {
|
|
98
|
-
disableSnapshot: true,
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
};
|