Skip to content

Commit

Permalink
Add audio duration to card models and use in audio pill (#13114)
Browse files Browse the repository at this point in the history
  • Loading branch information
Georges-GNM authored Jan 9, 2025
1 parent ac8a346 commit 5df7716
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions dotcom-rendering/src/components/Card/Card.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const basicCardProps: CardProps = {
showMainVideo: true,
absoluteServerTimes: true,
galleryCount: 8,
audioDuration: '20:25',
};

const aBasicLink = {
Expand Down
4 changes: 3 additions & 1 deletion dotcom-rendering/src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export type Props = {
/** A kicker image is seperate to the main media and renders as part of the kicker */
showKickerImage?: boolean;
galleryCount?: number;
audioDuration?: string;
};

const starWrapper = (cardHasImage: boolean) => css`
Expand Down Expand Up @@ -385,6 +386,7 @@ export const Card = ({
podcastImage,
showKickerImage = false,
galleryCount,
audioDuration,
}: Props) => {
const hasSublinks = supportingContent && supportingContent.length > 0;
const sublinkPosition = decideSublinkPosition(
Expand Down Expand Up @@ -464,7 +466,7 @@ export const Card = ({
>
{mainMedia?.type === 'Audio' && (
<Pill
content="0:00" // TODO: get podcast duration
content={audioDuration ?? ''}
icon={<SvgMediaControlsPlay />}
/>
)}
Expand Down
1 change: 1 addition & 0 deletions dotcom-rendering/src/components/FrontCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const FrontCard = (props: Props) => {
showMainVideo: trail.showMainVideo,
galleryCount: trail.galleryCount,
podcastImage: trail.podcastImage,
audioDuration: trail.audioDuration,
};

return Card({ ...defaultProps, ...cardProps });
Expand Down
1 change: 1 addition & 0 deletions dotcom-rendering/src/model/enhanceCards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,5 +329,6 @@ export const enhanceCards = (
}),
podcastImage,
galleryCount: faciaCard.card.galleryCount,
audioDuration: faciaCard.card.audioDuration,
};
});
9 changes: 9 additions & 0 deletions dotcom-rendering/src/model/front-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,9 @@
},
"galleryCount": {
"type": "number"
},
"audioDuration": {
"type": "string"
}
},
"required": [
Expand Down Expand Up @@ -1781,6 +1784,9 @@
},
"galleryCount": {
"type": "number"
},
"audioDuration": {
"type": "string"
}
},
"required": [
Expand Down Expand Up @@ -2532,6 +2538,9 @@
},
"galleryCount": {
"type": "number"
},
"audioDuration": {
"type": "string"
}
},
"required": [
Expand Down
3 changes: 3 additions & 0 deletions dotcom-rendering/src/model/tag-page-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,9 @@
},
"galleryCount": {
"type": "number"
},
"audioDuration": {
"type": "string"
}
},
"required": [
Expand Down
2 changes: 2 additions & 0 deletions dotcom-rendering/src/types/front.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ export type FEFrontCard = {
group: string;
isLive: boolean;
galleryCount?: number;
audioDuration?: string;
};
discussion: {
isCommentable: boolean;
Expand Down Expand Up @@ -350,6 +351,7 @@ export type DCRFrontCard = {
showMainVideo?: boolean;
galleryCount?: number;
podcastImage?: PodcastSeriesImage;
audioDuration?: string;
};

export type DCRSlideshowImage = {
Expand Down

0 comments on commit 5df7716

Please sign in to comment.