Skip to content

Commit 23b9708

Browse files
committed
Don't fix podcast image width when card is horizontal
1 parent 16b8706 commit 23b9708

File tree

3 files changed

+45
-25
lines changed

3 files changed

+45
-25
lines changed

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

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -227,33 +227,37 @@ const HorizontalDivider = () => (
227227
/>
228228
);
229229

230-
const podcastImageStyles = (imageSize: MediaSizeType) => {
231-
switch (imageSize) {
232-
case 'small':
233-
return css`
234-
width: 69px;
235-
height: 69px;
236-
${from.tablet} {
237-
width: 98px;
238-
height: 98px;
239-
}
240-
`;
241-
242-
case 'medium':
243-
return css`
230+
const podcastImageStyles = (
231+
fixImageWidth: boolean,
232+
imagePositionOnDesktop: MediaPositionType,
233+
) => {
234+
if (fixImageWidth) {
235+
return css`
236+
width: 69px;
237+
height: 69px;
238+
${from.tablet} {
244239
width: 98px;
245240
height: 98px;
246-
${from.tablet} {
247-
width: 120px;
248-
height: 120px;
249-
}
250-
`;
251-
default:
252-
return css`
241+
}
242+
`;
243+
}
244+
245+
if (
246+
imagePositionOnDesktop === 'top' ||
247+
imagePositionOnDesktop === 'bottom'
248+
) {
249+
return css`
250+
width: 98px;
251+
height: 98px;
252+
${from.tablet} {
253253
width: 120px;
254254
height: 120px;
255-
`;
255+
}
256+
`;
256257
}
258+
259+
// Don't fix the image width if the image is horizontal on desktop
260+
return undefined;
257261
};
258262

259263
const getMedia = ({
@@ -908,8 +912,9 @@ export const Card = ({
908912
mediaPositionOnMobile={mediaPositionOnMobile}
909913
fixImageWidth={
910914
fixImageWidth ??
911-
(mediaPositionOnMobile === 'left' ||
912-
mediaPositionOnMobile === 'right')
915+
(!isBetaContainer &&
916+
(mediaPositionOnMobile === 'left' ||
917+
mediaPositionOnMobile === 'right'))
913918
}
914919
hideImageOverlay={media.type === 'slideshow'}
915920
padMedia={isMediaCardOrNewsletter && isBetaContainer}
@@ -1119,7 +1124,12 @@ export const Card = ({
11191124
{media.type === 'podcast' && (
11201125
<>
11211126
{media.podcastImage?.src && !showKickerImage ? (
1122-
<div css={podcastImageStyles(mediaSize)}>
1127+
<div
1128+
css={podcastImageStyles(
1129+
!!fixImageWidth,
1130+
mediaPositionOnDesktop,
1131+
)}
1132+
>
11231133
<CardPicture
11241134
mainImage={media.podcastImage.src}
11251135
imageSize="small"

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,15 @@ export const MediaWrapper = ({
213213
mediaSize,
214214
isBetaContainer,
215215
}),
216+
mediaType === 'podcast' &&
217+
isHorizontalOnDesktop &&
218+
!fixImageWidth &&
219+
css`
220+
flex-basis: 120px;
221+
${from.desktop} {
222+
flex-basis: 168px;
223+
}
224+
`,
216225
mediaType === 'avatar' &&
217226
css`
218227
display: flex;

dotcom-rendering/src/components/ScrollableSmall.importable.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export const ScrollableSmall = ({
104104
showTopBarMobile={mobileBottomCards.includes(index)}
105105
canPlayInline={false}
106106
showLabsRedesign={showLabsRedesign}
107+
fixImageWidth={true}
107108
/>
108109
</ScrollableCarousel.Item>
109110
);

0 commit comments

Comments
 (0)