Skip to content

Commit f5b2a03

Browse files
authored
Merge pull request #13685 from guardian/doml/media-sublinks
Give sublinks grey background on media cards
2 parents 5873ef5 + bc216be commit f5b2a03

File tree

6 files changed

+127
-33
lines changed

6 files changed

+127
-33
lines changed

dotcom-rendering/fixtures/manual/trails.ts

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -439,29 +439,71 @@ export const trails: [
439439
isImmersive: false,
440440
},
441441
{
442-
url: 'https://www.theguardian.com/uk-news/2021/feb/16/qcovid-how-improved-algorithm-can-identify-more-higher-risk-adults',
442+
url: 'https://www.theguardian.com/world/video/2025/mar/06/how-nanoplastics-are-invading-our-bodies-video-report',
443443
showByline: false,
444-
byline: 'Sarah Boseley Health editor',
444+
byline: ' Neelam Tailor, Alex Healey, Ali Assaf, Steve Glew, Ryan Baxter',
445445
image: {
446-
src: 'https://media.guim.co.uk/6d152e60fdb37dbbc063a68e2cffccf97cdab183/0_40_5458_3275/master/5458.jpg',
447-
altText: 'A covid vaccine',
446+
src: 'https://media.guim.co.uk/13dd7e5c4ca32a53cd22dfd90ac1845ef5e5d643/91_0_1800_1080/master/1800.jpg',
447+
altText:
448+
'Plastics are everywhere, but their smallest fragments – nanoplastics – are making their way into the deepest parts of our bodies, including our brains and breast milk',
448449
},
449450
format: {
450451
display: ArticleDisplay.Standard,
451452
theme: Pillar.News,
452-
design: ArticleDesign.Analysis,
453+
design: ArticleDesign.Video,
453454
},
454-
webPublicationDate: '2021-02-16T18:42:44.000Z',
455-
headline:
456-
'QCovid: how improved algorithm can identify more higher-risk adults',
457-
dataLinkName: 'news | group-0 | card-@1',
455+
webPublicationDate: '2025-03-06T10:14:00.000Z',
456+
headline: 'How plastics are invading our brain cells – video',
457+
dataLinkName: 'media | group-0 | card-@11',
458458
showQuotedHeadline: false,
459-
mainMedia: undefined,
459+
mainMedia: {
460+
type: 'Video',
461+
id: '966acc06-a238-4d5f-b477-816eec0476f3',
462+
videoId: '4JUvvbpx2So',
463+
duration: 322,
464+
title: 'How plastics are invading our brain cells – video',
465+
width: 500,
466+
height: 300,
467+
origin: 'The Guardian',
468+
images: [
469+
{
470+
url: 'https://media.guim.co.uk/13dd7e5c4ca32a53cd22dfd90ac1845ef5e5d643/0_0_1920_1080/1000.jpg',
471+
width: 1000,
472+
},
473+
{
474+
url: 'https://media.guim.co.uk/13dd7e5c4ca32a53cd22dfd90ac1845ef5e5d643/0_0_1920_1080/500.jpg',
475+
width: 500,
476+
},
477+
{
478+
url: 'https://media.guim.co.uk/13dd7e5c4ca32a53cd22dfd90ac1845ef5e5d643/0_0_1920_1080/140.jpg',
479+
width: 140,
480+
},
481+
{
482+
url: 'https://media.guim.co.uk/13dd7e5c4ca32a53cd22dfd90ac1845ef5e5d643/0_0_1920_1080/1920.jpg',
483+
width: 1920,
484+
},
485+
],
486+
expired: false,
487+
},
460488
isExternalLink: false,
461489
showLivePlayable: false,
462490
discussionApiUrl,
463491
showMainVideo: true,
464492
isImmersive: false,
493+
trailText:
494+
'Plastics are everywhere, but their smallest fragments – nanoplastics – are making their way into the deepest parts of our bodies, including our brains and breast milk',
495+
supportingContent: [
496+
{
497+
format: {
498+
display: ArticleDisplay.Standard,
499+
theme: Pillar.News,
500+
design: ArticleDesign.Standard,
501+
},
502+
headline:
503+
'Edwyn Collins: ‘Could an Orange Juice reunion ever be on the cards? No!’',
504+
url: '/culture/2025/mar/06/edwyn-collins-could-an-orange-juice-reunion-ever-be-on-the-cards-no',
505+
},
506+
],
465507
},
466508
{
467509
url: 'https://www.theguardian.com/world/2019/nov/28/eu-parliament-declares-climate-emergency',

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

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,40 @@ export const WithMediaType = () => {
337337
);
338338
};
339339

340+
export const WithMediaTypeAndSublinks = () => {
341+
return (
342+
<CardGroup>
343+
<CardWrapper>
344+
<Card
345+
{...basicCardProps}
346+
format={{
347+
display: ArticleDisplay.Standard,
348+
design: ArticleDesign.Video,
349+
theme: Pillar.Sport,
350+
}}
351+
containerType="flexible/general"
352+
mainMedia={{ ...mainVideo, duration: 30 }}
353+
headlineText="Video"
354+
imagePositionOnDesktop="top"
355+
imagePositionOnMobile="left"
356+
supportingContent={[
357+
{
358+
...aBasicLink,
359+
headline: 'Headline 1',
360+
kickerText: 'Kicker',
361+
},
362+
{
363+
...aBasicLink,
364+
headline: 'Headline 2',
365+
kickerText: 'Kicker',
366+
},
367+
]}
368+
/>
369+
</CardWrapper>
370+
</CardGroup>
371+
);
372+
};
373+
340374
export const WithMediaTypeSpecialReportAlt = () => {
341375
return (
342376
<CardGroup>
@@ -1728,11 +1762,9 @@ export const WithAVerticalGapWhenScrollableSmallContainer = () => {
17281762
export const WithBetaContainerAndSublinks = () => {
17291763
return (
17301764
<CardGroup>
1731-
{/* With an image */}
17321765
<CardWrapper>
17331766
<Card
17341767
{...basicCardProps}
1735-
image={undefined}
17361768
containerType="flexible/general"
17371769
imagePositionOnMobile="bottom"
17381770
supportingContent={[
@@ -1749,10 +1781,17 @@ export const WithBetaContainerAndSublinks = () => {
17491781
]}
17501782
/>
17511783
</CardWrapper>
1752-
{/* Without an image */}
1784+
</CardGroup>
1785+
);
1786+
};
1787+
1788+
export const WithBetaContainerAndSublinksNoImage = () => {
1789+
return (
1790+
<CardGroup>
17531791
<CardWrapper>
17541792
<Card
17551793
{...basicCardProps}
1794+
image={undefined}
17561795
containerType="flexible/general"
17571796
imagePositionOnMobile="bottom"
17581797
supportingContent={[

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -688,41 +688,44 @@ export const Card = ({
688688
* - Returns `null` if `supportingContent` is unavailable or `sublinkPosition` is `none`.
689689
* - Renders `SupportingContent` for all breakpoints if `sublinkPosition` is `outer`.
690690
* - If `sublinkPosition` is `inner`, hides `SupportingContent` from tablet but displays it on smaller breakpoints.
691-
*
692691
*/
693692
const decideOuterSublinks = () => {
694693
if (!hasSublinks) return null;
695694
if (sublinkPosition === 'none') return null;
696695

697-
const OuterSublinks = () => (
696+
const Sublinks = () => (
698697
<SupportingContent
699698
supportingContent={supportingContent}
700699
containerPalette={containerPalette}
701700
alignment={supportingContentAlignment}
702701
isDynamo={isDynamo}
702+
isMedia={isMediaCard(format)}
703703
fillBackgroundOnMobile={
704704
!!isFlexSplash ||
705705
(isBetaContainer &&
706706
!!image &&
707-
imagePositionOnMobile === 'bottom')
707+
(imagePositionOnMobile === 'bottom' ||
708+
isMediaCard(format)))
708709
}
710+
fillBackgroundOnDesktop={isBetaContainer && isMediaCard(format)}
709711
/>
710712
);
711713

712714
if (sublinkPosition === 'outer') {
713-
return <OuterSublinks />;
715+
return <Sublinks />;
714716
}
715717

716718
return (
717719
<Hide from={isFlexSplash ? 'desktop' : 'tablet'}>
718-
<OuterSublinks />
720+
<Sublinks />
719721
</Hide>
720722
);
721723
};
722724

723725
const decideInnerSublinks = () => {
724726
if (!hasSublinks) return null;
725727
if (sublinkPosition !== 'inner') return null;
728+
726729
return (
727730
<Hide until={isFlexSplash ? 'desktop' : 'tablet'}>
728731
<SupportingContent
@@ -1241,7 +1244,8 @@ export const Card = ({
12411244

12421245
<div
12431246
css={
1244-
/** We allow this area to take up more space so that cards without sublinks next to cards with sublinks have the same meta alignment */
1247+
/** We allow this area to take up more space so that cards without
1248+
* sublinks next to cards with sublinks have the same meta alignment */
12451249
isBetaContainer &&
12461250
(imagePositionOnDesktop === 'left' ||
12471251
imagePositionOnDesktop === 'right') &&
@@ -1253,10 +1257,7 @@ export const Card = ({
12531257
`
12541258
}
12551259
style={{
1256-
padding:
1257-
isMediaCardOrNewsletter || isOnwardContent
1258-
? `0 ${space[2]}px`
1259-
: 0,
1260+
padding: isOnwardContent ? `0 ${space[2]}px` : 0,
12601261
}}
12611262
>
12621263
{showLivePlayable && liveUpdatesPosition === 'outer' && (
@@ -1276,6 +1277,7 @@ export const Card = ({
12761277
></LatestLinks>
12771278
</Island>
12781279
)}
1280+
12791281
{decideOuterSublinks()}
12801282

12811283
{isOpinionCardWithAvatar && (

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,18 @@ const standardCards = standards.map((card, index) => {
4646
}) satisfies DCRFrontCard;
4747

4848
switch (index + 1) {
49-
// The second card has two sublinks
5049
case 2:
5150
return enhanceCardFields({ supportingContent: getSublinks(2) });
52-
// The third card is boosted and has one sublink
5351
case 3:
5452
return enhanceCardFields({
5553
boostLevel: 'boost',
5654
supportingContent: getSublinks(1),
5755
});
58-
// The fifth card is megaboosted and has two sublinks
5956
case 5:
6057
return enhanceCardFields({
6158
boostLevel: 'megaboost',
6259
supportingContent: getSublinks(2),
6360
});
64-
6561
default:
6662
return enhanceCardFields({});
6763
}

dotcom-rendering/src/components/SupportingContent.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type Props = {
1616
alignment: Alignment;
1717
containerPalette?: DCRContainerPalette;
1818
isDynamo?: boolean;
19+
isMedia?: boolean;
1920
/** Allows sublinks container to have a background colour on mobile screen sizes */
2021
fillBackgroundOnMobile?: boolean;
2122
/** Allows sublinks container to have a background colour on desktop screen sizes */
@@ -120,19 +121,23 @@ const wrapperStyles = css`
120121
}
121122
`;
122123

123-
const backgroundFillMobile = css`
124+
const backgroundFillMobile = (isMedia: boolean) => css`
124125
${until.tablet} {
125126
padding: ${space[2]}px;
126127
padding-bottom: ${space[3]}px;
127-
background-color: ${palette('--card-sublinks-background')};
128+
background-color: ${isMedia
129+
? palette('--card-media-sublinks-background')
130+
: palette('--card-sublinks-background')};
128131
}
129132
`;
130133

131-
const backgroundFillDesktop = css`
134+
const backgroundFillDesktop = (isMedia: boolean) => css`
132135
${from.tablet} {
133136
padding: ${space[2]}px;
134137
padding-bottom: ${space[3]}px;
135-
background-color: ${palette('--card-sublinks-background')};
138+
background-color: ${isMedia
139+
? palette('--card-media-sublinks-background')
140+
: palette('--card-sublinks-background')};
136141
}
137142
`;
138143

@@ -141,6 +146,7 @@ export const SupportingContent = ({
141146
alignment,
142147
containerPalette,
143148
isDynamo,
149+
isMedia = false,
144150
fillBackgroundOnMobile = false,
145151
fillBackgroundOnDesktop = false,
146152
}: Props) => {
@@ -153,8 +159,8 @@ export const SupportingContent = ({
153159
wrapperStyles,
154160
baseGrid,
155161
(isDynamo ?? alignment === 'horizontal') && horizontalGrid,
156-
fillBackgroundOnMobile && backgroundFillMobile,
157-
fillBackgroundOnDesktop && backgroundFillDesktop,
162+
fillBackgroundOnMobile && backgroundFillMobile(isMedia),
163+
fillBackgroundOnDesktop && backgroundFillDesktop(isMedia),
158164
]}
159165
>
160166
{supportingContent.map((subLink, index) => {

dotcom-rendering/src/paletteDeclarations.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5663,6 +5663,11 @@ const cardSublinksBackgroundLight: PaletteFunction = () =>
56635663
const cardSublinksBackgroundDark: PaletteFunction = () =>
56645664
sourcePalette.neutral[10];
56655665

5666+
const cardMediaSublinksBackgroundLight: PaletteFunction = () =>
5667+
sourcePalette.neutral[97];
5668+
const cardMediaSublinksBackgroundDark: PaletteFunction = () =>
5669+
sourcePalette.neutral[20];
5670+
56665671
const latestLinksDottedLineLight: PaletteFunction = () =>
56675672
sourcePalette.neutral[60];
56685673
const latestLinksDottedLineDark: PaletteFunction = () =>
@@ -6122,6 +6127,10 @@ const paletteColours = {
61226127
light: cardMediaIconLight,
61236128
dark: cardMediaIconDark,
61246129
},
6130+
'--card-media-sublinks-background': {
6131+
light: cardMediaSublinksBackgroundLight,
6132+
dark: cardMediaSublinksBackgroundDark,
6133+
},
61256134
'--card-media-waveform': {
61266135
light: cardMediaWaveformLight,
61276136
dark: cardMediaWaveformDark,

0 commit comments

Comments
 (0)