Skip to content

Commit a04af74

Browse files
authored
Merge pull request #13670 from guardian/doml/slideshow-box
Give slideshow navigation background colour
2 parents f45c8e9 + 146300a commit a04af74

File tree

5 files changed

+69
-7
lines changed

5 files changed

+69
-7
lines changed

dotcom-rendering/src/components/Card/Card.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,9 @@ export const Card = ({
856856
<SlideshowCarousel
857857
images={media.slideshowImages}
858858
imageSize={imageSize}
859+
hasNavigationBackgroundColour={
860+
!!hasSublinks
861+
}
859862
/>
860863
</Island>
861864
</div>

dotcom-rendering/src/components/FlexibleGeneral.stories.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,45 @@ export const DefaultSplashWithLiveUpdates: Story = {
409409
},
410410
};
411411

412+
const slideshowCard = {
413+
...liveUpdatesCard,
414+
mainMedia: undefined,
415+
slideshowImages: [
416+
{
417+
imageSrc:
418+
'https://media.guim.co.uk/68333e95233d9c68b32b56c12205c5ded94dfbf8/0_117_4791_2696/1000.jpg',
419+
},
420+
{
421+
imageSrc:
422+
'https://media.guim.co.uk/77e960298d4339e047eac5c1986d0f3214f6285d/419_447_4772_2863/master/4772.jpg',
423+
},
424+
{
425+
imageSrc:
426+
'https://media.guim.co.uk/df5aea6391e21b5a5d2d25fd9aad81d497f99d42/0_45_3062_1837/master/3062.jpg',
427+
},
428+
{
429+
imageSrc:
430+
'https://media.guim.co.uk/5ebec1a8d662f0da39887dae16e4b2720379246e/0_0_5000_3000/master/5000.jpg',
431+
},
432+
{
433+
imageSrc:
434+
'https://media.guim.co.uk/77e960298d4339e047eac5c1986d0f3214f6285d/419_447_4772_2863/master/4772.jpg',
435+
},
436+
],
437+
} satisfies DCRFrontCard;
438+
439+
export const DefaultSplashWithLiveUpdatesAndSlideshow: Story = {
440+
name: 'Standard splash with live updates and slideshow',
441+
args: {
442+
frontSectionTitle: 'Standard splash with live updates and slideshow',
443+
groupedTrails: {
444+
...defaultGroupedTrails,
445+
446+
splash: [{ ...slideshowCard }],
447+
},
448+
},
449+
};
450+
412451
export const BoostedSplashWithLiveUpdates: Story = {
413452
name: 'Boosted splash with live updates',
414453
args: {

dotcom-rendering/src/components/SlideshowCarousel.importable.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
from,
44
space,
55
textSansBold12,
6+
until,
67
width,
78
} from '@guardian/source/foundations';
89
import type { ThemeButton } from '@guardian/source/react-components';
@@ -69,10 +70,16 @@ const captionStyles = css`
6970
padding: ${space[10]}px ${space[2]}px ${space[2]}px;
7071
`;
7172

72-
const navigationStyles = css`
73+
const navigationStyles = (hasBackgroundColour: boolean) => css`
7374
display: flex;
7475
align-items: center;
75-
margin-top: ${space[2]}px;
76+
padding-top: ${space[2]}px;
77+
78+
${until.tablet} {
79+
background-color: ${hasBackgroundColour
80+
? palette('--slideshow-navigation-background')
81+
: 'transparent'};
82+
}
7683
`;
7784

7885
const buttonStyles = css`
@@ -97,13 +104,17 @@ const scrollingDotStyles = css`
97104
}
98105
`;
99106

107+
type Props = {
108+
images: readonly DCRSlideshowImage[];
109+
imageSize: ImageSizeType;
110+
hasNavigationBackgroundColour: boolean;
111+
};
112+
100113
export const SlideshowCarousel = ({
101114
images,
102115
imageSize,
103-
}: {
104-
images: readonly DCRSlideshowImage[];
105-
imageSize: ImageSizeType;
106-
}) => {
116+
hasNavigationBackgroundColour,
117+
}: Props) => {
107118
const carouselRef = useRef<HTMLUListElement | null>(null);
108119
const [previousButtonEnabled, setPreviousButtonEnabled] = useState(false);
109120
const [nextButtonEnabled, setNextButtonEnabled] = useState(true);
@@ -211,7 +222,7 @@ export const SlideshowCarousel = ({
211222
</ul>
212223

213224
{slideshowImageCount > 1 && (
214-
<div css={navigationStyles}>
225+
<div css={navigationStyles(hasNavigationBackgroundColour)}>
215226
<div css={scrollingDotStyles}>
216227
<SlideshowCarouselScrollingDots
217228
total={slideshowImageCount}

dotcom-rendering/src/components/SlideshowCarousel.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ const meta = {
9090
args: {
9191
images,
9292
imageSize: 'medium',
93+
hasNavigationBackgroundColour: false,
9394
},
9495
render: (args) => (
9596
<Wrapper>

dotcom-rendering/src/paletteDeclarations.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7143,6 +7143,14 @@ const paletteColours = {
71437143
light: slideshowCaptionLight,
71447144
dark: slideshowCaptionDark,
71457145
},
7146+
/**
7147+
* The background colour should match the background colour of the
7148+
* sublinks when there is at least one sublink present.
7149+
*/
7150+
'--slideshow-navigation-background': {
7151+
light: cardSublinksBackgroundLight,
7152+
dark: cardSublinksBackgroundDark,
7153+
},
71467154
'--slideshow-pagination-dot': {
71477155
light: slideshowPaginationDotLight,
71487156
dark: slideshowPaginationDotDark,

0 commit comments

Comments
 (0)