@@ -7,23 +7,26 @@ import {
77} from 'pure-react-carousel' ;
88import 'pure-react-carousel/dist/react-carousel.es.css' ;
99import {
10- CarouselWrapper , SlideCopyWrapper , HeadingCopyWrapper
10+ CarouselWrapper , SlideCopyWrapper , HeadingCopyWrapper , Container
1111} from './RichtextCarousel.style' ;
1212import { breakpointValues } from '../../../theme/shared/allBreakpoints' ;
1313
1414const RichtextCarousel = ( {
1515 data : {
16- contentful_id : thisID ,
1716 autoPlay,
18- nodes ,
17+ contentful_id : thisID ,
1918 headingCopy,
19+ nodes,
2020 // Set some defaults for good measure:
21+ carouselBackgroundColour = 'white' ,
22+ desktopHeight = 350 ,
2123 mobileHeight = 300 ,
2224 tabletHeight = 350 ,
23- desktopHeight = 350 ,
24- carouselBackgroundColour = 'white' ,
2525 nodeBackgroundColour = 'white' ,
26- nodeOutlineColour = 'grey'
26+ nodeOutlineColour = 'grey' ,
27+ paddingBottom = '2rem' ,
28+ paddingTop = '2rem' ,
29+ rowBackgroundColour = 'grey_light'
2730 }
2831} ) => {
2932 // Defaults to mobile config:
@@ -67,84 +70,92 @@ const RichtextCarousel = ({
6770 }
6871
6972 return (
70- < CarouselWrapper
71- className = "CarouselWrapper"
72- id = { thisID }
73- mobileHeight = { mobileHeight }
74- tabletHeight = { tabletHeight }
75- desktopHeight = { desktopHeight }
76- carouselBackgroundColour = { carouselBackgroundColour }
73+ < Container
74+ paddingTop = { paddingTop }
75+ paddingBottom = { paddingBottom }
76+ rowBackgroundColour = { rowBackgroundColour }
7777 >
7878
79- < HeadingCopyWrapper >
80- { headingCopy }
81- </ HeadingCopyWrapper >
82-
83- { theseItems && (
84- < CarouselProvider
85- naturalSlideWidth = { 50 }
86- naturalSlideHeight = { 200 }
87- totalSlides = { totalSlides }
88- isPlaying = { autoPlay }
89- interval = { 5000 }
90- visibleSlides = { visibleSlides }
91- infinite
79+ < CarouselWrapper
80+ className = "CarouselWrapper"
81+ id = { thisID }
82+ mobileHeight = { mobileHeight }
83+ tabletHeight = { tabletHeight }
84+ desktopHeight = { desktopHeight }
85+ carouselBackgroundColour = { carouselBackgroundColour }
9286 >
93- < Slider classNameAnimation = "richtext-carousel" >
94-
95- { /* Dummy slide for our desired non-mobile layout and functionality */ }
96- { isMobile === false && (
97- < Slide index = { 0 } key = { 0 } />
98- ) }
9987
100- { Object . keys ( theseItems ) . map ( ( key , index ) => {
88+ < HeadingCopyWrapper >
89+ { headingCopy }
90+ </ HeadingCopyWrapper >
91+
92+ { theseItems && (
93+ < CarouselProvider
94+ naturalSlideWidth = { 50 }
95+ naturalSlideHeight = { 200 }
96+ totalSlides = { totalSlides }
97+ isPlaying = { autoPlay }
98+ interval = { 5000 }
99+ visibleSlides = { visibleSlides }
100+ infinite
101+ >
102+ < Slider classNameAnimation = "richtext-carousel" >
103+
104+ { /* Dummy slide for our desired non-mobile layout and functionality */ }
105+ { isMobile === false && (
106+ < Slide index = { 0 } key = { 0 } />
107+ ) }
108+
109+ { Object . keys ( theseItems ) . map ( ( key , index ) => {
101110 // Reflect that initial dummy/bookend slide shown on non-mobile/tablet views:
102- const thisOffsetIndex = index + ( isMobile ? 0 : 1 ) ;
111+ const thisOffsetIndex = index + ( isMobile ? 0 : 1 ) ;
103112
104- return (
113+ return (
105114 // Calculate the index offset accordingly to reflect the number of slides,
106115 // but use the REAL index when determining if its the last REAL slide
107- < Slide
108- index = { thisOffsetIndex }
109- className = { index === ( theseItems . length - 1 ) && 'last-slide' }
110- key = { thisOffsetIndex }
111- >
112-
113- < SlideCopyWrapper
114- className = "slide-copy-wrapper"
115- mobileHeight = { mobileHeight }
116- tabletHeight = { tabletHeight }
117- desktopHeight = { desktopHeight }
118- nodeBackgroundColour = { nodeBackgroundColour }
119- nodeOutlineColour = { nodeOutlineColour }
116+ < Slide
117+ index = { thisOffsetIndex }
118+ className = { index === ( theseItems . length - 1 ) && 'last-slide' }
119+ key = { thisOffsetIndex }
120120 >
121- { theseItems [ index ] . copy }
122- </ SlideCopyWrapper >
123-
124- </ Slide >
125- ) ;
126- } ) }
127-
128- { /* Dummy slide for our desired non-mobile layout and functionality */ }
129- { isMobile === false && (
130- < Slide index = { theseItems . length + 1 } key = "bookend-last" />
131- ) }
132121
133- </ Slider >
134- < ButtonBack > Back</ ButtonBack >
135- < ButtonNext > Next</ ButtonNext >
136- </ CarouselProvider >
137- ) }
122+ < SlideCopyWrapper
123+ className = "slide-copy-wrapper"
124+ mobileHeight = { mobileHeight }
125+ tabletHeight = { tabletHeight }
126+ desktopHeight = { desktopHeight }
127+ nodeBackgroundColour = { nodeBackgroundColour }
128+ nodeOutlineColour = { nodeOutlineColour }
129+ >
130+ { theseItems [ index ] . copy }
131+ </ SlideCopyWrapper >
132+
133+ </ Slide >
134+ ) ;
135+ } ) }
136+
137+ { /* Dummy slide for our desired non-mobile layout and functionality */ }
138+ { isMobile === false && (
139+ < Slide index = { theseItems . length + 1 } key = "bookend-last" />
140+ ) }
141+
142+ </ Slider >
143+ < ButtonBack > Back</ ButtonBack >
144+ < ButtonNext > Next</ ButtonNext >
145+ </ CarouselProvider >
146+ ) }
147+
148+ </ CarouselWrapper >
149+ </ Container >
138150
139- </ CarouselWrapper >
140151 ) ;
141152} ;
142153
143154RichtextCarousel . propTypes = {
144155 data : PropTypes . shape ( {
145- headingCopy : PropTypes . string . isRequired ,
156+ headingCopy : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . node ] ) . isRequired ,
146157 nodes : PropTypes . arrayOf ( PropTypes . shape ( {
147- copy : PropTypes . string . isRequired
158+ copy : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . node ] ) . isRequired
148159 } ) ) . isRequired ,
149160 autoPlay : PropTypes . bool . isRequired ,
150161 contentful_id : PropTypes . string . isRequired ,
@@ -153,7 +164,10 @@ RichtextCarousel.propTypes = {
153164 desktopHeight : PropTypes . number ,
154165 carouselBackgroundColour : PropTypes . string ,
155166 nodeBackgroundColour : PropTypes . string ,
156- nodeOutlineColour : PropTypes . string
167+ nodeOutlineColour : PropTypes . string ,
168+ paddingTop : PropTypes . string ,
169+ paddingBottom : PropTypes . string ,
170+ rowBackgroundColour : PropTypes . string
157171 } ) . isRequired
158172} ;
159173
0 commit comments