Skip to content

Commit

Permalink
fix(RichLink): ensure correct avatar colour
Browse files Browse the repository at this point in the history
Rich links may not share the same format
as the article that they are on, so we need
to override the CSS custom properties when
there is an Avatar, e.g. on Opinion pieces.
  • Loading branch information
mxdvl committed Oct 23, 2023
1 parent dfd8061 commit 5c034bd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions dotcom-rendering/src/components/RichLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
textSans,
} from '@guardian/source-foundations';
import { decidePalette } from '../lib/decidePalette';
import { paletteDeclarations } from '../palette';
import ArrowInCircle from '../static/icons/arrow-in-circle.svg';
import type { Palette } from '../types/palette';
import type { TagType } from '../types/tag';
Expand Down Expand Up @@ -160,7 +161,7 @@ const byline = css`
}
`;

const contributorImageWrapper = css`
const contributorImageWrapper = (format: ArticleFormat) => css`
width: 5rem;
height: 5rem;
margin-left: auto;
Expand All @@ -170,6 +171,11 @@ const contributorImageWrapper = css`
height: 8.5rem;
}
${paletteDeclarations(format, 'light').join('')}
@media (prefers-color-scheme: dark) {
${paletteDeclarations(format, 'dark').join('')}
}
/* TODO remove the default img styling in ArticleBody.tsx - do we need direct element styling? */
img {
width: 100%;
Expand Down Expand Up @@ -311,7 +317,7 @@ export const RichLink = ({
)}
</div>
{!!(isOpinion && contributorImage) && (
<div css={contributorImageWrapper}>
<div css={contributorImageWrapper(format)}>
<Avatar
src={contributorImage}
alt={mainContributor}
Expand Down

0 comments on commit 5c034bd

Please sign in to comment.