Skip to content

Commit 7233f18

Browse files
committed
Use the article main media in the card footer of youtube atom feature card overlay.
This requires drilling the article main media data through to be used on the card footer
1 parent 74dc796 commit 7233f18

5 files changed

Lines changed: 38 additions & 32 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ type Props = {
6262
isNewsletter?: boolean;
6363
shouldReserveSpace?: { mobile: boolean; desktop: boolean };
6464
isStorylines?: boolean;
65+
headline?: string;
6566
};
6667

6768
export const CardFooter = ({
@@ -73,6 +74,7 @@ export const CardFooter = ({
7374
isNewsletter,
7475
shouldReserveSpace,
7576
isStorylines,
77+
headline,
7678
}: Props) => {
7779
const shouldShowBranding =
7880
format.theme === ArticleSpecial.Labs && !!cardBranding;
@@ -83,6 +85,7 @@ export const CardFooter = ({
8385
mainMedia?.type === 'Gallery' ||
8486
isNewsletter;
8587

88+
console.log(headline, shouldShowPill, mainMedia);
8689
if (shouldShowPill) {
8790
return (
8891
<footer css={contentStyles}>

dotcom-rendering/src/components/FeatureCard.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ export const FeatureCard = ({
540540
byline={byline}
541541
showByline={showByline}
542542
isLive={media.mainMedia.isLive}
543+
articleMedia={articleMainMedia}
543544
/>
544545
</Island>
545546
</div>
@@ -803,6 +804,7 @@ export const FeatureCard = ({
803804
}
804805
isNewsletter={isNewsletter}
805806
mainMedia={articleMainMedia}
807+
headline={headlineText}
806808
/>
807809

808810
{!isImmersive &&

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useCallback, useState } from 'react';
44
import type { ArticleFormat } from '../../lib/articleFormat';
55
import type { AdTargeting } from '../../types/commercial';
66
import type { AspectRatio } from '../../types/front';
7+
import type { MainMedia } from '../../types/mainMedia';
78
import type { RenderingTarget } from '../../types/renderingTarget';
89
import type { PlayButtonSize } from '../Card/components/PlayIcon';
910
import type { ResponsiveFontSize } from '../CardHeadline';
@@ -64,6 +65,7 @@ export type Props = {
6465
byline?: string;
6566
showByline?: boolean;
6667
isLive?: boolean;
68+
articleMedia?: MainMedia;
6769
};
6870

6971
/**
@@ -119,6 +121,7 @@ export const YoutubeAtom = ({
119121
byline,
120122
showByline,
121123
isLive,
124+
articleMedia,
122125
}: Props): JSX.Element => {
123126
const [overlayClicked, setOverlayClicked] = useState<boolean>(false);
124127
const [playerReady, setPlayerReady] = useState<boolean>(false);
@@ -266,6 +269,7 @@ export const YoutubeAtom = ({
266269
isImmersive={isImmersive}
267270
byline={byline}
268271
showByline={showByline}
272+
articleMedia={articleMedia}
269273
/>
270274
) : (
271275
<YoutubeAtomOverlay

dotcom-rendering/src/components/YoutubeAtom/YoutubeAtomFeatureCardOverlay.tsx

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { secondsToDuration } from '../../lib/formatTime';
1111
import { transparentColour } from '../../lib/transparentColour';
1212
import { palette } from '../../palette';
1313
import type { AspectRatio } from '../../types/front';
14+
import type { MainMedia } from '../../types/mainMedia';
1415
import { CardFooter } from '../Card/components/CardFooter';
1516
import { narrowPlayIconDiameter, PlayIcon } from '../Card/components/PlayIcon';
1617
import { TrailText } from '../Card/components/TrailText';
@@ -140,6 +141,7 @@ type Props = {
140141
isImmersive?: boolean;
141142
byline?: string;
142143
showByline?: boolean;
144+
articleMedia?: MainMedia;
143145
};
144146

145147
export const YoutubeAtomFeatureCardOverlay = ({
@@ -166,6 +168,7 @@ export const YoutubeAtomFeatureCardOverlay = ({
166168
isImmersive,
167169
byline,
168170
showByline,
171+
articleMedia,
169172
}: Props) => {
170173
const id = `youtube-overlay-${uniqueId}`;
171174
const hasDuration = !isUndefined(duration) && duration > 0;
@@ -255,38 +258,28 @@ export const YoutubeAtomFeatureCardOverlay = ({
255258
/>
256259
</div>
257260
)}
258-
259-
{isVideoArticle ? (
260-
<Pill
261-
content={
262-
<time>{secondsToDuration(duration ?? 0)}</time>
263-
}
264-
prefix="Video"
265-
icon={<SvgMediaControlsPlay width={18} />}
266-
/>
267-
) : (
268-
<CardFooter
269-
format={format}
270-
age={
271-
showCardAge ? (
272-
<FeatureCardCardAge
273-
webPublicationDate={webPublicationDate}
274-
showClock={!!showClock}
275-
serverTime={serverTime}
276-
/>
277-
) : undefined
278-
}
279-
commentCount={
280-
showCommentCount ? (
281-
<FeatureCardCommentCount
282-
linkTo={linkTo}
283-
discussionId={discussionId}
284-
discussionApiUrl={discussionApiUrl}
285-
/>
286-
) : undefined
287-
}
288-
/>
289-
)}
261+
<CardFooter
262+
format={format}
263+
age={
264+
showCardAge ? (
265+
<FeatureCardCardAge
266+
webPublicationDate={webPublicationDate}
267+
showClock={!!showClock}
268+
serverTime={serverTime}
269+
/>
270+
) : undefined
271+
}
272+
commentCount={
273+
showCommentCount ? (
274+
<FeatureCardCommentCount
275+
linkTo={linkTo}
276+
discussionId={discussionId}
277+
discussionApiUrl={discussionApiUrl}
278+
/>
279+
) : undefined
280+
}
281+
mainMedia={articleMedia}
282+
/>
290283
</div>
291284
</button>
292285
</FormatBoundary>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useAB } from '../lib/useAB';
55
import { useAdTargeting } from '../lib/useAdTargeting';
66
import type { AdTargeting } from '../types/commercial';
77
import type { AspectRatio } from '../types/front';
8+
import type { MainMedia } from '../types/mainMedia';
89
import { Caption } from './Caption';
910
import type { PlayButtonSize } from './Card/components/PlayIcon';
1011
import type { ResponsiveFontSize } from './CardHeadline';
@@ -55,6 +56,7 @@ type Props = {
5556
contentType?: string;
5657
contentLayout?: string;
5758
isLive?: boolean;
59+
articleMedia?: MainMedia;
5860
};
5961

6062
export const YoutubeBlockComponent = ({
@@ -97,6 +99,7 @@ export const YoutubeBlockComponent = ({
9799
contentType,
98100
contentLayout,
99101
isLive,
102+
articleMedia,
100103
}: Props) => {
101104
const [consentState, setConsentState] = useState<ConsentState | undefined>(
102105
undefined,
@@ -225,6 +228,7 @@ export const YoutubeBlockComponent = ({
225228
byline={byline}
226229
showByline={showByline}
227230
isLive={isLive}
231+
articleMedia={articleMedia}
228232
/>
229233
{!hideCaption && (
230234
<Caption

0 commit comments

Comments
 (0)