Skip to content

Commit 1e6472a

Browse files
committed
Support playing youtube videos in feature cards
1 parent 89f133f commit 1e6472a

15 files changed

+652
-238
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ type Props = {
5555

5656
export const CardFooter = ({
5757
format,
58+
showLivePlayable,
5859
age,
5960
commentCount,
6061
cardBranding,
61-
showLivePlayable,
6262
isVideo,
6363
videoDuration,
6464
isAudio,
@@ -107,6 +107,10 @@ export const CardFooter = ({
107107
);
108108
}
109109

110+
if (age === undefined && commentCount === undefined) {
111+
return null;
112+
}
113+
110114
return (
111115
<footer css={contentStyles}>
112116
{age}

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

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { css } from '@emotion/react';
2-
import { from, palette } from '@guardian/source/foundations';
2+
import { from, palette as sourcePalette } from '@guardian/source/foundations';
33
import type { ThemeIcon } from '@guardian/source/react-components';
4-
import { SvgMediaControlsPlay } from '@guardian/source/react-components';
4+
import { SvgMediaControlsPlay as WidePlayIcon } from '@guardian/source/react-components';
5+
import { SvgMediaControlsPlay as NarrowPlayIcon } from '../../../components/SvgMediaControlsPlay';
6+
import { palette } from '../../../palette';
57

68
export type PlayButtonSize = keyof typeof sizes;
79

@@ -10,7 +12,7 @@ const sizes = {
1012
large: { button: 80, icon: 72 },
1113
} as const satisfies Record<string, { button: number; icon: number }>;
1214

13-
const iconStyles = (
15+
const wideIconStyles = (
1416
size: PlayButtonSize,
1517
sizeOnMobile: Extract<PlayButtonSize, 'small' | 'large'>,
1618
) => css`
@@ -41,22 +43,53 @@ const iconStyles = (
4143
}
4244
`;
4345

46+
const narrowPlayIconWidth = 56;
47+
const narrowStyles = css`
48+
position: absolute;
49+
/**
50+
* Subject to change. We will wait to see how fronts editors use the
51+
* headlines and standfirsts before we decide on a final position.
52+
*/
53+
top: 35%;
54+
left: calc(50% - ${narrowPlayIconWidth / 2}px);
55+
width: ${narrowPlayIconWidth}px;
56+
height: ${narrowPlayIconWidth}px;
57+
background-color: ${palette('--feature-card-play-icon-background')};
58+
opacity: 0.7;
59+
border-radius: 50%;
60+
border: 1px solid ${palette('--feature-card-play-icon-border')};
61+
fill: ${palette('--feature-card-play-icon-fill')};
62+
`;
63+
4464
const theme = {
45-
fill: palette.neutral[100],
65+
fill: sourcePalette.neutral[100],
4666
} satisfies Partial<ThemeIcon>;
4767

4868
type Props = {
4969
iconSizeOnDesktop: PlayButtonSize;
5070
iconSizeOnMobile: PlayButtonSize;
71+
iconWidth: 'narrow' | 'wide';
5172
};
5273

53-
export const PlayIcon = ({ iconSizeOnDesktop, iconSizeOnMobile }: Props) => {
74+
export const PlayIcon = ({
75+
iconSizeOnDesktop,
76+
iconSizeOnMobile,
77+
iconWidth,
78+
}: Props) => {
5479
return (
5580
<div
5681
className="play-icon"
57-
css={[iconStyles(iconSizeOnDesktop, iconSizeOnMobile)]}
82+
css={[
83+
iconWidth === 'narrow' && narrowStyles,
84+
iconWidth === 'wide' &&
85+
wideIconStyles(iconSizeOnDesktop, iconSizeOnMobile),
86+
]}
5887
>
59-
<SvgMediaControlsPlay theme={theme} />
88+
{iconWidth === 'narrow' ? (
89+
<NarrowPlayIcon theme={theme} />
90+
) : (
91+
<WidePlayIcon theme={theme} />
92+
)}
6093
</div>
6194
);
6295
};

dotcom-rendering/src/components/DecideContainer.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ type Props = {
4545
aspectRatio: AspectRatio;
4646
sectionId: string;
4747
frontId?: string;
48+
collectionId: number;
4849
};
4950

5051
export const DecideContainer = ({
@@ -58,6 +59,7 @@ export const DecideContainer = ({
5859
aspectRatio,
5960
sectionId,
6061
frontId,
62+
collectionId,
6163
}: Props) => {
6264
// If you add a new container type which contains an MPU, you must also add it to
6365
switch (containerType) {
@@ -313,6 +315,7 @@ export const DecideContainer = ({
313315
containerPalette={containerPalette}
314316
absoluteServerTimes={absoluteServerTimes}
315317
aspectRatio={aspectRatio}
318+
collectionId={collectionId}
316319
/>
317320
</Island>
318321
);
@@ -324,6 +327,7 @@ export const DecideContainer = ({
324327
absoluteServerTimes={absoluteServerTimes}
325328
imageLoading={imageLoading}
326329
aspectRatio={aspectRatio}
330+
collectionId={collectionId}
327331
/>
328332
);
329333
default:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const cardProps: CardProps = {
3131
showPulsingDot: false,
3232
showClock: false,
3333
imageSize: 'feature',
34+
collectionId: 1,
3435
};
3536

3637
const aBasicLink = {

0 commit comments

Comments
 (0)