@comicrelief/component-library 7.34.1 → 7.35.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.
@@ -0,0 +1,121 @@
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.default = void 0;
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _pureReactCarousel = require("pure-react-carousel");
11
+ var _utils = _interopRequireDefault(require("./_utils"));
12
+ require("pure-react-carousel/dist/react-carousel.es.css");
13
+ var _WYMDCarousel = require("./WYMDCarousel.style");
14
+ var _Text = _interopRequireDefault(require("../../Atoms/Text/Text"));
15
+ var _breakpoint = require("../../../theme/shared/breakpoint");
16
+ const WYMDCarousel = _ref => {
17
+ let {
18
+ data,
19
+ data: {
20
+ autoPlay,
21
+ contentful_id: thisID
22
+ }
23
+ } = _ref;
24
+ // Defaults to mobile config:
25
+ const [isMobileOrTablet, setIsMobileOrTablet] = (0, _react.useState)(true);
26
+ const [visibleSlides, setVisibleSlides] = (0, _react.useState)(1);
27
+ const [totalSlides, setTotalSlides] = (0, _react.useState)(null);
28
+ const [theseItems, setTheseItems] = (0, _react.useState)();
29
+
30
+ // Custom function to let us update the carousel config dynamically
31
+ const screenResize = (0, _react.useCallback)(() => {
32
+ const screenSize = typeof window !== 'undefined' ? window.innerWidth : null;
33
+ const isCurrentlyMobile = window.innerWidth < _breakpoint.sizes.medium;
34
+ if (screenSize !== null && isMobileOrTablet !== isCurrentlyMobile) {
35
+ setIsMobileOrTablet(isCurrentlyMobile);
36
+ setVisibleSlides(isCurrentlyMobile ? 1 : 3);
37
+ setTotalSlides(isCurrentlyMobile ? theseItems.length : theseItems.length + 2);
38
+ }
39
+ }, [isMobileOrTablet, theseItems]);
40
+
41
+ // Format our data BEFORE we use it in render:
42
+ (0, _react.useEffect)(() => {
43
+ setTheseItems((0, _utils.default)(data));
44
+ }, [setTheseItems, data]);
45
+ (0, _react.useEffect)(() => {
46
+ if (window !== 'undefined' && window.innerWidth >= _breakpoint.sizes.medium) {
47
+ // On inital render, update carousel plugin config
48
+ // to suit the non-mobile layout and functionality:
49
+ setIsMobileOrTablet(false);
50
+ setVisibleSlides(3);
51
+ }
52
+
53
+ // Hook into browser's own onresize event to call our custom wrapper function:
54
+ if (typeof window !== 'undefined') window.onresize = screenResize;
55
+ }, [screenResize]);
56
+ if (theseItems && totalSlides === null) {
57
+ // Reflects our two dummy/bookend slides for non-mobile/tablet views:
58
+ setTotalSlides(isMobileOrTablet ? theseItems.length : theseItems.length + 2);
59
+ }
60
+ return /*#__PURE__*/_react.default.createElement(_WYMDCarousel.CarouselWrapper, {
61
+ className: "CarouselWrapper",
62
+ id: thisID,
63
+ mobileHeight: data.mobileHeight,
64
+ desktopHeight: data.desktopHeight
65
+ }, /*#__PURE__*/_react.default.createElement(_WYMDCarousel.Heading, {
66
+ tag: "p",
67
+ weight: "bold"
68
+ }, data.heading), /*#__PURE__*/_react.default.createElement(_WYMDCarousel.PeopleHelpedText, {
69
+ tag: "h1",
70
+ family: "Anton",
71
+ uppercase: true,
72
+ weight: "normal",
73
+ color: "red"
74
+ }, data.peopleHelpedText), /*#__PURE__*/_react.default.createElement(_WYMDCarousel.Including, {
75
+ tag: "p"
76
+ }, "including..."), theseItems && /*#__PURE__*/_react.default.createElement(_pureReactCarousel.CarouselProvider, {
77
+ naturalSlideWidth: 50,
78
+ naturalSlideHeight: 200,
79
+ totalSlides: totalSlides,
80
+ isPlaying: autoPlay,
81
+ interval: 5000,
82
+ visibleSlides: visibleSlides,
83
+ infinite: true
84
+ }, /*#__PURE__*/_react.default.createElement(_pureReactCarousel.Slider, {
85
+ classNameAnimation: "wymd-carousel"
86
+ }, isMobileOrTablet === false && /*#__PURE__*/_react.default.createElement(_pureReactCarousel.Slide, {
87
+ index: 0,
88
+ key: 0
89
+ }), Object.keys(theseItems).map((key, index) => {
90
+ // Reflect that initial dummy/bookend slide shown on non-mobile/tablet views:
91
+ const thisOffsetIndex = index + (isMobileOrTablet ? 0 : 1);
92
+ return (
93
+ /*#__PURE__*/
94
+ // Calculate the index offset accordingly to reflect the number of slides,
95
+ // but use the REAL index when determining if its the last REAL slide
96
+ _react.default.createElement(_pureReactCarousel.Slide, {
97
+ index: thisOffsetIndex,
98
+ className: index === theseItems.length - 1 && 'last-slide',
99
+ key: thisOffsetIndex
100
+ }, /*#__PURE__*/_react.default.createElement(_WYMDCarousel.ImageWrapper, {
101
+ className: "image-wrapper"
102
+ }, /*#__PURE__*/_react.default.createElement("img", {
103
+ src: theseItems[key].image.file.url,
104
+ alt: theseItems[key].copy
105
+ })), /*#__PURE__*/_react.default.createElement(_WYMDCarousel.AmountWrapper, null, /*#__PURE__*/_react.default.createElement(_Text.default, {
106
+ tag: "h1",
107
+ family: "Anton",
108
+ uppercase: true,
109
+ weight: "normal",
110
+ size: "super"
111
+ }, theseItems[key].amount)), /*#__PURE__*/_react.default.createElement(_WYMDCarousel.CopyWrapper, null, /*#__PURE__*/_react.default.createElement(_Text.default, {
112
+ tag: "p",
113
+ size: "l"
114
+ }, theseItems[key].copy)))
115
+ );
116
+ }), isMobileOrTablet === false && /*#__PURE__*/_react.default.createElement(_pureReactCarousel.Slide, {
117
+ index: theseItems.length + 1,
118
+ key: "bookend-last"
119
+ })), /*#__PURE__*/_react.default.createElement(_pureReactCarousel.ButtonBack, null, "Back"), /*#__PURE__*/_react.default.createElement(_pureReactCarousel.ButtonNext, null, "Next")));
120
+ };
121
+ var _default = exports.default = WYMDCarousel;
@@ -0,0 +1,40 @@
1
+ # 'What Your Money Does' Carousel
2
+
3
+ ```js
4
+ const { carouselItemsComplete } = require('../../../styleguide/data/data');
5
+ import Text from '../../Atoms/Text/Text';
6
+
7
+ <div>
8
+ <h2 style={{textAlign: 'center'}}>
9
+ All fields supplied, autoplay on:
10
+ </h2>
11
+ <WYMDCarousel data={carouselItemsComplete}/>
12
+ </div>
13
+
14
+ ```
15
+
16
+ ```js
17
+ const { carouselItemsIncomplete } = require('../../../styleguide/data/data');
18
+ import Text from '../../Atoms/Text/Text';
19
+
20
+ <div>
21
+ <h2 style={{textAlign: 'center'}}>
22
+ All REQUIRED fields supplied (nodes 1-4), various incomplete nodes, node 11 complete, autoplay off:
23
+ </h2>
24
+ <WYMDCarousel data={carouselItemsIncomplete}/>
25
+ </div>
26
+
27
+ ```
28
+
29
+ ```js
30
+ const { carouselItemsMinimal } = require('../../../styleguide/data/data');
31
+ import Text from '../../Atoms/Text/Text';
32
+
33
+ <div>
34
+ <h2 style={{textAlign: 'center'}}>
35
+ All REQUIRED fields supplied (nodes 1-4), autoplay off:
36
+ </h2>
37
+ <WYMDCarousel data={carouselItemsMinimal}/>
38
+ </div>
39
+
40
+ ```
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.PeopleHelpedText = exports.Including = exports.ImageWrapper = exports.Heading = exports.CopyWrapper = exports.CarouselWrapper = exports.AmountWrapper = void 0;
8
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
9
+ var _spacing = _interopRequireDefault(require("../../../theme/shared/spacing"));
10
+ var _Text = _interopRequireDefault(require("../../Atoms/Text/Text"));
11
+ // Duration in seconds
12
+ const animationSpeed = 0.5;
13
+ const ImageWrapper = exports.ImageWrapper = _styledComponents.default.div.withConfig({
14
+ displayName: "WYMDCarouselstyle__ImageWrapper",
15
+ componentId: "sc-115z54p-0"
16
+ })(["width:33%;display:block;padding:7%;border:2px dashed #89888b;border-radius:50%;position:relative;overflow:visible;img{width:100%;height:auto;}&:after{position:absolute;content:'';top:50%;width:200%;right:calc(-200% - 8px);height:2px;border-bottom:2px dashed #89888b;}@media ", "{width:50%;padding:9%;&:after{width:100%;right:calc(-100% - 8px);}}"], _ref => {
17
+ let {
18
+ theme
19
+ } = _ref;
20
+ return theme.breakpoint('medium');
21
+ });
22
+ const AmountWrapper = exports.AmountWrapper = _styledComponents.default.div.withConfig({
23
+ displayName: "WYMDCarouselstyle__AmountWrapper",
24
+ componentId: "sc-115z54p-1"
25
+ })(["padding:", " 0;width:75%;margin:0 auto;"], (0, _spacing.default)('m'));
26
+ const CopyWrapper = exports.CopyWrapper = _styledComponents.default.div.withConfig({
27
+ displayName: "WYMDCarouselstyle__CopyWrapper",
28
+ componentId: "sc-115z54p-2"
29
+ })(["padding:", " 0;width:75%;margin:0 auto;"], (0, _spacing.default)('sm'));
30
+ const Heading = exports.Heading = (0, _styledComponents.default)(_Text.default).withConfig({
31
+ displayName: "WYMDCarouselstyle__Heading",
32
+ componentId: "sc-115z54p-3"
33
+ })(["width:75%;margin:0 auto;&:first-child{margin-bottom:", ";text-align:center;font-size:20px;line-height:23px;@media ", "{font-size:21px;line-height:23px;}}"], (0, _spacing.default)('l'), _ref2 => {
34
+ let {
35
+ theme
36
+ } = _ref2;
37
+ return theme.breakpoint('medium');
38
+ });
39
+ const PeopleHelpedText = exports.PeopleHelpedText = (0, _styledComponents.default)(_Text.default).withConfig({
40
+ displayName: "WYMDCarouselstyle__PeopleHelpedText",
41
+ componentId: "sc-115z54p-4"
42
+ })(["margin-bottom:", ";text-align:center;font-size:40px;line-height:40px;@media ", "{font-size:60px;line-height:60px;}@media ", "{font-size:75px;line-height:78px;}"], (0, _spacing.default)('l'), _ref3 => {
43
+ let {
44
+ theme
45
+ } = _ref3;
46
+ return theme.breakpoint('small');
47
+ }, _ref4 => {
48
+ let {
49
+ theme
50
+ } = _ref4;
51
+ return theme.breakpoint('medium');
52
+ });
53
+ const Including = exports.Including = (0, _styledComponents.default)(_Text.default).withConfig({
54
+ displayName: "WYMDCarouselstyle__Including",
55
+ componentId: "sc-115z54p-5"
56
+ })(["margin-bottom:0;text-align:center;font-size:14px;line-height:17px;@media ", "{font-size:17px;line-height:19px;}"], _ref5 => {
57
+ let {
58
+ theme
59
+ } = _ref5;
60
+ return theme.breakpoint('small');
61
+ });
62
+
63
+ // Unfortunately having to target plugin-created markup ye olde fashioned way:
64
+ const CarouselWrapper = exports.CarouselWrapper = _styledComponents.default.div.withConfig({
65
+ displayName: "WYMDCarouselstyle__CarouselWrapper",
66
+ componentId: "sc-115z54p-6"
67
+ })(["height:100%;padding:", ";.carousel{position:relative;margin:0 auto;padding-top:", ";@media ", "{padding-top:", ";}button.carousel__back-button,button.carousel__next-button{position:absolute;left:0;top:0;width:33% !important;height:100%;padding:0 !important;box-shadow:none;text-indent:-9999px;background-color:transparent;border:none;&:before{content:'';position:absolute;width:30px;height:30px;top:50%;left:0;transform:translate(0,-50%) rotate(90deg);}&:after{content:\"\";position:absolute;top:0;left:0;width:50%;height:100%;transition:opacity 0.2s linear;background:linear-gradient(90deg,rgba(255,255,255,0.95),rgba(255,255,255,0.5),rgba(255,255,255,0));}&:hover{&:after{opacity:0.5;}}@media ", "{width:33.3% !important;&:after{width:100%;}}}button.carousel__next-button{left:auto;right:0;&:before{transform:translate(0,-50%) rotate(-90deg);}&:after{left:auto;right:0;background:linear-gradient(270deg,rgba(255,255,255,0.95),rgba(255,255,255,0.75),rgba(255,255,255,0));}}.wymd-carousel{transition:-webkit-transform ", "s;-o-transition:transform ", "s;transition:transform ", "s;-webkit-transform:", "s;will-change:transform;.last-slide{.image-wrapper:after{content:none;}}.carousel__slide{padding-bottom:", "px !important;@media ", "{padding-bottom:", "px !important;.carousel__inner-slide{> div:first-child{transition:transform ", "s ease;transform:scale(0.5);&:after{transition:transform ", "s ease,width ", "s ease,right ", "s ease;right:calc(-300% - 6px);transform:scale(1);width:300%;}}}&.carousel__slide--visible{.carousel__inner-slide{> div:first-child{&:after{right:calc(-250% - 6px);transform:scale(1);width:250%;}}}+ .carousel__slide--visible{.carousel__inner-slide{> div:first-child{transform:scale(1);&:after{right:calc(-187% - 6px);transform:scale(0.5);width:250%;}}}+ .carousel__slide--visible{> div > div:first-child{transform:scale(0.5);&:after{right:calc(-250% - 6px);transform:scale(1);width:250%;}}}}}}.carousel__inner-slide{text-align:center;display:inline-flex;align-items:center;justify-content:flex-start;flex-direction:column;}}}}"], (0, _spacing.default)('m'), (0, _spacing.default)('l'), _ref6 => {
68
+ let {
69
+ theme
70
+ } = _ref6;
71
+ return theme.breakpoint('medium');
72
+ }, (0, _spacing.default)('lg'), _ref7 => {
73
+ let {
74
+ theme
75
+ } = _ref7;
76
+ return theme.breakpoint('medium');
77
+ }, animationSpeed, animationSpeed, animationSpeed, animationSpeed, props => props.mobileHeight, _ref8 => {
78
+ let {
79
+ theme
80
+ } = _ref8;
81
+ return theme.breakpoint('medium');
82
+ }, props => props.desktopHeight, animationSpeed, animationSpeed, animationSpeed, animationSpeed);
@@ -0,0 +1,16 @@
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("../../../hoc/shallowWithTheme"));
7
+ var _WYMDCarousel = _interopRequireDefault(require("./WYMDCarousel"));
8
+ const {
9
+ carouselItemsComplete
10
+ } = require("../../../styleguide/data/data");
11
+ it("renders correctly", () => {
12
+ const tree = (0, _shallowWithTheme.default)( /*#__PURE__*/_react.default.createElement(_WYMDCarousel.default, {
13
+ data: carouselItemsComplete
14
+ })).toJSON();
15
+ expect(tree).toMatchInlineSnapshot("\n .c1 {\n font-size: 1rem;\n line-height: 1rem;\n text-transform: inherit;\n font-weight: bold;\n line-height: normal;\n font-family: 'Montserrat',Helvetica,Arial,sans-serif;\n }\n\n .c3 {\n color: #E52630;\n font-size: 1rem;\n line-height: 1rem;\n text-transform: uppercase;\n font-weight: normal;\n font-family: 'Anton',Impact,sans-serif;\n -webkit-letter-spacing: 0.03rem;\n -moz-letter-spacing: 0.03rem;\n -ms-letter-spacing: 0.03rem;\n letter-spacing: 0.03rem;\n }\n\n .c5 {\n font-size: 1rem;\n line-height: 1rem;\n text-transform: inherit;\n line-height: normal;\n font-family: 'Montserrat',Helvetica,Arial,sans-serif;\n }\n\n .c2 {\n width: 75%;\n margin: 0 auto;\n }\n\n .c2:first-child {\n margin-bottom: 2rem;\n text-align: center;\n font-size: 20px;\n line-height: 23px;\n }\n\n .c4 {\n margin-bottom: 2rem;\n text-align: center;\n font-size: 40px;\n line-height: 40px;\n }\n\n .c6 {\n margin-bottom: 0;\n text-align: center;\n font-size: 14px;\n line-height: 17px;\n }\n\n .c0 {\n height: 100%;\n padding: 1.5rem;\n }\n\n .c0 .carousel {\n position: relative;\n margin: 0 auto;\n padding-top: 2rem;\n }\n\n .c0 .carousel button.carousel__back-button,\n .c0 .carousel button.carousel__next-button {\n position: absolute;\n left: 0;\n top: 0;\n width: 33% !important;\n height: 100%;\n padding: 0 !important;\n box-shadow: none;\n text-indent: -9999px;\n background-color: transparent;\n border: none;\n }\n\n .c0 .carousel button.carousel__back-button:before,\n .c0 .carousel button.carousel__next-button:before {\n content: '';\n position: absolute;\n width: 30px;\n height: 30px;\n top: 50%;\n left: 0;\n -webkit-transform: translate(0,-50%) rotate(90deg);\n -ms-transform: translate(0,-50%) rotate(90deg);\n transform: translate(0,-50%) rotate(90deg);\n }\n\n .c0 .carousel button.carousel__back-button:after,\n .c0 .carousel button.carousel__next-button:after {\n content: \"\";\n position: absolute;\n top: 0;\n left: 0;\n width: 50%;\n height: 100%;\n -webkit-transition: opacity 0.2s linear;\n transition: opacity 0.2s linear;\n background: linear-gradient(90deg,rgba(255,255,255,0.95),rgba(255,255,255,0.5),rgba(255,255,255,0));\n }\n\n .c0 .carousel button.carousel__back-button:hover:after,\n .c0 .carousel button.carousel__next-button:hover:after {\n opacity: 0.5;\n }\n\n .c0 .carousel button.carousel__next-button {\n left: auto;\n right: 0;\n }\n\n .c0 .carousel button.carousel__next-button:before {\n -webkit-transform: translate(0,-50%) rotate(-90deg);\n -ms-transform: translate(0,-50%) rotate(-90deg);\n transform: translate(0,-50%) rotate(-90deg);\n }\n\n .c0 .carousel button.carousel__next-button:after {\n left: auto;\n right: 0;\n background: linear-gradient(270deg,rgba(255,255,255,0.95),rgba(255,255,255,0.75),rgba(255,255,255,0));\n }\n\n .c0 .carousel .wymd-carousel {\n -webkit-transition: -webkit-transform 0.5s;\n -webkit-transition: -webkit-transform 0.5s;\n transition: -webkit-transform 0.5s;\n -o-transition: transform 0.5s;\n -webkit-transition: -webkit-transform 0.5s;\n -webkit-transition: transform 0.5s;\n transition: transform 0.5s;\n -webkit-transform: 0.5s;\n will-change: transform;\n }\n\n .c0 .carousel .wymd-carousel .last-slide .image-wrapper:after {\n content: none;\n }\n\n .c0 .carousel .wymd-carousel .carousel__slide {\n padding-bottom: 500px !important;\n }\n\n .c0 .carousel .wymd-carousel .carousel__slide .carousel__inner-slide {\n text-align: center;\n display: -webkit-inline-box;\n display: -webkit-inline-flex;\n display: -ms-inline-flexbox;\n display: inline-flex;\n -webkit-align-items: center;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: start;\n -webkit-justify-content: flex-start;\n -ms-flex-pack: start;\n justify-content: flex-start;\n -webkit-flex-direction: column;\n -ms-flex-direction: column;\n flex-direction: column;\n }\n\n @media (min-width:1024px) {\n .c2:first-child {\n font-size: 21px;\n line-height: 23px;\n }\n }\n\n @media (min-width:740px) {\n .c4 {\n font-size: 60px;\n line-height: 60px;\n }\n }\n\n @media (min-width:1024px) {\n .c4 {\n font-size: 75px;\n line-height: 78px;\n }\n }\n\n @media (min-width:740px) {\n .c6 {\n font-size: 17px;\n line-height: 19px;\n }\n }\n\n @media (min-width:1024px) {\n .c0 .carousel {\n padding-top: 3rem;\n }\n }\n\n @media (min-width:1024px) {\n .c0 .carousel button.carousel__back-button,\n .c0 .carousel button.carousel__next-button {\n width: 33.3% !important;\n }\n\n .c0 .carousel button.carousel__back-button:after,\n .c0 .carousel button.carousel__next-button:after {\n width: 100%;\n }\n }\n\n @media (min-width:1024px) {\n .c0 .carousel .wymd-carousel .carousel__slide {\n padding-bottom: 550px !important;\n }\n\n .c0 .carousel .wymd-carousel .carousel__slide .carousel__inner-slide > div:first-child {\n -webkit-transition: -webkit-transform 0.5s ease;\n -webkit-transition: transform 0.5s ease;\n transition: transform 0.5s ease;\n -webkit-transform: scale(0.5);\n -ms-transform: scale(0.5);\n transform: scale(0.5);\n }\n\n .c0 .carousel .wymd-carousel .carousel__slide .carousel__inner-slide > div:first-child:after {\n -webkit-transition: -webkit-transform 0.5s ease,width 0.5s ease,right 0.5s ease;\n -webkit-transition: transform 0.5s ease,width 0.5s ease,right 0.5s ease;\n transition: transform 0.5s ease,width 0.5s ease,right 0.5s ease;\n right: calc(-300% - 6px);\n -webkit-transform: scale(1);\n -ms-transform: scale(1);\n transform: scale(1);\n width: 300%;\n }\n\n .c0 .carousel .wymd-carousel .carousel__slide.carousel__slide--visible .carousel__inner-slide > div:first-child:after {\n right: calc(-250% - 6px);\n -webkit-transform: scale(1);\n -ms-transform: scale(1);\n transform: scale(1);\n width: 250%;\n }\n\n .c0 .carousel .wymd-carousel .carousel__slide.carousel__slide--visible + .carousel__slide--visible .carousel__inner-slide > div:first-child {\n -webkit-transform: scale(1);\n -ms-transform: scale(1);\n transform: scale(1);\n }\n\n .c0 .carousel .wymd-carousel .carousel__slide.carousel__slide--visible + .carousel__slide--visible .carousel__inner-slide > div:first-child:after {\n right: calc(-187% - 6px);\n -webkit-transform: scale(0.5);\n -ms-transform: scale(0.5);\n transform: scale(0.5);\n width: 250%;\n }\n\n .c0 .carousel .wymd-carousel .carousel__slide.carousel__slide--visible + .carousel__slide--visible + .carousel__slide--visible > div > div:first-child {\n -webkit-transform: scale(0.5);\n -ms-transform: scale(0.5);\n transform: scale(0.5);\n }\n\n .c0 .carousel .wymd-carousel .carousel__slide.carousel__slide--visible + .carousel__slide--visible + .carousel__slide--visible > div > div:first-child:after {\n right: calc(-250% - 6px);\n -webkit-transform: scale(1);\n -ms-transform: scale(1);\n transform: scale(1);\n width: 250%;\n }\n }\n\n <div\n className=\"c0 CarouselWrapper\"\n id=\"7zdR84QkZwrTh9NWx2H926\"\n >\n <p\n className=\"c1 c2\"\n color=\"inherit\"\n size=\"s\"\n >\n Over the past two years, we\u2019ve supported\n </p>\n <h1\n className=\"c3 c4\"\n color=\"red\"\n size=\"s\"\n >\n 11.7 million people\n </h1>\n <p\n className=\"c5 c6\"\n color=\"inherit\"\n size=\"s\"\n >\n including...\n </p>\n </div>\n ");
16
+ });
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const formatItems = thisData => {
8
+ // Somewhere to store our formatted items:
9
+ const allValidNodes = [];
10
+
11
+ // Set at a Content Type field level, so doesn't need to be dynamic:
12
+ const possibleNumberOfNodes = 12;
13
+
14
+ // Grab ALL keys from our raw data:
15
+ const theseKeys = Object.keys(thisData);
16
+
17
+ // Iterate over all of the data, using a dynamic key prefix to filter
18
+ // what we need in order to create each object for our allValidNodes array:
19
+ for (let i = 1; i <= possibleNumberOfNodes; i += 1) {
20
+ // Create a dynamic key prefix based on the counter, obviously matching
21
+ // the naming convention set at the Content Type level in the CMS
22
+ const thisKeyPrefix = "node".concat(i, "_");
23
+
24
+ // Make an array of objects, each object representing a specific node and its fields:
25
+ const thisNodeContent = theseKeys.filter(key => key.includes(thisKeyPrefix)).reduce((thisObj, thisKey) => {
26
+ const thisFilteredObj = thisObj;
27
+ // Only assign if we have actually have a value; only the fields for nodes 1-4 are required:
28
+ if (thisData[thisKey]) {
29
+ // Use a repeatable, generic key so rendering is a LOT easier:
30
+ const simplifedKey = thisKey.split('_').pop().toLowerCase();
31
+ thisFilteredObj[simplifedKey] = thisData[thisKey];
32
+ }
33
+ return thisFilteredObj;
34
+ }, {});
35
+
36
+ // Add our new object to the allValidNodes array, but only if we've got all 3 necessary fields:
37
+ if (Object.keys(thisNodeContent).length === 3) {
38
+ allValidNodes.push(thisNodeContent);
39
+ }
40
+ }
41
+ return allValidNodes;
42
+ };
43
+ var _default = exports.default = formatItems;
package/dist/index.js CHANGED
@@ -322,6 +322,12 @@ Object.defineProperty(exports, "VideoBanner", {
322
322
  return _VideoBanner.default;
323
323
  }
324
324
  });
