Skip to content

Commit d6eceb7

Browse files
authored
Fix hover state on card branding (#14602)
* prevent hover state at card level applying when hovering on inner card link * ensures link stays on top of the card content to allow click through to the configured brand URL
1 parent a27156c commit d6eceb7

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export const CardBranding = ({
8383
data-testid="card-branding-logo"
8484
data-component={dataAttributes?.ophanComponentName}
8585
data-link-name={dataAttributes?.ophanComponentLink}
86+
className="branding-logo"
8687
>
8788
<picture>
8889
{darkModeAvailable && branding.logoForDarkBackground && (

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ const hoverStyles = css`
5858
:has(
5959
ul.sublinks:hover,
6060
.loop-video-container:hover,
61-
.slideshow-carousel:hover
61+
.slideshow-carousel:hover,
62+
.branding-logo:hover
6263
) {
6364
.card-headline .show-underline {
6465
text-decoration: none;

dotcom-rendering/src/components/SponsoredContentLabel.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
visuallyHidden,
66
} from '@guardian/source/foundations';
77
import { decideBrandingLogo } from '../lib/decideLogo';
8+
import { getZIndex } from '../lib/getZIndex';
89
import { palette } from '../palette';
910
import type { Branding } from '../types/branding';
1011
import type { DCRContainerPalette } from '../types/front';
@@ -52,6 +53,11 @@ const verticalStyles = {
5253
`,
5354
};
5455

56+
const linkStyles = css`
57+
/* See: https://css-tricks.com/nested-links/ */
58+
z-index: ${getZIndex('card-nested-link')};
59+
`;
60+
5561
/**
5662
* Component used to display "paid for" label alonside the sponsor logo
5763
* for a particular set of branding
@@ -90,13 +96,15 @@ export const SponsoredContentLabel = ({
9096
: 'This content has been paid for by an advertiser and produced by the Guardian Labs team.'}
9197
</span>
9298
<a
99+
css={linkStyles}
93100
href={logo.link}
94101
data-sponsor={branding.sponsorName.toLowerCase()}
95102
rel="nofollow"
96103
aria-label={`Visit the ${branding.sponsorName} website`}
97104
data-testid="branding-logo"
98105
data-component={ophanComponentName}
99106
data-link-name={ophanComponentLink}
107+
className="branding-logo"
100108
>
101109
<picture>
102110
{darkModeAvailable && branding.logoForDarkBackground && (

0 commit comments

Comments
 (0)