Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for podcast image i n Picture.tsx #12568

Merged
merged 17 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions dotcom-rendering/src/components/Picture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ import type { Loading } from './CardPicture';

export type Orientation = 'portrait' | 'landscape';

type PictureRoleType =
| RoleType
// Custom image role types that are used but do not come from CAPI / FE
| 'podcastCover';

type Props = {
role: RoleType;
role: PictureRoleType;
format: ArticleFormat;
master: string;
alt: string;
Expand Down Expand Up @@ -54,7 +59,7 @@ const decideImageWidths = ({
isLightbox,
orientation,
}: {
role: RoleType;
role: PictureRoleType;
isMainMedia?: boolean;
format: ArticleFormat;
isLightbox: boolean;
Expand Down Expand Up @@ -163,6 +168,11 @@ const decideImageWidths = ({
case 'supporting':
case 'halfWidth':
return [{ breakpoint: breakpoints.mobile, width: 445 }];
case 'podcastCover':
return [
{ breakpoint: breakpoints.mobile, width: 140 },
{ breakpoint: breakpoints.wide, width: 219 },
];
case 'inline':
default:
return [
Expand Down
43 changes: 41 additions & 2 deletions dotcom-rendering/src/layouts/StandardLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { MostViewedFooterData } from '../components/MostViewedFooterData.importa
import { MostViewedFooterLayout } from '../components/MostViewedFooterLayout';
import { MostViewedRightWithAd } from '../components/MostViewedRightWithAd.importable';
import { OnwardsUpper } from '../components/OnwardsUpper.importable';
import { Picture } from '../components/Picture';
import { RightColumn } from '../components/RightColumn';
import { Section } from '../components/Section';
import { SlotBodyEnd } from '../components/SlotBodyEnd.importable';
Expand Down Expand Up @@ -120,7 +121,7 @@ const StandardGrid = ({
? css`
grid-template-areas:
'title border headline headline .'
'. border disclaimer disclaimer right-column'
'image border disclaimer disclaimer right-column'
'meta border media media right-column'
'meta border standfirst standfirst right-column'
'. border body body right-column'
Expand Down Expand Up @@ -163,7 +164,7 @@ const StandardGrid = ({
? css`
grid-template-areas:
'title border headline .'
'. border disclaimer right-column'
'image border disclaimer right-column'
'meta border media right-column'
'meta border standfirst right-column'
'meta border body right-column'
Expand Down Expand Up @@ -209,6 +210,7 @@ const StandardGrid = ({
'disclaimer right-column'
'media right-column'
'standfirst right-column'
'image right-column'
'meta right-column'
'body right-column'
'. right-column';
Expand Down Expand Up @@ -248,6 +250,7 @@ const StandardGrid = ({
'disclaimer'
'media'
'standfirst'
'image'
'meta'
'body';
`
Expand Down Expand Up @@ -287,6 +290,7 @@ const StandardGrid = ({
'disclaimer'
'media'
'standfirst'
'image'
'meta'
'body';
`
Expand Down Expand Up @@ -344,6 +348,20 @@ const stretchLines = css`
}
`;

const podcastResponsiveCoverImage = css`
img {
width: 140px;
height: 140px;
}
margin: 0.375rem 0 0.375rem 0;
${from.wide} {
img {
width: 219px;
height: 219px;
}
}
`;

const starWrapper = css`
background-color: ${themePalette('--star-rating-background')};
color: ${themePalette('--star-rating-fill')};
Expand Down Expand Up @@ -417,6 +435,8 @@ export const StandardLayout = (props: WebProps | AppProps) => {

const renderAds = isWeb && canRenderAds(article);

const podcastSeries = article.tags.find((tag) => tag.type === 'Series');
arelra marked this conversation as resolved.
Show resolved Hide resolved

return (
<>
{isWeb && (
Expand Down Expand Up @@ -736,6 +756,25 @@ export const StandardLayout = (props: WebProps | AppProps) => {
</>
)}
</GridItem>
{format.design === ArticleDesign.Audio &&
podcastSeries && (
<GridItem area="image" element="aside">
<div css={podcastResponsiveCoverImage}>
<Picture
role={'podcastCover'}
format={format}
master={
podcastSeries.podcast?.image ??
''
}
alt={podcastSeries.title}
height={1}
width={1}
loading="lazy"
/>
</div>
</GridItem>
)}
<GridItem area="body">
{isWeb && (
<Hide from="leftCol">
Expand Down
Loading