Skip to content

Commit

Permalink
Remove decidePalette from ArticleHeadline (#12378)
Browse files Browse the repository at this point in the history
* Remove `decidePalette` from `ArticleHeadline`

* Add alias for series title match text
  • Loading branch information
jamesmockett committed Sep 17, 2024
1 parent 8b50fcb commit 904c552
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
6 changes: 3 additions & 3 deletions dotcom-rendering/src/components/ArticleHeadline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
} from '@guardian/source/foundations';
import { interactiveLegacyClasses } from '../layouts/lib/interactiveLegacyStyling';
import { getAgeWarning } from '../lib/age-warning';
import { decidePalette } from '../lib/decidePalette';
import { getZIndex } from '../lib/getZIndex';
import { palette as themePalette } from '../palette';
import type { TagType } from '../types/tag';
Expand Down Expand Up @@ -371,7 +370,6 @@ export const ArticleHeadline = ({
hasAvatar,
isMatch,
}: Props) => {
const palette = decidePalette(format);
switch (format.display) {
case ArticleDisplay.Immersive: {
switch (format.design) {
Expand Down Expand Up @@ -764,7 +762,9 @@ export const ArticleHeadline = ({
: headlineFont(format),
css`
color: ${isMatch
? palette.text.headlineWhenMatch
? themePalette(
'--headline-match-colour',
)
: themePalette(
'--headline-colour',
)};
Expand Down
12 changes: 0 additions & 12 deletions dotcom-rendering/src/lib/decidePalette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ArticleDesign, ArticleSpecial, Pillar } from '@guardian/libs';
import { brandAltBackground, palette } from '@guardian/source/foundations';
// Here is the one place where we use `pillarPalette`
import { pillarPalette_DO_NOT_USE as pillarPalette } from '../lib/pillars';
import { palette as themePalette } from '../palette';
import type { Palette } from '../types/palette';
import { transparentColour } from './transparentColour';

Expand All @@ -22,16 +21,6 @@ const {
const WHITE = neutral[100];
const BLACK = neutral[7];

const textHeadlineWhenMatch = (format: ArticleFormat): string => {
switch (format.design) {
case ArticleDesign.MatchReport:
case ArticleDesign.LiveBlog:
return BLACK;
default:
return themePalette('--series-title-text');
}
};

const textStandfirst = (format: ArticleFormat): string => {
if (format.design === ArticleDesign.LiveBlog) return WHITE;
if (format.design === ArticleDesign.Picture) return palette.neutral[86];
Expand Down Expand Up @@ -444,7 +433,6 @@ const textExpandableAtomHover = (format: ArticleFormat) => {
export const decidePalette = (format: ArticleFormat): Palette => {
return {
text: {
headlineWhenMatch: textHeadlineWhenMatch(format),
standfirst: textStandfirst(format),
standfirstLink: textStandfirstLink(format),
disclaimerLink: textDisclaimerLink(format),
Expand Down
11 changes: 11 additions & 0 deletions dotcom-rendering/src/palette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ const headlineTextDark: PaletteFunction = ({ design, display, theme }) => {
}
}
};

const headlineMatchTextLight: PaletteFunction = (format) =>
seriesTitleMatchTextLight(format);

const headlineMatchTextDark: PaletteFunction = (format) =>
seriesTitleMatchTextDark(format);

const headlineBackgroundLight: PaletteFunction = ({
display,
design,
Expand Down Expand Up @@ -6229,6 +6236,10 @@ const paletteColours = {
light: headlineTextLight,
dark: headlineTextDark,
},
'--headline-match-colour': {
light: headlineMatchTextLight,
dark: headlineMatchTextDark,
},
'--highlights-card-headline': {
light: highlightsCardHeadline,
dark: highlightsCardHeadline,
Expand Down
1 change: 0 additions & 1 deletion dotcom-rendering/src/types/palette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export type Colour = string;

export type Palette = {
text: {
headlineWhenMatch: Colour;
standfirst: Colour;
standfirstLink: Colour;
disclaimerLink: Colour;
Expand Down

0 comments on commit 904c552

Please sign in to comment.