@transferwise/components 46.31.0 → 46.32.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/index.js +742 -467
- package/build/index.js.map +1 -1
- package/build/index.mjs +742 -468
- package/build/index.mjs.map +1 -1
- package/build/main.css +135 -0
- package/build/styles/carousel/Carousel.css +135 -0
- package/build/styles/main.css +135 -0
- package/build/types/carousel/Carousel.d.ts +26 -0
- package/build/types/carousel/Carousel.d.ts.map +1 -0
- package/build/types/carousel/index.d.ts +3 -0
- package/build/types/carousel/index.d.ts.map +1 -0
- package/build/types/common/card/Card.d.ts +2 -2
- package/build/types/common/card/Card.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/promoCard/PromoCard.d.ts +16 -5
- package/build/types/promoCard/PromoCard.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/carousel/Carousel.css +135 -0
- package/src/carousel/Carousel.less +133 -0
- package/src/carousel/Carousel.spec.tsx +221 -0
- package/src/carousel/Carousel.story.tsx +63 -0
- package/src/carousel/Carousel.tsx +345 -0
- package/src/carousel/index.ts +3 -0
- package/src/common/card/Card.tsx +51 -43
- package/src/index.ts +2 -0
- package/src/main.css +135 -0
- package/src/main.less +1 -0
- package/src/promoCard/PromoCard.story.tsx +2 -2
- package/src/promoCard/PromoCard.tsx +30 -9
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
.carousel-wrapper {
|
|
2
|
+
overflow: hidden;
|
|
3
|
+
}
|
|
4
|
+
.carousel {
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
overflow-x: scroll;
|
|
8
|
+
overflow-y: hidden;
|
|
9
|
+
scroll-snap-type: x mandatory;
|
|
10
|
+
scroll-behavior: smooth;
|
|
11
|
+
gap: 16px;
|
|
12
|
+
gap: var(--size-16);
|
|
13
|
+
padding: 8px;
|
|
14
|
+
padding: var(--size-8);
|
|
15
|
+
margin: 8px;
|
|
16
|
+
margin: var(--size-8);
|
|
17
|
+
}
|
|
18
|
+
@media (max-width: 767px) {
|
|
19
|
+
.carousel {
|
|
20
|
+
gap: 8px;
|
|
21
|
+
gap: var(--size-8);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
.carousel__header {
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
min-height: 32px;
|
|
29
|
+
min-height: var(--size-32);
|
|
30
|
+
padding-bottom: 16px;
|
|
31
|
+
padding-bottom: var(--size-16);
|
|
32
|
+
}
|
|
33
|
+
.carousel__card,
|
|
34
|
+
.carousel__card:hover,
|
|
35
|
+
.carousel__card:focus,
|
|
36
|
+
.carousel__card:focus-within {
|
|
37
|
+
-webkit-text-decoration: none;
|
|
38
|
+
text-decoration: none;
|
|
39
|
+
transition: none !important;
|
|
40
|
+
box-shadow: none !important;
|
|
41
|
+
}
|
|
42
|
+
.carousel__card {
|
|
43
|
+
display: block;
|
|
44
|
+
position: relative;
|
|
45
|
+
text-align: left;
|
|
46
|
+
border: none;
|
|
47
|
+
overflow: hidden;
|
|
48
|
+
background: rgba(134,167,189,0.10196);
|
|
49
|
+
background: var(--color-background-neutral);
|
|
50
|
+
border-radius: 32px;
|
|
51
|
+
border-radius: var(--size-32);
|
|
52
|
+
scroll-snap-align: center;
|
|
53
|
+
-webkit-scroll-snap-align: center;
|
|
54
|
+
transition: all 0.4s !important;
|
|
55
|
+
}
|
|
56
|
+
@media (min-width: 1200px) {
|
|
57
|
+
.carousel__card {
|
|
58
|
+
min-width: 280px;
|
|
59
|
+
width: 280px;
|
|
60
|
+
height: 280px;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
@media (max-width: 1199px) {
|
|
64
|
+
.carousel__card {
|
|
65
|
+
min-width: 242px;
|
|
66
|
+
width: 242px;
|
|
67
|
+
height: 242px;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
@media (max-width: 767px) {
|
|
71
|
+
.carousel__card {
|
|
72
|
+
min-width: 336px;
|
|
73
|
+
width: 336px;
|
|
74
|
+
height: 336px;
|
|
75
|
+
scroll-snap-stop: always;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
.carousel__card:focus,
|
|
79
|
+
.carousel__card:has(:focus-visible) {
|
|
80
|
+
outline: var(--ring-outline-color) solid var(--ring-outline-width) !important;
|
|
81
|
+
outline-offset: var(--ring-outline-offset) !important;
|
|
82
|
+
}
|
|
83
|
+
.carousel__card:hover {
|
|
84
|
+
background-color: var(--color-background-neutral-hover);
|
|
85
|
+
}
|
|
86
|
+
.carousel__card:focus {
|
|
87
|
+
background-color: var(--color-background-neutral-hover);
|
|
88
|
+
}
|
|
89
|
+
.carousel__card-content {
|
|
90
|
+
height: 100%;
|
|
91
|
+
font-weight: normal;
|
|
92
|
+
padding: 24px;
|
|
93
|
+
padding: var(--size-24);
|
|
94
|
+
}
|
|
95
|
+
.carousel__scroll-button {
|
|
96
|
+
width: 32px;
|
|
97
|
+
width: var(--size-32);
|
|
98
|
+
height: 32px;
|
|
99
|
+
height: var(--size-32);
|
|
100
|
+
align-items: center;
|
|
101
|
+
justify-content: center;
|
|
102
|
+
}
|
|
103
|
+
.carousel__indicators {
|
|
104
|
+
display: flex;
|
|
105
|
+
justify-content: center;
|
|
106
|
+
padding-top: 8px;
|
|
107
|
+
padding-top: var(--size-8);
|
|
108
|
+
gap: 8px;
|
|
109
|
+
gap: var(--size-8);
|
|
110
|
+
}
|
|
111
|
+
.carousel__indicator {
|
|
112
|
+
width: 12px;
|
|
113
|
+
width: var(--size-12);
|
|
114
|
+
height: 12px;
|
|
115
|
+
height: var(--size-12);
|
|
116
|
+
border-radius: 8px;
|
|
117
|
+
border-radius: var(--size-8);
|
|
118
|
+
background: #c9cbce;
|
|
119
|
+
background: var(--color-interactive-secondary);
|
|
120
|
+
border: none;
|
|
121
|
+
-webkit-appearance: none;
|
|
122
|
+
-moz-appearance: none;
|
|
123
|
+
appearance: none;
|
|
124
|
+
transition: all 0.1s;
|
|
125
|
+
}
|
|
126
|
+
.carousel__indicator:hover {
|
|
127
|
+
width: 16px;
|
|
128
|
+
width: var(--size-16);
|
|
129
|
+
}
|
|
130
|
+
.carousel__indicator--selected,
|
|
131
|
+
.carousel__indicator--selected:hover {
|
|
132
|
+
background: var(--color-interactive-primary);
|
|
133
|
+
width: 24px;
|
|
134
|
+
width: var(--size-24);
|
|
135
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
.carousel-wrapper {
|
|
2
|
+
overflow: hidden;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.carousel {
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
overflow-x: scroll;
|
|
9
|
+
overflow-y: hidden;
|
|
10
|
+
scroll-snap-type: x mandatory;
|
|
11
|
+
scroll-behavior: smooth;
|
|
12
|
+
gap: var(--size-16);
|
|
13
|
+
padding: var(--size-8);
|
|
14
|
+
margin: var(--size-8);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@media (--screen-sm-max) {
|
|
18
|
+
.carousel {
|
|
19
|
+
gap: var(--size-8);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
.carousel__header {
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
min-height: var(--size-32);
|
|
29
|
+
padding-bottom: var(--size-16)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// The specificity inside PromoCard is too high for transition / box-shaodw, so we need to use !important below
|
|
33
|
+
.carousel__card,
|
|
34
|
+
.carousel__card:hover,
|
|
35
|
+
.carousel__card:focus,
|
|
36
|
+
.carousel__card:focus-within {
|
|
37
|
+
text-decoration: none;
|
|
38
|
+
transition: none !important;
|
|
39
|
+
box-shadow: none !important;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.carousel__card {
|
|
43
|
+
display: block;
|
|
44
|
+
position: relative;
|
|
45
|
+
text-align: left;
|
|
46
|
+
border: none;
|
|
47
|
+
overflow: hidden;
|
|
48
|
+
background: var(--color-background-neutral);
|
|
49
|
+
border-radius: var(--size-32);
|
|
50
|
+
scroll-snap-align: center;
|
|
51
|
+
-webkit-scroll-snap-align: center;
|
|
52
|
+
transition: all 0.4s !important;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@media (--screen-xl) {
|
|
56
|
+
.carousel__card {
|
|
57
|
+
min-width: 280px;
|
|
58
|
+
width: 280px;
|
|
59
|
+
height: 280px;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@media (--screen-lg-max) {
|
|
65
|
+
.carousel__card {
|
|
66
|
+
min-width: 242px;
|
|
67
|
+
width: 242px;
|
|
68
|
+
height: 242px;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@media (--screen-sm-max) {
|
|
74
|
+
.carousel__card {
|
|
75
|
+
min-width: 336px;
|
|
76
|
+
width: 336px;
|
|
77
|
+
height: 336px;
|
|
78
|
+
scroll-snap-stop: always;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.carousel__card:focus, .carousel__card:has(:focus-visible) {
|
|
83
|
+
outline: var(--ring-outline-color) solid var(--ring-outline-width) !important;
|
|
84
|
+
outline-offset: var(--ring-outline-offset) !important;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.carousel__card:hover {
|
|
88
|
+
background-color: var(--color-background-neutral-hover);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.carousel__card:focus {
|
|
92
|
+
background-color: var(--color-background-neutral-hover);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.carousel__card-content {
|
|
96
|
+
height: 100%;
|
|
97
|
+
font-weight: normal;
|
|
98
|
+
padding: var(--size-24);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.carousel__scroll-button {
|
|
102
|
+
width: var(--size-32);
|
|
103
|
+
height: var(--size-32);
|
|
104
|
+
align-items: center;
|
|
105
|
+
justify-content: center;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.carousel__indicators {
|
|
109
|
+
display: flex;
|
|
110
|
+
justify-content: center;
|
|
111
|
+
padding-top: var(--size-8);
|
|
112
|
+
gap: var(--size-8);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.carousel__indicator {
|
|
116
|
+
width: var(--size-12);
|
|
117
|
+
height: var(--size-12);
|
|
118
|
+
border-radius: var(--size-8);
|
|
119
|
+
background: var(--color-interactive-secondary);
|
|
120
|
+
border: none;
|
|
121
|
+
appearance: none;
|
|
122
|
+
transition: all 0.1s;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.carousel__indicator:hover {
|
|
126
|
+
width: var(--size-16)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.carousel__indicator--selected,
|
|
130
|
+
.carousel__indicator--selected:hover {
|
|
131
|
+
background: var(--color-interactive-primary);
|
|
132
|
+
width: var(--size-24);
|
|
133
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
2
|
+
import { userEvent } from '../test-utils';
|
|
3
|
+
|
|
4
|
+
import Display from '../display';
|
|
5
|
+
import Title from '../title';
|
|
6
|
+
|
|
7
|
+
import Carousel, { type CarouselCard } from './Carousel';
|
|
8
|
+
|
|
9
|
+
jest.mock('@wise/components-theming', () => ({
|
|
10
|
+
...jest.requireActual<Record<string, unknown>>('@wise/components-theming'),
|
|
11
|
+
useTheme: jest.fn().mockReturnValue({ theme: 'personal' }),
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
const yourInvoiceOnClick = jest.fn();
|
|
15
|
+
|
|
16
|
+
const carouselCards: CarouselCard[] = [
|
|
17
|
+
{
|
|
18
|
+
id: 'YOUR_INVOICE',
|
|
19
|
+
type: 'anchor',
|
|
20
|
+
href: 'https://wise.com',
|
|
21
|
+
onClick: yourInvoiceOnClick,
|
|
22
|
+
content: <div>Add a link in accounting software like Xero or QuickBooks.</div>,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: 'YOUR_WEBSITE',
|
|
26
|
+
type: 'button',
|
|
27
|
+
onClick: () => {},
|
|
28
|
+
content: <Title type="title-screen">Wise.</Title>,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: 'SHOP_OR_STALL',
|
|
32
|
+
type: 'anchor',
|
|
33
|
+
href: 'https://wise.com',
|
|
34
|
+
onClick: () => {},
|
|
35
|
+
content: <Display type="display-small">Get Quick Pay</Display>,
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const onClick = jest.fn();
|
|
40
|
+
|
|
41
|
+
const renderCarousel = () => {
|
|
42
|
+
render(<Carousel header="Cool stuff" cards={carouselCards} onClick={onClick} />);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
describe('Carousel', () => {
|
|
46
|
+
const focusSpy = jest.fn();
|
|
47
|
+
const scrollBy = jest.fn();
|
|
48
|
+
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
// eslint-disable-next-line functional/immutable-data
|
|
51
|
+
window.HTMLElement.prototype.scrollIntoView = focusSpy;
|
|
52
|
+
// eslint-disable-next-line functional/immutable-data
|
|
53
|
+
window.HTMLElement.prototype.scrollBy = scrollBy;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
afterEach(() => {
|
|
57
|
+
focusSpy.mockClear();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('shows expected content on page', async () => {
|
|
61
|
+
renderCarousel();
|
|
62
|
+
|
|
63
|
+
expect(
|
|
64
|
+
screen.getByText('Add a link in accounting software like Xero or QuickBooks.'),
|
|
65
|
+
).toBeInTheDocument();
|
|
66
|
+
|
|
67
|
+
expect(screen.getByText('Wise.')).toBeInTheDocument();
|
|
68
|
+
|
|
69
|
+
expect(screen.getByText('Get Quick Pay')).toBeInTheDocument();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('allows user to scroll carousel to the right when at start', () => {
|
|
73
|
+
mockPositions(948, 903);
|
|
74
|
+
|
|
75
|
+
renderCarousel();
|
|
76
|
+
|
|
77
|
+
const scrollLeftButton = screen.getByTestId('scroll-carousel-left');
|
|
78
|
+
const scrollRightButton = screen.getByTestId('scroll-carousel-right');
|
|
79
|
+
|
|
80
|
+
expect(scrollLeftButton).toBeDisabled();
|
|
81
|
+
expect(scrollRightButton).toBeEnabled();
|
|
82
|
+
|
|
83
|
+
userEvent.click(scrollRightButton);
|
|
84
|
+
|
|
85
|
+
expect(scrollBy).toHaveBeenCalledWith({ left: 300, behavior: 'smooth' });
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('allows user to scroll carousel to the left or right when in middle', () => {
|
|
89
|
+
mockPositions(948, 903);
|
|
90
|
+
|
|
91
|
+
renderCarousel();
|
|
92
|
+
|
|
93
|
+
const carousel = screen.getByRole('list');
|
|
94
|
+
fireEvent.scroll(carousel, { target: { scrollLeft: 10 } });
|
|
95
|
+
|
|
96
|
+
const scrollLeftButton = screen.getByTestId('scroll-carousel-left');
|
|
97
|
+
const scrollRightButton = screen.getByTestId('scroll-carousel-right');
|
|
98
|
+
|
|
99
|
+
expect(scrollLeftButton).toBeEnabled();
|
|
100
|
+
expect(scrollRightButton).toBeEnabled();
|
|
101
|
+
|
|
102
|
+
userEvent.click(scrollLeftButton);
|
|
103
|
+
|
|
104
|
+
expect(scrollBy).toHaveBeenCalledWith({ left: -300, behavior: 'smooth' });
|
|
105
|
+
|
|
106
|
+
userEvent.click(scrollRightButton);
|
|
107
|
+
|
|
108
|
+
expect(scrollBy).toHaveBeenCalledWith({ left: 300, behavior: 'smooth' });
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('allows user to scroll carousel to the left when at end', () => {
|
|
112
|
+
mockPositions(948, 903);
|
|
113
|
+
|
|
114
|
+
renderCarousel();
|
|
115
|
+
|
|
116
|
+
const carousel = screen.getByRole('list');
|
|
117
|
+
fireEvent.scroll(carousel, { target: { scrollLeft: 50 } });
|
|
118
|
+
|
|
119
|
+
const scrollLeftButton = screen.getByTestId('scroll-carousel-left');
|
|
120
|
+
const scrollRightButton = screen.getByTestId('scroll-carousel-right');
|
|
121
|
+
|
|
122
|
+
expect(scrollLeftButton).toBeEnabled();
|
|
123
|
+
expect(scrollRightButton).toBeDisabled();
|
|
124
|
+
|
|
125
|
+
userEvent.click(scrollLeftButton);
|
|
126
|
+
|
|
127
|
+
expect(scrollBy).toHaveBeenCalledWith({ left: -300, behavior: 'smooth' });
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('allows user to go through carousel by indicator', async () => {
|
|
131
|
+
mockPositions(948, 903);
|
|
132
|
+
|
|
133
|
+
renderCarousel();
|
|
134
|
+
|
|
135
|
+
const yourInvoiceIndicator = screen.getByTestId('YOUR_INVOICE-indicator');
|
|
136
|
+
const yourWebsiteIndicator = screen.getByTestId('YOUR_WEBSITE-indicator');
|
|
137
|
+
const shopOrStallIndicator = screen.getByTestId('SHOP_OR_STALL-indicator');
|
|
138
|
+
const firstCard = getFirstCard();
|
|
139
|
+
const secondCard = getSecondCard();
|
|
140
|
+
const thirdCard = getThirdCard();
|
|
141
|
+
|
|
142
|
+
expect(focusSpy).toHaveBeenCalledTimes(0);
|
|
143
|
+
expect(firstCard).toHaveClass('carousel__card--focused');
|
|
144
|
+
|
|
145
|
+
userEvent.click(yourWebsiteIndicator);
|
|
146
|
+
|
|
147
|
+
expect(focusSpy).toHaveBeenCalledTimes(1);
|
|
148
|
+
expect(secondCard).toHaveClass('carousel__card--focused');
|
|
149
|
+
|
|
150
|
+
userEvent.click(shopOrStallIndicator);
|
|
151
|
+
|
|
152
|
+
expect(focusSpy).toHaveBeenCalledTimes(2);
|
|
153
|
+
expect(thirdCard).toHaveClass('carousel__card--focused');
|
|
154
|
+
|
|
155
|
+
userEvent.click(yourInvoiceIndicator);
|
|
156
|
+
|
|
157
|
+
expect(focusSpy).toHaveBeenCalledTimes(3);
|
|
158
|
+
expect(firstCard).toHaveClass('carousel__card--focused');
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('is focused on the first element and lets user navigate through them', () => {
|
|
162
|
+
renderCarousel();
|
|
163
|
+
|
|
164
|
+
const firstCard = getFirstCard();
|
|
165
|
+
const secondCard = getSecondCard();
|
|
166
|
+
const thirdCard = getThirdCard();
|
|
167
|
+
|
|
168
|
+
expect(firstCard).toBeInTheDocument();
|
|
169
|
+
|
|
170
|
+
firstCard.focus();
|
|
171
|
+
expect(firstCard).toHaveFocus();
|
|
172
|
+
|
|
173
|
+
userEvent.keyboard('{arrowright}');
|
|
174
|
+
|
|
175
|
+
expect(secondCard).toHaveFocus();
|
|
176
|
+
|
|
177
|
+
userEvent.keyboard('{arrowright}');
|
|
178
|
+
|
|
179
|
+
expect(thirdCard).toHaveFocus();
|
|
180
|
+
|
|
181
|
+
userEvent.keyboard('{arrowleft}');
|
|
182
|
+
|
|
183
|
+
expect(secondCard).toHaveFocus();
|
|
184
|
+
|
|
185
|
+
userEvent.keyboard('{arrowleft}');
|
|
186
|
+
|
|
187
|
+
expect(firstCard).toHaveFocus();
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('calls onClick when a card is clicked', () => {
|
|
191
|
+
renderCarousel();
|
|
192
|
+
|
|
193
|
+
userEvent.click(getFirstCard());
|
|
194
|
+
|
|
195
|
+
expect(onClick).toHaveBeenCalledTimes(1);
|
|
196
|
+
expect(yourInvoiceOnClick).toHaveBeenCalledTimes(1);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
const mockPositions = (scrollWidth: number, offsetWidth: number) => {
|
|
201
|
+
// eslint-disable-next-line functional/immutable-data
|
|
202
|
+
Object.defineProperty(HTMLElement.prototype, 'scrollWidth', {
|
|
203
|
+
configurable: true,
|
|
204
|
+
value: scrollWidth,
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
// eslint-disable-next-line functional/immutable-data
|
|
208
|
+
Object.defineProperty(HTMLElement.prototype, 'offsetWidth', {
|
|
209
|
+
configurable: true,
|
|
210
|
+
value: offsetWidth,
|
|
211
|
+
});
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
const getFirstCard = () =>
|
|
215
|
+
screen.getByRole('link', {
|
|
216
|
+
name: /Add a link in accounting software like Xero or QuickBooks\./,
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
const getSecondCard = () => screen.getByRole('button', { name: /Wise\./ });
|
|
220
|
+
|
|
221
|
+
const getThirdCard = () => screen.getByRole('link', { name: /Get Quick Pay/ });
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { StoryFn } from '@storybook/react';
|
|
2
|
+
import { Illustration } from '@wise/art';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import Display from '../display';
|
|
6
|
+
|
|
7
|
+
import Carousel, { type CarouselCard } from './Carousel';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
component: Carousel,
|
|
11
|
+
title: 'Navigation/Carousel',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const carouselCards: CarouselCard[] = [
|
|
15
|
+
{
|
|
16
|
+
id: 'YOUR_INVOICE',
|
|
17
|
+
type: 'button',
|
|
18
|
+
onClick: () => {
|
|
19
|
+
console.log('Clicked on button');
|
|
20
|
+
},
|
|
21
|
+
content: (
|
|
22
|
+
<div className="d-flex p-a-1 p-t-0 flex-column align-items-center">
|
|
23
|
+
<div style={{ position: 'absolute' }}>
|
|
24
|
+
<Illustration disablePadding name="globe" size="small" alt="" />
|
|
25
|
+
</div>
|
|
26
|
+
<div style={{ position: 'absolute', zIndex: '2', bottom: '8px', left: '16px' }}>
|
|
27
|
+
<Display type="display-small">Here there, everywhere</Display>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
),
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: 'YOUR_WEBSITE',
|
|
34
|
+
type: 'promo',
|
|
35
|
+
onClick: () => {
|
|
36
|
+
console.log('hi');
|
|
37
|
+
},
|
|
38
|
+
href: 'http://wise.com',
|
|
39
|
+
title: 'Wise',
|
|
40
|
+
description: 'The best way to move money internationally',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: 'SHOP_OR_STALL',
|
|
44
|
+
type: 'anchor',
|
|
45
|
+
href: 'https://wise.com',
|
|
46
|
+
onClick: () => {},
|
|
47
|
+
styles: {
|
|
48
|
+
backgroundImage:
|
|
49
|
+
'url(https://wise.com/public-resources/assets/team-page/tapestry/team_member_tapestry_01.jpg)',
|
|
50
|
+
backgroundSize: 'cover',
|
|
51
|
+
},
|
|
52
|
+
content: <Display type="display-small">Get Quick Pay</Display>,
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
const Template: StoryFn = (args) => {
|
|
57
|
+
return <Carousel header="Pretty nifty stuff" cards={carouselCards} {...args} />;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const CarouselDefault = {
|
|
61
|
+
render: Template,
|
|
62
|
+
args: {},
|
|
63
|
+
};
|