@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.
Files changed (57) hide show
  1. package/dist/components/Molecules/Accordion/Accordion.js +8 -1
  2. package/dist/components/Molecules/Accordion/__snapshots__/Accordion.test.js.snap +60 -21
  3. package/dist/components/Molecules/ArticleTeaser/ArticleTeaser.js +1 -6
  4. package/dist/components/Molecules/ArticleTeaser/ArticleTeaser.test.js +0 -16
  5. package/dist/components/Molecules/CTA/CTAMultiCard/CTAMultiCard.js +59 -0
  6. package/{src/components/Molecules → dist/components/Molecules/CTA}/CTAMultiCard/CTAMultiCard.md +4 -4
  7. package/dist/components/Molecules/CTA/CTAMultiCard/CTAMultiCard.style.js +55 -0
  8. package/dist/components/Molecules/CTA/CTAMultiCard/CTAMultiCard.test.js +91 -0
  9. package/dist/components/Molecules/CTA/CTAMultiCard/__snapshots__/CTAMultiCard.test.js.snap +2931 -0
  10. package/dist/components/Molecules/CTA/CTAMultiCard/example_data.json +107 -0
  11. package/dist/components/Molecules/CTA/CTASingleCard/CTASingleCard.js +44 -0
  12. package/dist/components/Molecules/CTA/CTASingleCard/CTASingleCard.md +124 -0
  13. package/dist/components/Molecules/CTA/CTASingleCard/CTASingleCard.style.js +23 -0
  14. package/dist/components/Molecules/CTA/CTASingleCard/CTASingleCard.test.js +96 -0
  15. package/dist/components/Molecules/CTA/CTASingleCard/__snapshots__/CTASingleCard.test.js.snap +903 -0
  16. package/dist/components/Molecules/CTA/shared/CTACard.js +67 -0
  17. package/dist/components/Molecules/CTA/shared/CTACard.style.js +269 -0
  18. package/dist/components/Molecules/{CTAMultiCard → CTA/shared}/_ArrowIcon.js +1 -1
  19. package/dist/components/Molecules/Descriptor/Descriptor.js +1 -5
  20. package/dist/components/Molecules/Descriptor/Descriptor.test.js +0 -8
  21. package/dist/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/CTAMultiCard.style.js +11 -11
  22. package/dist/components/Molecules/OLD_CTAMultiCard/_ArrowIcon.js +29 -0
  23. package/dist/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/__snapshots__/CTAMultiCard.test.js.snap +8 -0
  24. package/dist/index.js +8 -1
  25. package/package.json +1 -1
  26. package/src/components/Molecules/Accordion/Accordion.js +8 -1
  27. package/src/components/Molecules/Accordion/__snapshots__/Accordion.test.js.snap +60 -21
  28. package/src/components/Molecules/ArticleTeaser/ArticleTeaser.js +0 -6
  29. package/src/components/Molecules/ArticleTeaser/ArticleTeaser.test.js +0 -16
  30. package/src/components/Molecules/CTA/CTAMultiCard/CTAMultiCard.js +99 -0
  31. package/{dist/components/Molecules → src/components/Molecules/CTA}/CTAMultiCard/CTAMultiCard.md +4 -4
  32. package/src/components/Molecules/CTA/CTAMultiCard/CTAMultiCard.style.js +68 -0
  33. package/src/components/Molecules/CTA/CTAMultiCard/CTAMultiCard.test.js +107 -0
  34. package/src/components/Molecules/CTA/CTAMultiCard/__snapshots__/CTAMultiCard.test.js.snap +2931 -0
  35. package/src/components/Molecules/CTA/CTAMultiCard/example_data.json +107 -0
  36. package/src/components/Molecules/CTA/CTASingleCard/CTASingleCard.js +72 -0
  37. package/src/components/Molecules/CTA/CTASingleCard/CTASingleCard.md +124 -0
  38. package/src/components/Molecules/CTA/CTASingleCard/CTASingleCard.style.js +19 -0
  39. package/src/components/Molecules/CTA/CTASingleCard/CTASingleCard.test.js +96 -0
  40. package/src/components/Molecules/CTA/CTASingleCard/__snapshots__/CTASingleCard.test.js.snap +903 -0
  41. package/src/components/Molecules/CTA/shared/CTACard.js +115 -0
  42. package/src/components/Molecules/CTA/shared/CTACard.style.js +356 -0
  43. package/src/components/Molecules/Descriptor/Descriptor.js +0 -4
  44. package/src/components/Molecules/Descriptor/Descriptor.test.js +0 -8
  45. package/src/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/CTAMultiCard.style.js +2 -0
  46. package/src/components/Molecules/OLD_CTAMultiCard/_ArrowIcon.js +22 -0
  47. package/src/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/__snapshots__/CTAMultiCard.test.js.snap +8 -0
  48. package/src/index.js +2 -1
  49. /package/dist/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/CTAMultiCard.js +0 -0
  50. /package/dist/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/CTAMultiCard.test.js +0 -0
  51. /package/dist/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/SingleCard.js +0 -0
  52. /package/dist/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/example_data.json +0 -0
  53. /package/src/components/Molecules/{CTAMultiCard → CTA/shared}/_ArrowIcon.js +0 -0
  54. /package/src/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/CTAMultiCard.js +0 -0
  55. /package/src/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/CTAMultiCard.test.js +0 -0
  56. /package/src/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/SingleCard.js +0 -0
  57. /package/src/components/Molecules/{CTAMultiCard → OLD_CTAMultiCard}/example_data.json +0 -0
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.default = void 0;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
10
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
11
+ var _Text = _interopRequireDefault(require("../../Atoms/Text/Text"));
11
12
  var _spacing = _interopRequireDefault(require("../../../theme/shared/spacing"));
