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 audio duration to card models and use in audio pill #13114

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading