Skip to content

Commit 477ec8d

Browse files
committed
Tweak when sublinks have a grey background
1 parent 5873ef5 commit 477ec8d

File tree

3 files changed

+56
-16
lines changed

3 files changed

+56
-16
lines changed

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: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -688,13 +688,12 @@ 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
*/
693-
const decideOuterSublinks = () => {
692+
const decideSublinks = () => {
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}
@@ -704,18 +703,22 @@ export const Card = ({
704703
!!isFlexSplash ||
705704
(isBetaContainer &&
706705
!!image &&
707-
imagePositionOnMobile === 'bottom')
706+
(imagePositionOnMobile === 'bottom' ||
707+
isMediaCard(format)))
708+
}
709+
fillBackgroundOnDesktop={
710+
isMediaCard(format) && imagePositionOnDesktop === 'top'
708711
}
709712
/>
710713
);
711714

712715
if (sublinkPosition === 'outer') {
713-
return <OuterSublinks />;
716+
return <Sublinks />;
714717
}
715718

716719
return (
717720
<Hide from={isFlexSplash ? 'desktop' : 'tablet'}>
718-
<OuterSublinks />
721+
<Sublinks />
719722
</Hide>
720723
);
721724
};
@@ -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,7 +1277,8 @@ export const Card = ({
12761277
></LatestLinks>
12771278
</Island>
12781279
)}
1279-
{decideOuterSublinks()}
1280+
1281+
{decideSublinks()}
12801282

12811283
{isOpinionCardWithAvatar && (
12821284
<CardFooter

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ const standardCards = standards.map((card, index) => {
6161
boostLevel: 'megaboost',
6262
supportingContent: getSublinks(2),
6363
});
64-
6564
default:
6665
return enhanceCardFields({});
6766
}

0 commit comments

Comments
 (0)