Skip to content

Commit 4da7365

Browse files
committed
fix: background colour on hover no longer covers padding of card
1 parent bce9042 commit 4da7365

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,8 @@ const baseCardStyles = css`
4242

4343
const hoverStyles = css`
4444
:hover .image-overlay {
45-
position: absolute;
46-
top: 0;
4745
width: 100%;
4846
height: 100%;
49-
left: 0;
5047
background-color: ${palette('--card-background-hover')};
5148
}
5249

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,17 @@ type Props = {
4444
padImage?: boolean;
4545
};
4646

47+
const imageOverlayContainerStyles = css`
48+
position: absolute;
49+
top: 0;
50+
left: 0;
51+
width: 100%;
52+
height: 100%;
53+
`;
54+
4755
/**
4856
* This function works in partnership with its sibling in `ContentWrapper`. If you
4957
* change any values here be sure to update that file as well.
50-
*
5158
*/
5259
const flexBasisStyles = ({
5360
imageSize,
@@ -179,7 +186,18 @@ export const ImageWrapper = ({
179186
{children}
180187
{/* This image overlay is styled when the CardLink is hovered */}
181188
{(imageType === 'picture' || imageType === 'slideshow') &&
182-
!hideImageOverlay && <div className="image-overlay" />}
189+
!hideImageOverlay && (
190+
<div
191+
css={[
192+
imageOverlayContainerStyles,
193+
padImage && imagePadding,
194+
]}
195+
>
196+
{/* This child div is needed as the hover background colour covers the padded
197+
area around the image when the hover styles are applied to the top-level div */}
198+
<div className="image-overlay" />
199+
</div>
200+
)}
183201
</>
184202
</div>
185203
);

dotcom-rendering/src/components/FeatureCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ const hoverStyles = css`
6666
:hover .image-overlay {
6767
position: absolute;
6868
top: 0;
69+
left: 0;
6970
width: 100%;
7071
height: 100%;
71-
left: 0;
7272
background-color: ${palette('--card-background-hover')};
7373
}
7474

dotcom-rendering/src/components/FlexibleGeneral.stories.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ export const TwoSublinkSplash: Story = {
182182
groupedTrails: {
183183
...defaultGroupedTrails,
184184
splash: [{ ...splashCard, supportingContent: getSublinks(2) }],
185-
standard: standardCards,
186185
},
187186
},
188187
};
@@ -198,7 +197,6 @@ export const FourSublinkSplash: Story = {
198197
groupedTrails: {
199198
...defaultGroupedTrails,
200199
splash: [splashWithFourSublinks],
201-
standard: standardCards,
202200
},
203201
},
204202
};
@@ -273,7 +271,6 @@ export const FourSublinkSplashWithLiveUpdates: Story = {
273271
groupedTrails: {
274272
...defaultGroupedTrails,
275273
splash: [liveUpdatesCard],
276-
standard: standardCards,
277274
},
278275
},
279276
render: ({ frontSectionTitle, ...args }) => {
@@ -303,7 +300,6 @@ export const BoostedSplash: Story = {
303300
boostLevel: 'boost',
304301
},
305302
],
306-
standard: standardCards,
307303
},
308304
},
309305
};
@@ -320,7 +316,6 @@ export const MegaBoostedSplash: Story = {
320316
boostLevel: 'megaboost',
321317
},
322318
],
323-
standard: standardCards,
324319
},
325320
},
326321
};
@@ -337,7 +332,6 @@ export const GigaBoostedSplash: Story = {
337332
boostLevel: 'gigaboost',
338333
},
339334
],
340-
standard: standardCards,
341335
},
342336
},
343337
};

0 commit comments

Comments
 (0)