Skip to content

Commit 83c4f83

Browse files
committed
Give slideshow navigation background when sublinks
1 parent 8331892 commit 83c4f83

File tree

5 files changed

+65
-7
lines changed

5 files changed

+65
-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: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,13 @@ const captionStyles = css`
6969
padding: ${space[10]}px ${space[2]}px ${space[2]}px;
7070
`;
7171

72-
const navigationStyles = css`
72+
const navigationStyles = (hasBackgroundColour: boolean) => css`
7373
display: flex;
7474
align-items: center;
75-
margin-top: ${space[2]}px;
75+
padding-top: ${space[2]}px;
76+
background-color: ${hasBackgroundColour
77+
? palette('--slideshow-navigation-background')
78+
: 'transparent'};
7679
`;
7780

7881
const buttonStyles = css`
@@ -97,13 +100,17 @@ const scrollingDotStyles = css`
97100
}
98101
`;
99102

103+
type Props = {
104+
images: readonly DCRSlideshowImage[];
105+
imageSize: ImageSizeType;
106+
hasNavigationBackgroundColour: boolean;
107+
};
108+
100109
export const SlideshowCarousel = ({
101110
images,
102111
imageSize,
103-
}: {
104-
images: readonly DCRSlideshowImage[];
105-
imageSize: ImageSizeType;
106-
}) => {
112+
hasNavigationBackgroundColour,
113+
}: Props) => {
107114
const carouselRef = useRef<HTMLUListElement | null>(null);
108115
const [previousButtonEnabled, setPreviousButtonEnabled] = useState(false);
109116
const [nextButtonEnabled, setNextButtonEnabled] = useState(true);
@@ -211,7 +218,7 @@ export const SlideshowCarousel = ({
211218
</ul>
212219

213220
{slideshowImageCount > 1 && (
214-
<div css={navigationStyles}>
221+
<div css={[navigationStyles(hasNavigationBackgroundColour)]}>
215222
<div css={scrollingDotStyles}>
216223
<SlideshowCarouselScrollingDots
217224
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)