@@ -13,6 +13,7 @@ import {
1313 SvgChevronRightSingle ,
1414} from '@guardian/source/react-components' ;
1515import { useEffect , useRef , useState } from 'react' ;
16+ import { getZIndex } from '../lib/getZIndex' ;
1617import { takeFirst } from '../lib/tuple' ;
1718import { palette } from '../palette' ;
1819import type { DCRSlideshowImage } from '../types/front' ;
@@ -55,6 +56,11 @@ const carouselItemStyles = css`
5556 scroll-snap-align : start;
5657` ;
5758
59+ const carouselLinkStyles = css `
60+ position : relative;
61+ z-index : ${ getZIndex ( 'card-nested-link' ) } ;
62+ ` ;
63+
5864const captionStyles = css `
5965 position : absolute;
6066 bottom : 0 ;
@@ -74,6 +80,8 @@ const navigationStyles = (hasBackgroundColour: boolean) => css`
7480 display : flex;
7581 align-items : center;
7682 padding-top : ${ space [ 2 ] } px;
83+ position : relative;
84+ z-index : ${ getZIndex ( 'card-nested-link' ) } ;
7785
7886 ${ until . tablet } {
7987 background-color : ${ hasBackgroundColour
@@ -108,12 +116,18 @@ type Props = {
108116 images : readonly DCRSlideshowImage [ ] ;
109117 imageSize : MediaSizeType ;
110118 hasNavigationBackgroundColour : boolean ;
119+ linkTo : string ;
120+ linkAriaLabel : string ;
121+ dataLinkName ?: string ;
111122} ;
112123
113124export const SlideshowCarousel = ( {
114125 images,
115126 imageSize,
116127 hasNavigationBackgroundColour,
128+ linkTo,
129+ linkAriaLabel,
130+ dataLinkName,
117131} : Props ) => {
118132 const carouselRef = useRef < HTMLUListElement | null > ( null ) ;
119133 const [ previousButtonEnabled , setPreviousButtonEnabled ] = useState ( false ) ;
@@ -192,37 +206,47 @@ export const SlideshowCarousel = ({
192206 const slideshowImageCount = slideshowImages . length ;
193207
194208 return (
195- < div className = "slideshow-carousel" >
196- < ul
197- ref = { carouselRef }
198- css = { carouselStyles }
199- data-heatphan-type = "carousel"
209+ < >
210+ < a
211+ href = { linkTo }
212+ css = { carouselLinkStyles }
213+ aria-label = { linkAriaLabel }
214+ data-link-name = { dataLinkName }
200215 >
201- { slideshowImages . map ( ( image , index ) => {
202- const loading = index > 0 ? 'lazy' : 'eager' ;
203- return (
204- < li css = { carouselItemStyles } key = { image . imageSrc } >
205- < figure >
206- < CardPicture
207- mainImage = { image . imageSrc }
208- imageSize = { imageSize }
209- aspectRatio = "5:4"
210- alt = { image . imageCaption }
211- loading = { loading }
212- />
213- { ! ! image . imageCaption && (
214- < figcaption css = { captionStyles } >
215- { image . imageCaption }
216- </ figcaption >
217- ) }
218- </ figure >
219- </ li >
220- ) ;
221- } ) }
222- </ ul >
216+ < ul
217+ ref = { carouselRef }
218+ css = { carouselStyles }
219+ data-heatphan-type = "carousel"
220+ >
221+ { slideshowImages . map ( ( image , index ) => {
222+ const loading = index > 0 ? 'lazy' : 'eager' ;
223+ return (
224+ < li css = { carouselItemStyles } key = { image . imageSrc } >
225+ < figure >
226+ < CardPicture
227+ mainImage = { image . imageSrc }
228+ imageSize = { imageSize }
229+ aspectRatio = "5:4"
230+ alt = { image . imageCaption }
231+ loading = { loading }
232+ />
233+ { ! ! image . imageCaption && (
234+ < figcaption css = { captionStyles } >
235+ { image . imageCaption }
236+ </ figcaption >
237+ ) }
238+ </ figure >
239+ </ li >
240+ ) ;
241+ } ) }
242+ </ ul >
243+ </ a >
223244
224245 { slideshowImageCount > 1 && (
225- < div css = { navigationStyles ( hasNavigationBackgroundColour ) } >
246+ < div
247+ className = "slideshow-carousel-footer"
248+ css = { navigationStyles ( hasNavigationBackgroundColour ) }
249+ >
226250 < div css = { scrollingDotStyles } >
227251 < SlideshowCarouselScrollingDots
228252 total = { slideshowImageCount }
@@ -266,6 +290,6 @@ export const SlideshowCarousel = ({
266290 </ div >
267291 </ div >
268292 ) }
269- </ div >
293+ </ >
270294 ) ;
271295} ;
0 commit comments