Skip to content

Commit ac2d51d

Browse files
committed
Use correct image size for flexible layouts in half-width slots
1 parent e266ca7 commit ac2d51d

File tree

6 files changed

+41
-21
lines changed

6 files changed

+41
-21
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ export const Card = ({
835835
media.type === 'slideshow' && isFlexibleContainer
836836
}
837837
padImage={isMediaCardOrNewsletter && isBetaContainer}
838+
isBetaContainer={isBetaContainer}
838839
>
839840
{media.type === 'slideshow' &&
840841
(isFlexibleContainer ? (

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

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,36 @@ const sizingStyles = css`
1818
const flexBasisStyles = ({
1919
imageSize,
2020
imageType,
21+
isBetaContainer,
2122
}: {
2223
imageSize: ImageSizeType;
2324
imageType?: CardImageType;
25+
isBetaContainer: boolean;
2426
}): SerializedStyles => {
2527
if (imageType === 'avatar') {
2628
return css`
2729
flex-basis: 100%;
2830
`;
2931
}
32+
3033
switch (imageSize) {
3134
default:
3235
case 'small':
33-
return css`
34-
flex-basis: 75%;
35-
${between.tablet.and.desktop} {
36-
flex-basis: 60%;
37-
}
38-
${from.desktop} {
39-
flex-basis: 70%;
40-
}
41-
`;
36+
return isBetaContainer
37+
? css`
38+
${from.tablet} {
39+
flex-basis: 50%;
40+
}
41+
`
42+
: css`
43+
flex-basis: 75%;
44+
${between.tablet.and.desktop} {
45+
flex-basis: 60%;
46+
}
47+
${from.desktop} {
48+
flex-basis: 70%;
49+
}
50+
`;
4251
case 'medium':
4352
return css`
4453
${from.tablet} {
@@ -139,7 +148,7 @@ export const ContentWrapper = ({
139148
css={[
140149
sizingStyles,
141150
imageDirectionDesktop === 'horizontal' &&
142-
flexBasisStyles({ imageSize, imageType }),
151+
flexBasisStyles({ imageSize, imageType, isBetaContainer }),
143152
padContent &&
144153
!isBetaContainer &&
145154
css`

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

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type Props = {
4444
*/
4545
hideImageOverlay?: boolean;
4646
padImage?: boolean;
47+
isBetaContainer?: boolean;
4748
};
4849

4950
const imageOverlayContainerStyles = css`
@@ -81,21 +82,27 @@ const imagePaddingStyles = (
8182
*/
8283
const flexBasisStyles = ({
8384
imageSize,
85+
isBetaContainer,
8486
}: {
8587
imageSize: ImageSizeType;
88+
isBetaContainer: boolean;
8689
}): SerializedStyles => {
8790
switch (imageSize) {
8891
default:
8992
case 'small':
90-
return css`
91-
flex-basis: 25%;
92-
${between.tablet.and.desktop} {
93-
flex-basis: 40%;
94-
}
95-
${from.desktop} {
96-
flex-basis: 30%;
97-
}
98-
`;
93+
return isBetaContainer
94+
? css`
95+
flex-basis: 50%;
96+
`
97+
: css`
98+
flex-basis: 25%;
99+
${between.tablet.and.desktop} {
100+
flex-basis: 40%;
101+
}
102+
${from.desktop} {
103+
flex-basis: 30%;
104+
}
105+
`;
99106
case 'medium':
100107
return css`
101108
flex-basis: 50%;
@@ -154,6 +161,7 @@ export const ImageWrapper = ({
154161
imagePositionOnMobile,
155162
hideImageOverlay,
156163
padImage,
164+
isBetaContainer,
157165
}: Props) => {
158166
const isHorizontalOnDesktop =
159167
imagePositionOnDesktop === 'left' || imagePositionOnDesktop === 'right';
@@ -170,6 +178,7 @@ export const ImageWrapper = ({
170178
isHorizontalOnDesktop &&
171179
flexBasisStyles({
172180
imageSize,
181+
isBetaContainer: !!isBetaContainer,
173182
}),
174183
imageType === 'avatar' &&
175184
css`

dotcom-rendering/src/components/CardPicture.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ export const CardPicture = ({
206206
if (mainImage === '') {
207207
return null;
208208
}
209+
209210
const sources = generateSources(
210211
mainImage,
211212
decideImageWidths(imageSize, aspectRatio),

dotcom-rendering/src/components/FlexibleGeneral.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ const HalfWidthCardLayout = ({
549549
)}
550550
supportingContentAlignment="vertical"
551551
supportingContentPosition="outer"
552-
imageSize="medium"
552+
imageSize="small"
553553
aspectRatio={aspectRatio}
554554
kickerText={card.kickerText}
555555
showLivePlayable={false}

dotcom-rendering/src/components/FlexibleSpecial.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ const TwoOrFourCardLayout = ({
245245
)}
246246
/* we don't want to support sublinks on standard cards here so we hard code to undefined */
247247
supportingContent={undefined}
248-
imageSize="medium"
248+
imageSize="small"
249249
aspectRatio={aspectRatio}
250250
kickerText={card.kickerText}
251251
showLivePlayable={false}

0 commit comments

Comments
 (0)