@comicrelief/component-library 8.49.1 → 8.50.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Molecules/Accordion/Accordion.js +8 -1
- package/dist/components/Molecules/Accordion/__snapshots__/Accordion.test.js.snap +60 -21
- package/dist/components/Molecules/ArticleTeaser/ArticleTeaser.js +1 -6
- package/dist/components/Molecules/ArticleTeaser/ArticleTeaser.test.js +0 -16
- package/dist/components/Molecules/CTA/CTAMultiCard/CTAMultiCard.js +59 -0
- package/{src/components/Molecules → dist/components/Molecules/CTA}/CTAMultiCard/CTAMultiCard.md +4 -4
- package/dist/components/Molecules/CTA/CTAMultiCard/CTAMultiCard.style.js +55 -0
- package/dist/components/Molecules/CTA/CTAMultiCard/CTAMultiCard.test.js +91 -0
- package/dist/components/Molecules/CTA/CTAMultiCard/__snapshots__/CTAMultiCard.test.js.snap +2931 -0
- package/dist/components/Molecules/CTA/CTAMultiCard/example_data.json +107 -0
- package/dist/components/Molecules/CTA/CTASingleCard/CTASingleCard.js +44 -0
- package/dist/components/Molecules/CTA/CTASingleCard/CTASingleCard.md +124 -0
- package/dist/components/Molecules/CTA/CTASingleCard/CTASingleCard.style.js +23 -0
- package/dist/components/Molecules/CTA/CTASingleCard/CTASingleCard.test.js +96 -0
- package/dist/components/Molecules/CTA/CTASingleCard/__snapshots__/CTASingleCard.test.js.snap +903 -0
- package/dist/components/Molecules/CTA/shared/CTACard.js +67 -0
- package/dist/components/Molecules/CTA/shared/CTACard.style.js +269 -0
- package/dist/components/Molecules/{CTAMultiCard → CTA/shared}/_ArrowIcon.js +1 -1
- package/dist/components/Molecules/Descriptor/Descriptor.js +1 -5
- package/dist/components/Molecules/Descriptor/Descriptor.test.js +0 -8
- package/dist/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/CTAMultiCard.style.js +11 -11
- package/dist/components/Molecules/OLD_CTAMultiCard/_ArrowIcon.js +29 -0
- package/dist/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/__snapshots__/CTAMultiCard.test.js.snap +8 -0
- package/dist/index.js +8 -1
- package/package.json +1 -1
- package/src/components/Molecules/Accordion/Accordion.js +8 -1
- package/src/components/Molecules/Accordion/__snapshots__/Accordion.test.js.snap +60 -21
- package/src/components/Molecules/ArticleTeaser/ArticleTeaser.js +0 -6
- package/src/components/Molecules/ArticleTeaser/ArticleTeaser.test.js +0 -16
- package/src/components/Molecules/CTA/CTAMultiCard/CTAMultiCard.js +99 -0
- package/{dist/components/Molecules → src/components/Molecules/CTA}/CTAMultiCard/CTAMultiCard.md +4 -4
- package/src/components/Molecules/CTA/CTAMultiCard/CTAMultiCard.style.js +68 -0
- package/src/components/Molecules/CTA/CTAMultiCard/CTAMultiCard.test.js +107 -0
- package/src/components/Molecules/CTA/CTAMultiCard/__snapshots__/CTAMultiCard.test.js.snap +2931 -0
- package/src/components/Molecules/CTA/CTAMultiCard/example_data.json +107 -0
- package/src/components/Molecules/CTA/CTASingleCard/CTASingleCard.js +72 -0
- package/src/components/Molecules/CTA/CTASingleCard/CTASingleCard.md +124 -0
- package/src/components/Molecules/CTA/CTASingleCard/CTASingleCard.style.js +19 -0
- package/src/components/Molecules/CTA/CTASingleCard/CTASingleCard.test.js +96 -0
- package/src/components/Molecules/CTA/CTASingleCard/__snapshots__/CTASingleCard.test.js.snap +903 -0
- package/src/components/Molecules/CTA/shared/CTACard.js +115 -0
- package/src/components/Molecules/CTA/shared/CTACard.style.js +356 -0
- package/src/components/Molecules/Descriptor/Descriptor.js +0 -4
- package/src/components/Molecules/Descriptor/Descriptor.test.js +0 -8
- package/src/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/CTAMultiCard.style.js +2 -0
- package/src/components/Molecules/OLD_CTAMultiCard/_ArrowIcon.js +22 -0
- package/src/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/__snapshots__/CTAMultiCard.test.js.snap +8 -0
- package/src/index.js +2 -1
- /package/dist/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/CTAMultiCard.js +0 -0
- /package/dist/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/CTAMultiCard.test.js +0 -0
- /package/dist/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/SingleCard.js +0 -0
- /package/dist/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/example_data.json +0 -0
- /package/src/components/Molecules/{CTAMultiCard → CTA/shared}/_ArrowIcon.js +0 -0
- /package/src/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/CTAMultiCard.js +0 -0
- /package/src/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/CTAMultiCard.test.js +0 -0
- /package/src/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/SingleCard.js +0 -0
- /package/src/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/example_data.json +0 -0
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`renders correctly 1`] = `
|
|
4
4
|
.c2 {
|
|
5
|
+
font-family: 'Montserrat',Helvetica,Arial,sans-serif;
|
|
6
|
+
font-weight: 700;
|
|
7
|
+
text-transform: inherit;
|
|
8
|
+
-webkit-letter-spacing: 0;
|
|
9
|
+
-moz-letter-spacing: 0;
|
|
10
|
+
-ms-letter-spacing: 0;
|
|
11
|
+
letter-spacing: 0;
|
|
12
|
+
font-size: 1.25rem;
|
|
13
|
+
line-height: 1.5rem;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.c2 span {
|
|
17
|
+
font-size: inherit;
|
|
18
|
+
line-height: inherit;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.c4 {
|
|
5
22
|
font-family: 'Anton',Impact,sans-serif;
|
|
6
23
|
font-weight: 400;
|
|
7
24
|
text-transform: uppercase;
|
|
@@ -13,17 +30,17 @@ exports[`renders correctly 1`] = `
|
|
|
13
30
|
line-height: 1.5rem;
|
|
14
31
|
}
|
|
15
32
|
|
|
16
|
-
.
|
|
33
|
+
.c4 {
|
|
17
34
|
font-size: 1.5rem;
|
|
18
35
|
line-height: normal;
|
|
19
36
|
}
|
|
20
37
|
|
|
21
|
-
.
|
|
38
|
+
.c4 span {
|
|
22
39
|
font-size: inherit;
|
|
23
40
|
line-height: inherit;
|
|
24
41
|
}
|
|
25
42
|
|
|
26
|
-
.
|
|
43
|
+
.c8 {
|
|
27
44
|
font-family: 'Montserrat',Helvetica,Arial,sans-serif;
|
|
28
45
|
font-weight: 400;
|
|
29
46
|
text-transform: inherit;
|
|
@@ -35,17 +52,17 @@ exports[`renders correctly 1`] = `
|
|
|
35
52
|
line-height: 1.25rem;
|
|
36
53
|
}
|
|
37
54
|
|
|
38
|
-
.
|
|
55
|
+
.c8 {
|
|
39
56
|
font-size: 1rem;
|
|
40
57
|
line-height: normal;
|
|
41
58
|
}
|
|
42
59
|
|
|
43
|
-
.
|
|
60
|
+
.c8 span {
|
|
44
61
|
font-size: inherit;
|
|
45
62
|
line-height: inherit;
|
|
46
63
|
}
|
|
47
64
|
|
|
48
|
-
.
|
|
65
|
+
.c6 {
|
|
49
66
|
-webkit-transform: rotate(180deg);
|
|
50
67
|
-ms-transform: rotate(180deg);
|
|
51
68
|
transform: rotate(180deg);
|
|
@@ -95,7 +112,7 @@ exports[`renders correctly 1`] = `
|
|
|
95
112
|
animation-duration: 0.4s;
|
|
96
113
|
}
|
|
97
114
|
|
|
98
|
-
.
|
|
115
|
+
.c5 {
|
|
99
116
|
display: -webkit-box;
|
|
100
117
|
display: -webkit-flex;
|
|
101
118
|
display: -ms-flexbox;
|
|
@@ -109,7 +126,7 @@ exports[`renders correctly 1`] = `
|
|
|
109
126
|
align-content: center;
|
|
110
127
|
}
|
|
111
128
|
|
|
112
|
-
.
|
|
129
|
+
.c7 {
|
|
113
130
|
overflow: hidden;
|
|
114
131
|
height: 0;
|
|
115
132
|
visibility: none;
|
|
@@ -118,36 +135,54 @@ exports[`renders correctly 1`] = `
|
|
|
118
135
|
padding: 0 2rem;
|
|
119
136
|
}
|
|
120
137
|
|
|
138
|
+
.c3 {
|
|
139
|
+
margin-bottom: 0;
|
|
140
|
+
}
|
|
141
|
+
|
|
121
142
|
@media (min-width:740px) {
|
|
122
143
|
.c2 {
|
|
144
|
+
font-size: 1.25rem;
|
|
145
|
+
line-height: 1.5rem;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@media (min-width:1024px) {
|
|
150
|
+
.c2 {
|
|
151
|
+
font-size: 1.375rem;
|
|
152
|
+
line-height: 1.625rem;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
@media (min-width:740px) {
|
|
157
|
+
.c4 {
|
|
123
158
|
font-size: 1.875rem;
|
|
124
159
|
line-height: 1.875rem;
|
|
125
160
|
}
|
|
126
161
|
}
|
|
127
162
|
|
|
128
163
|
@media (min-width:1024px) {
|
|
129
|
-
.
|
|
164
|
+
.c4 {
|
|
130
165
|
font-size: 2rem;
|
|
131
166
|
line-height: 2rem;
|
|
132
167
|
}
|
|
133
168
|
}
|
|
134
169
|
|
|
135
170
|
@media (min-width:740px) {
|
|
136
|
-
.
|
|
171
|
+
.c8 {
|
|
137
172
|
font-size: 1rem;
|
|
138
173
|
line-height: 1.25rem;
|
|
139
174
|
}
|
|
140
175
|
}
|
|
141
176
|
|
|
142
177
|
@media (min-width:1024px) {
|
|
143
|
-
.
|
|
178
|
+
.c8 {
|
|
144
179
|
font-size: 1.125rem;
|
|
145
180
|
line-height: 1.375rem;
|
|
146
181
|
}
|
|
147
182
|
}
|
|
148
183
|
|
|
149
184
|
@media (min-width:1024px) {
|
|
150
|
-
.
|
|
185
|
+
.c6 {
|
|
151
186
|
fill: #000000;
|
|
152
187
|
}
|
|
153
188
|
}
|
|
@@ -159,7 +194,7 @@ exports[`renders correctly 1`] = `
|
|
|
159
194
|
}
|
|
160
195
|
|
|
161
196
|
@media (min-width:740px) {
|
|
162
|
-
.
|
|
197
|
+
.c7 {
|
|
163
198
|
padding: 0 3rem;
|
|
164
199
|
}
|
|
165
200
|
}
|
|
@@ -173,16 +208,20 @@ exports[`renders correctly 1`] = `
|
|
|
173
208
|
onClick={[Function]}
|
|
174
209
|
type="button"
|
|
175
210
|
>
|
|
176
|
-
<
|
|
177
|
-
className="c2"
|
|
211
|
+
<h3
|
|
212
|
+
className="c2 c3"
|
|
178
213
|
>
|
|
179
|
-
|
|
180
|
-
|
|
214
|
+
<h2
|
|
215
|
+
className="c4"
|
|
216
|
+
>
|
|
217
|
+
I am the title
|
|
218
|
+
</h2>
|
|
219
|
+
</h3>
|
|
181
220
|
<div
|
|
182
|
-
className="
|
|
221
|
+
className="c5"
|
|
183
222
|
>
|
|
184
223
|
<svg
|
|
185
|
-
className="
|
|
224
|
+
className="c6"
|
|
186
225
|
direction="down"
|
|
187
226
|
fill="#000000"
|
|
188
227
|
height={24}
|
|
@@ -197,10 +236,10 @@ exports[`renders correctly 1`] = `
|
|
|
197
236
|
</div>
|
|
198
237
|
</button>
|
|
199
238
|
<div
|
|
200
|
-
className="
|
|
239
|
+
className="c7"
|
|
201
240
|
>
|
|
202
241
|
<p
|
|
203
|
-
className="
|
|
242
|
+
className="c8"
|
|
204
243
|
>
|
|
205
244
|
Name, surname, email and billing address We need these to process your payment, create a receipt and send it to you. Establishment information We use this information to understand which institutions (e.g. schools, companies) raise money for us. Your details will be kept safe and never shared with other organisations; see our Privacy Policy for more information
|
|
206
245
|
</p>
|
|
@@ -141,7 +141,6 @@ const ArticleTeaser = ({
|
|
|
141
141
|
alt = '',
|
|
142
142
|
category = null,
|
|
143
143
|
logoSize = null,
|
|
144
|
-
family = 'Anton',
|
|
145
144
|
time = null
|
|
146
145
|
}) => (
|
|
147
146
|
<Wrapper>
|
|
@@ -175,11 +174,7 @@ const ArticleTeaser = ({
|
|
|
175
174
|
</Date>
|
|
176
175
|
<Title
|
|
177
176
|
time={time}
|
|
178
|
-
size="xl"
|
|
179
177
|
tag="h3"
|
|
180
|
-
height="2rem"
|
|
181
|
-
weight="normal"
|
|
182
|
-
family={family}
|
|
183
178
|
>
|
|
184
179
|
{title}
|
|
185
180
|
</Title>
|
|
@@ -198,7 +193,6 @@ ArticleTeaser.propTypes = {
|
|
|
198
193
|
image: PropTypes.string,
|
|
199
194
|
imageLow: PropTypes.string,
|
|
200
195
|
logoSize: PropTypes.string,
|
|
201
|
-
family: PropTypes.string,
|
|
202
196
|
category: PropTypes.string,
|
|
203
197
|
alt: PropTypes.string,
|
|
204
198
|
date: PropTypes.string.isRequired,
|
|
@@ -54,14 +54,6 @@ it('renders article teaser correctly', () => {
|
|
|
54
54
|
line-height: 1.5rem;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
.c10 {
|
|
58
|
-
font-size: 2rem;
|
|
59
|
-
line-height: normal;
|
|
60
|
-
font-family: 'Anton',Impact,sans-serif;
|
|
61
|
-
font-weight: normal;
|
|
62
|
-
line-height: 2rem;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
57
|
.c10 span {
|
|
66
58
|
font-size: inherit;
|
|
67
59
|
line-height: inherit;
|
|
@@ -355,14 +347,6 @@ it('renders press realese correctly', () => {
|
|
|
355
347
|
line-height: 1.5rem;
|
|
356
348
|
}
|
|
357
349
|
|
|
358
|
-
.c10 {
|
|
359
|
-
font-size: 2rem;
|
|
360
|
-
line-height: normal;
|
|
361
|
-
font-family: 'Anton',Impact,sans-serif;
|
|
362
|
-
font-weight: normal;
|
|
363
|
-
line-height: 2rem;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
350
|
.c10 span {
|
|
367
351
|
font-size: inherit;
|
|
368
352
|
line-height: inherit;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { snakeCase } from 'lodash';
|
|
4
|
+
import CTACard from '../shared/CTACard';
|
|
5
|
+
import CardsContainer from './CTAMultiCard.style';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* CTAMultiCard Component
|
|
9
|
+
*
|
|
10
|
+
* This component is a successor to the CardsDs component.
|
|
11
|
+
* Previously, the comicrelief-contentful frontend would map
|
|
12
|
+
* through data and create multiple CardsDs instances.
|
|
13
|
+
* Now CTAMultiCard handles the mapping internally, accepting
|
|
14
|
+
* a data object and rendering all cards.
|
|
15
|
+
*
|
|
16
|
+
* Note: The component expects pre-rendered content in the `body`
|
|
17
|
+
* field of each card. The frontend should handle rich text rendering
|
|
18
|
+
* before passing data to this component.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const CTAMultiCard = ({ data }) => {
|
|
22
|
+
const {
|
|
23
|
+
cards,
|
|
24
|
+
backgroundColour: bgCards,
|
|
25
|
+
layout,
|
|
26
|
+
carouselOfCards,
|
|
27
|
+
paddingAbove,
|
|
28
|
+
paddingBelow
|
|
29
|
+
} = data;
|
|
30
|
+
|
|
31
|
+
if (!cards || !Array.isArray(cards) || cards.length === 0) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Convert layout string to number (e.g., "3 columns"
|
|
36
|
+
// (that's how it comes through from Contentful) -> 3)
|
|
37
|
+
const columns = layout && layout.includes('3') ? 3 : 2;
|
|
38
|
+
|
|
39
|
+
const cardsBackground = snakeCase(bgCards || 'white');
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<CardsContainer
|
|
43
|
+
backgroundColor={cardsBackground}
|
|
44
|
+
columns={columns}
|
|
45
|
+
isCarousel={carouselOfCards}
|
|
46
|
+
paddingAbove={paddingAbove}
|
|
47
|
+
paddingBelow={paddingBelow}
|
|
48
|
+
>
|
|
49
|
+
{cards.map(card => (
|
|
50
|
+
<CTACard
|
|
51
|
+
key={card.id}
|
|
52
|
+
card={card}
|
|
53
|
+
columns={columns}
|
|
54
|
+
isCarousel={carouselOfCards}
|
|
55
|
+
/>
|
|
56
|
+
))}
|
|
57
|
+
</CardsContainer>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
CTAMultiCard.propTypes = {
|
|
62
|
+
data: PropTypes.shape({
|
|
63
|
+
cards: PropTypes.arrayOf(
|
|
64
|
+
PropTypes.shape({
|
|
65
|
+
id: PropTypes.string.isRequired,
|
|
66
|
+
body: PropTypes.node,
|
|
67
|
+
image: PropTypes.shape({
|
|
68
|
+
description: PropTypes.string,
|
|
69
|
+
gatsbyImageData: PropTypes.shape({
|
|
70
|
+
placeholder: PropTypes.shape({
|
|
71
|
+
fallback: PropTypes.string
|
|
72
|
+
}),
|
|
73
|
+
images: PropTypes.shape({
|
|
74
|
+
fallback: PropTypes.shape({
|
|
75
|
+
src: PropTypes.string,
|
|
76
|
+
srcSet: PropTypes.string
|
|
77
|
+
}),
|
|
78
|
+
sources: PropTypes.arrayOf(
|
|
79
|
+
PropTypes.shape({
|
|
80
|
+
srcSet: PropTypes.string
|
|
81
|
+
})
|
|
82
|
+
)
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
}),
|
|
86
|
+
backgroundColour: PropTypes.string,
|
|
87
|
+
link: PropTypes.string,
|
|
88
|
+
linkLabel: PropTypes.string
|
|
89
|
+
})
|
|
90
|
+
).isRequired,
|
|
91
|
+
backgroundColour: PropTypes.string,
|
|
92
|
+
layout: PropTypes.string,
|
|
93
|
+
carouselOfCards: PropTypes.bool,
|
|
94
|
+
paddingAbove: PropTypes.string,
|
|
95
|
+
paddingBelow: PropTypes.string
|
|
96
|
+
}).isRequired
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export default CTAMultiCard;
|
package/{dist/components/Molecules → src/components/Molecules/CTA}/CTAMultiCard/CTAMultiCard.md
RENAMED
|
@@ -18,8 +18,8 @@ The component expects pre-rendered content to be passed in the `body` field of e
|
|
|
18
18
|
|
|
19
19
|
```js
|
|
20
20
|
import CTAMultiCard from './CTAMultiCard';
|
|
21
|
-
import Text from '
|
|
22
|
-
import challengeExampleImage from '
|
|
21
|
+
import Text from '../../../Atoms/Text/Text';
|
|
22
|
+
import challengeExampleImage from '../../../../styleguide/assets/challenge-1.jpg';
|
|
23
23
|
const exampleData = require('./example_data.json');
|
|
24
24
|
|
|
25
25
|
// Map cards to include pre-rendered body content and processed image/link data
|
|
@@ -59,8 +59,8 @@ const data = {
|
|
|
59
59
|
|
|
60
60
|
```js
|
|
61
61
|
import CTAMultiCard from './CTAMultiCard';
|
|
62
|
-
import Text from '
|
|
63
|
-
import challengeExampleImage from '
|
|
62
|
+
import Text from '../../../Atoms/Text/Text';
|
|
63
|
+
import challengeExampleImage from '../../../../styleguide/assets/challenge-1.jpg';
|
|
64
64
|
const exampleData = require('./example_data.json');
|
|
65
65
|
|
|
66
66
|
// Map cards to include pre-rendered body content and processed image/link data
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
import { breakpointValues } from '../../../../theme/shared/allBreakpoints';
|
|
3
|
+
|
|
4
|
+
const CardsContainer = styled.div`
|
|
5
|
+
padding-top: ${({ paddingAbove }) => paddingAbove};
|
|
6
|
+
padding-bottom: ${({ paddingBelow }) => paddingBelow};
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
width: 100%;
|
|
10
|
+
background: ${({ theme, backgroundColor }) => theme.color(backgroundColor)};
|
|
11
|
+
gap: 1rem;
|
|
12
|
+
|
|
13
|
+
// Mobile stack mode - vertical layout (only on mobile, below M breakpoint)
|
|
14
|
+
${({ isCarousel }) => !isCarousel && css`
|
|
15
|
+
@media (max-width: ${breakpointValues.M - 1}px) {
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
background: transparent;
|
|
18
|
+
}
|
|
19
|
+
`}
|
|
20
|
+
|
|
21
|
+
// Non-mobile layout (M and above) - consistent across carousel/non-carousel, as above M we only do stacked mode.
|
|
22
|
+
@media ${({ theme }) => theme.allBreakpoints('M')} {
|
|
23
|
+
flex-direction: row;
|
|
24
|
+
flex-wrap: wrap;
|
|
25
|
+
justify-content: center;
|
|
26
|
+
align-items: stretch;
|
|
27
|
+
width: fit-content;
|
|
28
|
+
max-width: 100%;
|
|
29
|
+
margin: 0 auto;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Carousel mode - horizontal scroll container (M and below)
|
|
33
|
+
${({ isCarousel }) => isCarousel && css`
|
|
34
|
+
@media (max-width: ${breakpointValues.L - 1}px) {
|
|
35
|
+
flex-direction: row;
|
|
36
|
+
flex-wrap: nowrap;
|
|
37
|
+
justify-content: flex-start;
|
|
38
|
+
width: 100%;
|
|
39
|
+
margin: 0;
|
|
40
|
+
max-width: 100%;
|
|
41
|
+
overflow-x: visible;
|
|
42
|
+
overflow-y: scroll;
|
|
43
|
+
-webkit-overflow-scrolling: touch;
|
|
44
|
+
scroll-snap-type: x mandatory;
|
|
45
|
+
padding: 0.75rem 1rem;
|
|
46
|
+
|
|
47
|
+
scrollbar-width: none;
|
|
48
|
+
-ms-overflow-style: none;
|
|
49
|
+
&::-webkit-scrollbar {
|
|
50
|
+
display: none;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
`}
|
|
54
|
+
|
|
55
|
+
// Desktop grid layout for XL breakpoint - 3 columns
|
|
56
|
+
@media ${({ theme }) => theme.allBreakpoints('XL')} {
|
|
57
|
+
${({ columns }) => columns === 3 && css`
|
|
58
|
+
display: grid;
|
|
59
|
+
justify-content: center;
|
|
60
|
+
align-items: stretch;
|
|
61
|
+
grid-template-columns: repeat(3, minmax(0, 371px));
|
|
62
|
+
width: 100%;
|
|
63
|
+
margin: 0 auto;
|
|
64
|
+
max-width: 100%;
|
|
65
|
+
`}
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
export default CardsContainer;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import 'jest-styled-components';
|
|
3
|
+
import renderWithTheme from '../../../../../tests/hoc/shallowWithTheme';
|
|
4
|
+
import CTAMultiCard from './CTAMultiCard';
|
|
5
|
+
import exampleData from './example_data.json';
|
|
6
|
+
import Text from '../../../Atoms/Text/Text';
|
|
7
|
+
|
|
8
|
+
const makeProcessedCard = (card) => {
|
|
9
|
+
const fallback = card?.image?.gatsbyImageData?.images?.fallback?.src;
|
|
10
|
+
const imageLow = card?.image?.gatsbyImageData?.placeholder?.fallback;
|
|
11
|
+
const images = card?.image?.gatsbyImageData?.images?.sources?.[0]?.srcSet;
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
...card,
|
|
15
|
+
fallback,
|
|
16
|
+
imageLow,
|
|
17
|
+
images,
|
|
18
|
+
// tests focus on layout; use a stable processed value here
|
|
19
|
+
bgColour: 'white',
|
|
20
|
+
description: card?.image?.description || '',
|
|
21
|
+
target: 'self',
|
|
22
|
+
external: null
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// Map example data cards to include pre-rendered body content
|
|
27
|
+
const cardsWithRenderedBody = exampleData.cards.map(card => ({
|
|
28
|
+
...makeProcessedCard(card),
|
|
29
|
+
body: (
|
|
30
|
+
<Text tag="p">
|
|
31
|
+
<strong>Load</strong> of text here
|
|
32
|
+
</Text>
|
|
33
|
+
)
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
const mockData = {
|
|
37
|
+
...exampleData,
|
|
38
|
+
cards: [
|
|
39
|
+
...cardsWithRenderedBody,
|
|
40
|
+
// Add a card without image for testing edge cases. This should not ever really happen in real life, but just in case...
|
|
41
|
+
{
|
|
42
|
+
id: '6bc887c7-f939-5654-a0c5-1b2caf91de6c',
|
|
43
|
+
title: 'Card no pic',
|
|
44
|
+
backgroundColour: 'Blue Light',
|
|
45
|
+
link: '/test-no-image',
|
|
46
|
+
linkLabel: 'View card',
|
|
47
|
+
bgColour: 'blue_light',
|
|
48
|
+
target: 'self',
|
|
49
|
+
external: null,
|
|
50
|
+
body: (
|
|
51
|
+
<Text tag="p">
|
|
52
|
+
Load of text here
|
|
53
|
+
</Text>
|
|
54
|
+
),
|
|
55
|
+
image: null
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
it('renders correctly with data prop', () => {
|
|
61
|
+
const tree = renderWithTheme(
|
|
62
|
+
<CTAMultiCard data={mockData} />
|
|
63
|
+
).toJSON();
|
|
64
|
+
|
|
65
|
+
expect(tree).toMatchSnapshot();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('renders carousel mode correctly', () => {
|
|
69
|
+
const carouselData = {
|
|
70
|
+
...mockData,
|
|
71
|
+
carouselOfCards: true
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const tree = renderWithTheme(
|
|
75
|
+
<CTAMultiCard data={carouselData} />
|
|
76
|
+
).toJSON();
|
|
77
|
+
|
|
78
|
+
expect(tree).toMatchSnapshot();
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('renders 2 columns layout correctly', () => {
|
|
82
|
+
const twoColumnData = {
|
|
83
|
+
...mockData,
|
|
84
|
+
layout: '2 columns'
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const tree = renderWithTheme(
|
|
88
|
+
<CTAMultiCard data={twoColumnData} />
|
|
89
|
+
).toJSON();
|
|
90
|
+
|
|
91
|
+
expect(tree).toMatchSnapshot();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('handles data structure correctly', () => {
|
|
95
|
+
const testData = {
|
|
96
|
+
cards: mockData.cards,
|
|
97
|
+
backgroundColour: 'White',
|
|
98
|
+
layout: '3 columns',
|
|
99
|
+
carouselOfCards: false
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const tree = renderWithTheme(
|
|
103
|
+
<CTAMultiCard data={testData} />
|
|
104
|
+
).toJSON();
|
|
105
|
+
|
|
106
|
+
expect(tree).toMatchSnapshot();
|
|
107
|
+
});
|