12
13
  var _index = require("../../Atoms/Icons/index");
13
14
  const Container = _styledComponents.default.div.withConfig({
@@ -53,6 +54,10 @@ const Copy = _styledComponents.default.div.withConfig({
53
54
  return theme.allBreakpoints('M');
54
55
  }, (0, _spacing.default)('lg'), contentBottomPadding || (0, _spacing.default)('l'));
55
56
  });
57
+ const StyledText = (0, _styledComponents.default)(_Text.default).withConfig({
58
+ displayName: "Accordion__StyledText",
59
+ componentId: "sc-19u0s0h-4"
60
+ })(["margin-bottom:0;"]);
56
61
  const Accordion = _ref6 => {
57
62
  let {
58
63
  children,
@@ -69,7 +74,9 @@ const Accordion = _ref6 => {
69
74
  "aria-expanded": isOpen ? 'true' : 'false',
70
75
  ChevronKeyframes: ChevronKeyframes,
71
76
  type: "button"
72
- }, title, /*#__PURE__*/_react.default.createElement(Icon, null, /*#__PURE__*/_react.default.createElement(_index.Chevron, {
77
+ }, /*#__PURE__*/_react.default.createElement(StyledText, {
78
+ tag: "h3"
79
+ }, title), /*#__PURE__*/_react.default.createElement(Icon, null, /*#__PURE__*/_react.default.createElement(_index.Chevron, {
73
80
  colour: "black",
74
81
  direction: isOpen ? 'up' : 'down'
75
82
  }))), /*#__PURE__*/_react.default.createElement(Copy, {
@@ -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
- .c2 {
33
+ .c4 {
17
34
  font-size: 1.5rem;
18
35
  line-height: normal;
19
36
  }
20
37
 
21
- .c2 span {
38
+ .c4 span {
22
39
  font-size: inherit;
23
40
  line-height: inherit;
24
41
  }
25
42
 
26
- .c6 {
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
- .c6 {
55
+ .c8 {
39
56
  font-size: 1rem;
40
57
  line-height: normal;
41
58
  }
42
59
 
43
- .c6 span {
60
+ .c8 span {
44
61
  font-size: inherit;
45
62
  line-height: inherit;
46
63
  }
47
64
 
48
- .c4 {
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
- .c3 {
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
- .c5 {
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
- .c2 {
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
- .c6 {
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
- .c6 {
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
- .c4 {
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
- .c5 {
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
- <h2
177
- className="c2"
211
+ <h3
212
+ className="c2 c3"
178
213
  >
179
- I am the title
180
- </h2>
214
+ <h2
215
+ className="c4"
216
+ >
217
+ I am the title
218
+ </h2>
219
+ </h3>
181
220
  <div
182
- className="c3"
221
+ className="c5"
183
222
  >
184
223
  <svg
185
- className="c4"
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="c5"
239
+ className="c7"
201
240
  >
202
241
  <p
203
- className="c6"
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>
@@ -147,7 +147,6 @@ const ArticleTeaser = _ref15 => {
147
147
  alt = '',
148
148
  category = null,
149
149
  logoSize = null,
150
- family = 'Anton',
151
150
  time = null
152
151
  } = _ref15;
153
152
  return /*#__PURE__*/_react.default.createElement(Wrapper, null, /*#__PURE__*/_react.default.createElement(Link, {
@@ -172,11 +171,7 @@ const ArticleTeaser = _ref15 => {
172
171
  weight: "bold"
173
172
  }, date), /*#__PURE__*/_react.default.createElement(Title, {
174
173
  time: time,
175
- size: "xl",
176
- tag: "h3",
177
- height: "2rem",
178
- weight: "normal",
179
- family: family
174
+ tag: "h3"
180
175
  }, title), time && /*#__PURE__*/_react.default.createElement(Time, {
181
176
  size: "xs",
182
177
  weight: "400",
@@ -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;
@@ -351,14 +343,6 @@ it('renders press realese correctly', () => {
351
343
  line-height: 1.5rem;
352
344
  }
353
345
 
354
- .c10 {
355
- font-size: 2rem;
356
- line-height: normal;
357
- font-family: 'Anton',Impact,sans-serif;
358
- font-weight: normal;
359
- line-height: 2rem;
360
- }
361
-
362
346
  .c10 span {
363
347
  font-size: inherit;
364
348
  line-height: inherit;
@@ -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;
@@ -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 '../../Atoms/Text/Text';
22
- import challengeExampleImage from '../../../styleguide/assets/challenge-1.jpg';
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 '../../Atoms/Text/Text';
63
- import challengeExampleImage from '../../../styleguide/assets/challenge-1.jpg';
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
+ });