@comicrelief/component-library 8.49.0 → 8.50.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/dist/components/Atoms/Button/Button.style.js +1 -1
- package/dist/components/Atoms/Button/Button.test.js +1 -1
- package/dist/components/Atoms/Link/Link.style.js +1 -1
- package/dist/components/Atoms/Link/Link.test.js +1 -1
- package/dist/components/Molecules/ArticleTeaser/ArticleTeaser.js +0 -1
- package/dist/components/Molecules/ArticleTeaser/ArticleTeaser.test.js +0 -2
- 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/CardDs/__snapshots__/CardDs.test.js.snap +2 -2
- package/dist/components/Molecules/Countdown/Countdown.js +4 -8
- package/dist/components/Molecules/Descriptor/Descriptor.js +1 -2
- package/dist/components/Molecules/Descriptor/Descriptor.test.js +0 -2
- package/dist/components/Molecules/InfoBanner/InfoBanner.js +6 -12
- package/dist/components/Molecules/InfoBanner/__snapshots__/InfoBanner.test.js.snap +0 -1
- 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/components/Molecules/Promo/__snapshots__/Promo.test.js.snap +2 -2
- package/dist/components/Molecules/SearchResult/SearchResult.js +2 -4
- package/dist/components/Molecules/SearchResult/__snapshots__/SearchResult.test.js.snap +0 -8
- package/dist/components/Molecules/SingleMessage/__snapshots__/SingleMessage.test.js.snap +2 -2
- package/dist/components/Molecules/SingleMessageDS/SingleMessageDs.style.js +1 -1
- package/dist/components/Molecules/SingleMessageDS/__snapshots__/SingleMessageDs.test.js.snap +1 -2
- package/dist/components/Organisms/CookieBanner/CookieBanner.test.js +1 -1
- package/dist/components/Organisms/Donate/Donate.js +1 -2
- package/dist/components/Organisms/Donate/__snapshots__/Donate.test.js.snap +0 -4
- package/dist/components/Organisms/EmailSignUp/_EmailSignUp.js +1 -2
- package/dist/components/Organisms/EmailSignUp/__snapshots__/EmailSignUp.test.js.snap +1 -2
- package/dist/components/Organisms/FooterNew/__snapshots__/FooterNew.test.js.snap +1 -1
- package/dist/components/Organisms/ImpactSlider/ImpactSlider.js +0 -1
- package/dist/components/Organisms/ImpactSlider/_ImpactMoneybuys.js +0 -1
- package/dist/components/Organisms/WYMDCarousel/WYMDCarousel.js +0 -2
- package/dist/components/Organisms/WYMDCarousel/__snapshots__/WYMDCarousel.test.js.snap +0 -1
- package/dist/index.js +8 -1
- package/package.json +1 -1
- package/src/components/Atoms/Button/Button.style.js +1 -1
- package/src/components/Atoms/Button/Button.test.js +1 -1
- package/src/components/Atoms/Link/Link.style.js +1 -1
- package/src/components/Atoms/Link/Link.test.js +1 -1
- package/src/components/Molecules/ArticleTeaser/ArticleTeaser.js +0 -1
- package/src/components/Molecules/ArticleTeaser/ArticleTeaser.test.js +0 -2
- 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/CardDs/__snapshots__/CardDs.test.js.snap +2 -2
- package/src/components/Molecules/Countdown/Countdown.js +4 -4
- package/src/components/Molecules/Descriptor/Descriptor.js +0 -2
- package/src/components/Molecules/Descriptor/Descriptor.test.js +0 -2
- package/src/components/Molecules/InfoBanner/InfoBanner.js +6 -6
- package/src/components/Molecules/InfoBanner/__snapshots__/InfoBanner.test.js.snap +0 -1
- 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/components/Molecules/Promo/__snapshots__/Promo.test.js.snap +2 -2
- package/src/components/Molecules/SearchResult/SearchResult.js +2 -2
- package/src/components/Molecules/SearchResult/__snapshots__/SearchResult.test.js.snap +0 -8
- package/src/components/Molecules/SingleMessage/__snapshots__/SingleMessage.test.js.snap +2 -2
- package/src/components/Molecules/SingleMessageDS/SingleMessageDs.style.js +0 -1
- package/src/components/Molecules/SingleMessageDS/__snapshots__/SingleMessageDs.test.js.snap +1 -2
- package/src/components/Organisms/CookieBanner/CookieBanner.test.js +1 -1
- package/src/components/Organisms/Donate/Donate.js +1 -1
- package/src/components/Organisms/Donate/__snapshots__/Donate.test.js.snap +0 -4
- package/src/components/Organisms/EmailSignUp/_EmailSignUp.js +1 -1
- package/src/components/Organisms/EmailSignUp/__snapshots__/EmailSignUp.test.js.snap +1 -2
- package/src/components/Organisms/FooterNew/__snapshots__/FooterNew.test.js.snap +1 -1
- package/src/components/Organisms/ImpactSlider/ImpactSlider.js +1 -1
- package/src/components/Organisms/ImpactSlider/_ImpactMoneybuys.js +1 -1
- package/src/components/Organisms/WYMDCarousel/WYMDCarousel.js +2 -2
- package/src/components/Organisms/WYMDCarousel/__snapshots__/WYMDCarousel.test.js.snap +0 -1
- 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
|
@@ -11,7 +11,7 @@ var _fontHelper = _interopRequireDefault(require("../../../theme/crTheme/fontHel
|
|
|
11
11
|
const StyledButton = _styledComponents.default.button.withConfig({
|
|
12
12
|
displayName: "Buttonstyle__StyledButton",
|
|
13
13
|
componentId: "sc-k17brs-0"
|
|
14
|
-
})(["display:inline-flex;position:relative;text-decoration:none;transition:all 0.2s;
|
|
14
|
+
})(["display:inline-flex;position:relative;text-decoration:none;transition:all 0.2s;height:2.5rem;width:100%;justify-content:center;align-items:center;border:none;cursor:pointer;padding:0.6rem 1rem;border-radius:0.5rem;> a{text-decoration:none;}", ";", " @media ", "{width:", ";}@media ", "{width:", ";}"], _ref => {
|
|
15
15
|
let {
|
|
16
16
|
color,
|
|
17
17
|
theme,
|
|
@@ -20,7 +20,7 @@ it('renders a standard styled link correctly', () => {
|
|
|
20
20
|
text-decoration: none;
|
|
21
21
|
-webkit-transition: all 0.2s;
|
|
22
22
|
transition: all 0.2s;
|
|
23
|
-
|
|
23
|
+
height: 2.5rem;
|
|
24
24
|
width: 100%;
|
|
25
25
|
-webkit-box-pack: center;
|
|
26
26
|
-webkit-justify-content: center;
|
|
@@ -10,7 +10,7 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
|
10
10
|
var _spacing = _interopRequireDefault(require("../../../theme/shared/spacing"));
|
|
11
11
|
var _hideVisually = _interopRequireDefault(require("../../../theme/shared/hideVisually"));
|
|
12
12
|
var _fontHelper = _interopRequireDefault(require("../../../theme/crTheme/fontHelper"));
|
|
13
|
-
const buttonStyle = () => (0, _styledComponents.css)(["display:inline-flex;position:relative;text-decoration:none;transition:all 0.2s;
|
|
13
|
+
const buttonStyle = () => (0, _styledComponents.css)(["display:inline-flex;position:relative;text-decoration:none;transition:all 0.2s;height:2.5rem;width:100%;justify-content:center;align-items:center;border:none;cursor:pointer;padding:0.6rem 1rem;border-radius:0.5rem;", ";", " ", ";@media ", "{width:", ";}@media ", "{width:", ";", ";}"], _ref => {
|
|
14
14
|
let {
|
|
15
15
|
color,
|
|
16
16
|
theme,
|
|
@@ -196,7 +196,7 @@ it('renders link styled as button correctly', () => {
|
|
|
196
196
|
text-decoration: none;
|
|
197
197
|
-webkit-transition: all 0.2s;
|
|
198
198
|
transition: all 0.2s;
|
|
199
|
-
|
|
199
|
+
height: 2.5rem;
|
|
200
200
|
width: 100%;
|
|
201
201
|
-webkit-box-pack: center;
|
|
202
202
|
-webkit-justify-content: center;
|
|
@@ -60,7 +60,6 @@ it('renders article teaser correctly', () => {
|
|
|
60
60
|
font-family: 'Anton',Impact,sans-serif;
|
|
61
61
|
font-weight: normal;
|
|
62
62
|
line-height: 2rem;
|
|
63
|
-
text-transform: uppercase;
|
|
64
63
|
}
|
|
65
64
|
|
|
66
65
|
.c10 span {
|
|
@@ -358,7 +357,6 @@ it('renders press realese correctly', () => {
|
|
|
358
357
|
font-family: 'Anton',Impact,sans-serif;
|
|
359
358
|
font-weight: normal;
|
|
360
359
|
line-height: 2rem;
|
|
361
|
-
text-transform: uppercase;
|
|
362
360
|
}
|
|
363
361
|
|
|
364
362
|
.c10 span {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _snakeCase2 = _interopRequireDefault(require("lodash/snakeCase"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _CTACard = _interopRequireDefault(require("../shared/CTACard"));
|
|
11
|
+
var _CTAMultiCard = _interopRequireDefault(require("./CTAMultiCard.style"));
|
|
12
|
+
/**
|
|
13
|
+
* CTAMultiCard Component
|
|
14
|
+
*
|
|
15
|
+
* This component is a successor to the CardsDs component.
|
|
16
|
+
* Previously, the comicrelief-contentful frontend would map
|
|
17
|
+
* through data and create multiple CardsDs instances.
|
|
18
|
+
* Now CTAMultiCard handles the mapping internally, accepting
|
|
19
|
+
* a data object and rendering all cards.
|
|
20
|
+
*
|
|
21
|
+
* Note: The component expects pre-rendered content in the `body`
|
|
22
|
+
* field of each card. The frontend should handle rich text rendering
|
|
23
|
+
* before passing data to this component.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const CTAMultiCard = _ref => {
|
|
27
|
+
let {
|
|
28
|
+
data
|
|
29
|
+
} = _ref;
|
|
30
|
+
const {
|
|
31
|
+
cards,
|
|
32
|
+
backgroundColour: bgCards,
|
|
33
|
+
layout,
|
|
34
|
+
carouselOfCards,
|
|
35
|
+
paddingAbove,
|
|
36
|
+
paddingBelow
|
|
37
|
+
} = data;
|
|
38
|
+
if (!cards || !Array.isArray(cards) || cards.length === 0) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Convert layout string to number (e.g., "3 columns"
|
|
43
|
+
// (that's how it comes through from Contentful) -> 3)
|
|
44
|
+
const columns = layout && layout.includes('3') ? 3 : 2;
|
|
45
|
+
const cardsBackground = (0, _snakeCase2.default)(bgCards || 'white');
|
|
46
|
+
return /*#__PURE__*/_react.default.createElement(_CTAMultiCard.default, {
|
|
47
|
+
backgroundColor: cardsBackground,
|
|
48
|
+
columns: columns,
|
|
49
|
+
isCarousel: carouselOfCards,
|
|
50
|
+
paddingAbove: paddingAbove,
|
|
51
|
+
paddingBelow: paddingBelow
|
|
52
|
+
}, cards.map(card => /*#__PURE__*/_react.default.createElement(_CTACard.default, {
|
|
53
|
+
key: card.id,
|
|
54
|
+
card: card,
|
|
55
|
+
columns: columns,
|
|
56
|
+
isCarousel: carouselOfCards
|
|
57
|
+
})));
|
|
58
|
+
};
|
|
59
|
+
var _default = exports.default = CTAMultiCard;
|
package/{src/components/Molecules → dist/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,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
|
+
var _allBreakpoints = require("../../../../theme/shared/allBreakpoints");
|
|
10
|
+
const CardsContainer = _styledComponents.default.div.withConfig({
|
|
11
|
+
displayName: "CTAMultiCardstyle__CardsContainer",
|
|
12
|
+
componentId: "sc-gsdqzv-0"
|
|
13
|
+
})(["padding-top:", ";padding-bottom:", ";display:flex;flex-direction:column;width:100%;background:", ";gap:1rem;", " @media ", "{flex-direction:row;flex-wrap:wrap;justify-content:center;align-items:stretch;width:fit-content;max-width:100%;margin:0 auto;}", " @media ", "{", "}"], _ref => {
|
|
14
|
+
let {
|
|
15
|
+
paddingAbove
|
|
16
|
+
} = _ref;
|
|
17
|
+
return paddingAbove;
|
|
18
|
+
}, _ref2 => {
|
|
19
|
+
let {
|
|
20
|
+
paddingBelow
|
|
21
|
+
} = _ref2;
|
|
22
|
+
return paddingBelow;
|
|
23
|
+
}, _ref3 => {
|
|
24
|
+
let {
|
|
25
|
+
theme,
|
|
26
|
+
backgroundColor
|
|
27
|
+
} = _ref3;
|
|
28
|
+
return theme.color(backgroundColor);
|
|
29
|
+
}, _ref4 => {
|
|
30
|
+
let {
|
|
31
|
+
isCarousel
|
|
32
|
+
} = _ref4;
|
|
33
|
+
return !isCarousel && (0, _styledComponents.css)(["@media (max-width:", "px){flex-direction:column;background:transparent;}"], _allBreakpoints.breakpointValues.M - 1);
|
|
34
|
+
}, _ref5 => {
|
|
35
|
+
let {
|
|
36
|
+
theme
|
|
37
|
+
} = _ref5;
|
|
38
|
+
return theme.allBreakpoints('M');
|
|
39
|
+
}, _ref6 => {
|
|
40
|
+
let {
|
|
41
|
+
isCarousel
|
|
42
|
+
} = _ref6;
|
|
43
|
+
return isCarousel && (0, _styledComponents.css)(["@media (max-width:", "px){flex-direction:row;flex-wrap:nowrap;justify-content:flex-start;width:100%;margin:0;max-width:100%;overflow-x:visible;overflow-y:scroll;-webkit-overflow-scrolling:touch;scroll-snap-type:x mandatory;padding:0.75rem 1rem;scrollbar-width:none;-ms-overflow-style:none;&::-webkit-scrollbar{display:none;}}"], _allBreakpoints.breakpointValues.L - 1);
|
|
44
|
+
}, _ref7 => {
|
|
45
|
+
let {
|
|
46
|
+
theme
|
|
47
|
+
} = _ref7;
|
|
48
|
+
return theme.allBreakpoints('XL');
|
|
49
|
+
}, _ref8 => {
|
|
50
|
+
let {
|
|
51
|
+
columns
|
|
52
|
+
} = _ref8;
|
|
53
|
+
return columns === 3 && (0, _styledComponents.css)(["display:grid;justify-content:center;align-items:stretch;grid-template-columns:repeat(3,minmax(0,371px));width:100%;margin:0 auto;max-width:100%;"]);
|
|
54
|
+
});
|
|
55
|
+
var _default = exports.default = CardsContainer;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _react = _interopRequireDefault(require("react"));
|
|
5
|
+
require("jest-styled-components");
|
|
6
|
+
var _shallowWithTheme = _interopRequireDefault(require("../../../../../tests/hoc/shallowWithTheme"));
|
|
7
|
+
var _CTAMultiCard = _interopRequireDefault(require("./CTAMultiCard"));
|
|
8
|
+
var _example_data = _interopRequireDefault(require("./example_data.json"));
|
|
9
|
+
var _Text = _interopRequireDefault(require("../../../Atoms/Text/Text"));
|
|
10
|
+
const makeProcessedCard = card => {
|
|
11
|
+
var _card$image, _card$image$gatsbyIma, _card$image$gatsbyIma2, _card$image$gatsbyIma3, _card$image2, _card$image2$gatsbyIm, _card$image2$gatsbyIm2, _card$image3, _card$image3$gatsbyIm, _card$image3$gatsbyIm2, _card$image3$gatsbyIm3, _card$image3$gatsbyIm4, _card$image4;
|
|
12
|
+
const fallback = card === null || card === void 0 ? void 0 : (_card$image = card.image) === null || _card$image === void 0 ? void 0 : (_card$image$gatsbyIma = _card$image.gatsbyImageData) === null || _card$image$gatsbyIma === void 0 ? void 0 : (_card$image$gatsbyIma2 = _card$image$gatsbyIma.images) === null || _card$image$gatsbyIma2 === void 0 ? void 0 : (_card$image$gatsbyIma3 = _card$image$gatsbyIma2.fallback) === null || _card$image$gatsbyIma3 === void 0 ? void 0 : _card$image$gatsbyIma3.src;
|
|
13
|
+
const imageLow = card === null || card === void 0 ? void 0 : (_card$image2 = card.image) === null || _card$image2 === void 0 ? void 0 : (_card$image2$gatsbyIm = _card$image2.gatsbyImageData) === null || _card$image2$gatsbyIm === void 0 ? void 0 : (_card$image2$gatsbyIm2 = _card$image2$gatsbyIm.placeholder) === null || _card$image2$gatsbyIm2 === void 0 ? void 0 : _card$image2$gatsbyIm2.fallback;
|
|
14
|
+
const images = card === null || card === void 0 ? void 0 : (_card$image3 = card.image) === null || _card$image3 === void 0 ? void 0 : (_card$image3$gatsbyIm = _card$image3.gatsbyImageData) === null || _card$image3$gatsbyIm === void 0 ? void 0 : (_card$image3$gatsbyIm2 = _card$image3$gatsbyIm.images) === null || _card$image3$gatsbyIm2 === void 0 ? void 0 : (_card$image3$gatsbyIm3 = _card$image3$gatsbyIm2.sources) === null || _card$image3$gatsbyIm3 === void 0 ? void 0 : (_card$image3$gatsbyIm4 = _card$image3$gatsbyIm3[0]) === null || _card$image3$gatsbyIm4 === void 0 ? void 0 : _card$image3$gatsbyIm4.srcSet;
|
|
15
|
+
return {
|
|
16
|
+
...card,
|
|
17
|
+
fallback,
|
|
18
|
+
imageLow,
|
|
19
|
+
images,
|
|
20
|
+
// tests focus on layout; use a stable processed value here
|
|
21
|
+
bgColour: 'white',
|
|
22
|
+
description: (card === null || card === void 0 ? void 0 : (_card$image4 = card.image) === null || _card$image4 === void 0 ? void 0 : _card$image4.description) || '',
|
|
23
|
+
target: 'self',
|
|
24
|
+
external: null
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Map example data cards to include pre-rendered body content
|
|
29
|
+
const cardsWithRenderedBody = _example_data.default.cards.map(card => ({
|
|
30
|
+
...makeProcessedCard(card),
|
|
31
|
+
body: /*#__PURE__*/_react.default.createElement(_Text.default, {
|
|
32
|
+
tag: "p"
|
|
33
|
+
}, /*#__PURE__*/_react.default.createElement("strong", null, "Load"), " of text here")
|
|
34
|
+
}));
|
|
35
|
+
const mockData = {
|
|
36
|
+
..._example_data.default,
|
|
37
|
+
cards: [...cardsWithRenderedBody,
|
|
38
|
+
// Add a card without image for testing edge cases. This should not ever really happen in real life, but just in case...
|
|
39
|
+
{
|
|
40
|
+
id: '6bc887c7-f939-5654-a0c5-1b2caf91de6c',
|
|
41
|
+
title: 'Card no pic',
|
|
42
|
+
backgroundColour: 'Blue Light',
|
|
43
|
+
link: '/test-no-image',
|
|
44
|
+
linkLabel: 'View card',
|
|
45
|
+
bgColour: 'blue_light',
|
|
46
|
+
target: 'self',
|
|
47
|
+
external: null,
|
|
48
|
+
body: /*#__PURE__*/_react.default.createElement(_Text.default, {
|
|
49
|
+
tag: "p"
|
|
50
|
+
}, "Load of text here"),
|
|
51
|
+
image: null
|
|
52
|
+
}]
|
|
53
|
+
};
|
|
54
|
+
it('renders correctly with data prop', () => {
|
|
55
|
+
const tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(_CTAMultiCard.default, {
|
|
56
|
+
data: mockData
|
|
57
|
+
})).toJSON();
|
|
58
|
+
expect(tree).toMatchSnapshot();
|
|
59
|
+
});
|
|
60
|
+
it('renders carousel mode correctly', () => {
|
|
61
|
+
const carouselData = {
|
|
62
|
+
...mockData,
|
|
63
|
+
carouselOfCards: true
|
|
64
|
+
};
|
|
65
|
+
const tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(_CTAMultiCard.default, {
|
|
66
|
+
data: carouselData
|
|
67
|
+
})).toJSON();
|
|
68
|
+
expect(tree).toMatchSnapshot();
|
|
69
|
+
});
|
|
70
|
+
it('renders 2 columns layout correctly', () => {
|
|
71
|
+
const twoColumnData = {
|
|
72
|
+
...mockData,
|
|
73
|
+
layout: '2 columns'
|
|
74
|
+
};
|
|
75
|
+
const tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(_CTAMultiCard.default, {
|
|
76
|
+
data: twoColumnData
|
|
77
|
+
})).toJSON();
|
|
78
|
+
expect(tree).toMatchSnapshot();
|
|
79
|
+
});
|
|
80
|
+
it('handles data structure correctly', () => {
|
|
81
|
+
const testData = {
|
|
82
|
+
cards: mockData.cards,
|
|
83
|
+
backgroundColour: 'White',
|
|
84
|
+
layout: '3 columns',
|
|
85
|
+
carouselOfCards: false
|
|
86
|
+
};
|
|
87
|
+
const tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(_CTAMultiCard.default, {
|
|
88
|
+
data: testData
|
|
89
|
+
})).toJSON();
|
|
90
|
+
expect(tree).toMatchSnapshot();
|
|
91
|
+
});
|