Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slideshow: allow carousel interaction in cards #12852

Merged
merged 4 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions dotcom-rendering/src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { LatestLinks } from '../LatestLinks.importable';
import { MediaDuration } from '../MediaDuration';
import { MediaMeta } from '../MediaMeta';
import { Slideshow } from '../Slideshow';
import { SlideshowCarousel } from '../SlideshowCarousel.importable';
import { Snap } from '../Snap';
import { SnapCssSandbox } from '../SnapCssSandbox';
import { StarRating } from '../StarRating/StarRating';
Expand Down Expand Up @@ -604,14 +605,35 @@ export const Card = ({
imagePositionOnDesktop={imagePositionOnDesktop}
imagePositionOnMobile={imagePositionOnMobile}
showPlayIcon={showPlayIcon}
hideImageOverlay={
media.type === 'slideshow' && isFlexibleContainer
}
>
{media.type === 'slideshow' && (
<Slideshow
images={media.slideshowImages}
imageSize={imageSize}
isDynamo={isDynamo}
/>
)}
{media.type === 'slideshow' &&
(isFlexibleContainer ? (
<div
css={css`
position: relative;
${getZIndex('card-nested-link')}
`}
>
<Island
priority="feature"
defer={{ until: 'visible' }}
>
<SlideshowCarousel
images={media.slideshowImages}
imageSize={imageSize}
/>
</Island>
</div>
) : (
<Slideshow
images={media.slideshowImages}
imageSize={imageSize}
isDynamo={isDynamo}
/>
))}
{media.type === 'avatar' && (
<AvatarContainer
imageSize={imageSize}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ type Props = {
imagePositionOnDesktop: ImagePositionType;
imagePositionOnMobile: ImagePositionType;
showPlayIcon: boolean;
/**
* Forces hiding the image overlay added to pictures & slideshows on hover.
* This is to allow hiding the overlay on slideshow carousels where we don't
* want it to be shown whilst retaining it for existing slideshows.
*/
hideImageOverlay?: boolean;
};

/**
Expand Down Expand Up @@ -117,6 +123,7 @@ export const ImageWrapper = ({
imagePositionOnDesktop,
imagePositionOnMobile,
showPlayIcon,
hideImageOverlay,
}: Props) => {
const isHorizontalOnDesktop =
imagePositionOnDesktop === 'left' || imagePositionOnDesktop === 'right';
Expand Down Expand Up @@ -168,9 +175,8 @@ export const ImageWrapper = ({
<>
{children}
{/* This image overlay is styled when the CardLink is hovered */}
{(imageType === 'picture' || imageType === 'slideshow') && (
<div className="image-overlay" />
)}
{(imageType === 'picture' || imageType === 'slideshow') &&
!hideImageOverlay && <div className="image-overlay" />}
jamesmockett marked this conversation as resolved.
Show resolved Hide resolved
{imageType === 'picture' && showPlayIcon && (
<PlayIcon
imageSize={imageSize}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { breakpoints, space } from '@guardian/source/foundations';
import type { Meta, StoryObj } from '@storybook/react';
import type { ReactNode } from 'react';
import type { DCRSlideshowImage } from '../types/front';
import { SlideshowCarousel } from './SlideshowCarousel';
import { SlideshowCarousel } from './SlideshowCarousel.importable';

const meta = {
component: SlideshowCarousel,
Expand Down
Loading