@comicrelief/component-library 8.47.4 → 8.48.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 (56) hide show
  1. package/.eslintrc +3 -0
  2. package/dist/components/Atoms/Input/Input.md +1 -0
  3. package/dist/components/Molecules/CTAMultiCard/ArrowIcon.js +29 -0
  4. package/dist/components/Molecules/CTAMultiCard/CTAMultiCard.js +54 -0
  5. package/dist/components/Molecules/CTAMultiCard/CTAMultiCard.md +104 -0
  6. package/dist/components/Molecules/CTAMultiCard/CTAMultiCard.style.js +156 -0
  7. package/dist/components/Molecules/CTAMultiCard/CTAMultiCard.test.js +70 -0
  8. package/dist/components/Molecules/CTAMultiCard/SingleCard.js +56 -0
  9. package/dist/components/Molecules/CTAMultiCard/__snapshots__/CTAMultiCard.test.js.snap +2292 -0
  10. package/dist/components/Molecules/CTAMultiCard/example_data.json +107 -0
  11. package/dist/components/Molecules/CardDs/CardDs.md +1 -1
  12. package/dist/components/Molecules/Countdown/Countdown.js +12 -5
  13. package/dist/components/Molecules/Countdown/Countdown.md +1 -1
  14. package/dist/components/Molecules/HeroBanner/HeroBanner.js +1 -1
  15. package/dist/components/Organisms/Header/Nav/Nav.js +1 -1
  16. package/dist/components/Organisms/Header/data/data-extended.js +22 -22
  17. package/dist/components/Organisms/Header/data/data-live.js +1 -1
  18. package/dist/components/Organisms/Header/data/data.js +2 -2
  19. package/dist/components/Organisms/Header2025/Header2025.js +2 -2
  20. package/dist/components/Organisms/Header2025/Header2025.md +2 -2
  21. package/dist/components/Organisms/Header2025/HeaderNav2025/HeaderNav2025.js +1 -1
  22. package/dist/components/Organisms/Header2025/data/data-extended.js +23 -23
  23. package/dist/components/Organisms/Header2025/data/data-live--minimal.js +1 -1
  24. package/dist/components/Organisms/Header2025/data/data-live.js +2 -2
  25. package/dist/components/Organisms/Header2025/data/data.js +13 -13
  26. package/dist/index.js +7 -0
  27. package/dist/styleguide/assets/challenge-1.jpg +0 -0
  28. package/dist/{components/Molecules/HeroBanner → theme/shared}/assets/alt_cta_underline.svg +1 -0
  29. package/package.json +1 -1
  30. package/src/components/Atoms/Input/Input.md +1 -0
  31. package/src/components/Molecules/CTAMultiCard/ArrowIcon.js +22 -0
  32. package/src/components/Molecules/CTAMultiCard/CTAMultiCard.js +94 -0
  33. package/src/components/Molecules/CTAMultiCard/CTAMultiCard.md +104 -0
  34. package/src/components/Molecules/CTAMultiCard/CTAMultiCard.style.js +251 -0
  35. package/src/components/Molecules/CTAMultiCard/CTAMultiCard.test.js +86 -0
  36. package/src/components/Molecules/CTAMultiCard/SingleCard.js +100 -0
  37. package/src/components/Molecules/CTAMultiCard/__snapshots__/CTAMultiCard.test.js.snap +2292 -0
  38. package/src/components/Molecules/CTAMultiCard/example_data.json +107 -0
  39. package/src/components/Molecules/CardDs/CardDs.md +1 -1
  40. package/src/components/Molecules/Countdown/Countdown.js +12 -5
  41. package/src/components/Molecules/Countdown/Countdown.md +1 -1
  42. package/src/components/Molecules/HeroBanner/HeroBanner.js +1 -1
  43. package/src/components/Organisms/Header/Nav/Nav.js +2 -1
  44. package/src/components/Organisms/Header/data/data-extended.js +22 -22
  45. package/src/components/Organisms/Header/data/data-live.js +1 -1
  46. package/src/components/Organisms/Header/data/data.js +2 -2
  47. package/src/components/Organisms/Header2025/Header2025.js +5 -3
  48. package/src/components/Organisms/Header2025/Header2025.md +2 -2
  49. package/src/components/Organisms/Header2025/HeaderNav2025/HeaderNav2025.js +7 -4
  50. package/src/components/Organisms/Header2025/data/data-extended.js +23 -23
  51. package/src/components/Organisms/Header2025/data/data-live--minimal.js +1 -1
  52. package/src/components/Organisms/Header2025/data/data-live.js +2 -2
  53. package/src/components/Organisms/Header2025/data/data.js +13 -13
  54. package/src/index.js +1 -0
  55. package/src/styleguide/assets/challenge-1.jpg +0 -0
  56. package/src/{components/Molecules/HeroBanner → theme/shared}/assets/alt_cta_underline.svg +1 -0
