Skip to content

Commit 32e8a4c

Browse files
authored
Merge pull request #14829 from guardian/doml/refactor-image-overlay
Refactor image overlay
2 parents e2268c3 + 5d17400 commit 32e8a4c

File tree

7 files changed

+24
-22
lines changed

7 files changed

+24
-22
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ export const Card = ({
896896
mediaType={media.type}
897897
mediaPositionOnDesktop={mediaPositionOnDesktop}
898898
mediaPositionOnMobile={mediaPositionOnMobile}
899-
hideImageOverlay={media.type === 'slideshow'}
899+
hideMediaOverlay={media.type === 'slideshow'}
900900
padMedia={isMediaCardOrNewsletter && isBetaContainer}
901901
isBetaContainer={isBetaContainer}
902902
isSmallCard={isSmallCard}

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const baseCardStyles = css`
4242
`;
4343

4444
const hoverStyles = css`
45-
:hover .image-overlay {
45+
:hover .media-overlay {
4646
width: 100%;
4747
height: 100%;
4848
background-color: ${palette('--card-background-hover')};
@@ -53,8 +53,10 @@ const hoverStyles = css`
5353
text-decoration: underline;
5454
}
5555
56-
/** We want to prevent the general hover styles applying when
57-
a click won't result in navigating to the main article */
56+
/**
57+
* We want to prevent the general hover styles applying when
58+
* a click won't result in navigating to the main article
59+
*/
5860
:has(
5961
ul.sublinks:hover,
6062
.loop-video-container:hover,
@@ -64,7 +66,7 @@ const hoverStyles = css`
6466
.card-headline .show-underline {
6567
text-decoration: none;
6668
}
67-
.image-overlay {
69+
.media-overlay {
6870
background-color: transparent;
6971
}
7072
}
@@ -95,7 +97,7 @@ const onwardContentStyles = css`
9597
border-radius: ${space[2]}px;
9698
overflow: hidden;
9799
98-
:hover .image-overlay {
100+
:hover .media-overlay {
99101
border-radius: ${space[2]}px;
100102
}
101103
`;

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ type Props = {
3636
* This is to allow hiding the overlay on slideshow carousels where we don't
3737
* want it to be shown whilst retaining it for existing slideshows.
3838
*/
39-
hideImageOverlay?: boolean;
39+
hideMediaOverlay?: boolean;
4040
isBetaContainer: boolean;
4141
isSmallCard: boolean;
4242
padMedia?: boolean;
4343
};
4444

45-
const imageOverlayContainerStyles = css`
45+
const mediaOverlayContainerStyles = css`
4646
position: absolute;
4747
top: 0;
4848
left: 0;
@@ -203,7 +203,7 @@ export const MediaWrapper = ({
203203
mediaType,
204204
mediaPositionOnDesktop,
205205
mediaPositionOnMobile,
206-
hideImageOverlay,
206+
hideMediaOverlay,
207207
isBetaContainer,
208208
isSmallCard,
209209
padMedia,
@@ -269,10 +269,10 @@ export const MediaWrapper = ({
269269
{children}
270270
{/* This image overlay is styled when the CardLink is hovered */}
271271
{(mediaType === 'picture' || mediaType === 'slideshow') &&
272-
!hideImageOverlay && (
272+
!hideMediaOverlay && (
273273
<div
274274
css={[
275-
imageOverlayContainerStyles,
275+
mediaOverlayContainerStyles,
276276
padMedia &&
277277
mediaPaddingStyles(
278278
mediaPositionOnDesktop,
@@ -282,7 +282,7 @@ export const MediaWrapper = ({
282282
>
283283
{/* This child div is needed as the hover background colour covers the padded
284284
area around the image when the hover styles are applied to the top-level div */}
285-
<div className="image-overlay" />
285+
<div className="media-overlay" />
286286
</div>
287287
)}
288288
</>

dotcom-rendering/src/components/FeatureCard.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const baseCardStyles = css`
7373
`;
7474

7575
const hoverStyles = css`
76-
:hover .image-overlay {
76+
:hover .media-overlay {
7777
position: absolute;
7878
top: 0;
7979
left: 0;
@@ -94,7 +94,7 @@ const sublinkHoverStyles = css`
9494
.card-headline .show-underline {
9595
text-decoration: none;
9696
}
97-
.image-overlay {
97+
.media-overlay {
9898
background-color: transparent;
9999
}
100100
}
@@ -536,8 +536,8 @@ export const FeatureCard = ({
536536
</>
537537
)}
538538

539-
{/* This image overlay is styled when the CardLink is hovered */}
540-
<div className="image-overlay" />
539+
{/* This overlay is styled when the CardLink is hovered */}
540+
<div className="media-overlay" />
541541

542542
<div
543543
css={[

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const container = css`
7474
`;
7575

7676
const hoverStyles = css`
77-
:hover .image-overlay {
77+
:hover .media-overlay {
7878
position: absolute;
7979
bottom: 0;
8080
right: 0;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const HighlightsCardImage = ({
6161
isCircular={false}
6262
aspectRatio="1:1"
6363
/>
64-
<div className="image-overlay" />
64+
<div className="media-overlay" />
6565
</div>
6666
);
6767
}
@@ -76,8 +76,8 @@ export const HighlightsCardImage = ({
7676
isCircular={true}
7777
aspectRatio="1:1"
7878
/>
79-
{/* This image overlay is styled when the CardLink is hovered */}
80-
<div className="image-overlay circular" />
79+
{/* This overlay is styled when the CardLink is hovered */}
80+
<div className="media-overlay circular" />
8181
</div>
8282
);
8383
}

dotcom-rendering/src/components/YoutubeAtom/YoutubeAtomFeatureCardOverlay.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const buttonStyles = css`
3939
`;
4040

4141
const hoverStyles = css`
42-
:hover .image-overlay {
42+
:hover .media-overlay {
4343
position: absolute;
4444
top: 0;
4545
width: 100%;
@@ -209,7 +209,7 @@ export const YoutubeAtomFeatureCardOverlay = ({
209209
/>
210210
</div>
211211
) : null}
212-
<div className="image-overlay" />
212+
<div className="media-overlay" />
213213
<div css={playIconStyles}>
214214
<PlayIcon iconWidth="narrow" />
215215
</div>

0 commit comments

Comments
 (0)