Skip to content

Commit 9ba0632

Browse files
authored
Reduce blur of avatars on fronts (#14452)
* Add a highlights-card image size type for avatar images * For avatars in the highlights container, use a 1:1 aspect ratio instead of forcing the height and width in the parent container. This prevents the image becoming distorted as avatars as actually a 6:5 ratio. * Always use a 1:1 aspect ratio for avatars
1 parent b3ba16f commit 9ba0632

File tree

2 files changed

+56
-11
lines changed

2 files changed

+56
-11
lines changed

dotcom-rendering/src/components/Avatar.tsx

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,74 @@ const decideImageWidths = (
6464
): [ImageWidthType, ...ImageWidthType[]] => {
6565
switch (imageSize) {
6666
case 'small':
67-
return [{ breakpoint: breakpoints.mobile, width: 80 }];
67+
return [
68+
{
69+
breakpoint: breakpoints.mobile,
70+
width: 80,
71+
aspectRatio: '1:1',
72+
},
73+
];
6874

6975
case 'medium':
7076
default:
7177
return [
72-
{ breakpoint: breakpoints.mobile, width: 80 },
73-
{ breakpoint: breakpoints.desktop, width: 90 },
78+
{
79+
breakpoint: breakpoints.mobile,
80+
width: 80,
81+
aspectRatio: '1:1',
82+
},
83+
{
84+
breakpoint: breakpoints.desktop,
85+
width: 90,
86+
aspectRatio: '1:1',
87+
},
7488
];
7589

7690
case 'large':
7791
return [
78-
{ breakpoint: breakpoints.mobile, width: 150 },
79-
{ breakpoint: breakpoints.tablet, width: 130 },
80-
{ breakpoint: breakpoints.desktop, width: 150 },
92+
{
93+
breakpoint: breakpoints.mobile,
94+
width: 150,
95+
aspectRatio: '1:1',
96+
},
97+
{
98+
breakpoint: breakpoints.tablet,
99+
width: 130,
100+
aspectRatio: '1:1',
101+
},
102+
{
103+
breakpoint: breakpoints.desktop,
104+
width: 150,
105+
aspectRatio: '1:1',
106+
},
81107
];
82108

83109
case 'jumbo':
84110
return [
85-
{ breakpoint: breakpoints.mobile, width: 180 },
86-
{ breakpoint: breakpoints.tablet, width: 160 },
87-
{ breakpoint: breakpoints.desktop, width: 190 },
111+
{
112+
breakpoint: breakpoints.mobile,
113+
width: 180,
114+
aspectRatio: '1:1',
115+
},
116+
{
117+
breakpoint: breakpoints.tablet,
118+
width: 160,
119+
aspectRatio: '1:1',
120+
},
121+
{
122+
breakpoint: breakpoints.desktop,
123+
width: 190,
124+
aspectRatio: '1:1',
125+
},
126+
];
127+
/* Avatars on cards in the highlights container are fixed to 98px on all breakpoints */
128+
case 'highlights-card':
129+
return [
130+
{
131+
breakpoint: breakpoints.mobile,
132+
width: 98,
133+
aspectRatio: '1:1',
134+
},
88135
];
89136
}
90137
};

dotcom-rendering/src/components/Masthead/HighlightsCardImage.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ const imageStyles = css`
1010
position: relative;
1111
align-self: flex-end;
1212
flex-shrink: 0;
13-
height: 98px;
1413
width: 98px;
15-
1614
${until.tablet} {
1715
margin-top: ${space[2]}px;
1816
}

0 commit comments

Comments
 (0)