package/.eslintrc CHANGED
@@ -34,6 +34,9 @@
34
34
  "jest": true,
35
35
  "browser": true
36
36
  },
37
+ "parserOptions": {
38
+ "ecmaVersion": 2020
39
+ },
37
40
  "globals": {
38
41
  "window": true
39
42
  },
@@ -141,6 +141,7 @@ const ItalicText = styled(Text).attrs({weight: 'normal'})`
141
141
  <>
142
142
  <h4>Input with Description:</h4>
143
143
  <Input
144
+ name="input-with-description"
144
145
  placeholder="I have a description"
145
146
  type="text"
146
147
  label="My Great Input"
@@ -0,0 +1,29 @@
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 _react = _interopRequireDefault(require("react"));
9
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
10
+ const StyledArrowIcon = _styledComponents.default.svg.withConfig({
11
+ displayName: "ArrowIcon__StyledArrowIcon",
12
+ componentId: "sc-jxto1w-0"
13
+ })(["display:inline-block;color:", ";fill:currentColor;"], _ref => {
14
+ let {
15
+ theme
16
+ } = _ref;
17
+ return theme.color('white');
18
+ });
19
+ const ArrowIcon = () => /*#__PURE__*/_react.default.createElement(StyledArrowIcon, {
20
+ width: "15",
21
+ height: "13",
22
+ viewBox: "0 0 15 13",
23
+ fill: "none",
24
+ xmlns: "http://www.w3.org/2000/svg"
25
+ }, /*#__PURE__*/_react.default.createElement("path", {
26
+ d: "M9.58496 0.349976C9.1395 -0.116662 8.40641 -0.116634 7.96094 0.349976C7.52803 0.803486 7.5281 1.53021 7.96094 1.98376L11.1582 5.33337H1.13672C0.48748 5.33337 0 5.87822 0 6.50037C2.15408e-05 7.1225 0.487494 7.66736 1.13672 7.66736H11.1582L7.96094 11.017C7.52806 11.4705 7.52899 12.1972 7.96191 12.6508C8.18163 12.8803 8.47556 13.0004 8.77344 13.0004C9.07114 13.0002 9.36533 12.8808 9.58496 12.6508L14.6758 7.31677L14.6748 7.3158L14.6875 7.3031L14.6865 7.30212C14.6954 7.29215 14.7044 7.28482 14.71 7.27771C14.7117 7.27545 14.7133 7.27285 14.7148 7.27087C14.7485 7.23203 14.7824 7.18925 14.8135 7.14099L14.8154 7.13806C14.8354 7.10658 14.8493 7.07842 14.8564 7.06384L14.8652 7.04626L14.8662 7.04431L14.8672 7.04333C14.8672 7.04333 14.868 7.04057 14.8691 7.03845C14.8709 7.03512 14.8758 7.02671 14.8799 7.01892L14.8802 7.01839C14.8888 7.002 14.9034 6.97423 14.917 6.93982V6.93787C14.9303 6.90375 14.9391 6.87285 14.9443 6.85388C14.9469 6.84458 14.9498 6.83567 14.9512 6.83044C14.9527 6.82454 14.9535 6.8228 14.9541 6.82068C14.9541 6.82068 14.9542 6.81753 14.9551 6.81482L14.958 6.80603L14.9586 6.80422C14.9631 6.78961 14.9718 6.76119 14.9785 6.72693V6.72498C15.0066 6.57705 15.0066 6.4246 14.9785 6.27673V6.27478L14.958 6.19568L14.9551 6.18591L14.9531 6.18005L14.9512 6.17224C14.9497 6.1664 14.9481 6.15677 14.9453 6.14685C14.9398 6.12695 14.9307 6.09654 14.917 6.06189C14.9032 6.02688 14.8885 5.99813 14.8799 5.98181C14.8758 5.97402 14.8709 5.96562 14.8691 5.96228L14.8564 5.93689C14.849 5.92177 14.8351 5.89372 14.8154 5.86267L14.8145 5.86072L14.7529 5.7738C14.7316 5.74659 14.7094 5.72129 14.6875 5.69763C14.6837 5.69341 14.6802 5.68854 14.6758 5.68396L9.58496 0.349976Z",
27
+ fill: "currentColor"
28
+ }));
29
+ var _default = exports.default = ArrowIcon;
@@ -0,0 +1,54 @@
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 _SingleCard = _interopRequireDefault(require("./SingleCard"));
11
+ var _CTAMultiCard = 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
+ } = data;
36
+ if (!cards || !Array.isArray(cards) || cards.length === 0) {
37
+ return null;
38
+ }
39
+
40
+ // Convert layout string to number (e.g., "3 columns"
41
+ // (that's how it comes through from Contentful) -> 3)
42
+ const columns = layout && layout.includes('3') ? 3 : 2;
43
+ const cardsBackground = (0, _snakeCase2.default)(bgCards || 'white');
44
+ return /*#__PURE__*/_react.default.createElement(_CTAMultiCard.CardsContainer, {
45
+ backgroundColor: cardsBackground,
46
+ columns: columns,
47
+ isCarousel: carouselOfCards
48
+ }, cards.map(card => /*#__PURE__*/_react.default.createElement(_SingleCard.default, {
49
+ key: card.id,
50
+ card: card,
51
+ isCarousel: carouselOfCards
52
+ })));
53
+ };
54
+ var _default = exports.default = CTAMultiCard;
@@ -0,0 +1,104 @@
1
+ # CTAMultiCard
2
+ ## Multi-card component that handles mapping through cards array internally
3
+
4
+ The component expects pre-rendered content to be passed in the `body` field of each card. The frontend should handle rich text rendering before passing data to this component.
5
+
6
+ **Note:** The frontend is responsible for processing image data, link targets, and background colors. Each card object should include the following processed fields:
7
+ - `fallback`: The fallback image src from `image.gatsbyImageData.images.fallback.src`
8
+ - `imageLow`: The placeholder image from `image.gatsbyImageData.placeholder.fallback`
9
+ - `images`: The srcSet from `image.gatsbyImageData.images.sources[0].srcSet`
10
+ - `bgColour`: The processed background color (snake_case format)
11
+ - `description`: The image description from `image.description`
12
+ - `target`: The link target ('self' for internal links, 'blank' for external)
13
+ - `external`: The rel attribute ('noopener' for external links, null for internal)
14
+
15
+ ### CTAMultiCard: Desktop Grid View (3 columns)
16
+
17
+ **NB: In mobile view, this example displays as a carousel.**
18
+
19
+ ```js
20
+ import CTAMultiCard from './CTAMultiCard';
21
+ import Text from '../../Atoms/Text/Text';
22
+ import challengeExampleImage from '../../../styleguide/assets/challenge-1.jpg';
23
+ const exampleData = require('./example_data.json');
24
+
25
+ // Map cards to include pre-rendered body content and processed image/link data
26
+ const cardsWithRenderedBody = exampleData.cards.map(card => ({
27
+ ...card,
28
+ body: (
29
+ <Text tag="p">
30
+ <strong>Load</strong> of text here
31
+ </Text>
32
+ ),
33
+ fallback: challengeExampleImage,
34
+ imageLow: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAPABQDASIAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAAAAcIBAb/xAAjEAACAgIBBAIDAAAAAAAAAAABAgMEABEGBRIhMQdBE1Fh/8QAFQEBAQAAAAAAAAAAAAAAAAAAAgT/xAAaEQADAQADAAAAAAAAAAAAAAAAAQIDERIT/9oADAMBAAIRAxEAPwBzRcrjVY+0tonyT41nG8y+SLFTkgpQTVFpoqiRZGHc2/egf4RrMM12OHpNi3LsrAjO2vsKCcQtvkbTW570sMUt6xphJKnd+Ma9A78ZRWcS+SWNLpNMqAdQidVaSxErEA6ZgCNj9YZNPTOTpJW7+ovdlnLHyjgAD6GGPug+bP/Z",
35
+ images: `${challengeExampleImage} 678w`,
36
+ bgColour: "white",
37
+ description: "",
38
+ target: "self",
39
+ external: null
40
+ }));
41
+
42
+ const data = {
43
+ ...exampleData,
44
+ cards: cardsWithRenderedBody,
45
+ carouselOfCards: true,
46
+ backgroundColour: "transparent"
47
+ };
48
+
49
+ <div style={{ padding: '2rem', background: '#E1E2E3' }}>
50
+ <CTAMultiCard data={data} />
51
+ </div>;
52
+ ```
53
+
54
+ ### CTAMultiCard: Desktop Grid View (2 columns)
55
+
56
+ **NB: One card contains a lot of lorem ipsum text to demonstrate that all cards will match the height of the tallest sibling card. In mobile view, this example displays as a vertical stack (non-carousel).**
57
+
58
+ ```js
59
+ import CTAMultiCard from './CTAMultiCard';
60
+ import Text from '../../Atoms/Text/Text';
61
+ import challengeExampleImage from '../../../styleguide/assets/challenge-1.jpg';
62
+ const exampleData = require('./example_data.json');
63
+
64
+ // Map cards to include pre-rendered body content and processed image/link data
65
+ const cardsWithRenderedBody = exampleData.cards.map((card, index) => ({
66
+ ...card,
67
+ body: index === 1 ? (
68
+ <>
69
+ <Text tag="p">
70
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
71
+ </Text>
72
+ <Text tag="p">
73
+ Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.
74
+ </Text>
75
+ <Text tag="p">
76
+ Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.
77
+ </Text>
78
+ </>
79
+ ) : (
80
+ <Text tag="p">
81
+ <strong>Load</strong> of text here
82
+ </Text>
83
+ ),
84
+ fallback: challengeExampleImage,
85
+ imageLow: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAPABQDASIAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAAAAcIBAb/xAAjEAACAgIBBAIDAAAAAAAAAAABAgMEABEGBRIhMQdBE1Fh/8QAFQEBAQAAAAAAAAAAAAAAAAAAAgT/xAAaEQADAQADAAAAAAAAAAAAAAAAAQIDERIT/9oADAMBAAIRAxEAPwBzRcrjVY+0tonyT41nG8y+SLFTkgpQTVFpoqiRZGHc2/egf4RrMM12OHpNi3LsrAjO2vsKCcQtvkbTW570sMUt6xphJKnd+Ma9A78ZRWcS+SWNLpNMqAdQidVaSxErEA6ZgCNj9YZNPTOTpJW7+ovdlnLHyjgAD6GGPug+bP/Z",
86
+ images: `${challengeExampleImage} 678w`,
87
+ bgColour: "white",
88
+ description: "",
89
+ target: "self",
90
+ external: null
91
+ }));
92
+
93
+ const dataWithLongText = {
94
+ ...exampleData,
95
+ layout: "2 columns",
96
+ carouselOfCards: false,
97
+ backgroundColour: "Transparent",
98
+ cards: cardsWithRenderedBody
99
+ };
100
+
101
+ <div style={{ padding: '2rem', background: '#E1E2E3' }}>
102
+ <CTAMultiCard data={dataWithLongText} />
103
+ </div>;
104
+ ```
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ImageWrapper = exports.CopyAndLinkSection = exports.Copy = exports.CardsContainer = exports.CardWrapper = exports.CardLink = exports.CTATextUnderline = exports.CTAText = exports.CTA = exports.ArrowIconWrapper = void 0;
9
+ var _styledComponents = _interopRequireWildcard(require("styled-components"));
10
+ var _animations = require("../../../theme/shared/animations");
11
+ var _allBreakpoints = require("../../../theme/shared/allBreakpoints");
12
+ var _fontHelper = _interopRequireDefault(require("../../../theme/crTheme/fontHelper"));
13
+ const CardsContainer = exports.CardsContainer = _styledComponents.default.div.withConfig({
14
+ displayName: "CTAMultiCardstyle__CardsContainer",
15
+ componentId: "sc-qq5ca0-0"
16
+ })(["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 ", "{display:grid;justify-content:center;grid-template-columns:", ";width:", ";margin:", ";max-width:100%;}"], _ref => {
17
+ let {
18
+ theme,
19
+ backgroundColor
20
+ } = _ref;
21
+ return theme.color(backgroundColor);
22
+ }, _ref2 => {
23
+ let {
24
+ isCarousel
25
+ } = _ref2;
26
+ return isCarousel && (0, _styledComponents.css)(["@media (max-width:", "px){flex-direction:row;flex-wrap:nowrap;overflow-x:visible;overflow-y:scroll;-webkit-overflow-scrolling:touch;scroll-snap-type:x mandatory;padding:0.75rem 0.5rem;margin-left:0.5rem;scrollbar-width:none;-ms-overflow-style:none;&::-webkit-scrollbar{display:none;}}"], _allBreakpoints.breakpointValues.M - 1);
27
+ }, _ref3 => {
28
+ let {
29
+ isCarousel
30
+ } = _ref3;
31
+ return !isCarousel && (0, _styledComponents.css)(["@media (max-width:", "px){flex-direction:column;background:transparent;}"], _allBreakpoints.breakpointValues.M - 1);
32
+ }, _ref4 => {
33
+ let {
34
+ theme
35
+ } = _ref4;
36
+ return theme.allBreakpoints('M');
37
+ }, _ref5 => {
38
+ let {
39
+ theme
40
+ } = _ref5;
41
+ return theme.allBreakpoints('XL');
42
+ }, _ref6 => {
43
+ let {
44
+ columns
45
+ } = _ref6;
46
+ return `repeat(${columns}, 1fr)`;
47
+ }, _ref7 => {
48
+ let {
49
+ columns
50
+ } = _ref7;
51
+ return columns === 2 ? 'fit-content' : '100%';
52
+ }, _ref8 => {
53
+ let {
54
+ columns
55
+ } = _ref8;
56
+ return columns === 2 ? '0 auto' : '0';
57
+ });
58
+ const ImageWrapper = exports.ImageWrapper = _styledComponents.default.div.withConfig({
59
+ displayName: "CTAMultiCardstyle__ImageWrapper",
60
+ componentId: "sc-qq5ca0-1"
61
+ })(["width:100%;overflow:hidden;flex-shrink:0;background:transparent;img{width:100%;height:auto;object-fit:cover;display:block;@media ", "{", "}}"], _ref9 => {
62
+ let {
63
+ theme
64
+ } = _ref9;
65
+ return theme.allBreakpoints('M');
66
+ }, (0, _animations.springScaleAnimation)(true));
67
+ const CTAText = exports.CTAText = _styledComponents.default.span.withConfig({
68
+ displayName: "CTAMultiCardstyle__CTAText",
69
+ componentId: "sc-qq5ca0-2"
70
+ })(["", " color:", ";font-weight:bold;text-decoration:none;position:relative;display:inline-block;"], _ref10 => {
71
+ let {
72
+ theme
73
+ } = _ref10;
74
+ return (0, _fontHelper.default)(theme, 'span');
75
+ }, _ref11 => {
76
+ let {
77
+ theme
78
+ } = _ref11;
79
+ return theme.color('grey');
80
+ });
81
+ const CTATextUnderline = exports.CTATextUnderline = _styledComponents.default.img.withConfig({
82
+ displayName: "CTAMultiCardstyle__CTATextUnderline",
83
+ componentId: "sc-qq5ca0-3"
84
+ })(["height:4px;width:100%;position:absolute;left:0;bottom:-5px;transition:opacity 0.15s 0.1s;opacity:0;pointer-events:none;"]);
85
+ const ArrowIconWrapper = exports.ArrowIconWrapper = _styledComponents.default.div.withConfig({
86
+ displayName: "CTAMultiCardstyle__ArrowIconWrapper",
87
+ componentId: "sc-qq5ca0-4"
88
+ })(["width:32px;height:32px;border-radius:50%;background:", ";display:flex;align-items:center;justify-content:center;flex-shrink:0;"], _ref12 => {
89
+ let {
90
+ theme
91
+ } = _ref12;
92
+ return theme.color('grey');
93
+ });
94
+
95
+ // Card wrapper link - makes entire card clickable
96
+ const CardLink = exports.CardLink = _styledComponents.default.a.withConfig({
97
+ displayName: "CTAMultiCardstyle__CardLink",
98
+ componentId: "sc-qq5ca0-5"
99
+ })(["display:flex;position:relative;flex-direction:column;width:100%;height:100%;background:transparent;border-radius:1rem;box-shadow:0 0 1rem rgba(0,0,0,0.15);text-decoration:none;overflow:hidden;cursor:pointer;img{transform:scale(1.02);transition:transform ", "s cubic-bezier(0.68,", ",0.265,", ");}@media ", "{", ";&:hover{box-shadow:0 0 1.5rem rgba(0,0,0,0.25);", " img{transform:scale(1.1);}", "{color:", ";text-decoration:none;}", "{opacity:1;}", "{background:", ";}}}"], 0.4, -1.15, 2.35, _ref13 => {
100
+ let {
101
+ theme
102
+ } = _ref13;
103
+ return theme.allBreakpoints('M');
104
+ }, (0, _animations.bounceUpAnimation)(true, 0.02, 1), ImageWrapper, CTAText, _ref14 => {
105
+ let {
106
+ theme
107
+ } = _ref14;
108
+ return theme.color('red');
109
+ }, CTATextUnderline, ArrowIconWrapper, _ref15 => {
110
+ let {
111
+ theme
112
+ } = _ref15;
113
+ return theme.color('red');
114
+ });
115
+ const CardWrapper = exports.CardWrapper = _styledComponents.default.div.withConfig({
116
+ displayName: "CTAMultiCardstyle__CardWrapper",
117
+ componentId: "sc-qq5ca0-6"
118
+ })(["width:100%;flex-shrink:0;display:flex;flex-direction:column;align-self:stretch;", " ", " @media ", "{flex-basis:calc(50% - 1rem);max-width:564px;height:100%;align-self:stretch;}@media ", "{flex-basis:unset;max-width:564px;height:100%;align-self:stretch;}"], _ref16 => {
119
+ let {
120
+ isCarousel
121
+ } = _ref16;
122
+ return isCarousel && (0, _styledComponents.css)(["@media (max-width:", "px){scroll-snap-align:start;flex:0 0 calc(100% - 1.5rem);min-width:calc(100% - 1.5rem);max-width:calc(100% - 1.5rem);flex-shrink:0;margin-right:0.5rem;&:first-child{padding-left:0.5rem;}&:last-child{margin-right:0;padding-right:0.5rem;}}"], _allBreakpoints.breakpointValues.M - 1);
123
+ }, _ref17 => {
124
+ let {
125
+ isCarousel
126
+ } = _ref17;
127
+ return !isCarousel && (0, _styledComponents.css)(["@media (max-width:", "px){width:100%;}"], _allBreakpoints.breakpointValues.M - 1);
128
+ }, _ref18 => {
129
+ let {
130
+ theme
131
+ } = _ref18;
132
+ return theme.allBreakpoints('M');
133
+ }, _ref19 => {
134
+ let {
135
+ theme
136
+ } = _ref19;
137
+ return theme.allBreakpoints('XL');
138
+ });
139
+ const CopyAndLinkSection = exports.CopyAndLinkSection = _styledComponents.default.div.withConfig({
140
+ displayName: "CTAMultiCardstyle__CopyAndLinkSection",
141
+ componentId: "sc-qq5ca0-7"
142
+ })(["width:100%;background:", ";display:flex;flex-direction:column;padding:2rem;flex:1;min-height:0;border-radius:0 0 1rem 1rem;"], _ref20 => {
143
+ let {
144
+ theme,
145
+ backgroundColor
146
+ } = _ref20;
147
+ return theme.color(backgroundColor);
148
+ });
149
+ const Copy = exports.Copy = _styledComponents.default.div.withConfig({
150
+ displayName: "CTAMultiCardstyle__Copy",
151
+ componentId: "sc-qq5ca0-8"
152
+ })(["flex:1;display:flex;flex-direction:column;min-height:0;"]);
153
+ const CTA = exports.CTA = _styledComponents.default.div.withConfig({
154
+ displayName: "CTAMultiCardstyle__CTA",
155
+ componentId: "sc-qq5ca0-9"
156
+ })(["width:100%;display:flex;flex-direction:row;align-items:center;justify-content:space-between;margin-top:auto;padding-top:1rem;"]);
@@ -0,0 +1,70 @@
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
+ // Map example data cards to include pre-rendered body content
11
+ const cardsWithRenderedBody = _example_data.default.cards.map(card => ({
12
+ ...card,
13
+ body: /*#__PURE__*/_react.default.createElement(_Text.default, {
14
+ tag: "p"
15
+ }, /*#__PURE__*/_react.default.createElement("strong", null, "Load"), " of text here")
16
+ }));
17
+ const mockData = {
18
+ ..._example_data.default,
19
+ cards: [...cardsWithRenderedBody,
20
+ // Add a card without image for testing edge cases. This should not ever really happen in real life, but just in case...
21
+ {
22
+ id: '6bc887c7-f939-5654-a0c5-1b2caf91de6c',
23
+ title: 'Card no pic',
24
+ backgroundColour: 'Blue Light',
25
+ link: '/test-no-image',
26
+ linkLabel: 'View card',
27
+ body: /*#__PURE__*/_react.default.createElement(_Text.default, {
28
+ tag: "p"
29
+ }, "Load of text here"),
30
+ image: null
31
+ }]
32
+ };
33
+ it('renders correctly with data prop', () => {
34
+ const tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(_CTAMultiCard.default, {
35
+ data: mockData
36
+ })).toJSON();
37
+ expect(tree).toMatchSnapshot();
38
+ });
39
+ it('renders carousel mode correctly', () => {
40
+ const carouselData = {
41
+ ...mockData,
42
+ carouselOfCards: true
43
+ };
44
+ const tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(_CTAMultiCard.default, {
45
+ data: carouselData
46
+ })).toJSON();
47
+ expect(tree).toMatchSnapshot();
48
+ });
49
+ it('renders 2 columns layout correctly', () => {
50
+ const twoColumnData = {
51
+ ...mockData,
52
+ layout: '2 columns'
53
+ };
54
+ const tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(_CTAMultiCard.default, {
55
+ data: twoColumnData
56
+ })).toJSON();
57
+ expect(tree).toMatchSnapshot();
58
+ });
59
+ it('handles data structure correctly', () => {
60
+ const testData = {
61
+ cards: mockData.cards,
62
+ backgroundColour: 'White',
63
+ layout: '3 columns',
64
+ carouselOfCards: false
65
+ };
66
+ const tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(_CTAMultiCard.default, {
67
+ data: testData
68
+ })).toJSON();
69
+ expect(tree).toMatchSnapshot();
70
+ });
@@ -0,0 +1,56 @@
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 _react = _interopRequireDefault(require("react"));
9
+ var _Picture = _interopRequireDefault(require("../../Atoms/Picture/Picture"));
10
+ var _ArrowIcon = _interopRequireDefault(require("./ArrowIcon"));
11
+ var _alt_cta_underline = _interopRequireDefault(require("../../../theme/shared/assets/alt_cta_underline.svg"));
12
+ var _CTAMultiCard = require("./CTAMultiCard.style");
13
+ const SingleCard = _ref => {
14
+ let {
15
+ card,
16
+ isCarousel
17
+ } = _ref;
18
+ const {
19
+ id,
20
+ body,
21
+ link,
22
+ linkLabel,
23
+ fallback,
24
+ imageLow,
25
+ images,
26
+ bgColour,
27
+ description,
28
+ target,
29
+ external
30
+ } = card;
31
+ return /*#__PURE__*/_react.default.createElement(_CTAMultiCard.CardWrapper, {
32
+ key: id,
33
+ isCarousel: isCarousel
34
+ }, /*#__PURE__*/_react.default.createElement(_CTAMultiCard.CardLink, {
35
+ href: link,
36
+ target: target,
37
+ rel: external,
38
+ isCarousel: isCarousel,
39
+ backgroundColor: bgColour
40
+ }, imageLow && /*#__PURE__*/_react.default.createElement(_CTAMultiCard.ImageWrapper, null, /*#__PURE__*/_react.default.createElement(_Picture.default, {
41
+ alt: description,
42
+ imageLow: imageLow,
43
+ images: images,
44
+ image: fallback,
45
+ objectFit: "cover",
46
+ width: "100%",
47
+ height: "100%"
48
+ })), /*#__PURE__*/_react.default.createElement(_CTAMultiCard.CopyAndLinkSection, {
49
+ backgroundColor: bgColour
50
+ }, /*#__PURE__*/_react.default.createElement(_CTAMultiCard.Copy, null, body), linkLabel && /*#__PURE__*/_react.default.createElement(_CTAMultiCard.CTA, null, /*#__PURE__*/_react.default.createElement(_CTAMultiCard.CTAText, null, linkLabel, /*#__PURE__*/_react.default.createElement(_CTAMultiCard.CTATextUnderline, {
51
+ src: _alt_cta_underline.default,
52
+ alt: "",
53
+ "aria-hidden": "true"
54
+ })), /*#__PURE__*/_react.default.createElement(_CTAMultiCard.ArrowIconWrapper, null, /*#__PURE__*/_react.default.createElement(_ArrowIcon.default, null))))));
55
+ };
56
+ var _default = exports.default = SingleCard;