Skip to content

Commit 50ed3a6

Browse files
authored
Merge pull request #13318 from guardian/doml/feature-card-video
Play Youtube video within Feature Cards
2 parents 9f7fe76 + 92fcbe7 commit 50ed3a6

23 files changed

+906
-491
lines changed

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -914,12 +914,9 @@ export const Card = ({
914914
containerType ===
915915
'fixed/video'
916916
}
917-
imagePositionOnMobile={
918-
imagePositionOnMobile
919-
}
920917
//** TODO: IMPROVE THIS MAPPING */
921918
// image size defaults to small if not provided. However, if the headline size is large or greater, we want to assume the image is also large so that the play icon is correctly sized.
922-
imageSize={
919+
iconSizeOnDesktop={
923920
[
924921
'small',
925922
'medium',
@@ -929,9 +926,23 @@ export const Card = ({
929926
].includes(
930927
headlineSizes?.desktop ??
931928
'',
932-
)
929+
) || imageSize !== 'small'
933930
? 'large'
934-
: imageSize
931+
: 'small'
932+
}
933+
iconSizeOnMobile={
934+
imagePositionOnMobile ===
935+
'left' ||
936+
imagePositionOnMobile ===
937+
'right'
938+
? 'small'
939+
: 'large'
940+
}
941+
hidePillOnMobile={
942+
imagePositionOnMobile ===
943+
'left' ||
944+
imagePositionOnMobile ===
945+
'right'
935946
}
936947
enableAds={false}
937948
aspectRatio={aspectRatio}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ type Props = {
1919
const ageStyles = (colour: string) => {
2020
return css`
2121
${textSansBold12};
22-
2322
color: ${colour};
24-
2523
margin-top: -4px;
2624
2725
svg {

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}
Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
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';
5-
import type { ImagePositionType, ImageSizeType } from './ImageWrapper';
4+
import { SvgMediaControlsPlay as WidePlayIcon } from '@guardian/source/react-components';
5+
import { SvgMediaControlsPlay as NarrowPlayIcon } from '../../../components/SvgMediaControlsPlay';
6+
import { palette } from '../../../palette';
67

7-
type PlayButtonSize = keyof typeof sizes;
8+
export type PlayButtonSize = keyof typeof sizes;
89

910
const sizes = {
1011
small: { button: 40, icon: 32 },
1112
large: { button: 80, icon: 72 },
1213
} as const satisfies Record<string, { button: number; icon: number }>;
1314

14-
const iconStyles = (
15+
const wideIconStyles = (
1516
size: PlayButtonSize,
1617
sizeOnMobile: Extract<PlayButtonSize, 'small' | 'large'>,
1718
) => css`
@@ -42,48 +43,59 @@ const iconStyles = (
4243
}
4344
`;
4445

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+
4564
const theme = {
46-
fill: palette.neutral[100],
65+
fill: sourcePalette.neutral[100],
4766
} satisfies Partial<ThemeIcon>;
4867

49-
const getIconSizeOnDesktop = (imageSize: ImageSizeType) => {
50-
switch (imageSize) {
51-
case 'jumbo':
52-
case 'large':
53-
case 'podcast':
54-
case 'carousel':
55-
case 'medium':
56-
case 'feature':
57-
case 'feature-large':
58-
return 'large';
59-
case 'small':
60-
return 'small';
61-
}
62-
};
63-
64-
const getIconSizeOnMobile = (imagePositionOnMobile: ImagePositionType) =>
65-
imagePositionOnMobile === 'left' || imagePositionOnMobile === 'right'
66-
? 'small'
67-
: 'large';
68+
type Props =
69+
| {
70+
iconWidth: 'wide';
71+
iconSizeOnDesktop: PlayButtonSize;
72+
iconSizeOnMobile: PlayButtonSize;
73+
}
74+
| {
75+
iconWidth: 'narrow';
76+
iconSizeOnDesktop?: never;
77+
iconSizeOnMobile?: never;
78+
};
6879

6980
export const PlayIcon = ({
70-
imageSize,
71-
imagePositionOnMobile,
72-
}: {
73-
imageSize: ImageSizeType;
74-
imagePositionOnMobile: ImagePositionType;
75-
}) => {
81+
iconWidth,
82+
iconSizeOnDesktop,
83+
iconSizeOnMobile,
84+
}: Props) => {
7685
return (
7786
<div
7887
className="play-icon"
7988
css={[
80-
iconStyles(
81-
getIconSizeOnDesktop(imageSize),
82-
getIconSizeOnMobile(imagePositionOnMobile),
83-
),
89+
iconWidth === 'narrow' && narrowStyles,
90+
iconWidth === 'wide' &&
91+
wideIconStyles(iconSizeOnDesktop, iconSizeOnMobile),
8492
]}
8593
>
86-
<SvgMediaControlsPlay theme={theme} />
94+
{iconWidth === 'narrow' ? (
95+
<NarrowPlayIcon theme={theme} />
96+
) : (
97+
<WidePlayIcon theme={theme} />
98+
)}
8799
</div>
88100
);
89101
};

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)