325
+ Object.defineProperty(exports, "WYMDCarousel", {
326
+ enumerable: true,
327
+ get: function () {
328
+ return _WYMDCarousel.default;
329
+ }
330
+ });
325
331
  Object.defineProperty(exports, "allowListed", {
326
332
  enumerable: true,
327
333
  get: function () {
@@ -459,4 +465,5 @@ var _EmailSignUp = require("./components/Organisms/EmailSignUp/_EmailSignUp");
459
465
  var _CookieBanner = _interopRequireDefault(require("./components/Organisms/CookieBanner/CookieBanner"));
460
466
  var _Membership = _interopRequireDefault(require("./components/Organisms/Membership/Membership"));
461
467
  var _MarketingPreferencesDS = require("./components/Organisms/MarketingPreferencesDS/_MarketingPreferencesDS");
462
- var _ImpactSlider = _interopRequireDefault(require("./components/Organisms/ImpactSlider/ImpactSlider"));
468
+ var _ImpactSlider = _interopRequireDefault(require("./components/Organisms/ImpactSlider/ImpactSlider"));
469
+ var _WYMDCarousel = _interopRequireDefault(require("./components/Organisms/WYMDCarousel/WYMDCarousel"));
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.testImpactSliderItems = exports.mobileImages = exports.defaultData = void 0;
6
+ exports.testImpactSliderItems = exports.mobileImages = exports.defaultData = exports.carouselItemsMinimal = exports.carouselItemsIncomplete = exports.carouselItemsComplete = void 0;
7
7
  const defaultData = exports.defaultData = {
8
8
  title: 'What your money does',
9
9
  text: 'When you donate to Comic Relief or Sport Relief, you’re supporting vulnerable people and communities in the UK and internationally.',
@@ -39,4 +39,214 @@ const testImpactSliderItems = exports.testImpactSliderItems = [{
39
39
  poundsPerItem: 20,
40
40
  description: 'School in a bag kit',
41
41
  imageURL: 'https://images.ctfassets.net/zsfivwzfgl3t/PPIJtSArW4wYy1CXvRGk9/c9de72766db42a0e158889a140c90445/ImpactSliderMoneybuy4.png'
42
- }];
42
+ }];
43
+ const carouselItemsComplete = exports.carouselItemsComplete = {
44
+ __typename: 'ContentfulWhatYourMoneyDoesCarousel',
45
+ contentful_id: '7zdR84QkZwrTh9NWx2H926',
46
+ mobileHeight: 500,
47
+ desktopHeight: 550,
48
+ heading: 'Over the past two years, we’ve supported',
49
+ peopleHelpedText: '11.7 million people',
50
+ autoPlay: true,
51
+ node1_Copy: 'NODE1: people in the UK experiencing poverty to access advice and support.',
52
+ node1_Amount: '1,000',
53
+ node1_Image: {
54
+ file: {
55
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
56
+ }
57
+ },
58
+ node2_Copy: 'NODE2: people in the UK experiencing poverty to access advice and support. This node has a load of copy to make things extra difficult',
59
+ node2_Amount: '2,000',
60
+ node2_Image: {
61
+ file: {
62
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
63
+ }
64
+ },
65
+ node3_Copy: 'NODE3: people in the UK experiencing poverty to access advice and support.',
66
+ node3_Amount: '3,000',
67
+ node3_Image: {
68
+ file: {
69
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
70
+ }
71
+ },
72
+ node4_Copy: 'NODE4: people in the UK experiencing poverty to access advice and support.',
73
+ node4_Amount: '4,000',
74
+ node4_Image: {
75
+ file: {
76
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
77
+ }
78
+ },
79
+ node5_Copy: 'NODE5: people in the UK experiencing poverty to access advice and support.',
80
+ node5_Amount: '5,000',
81
+ node5_Image: {
82
+ file: {
83
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
84
+ }
85
+ },
86
+ node6_Copy: 'NODE6: people in the UK experiencing poverty to access advice and support.',
87
+ node6_Amount: '6,000',
88
+ node6_Image: {
89
+ file: {
90
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
91
+ }
92
+ },
93
+ node7_Copy: 'NODE7: people in the UK experiencing poverty to access advice and support.',
94
+ node7_Amount: '7,000',
95
+ node7_Image: {
96
+ file: {
97
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
98
+ }
99
+ },
100
+ node8_Copy: 'NODE8: people in the UK experiencing poverty to access advice and support.',
101
+ node8_Amount: '8,000',
102
+ node8_Image: {
103
+ file: {
104
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
105
+ }
106
+ },
107
+ node9_Copy: 'NODE9: people in the UK experiencing poverty to access advice and support.',
108
+ node9_Amount: '9,000',
109
+ node9_Image: {
110
+ file: {
111
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
112
+ }
113
+ },
114
+ node10_Copy: 'NODE10: people in the UK experiencing poverty to access advice and support.',
115
+ node10_Amount: '10,000',
116
+ node10_Image: {
117
+ file: {
118
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
119
+ }
120
+ },
121
+ node11_Copy: 'NODE11: people in the UK experiencing poverty to access advice and support.',
122
+ node11_Amount: '11,000',
123
+ node11_Image: {
124
+ file: {
125
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
126
+ }
127
+ },
128
+ node12_Copy: 'NODE12: people in the UK experiencing poverty to access advice and support.750,000',
129
+ node12_Amount: '12,000',
130
+ node12_Image: {
131
+ file: {
132
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
133
+ }
134
+ }
135
+ };
136
+ const carouselItemsIncomplete = exports.carouselItemsIncomplete = {
137
+ __typename: 'ContentfulWhatYourMoneyDoesCarousel',
138
+ contentful_id: '7zdR84QkZwrTh9NWx2H9262',
139
+ mobileHeight: 500,
140
+ desktopHeight: 550,
141
+ heading: 'Over the past two years, we’ve supported',
142
+ peopleHelpedText: '11.7 million people',
143
+ autoPlay: false,
144
+ node1_Copy: 'NODE1: people in the UK experiencing poverty to access advice and support.',
145
+ node1_Amount: '1,000',
146
+ node1_Image: {
147
+ file: {
148
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
149
+ }
150
+ },
151
+ node2_Copy: 'NODE2: people in the UK experiencing poverty to access advice and support.',
152
+ node2_Amount: '2,000',
153
+ node2_Image: {
154
+ file: {
155
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
156
+ }
157
+ },
158
+ node3_Copy: 'NODE3: people in the UK experiencing poverty to access advice and support.',
159
+ node3_Amount: '3,000',
160
+ node3_Image: {
161
+ file: {
162
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
163
+ }
164
+ },
165
+ node4_Copy: 'NODE4: people in the UK experiencing poverty to access advice and support.',
166
+ node4_Amount: '4,000',
167
+ node4_Image: {
168
+ file: {
169
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
170
+ }
171
+ },
172
+ node5_Copy: 'NODE5: people in the UK experiencing poverty to access advice and support.',
173
+ node5_Image: {
174
+ file: {
175
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
176
+ }
177
+ },
178
+ node6_Copy: 'NODE6: people in the UK experiencing poverty to access advice and support.',
179
+ node6_Amount: '6,000',
180
+ node6_Image: null,
181
+ node7_Copy: null,
182
+ node7_Amount: null,
183
+ node7_Image: null,
184
+ node8_Copy: null,
185
+ node8_Amount: null,
186
+ node8_Image: {
187
+ file: {
188
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
189
+ }
190
+ },
191
+ node9_Copy: 'NODE9: people in the UK experiencing poverty to access advice and support.',
192
+ node9_Amount: null,
193
+ node9_Image: null,
194
+ node10_Copy: null,
195
+ node10_Amount: '10,000',
196
+ node10_Image: {
197
+ file: {
198
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
199
+ }
200
+ },
201
+ node11_Copy: 'NODE11: people in the UK experiencing poverty to access advice and support.',
202
+ node11_Amount: '11,000',
203
+ node11_Image: {
204
+ file: {
205
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
206
+ }
207
+ },
208
+ node12_Copy: 'people in the UK experiencing poverty to access advice and support.750,000',
209
+ node12_Amount: null,
210
+ node12_Image: {
211
+ file: {
212
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
213
+ }
214
+ }
215
+ };
216
+ const carouselItemsMinimal = exports.carouselItemsMinimal = {
217
+ __typename: 'ContentfulWhatYourMoneyDoesCarousel',
218
+ contentful_id: '7zdR84QkZwrTh9NWx2H9263',
219
+ mobileHeight: 500,
220
+ desktopHeight: 550,
221
+ heading: 'Over the past two years, we’ve supported',
222
+ peopleHelpedText: '11.7 million people',
223
+ autoPlay: false,
224
+ node1_Copy: 'NODE1: people in the UK experiencing poverty to access advice and support.',
225
+ node1_Amount: '1,000',
226
+ node1_Image: {
227
+ file: {
228
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
229
+ }
230
+ },
231
+ node2_Copy: 'NODE2: people in the UK experiencing poverty to access advice and support.',
232
+ node2_Amount: '2,000',
233
+ node2_Image: {
234
+ file: {
235
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
236
+ }
237
+ },
238
+ node3_Copy: 'NODE3: people in the UK experiencing poverty to access advice and support.',
239
+ node3_Amount: '3,000',
240
+ node3_Image: {
241
+ file: {
242
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
243
+ }
244
+ },
245
+ node4_Copy: 'NODE4: people in the UK experiencing poverty to access advice and support.',
246
+ node4_Amount: '4,000',
247
+ node4_Image: {
248
+ file: {
249
+ url: '//images.ctfassets.net/zsfivwzfgl3t/45yv3H0XZsvsySHtutQ8vb/1fb6d1afe4037c7dccde743a747f6b4f/Test-Carousel-Icon.png'
250
+ }
251
+ }
252
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@comicrelief/component-library",
3
3
  "author": "Comic Relief Engineering Team",
4
- "version": "7.34.1",
4
+ "version": "7.35.1",
5
5
  "main": "dist/index.js",
6
6
  "license": "ISC",
7
7
  "jest": {
@@ -32,6 +32,7 @@
32
32
  "lodash": "^4.17.11",
33
33
  "moment": "^2.29.4",
34
34
  "prop-types": "^15.8.1",
35
+ "pure-react-carousel": "1.30.1",
35
36
  "react": "^17.0.2",
36
37
  "react-canvas-confetti": "^1.4.0",
37
38
  "react-currency-format": "^1.1.0",