Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove decidePalette from TextBlock component #12997

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions dotcom-rendering/src/components/TextBlockComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
type ArticleFormat,
ArticleSpecial,
} from '../lib/articleFormat';
import { decidePalette } from '../lib/decidePalette';
import { getAttrs, isElement, parseHtml } from '../lib/domUtils';
import { palette as themePalette } from '../palette';
import { logger } from '../server/lib/logging';
Expand Down Expand Up @@ -228,7 +227,7 @@ const styles = (format: ArticleFormat) => css`
border-radius: 50%;
height: ${remSpace[2]};
width: ${remSpace[2]};
background-color: ${decidePalette(format).background.bullet};
background-color: ${themePalette('--textblock-bullet-background')};
}

${until.tablet} {
Expand Down
17 changes: 0 additions & 17 deletions dotcom-rendering/src/lib/decidePalette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,6 @@ const textStandfirstLink = (format: ArticleFormat): string => {
}
};

const backgroundBullet = (format: ArticleFormat): string => {
if (format.theme === ArticleSpecial.Labs) return BLACK;
if (format.theme === ArticleSpecial.SpecialReport) {
return specialReport[300];
}
if (format.design === ArticleDesign.Analysis) {
switch (format.theme) {
case Pillar.News:
return news[300];
default:
return pillarPalette[format.theme].main;
}
}
return pillarPalette[format.theme].main;
};

const backgroundBulletStandfirst = (format: ArticleFormat): string => {
if (
format.design === ArticleDesign.DeadBlog ||
Expand Down Expand Up @@ -425,7 +409,6 @@ export const decidePalette = (format: ArticleFormat): Palette => {
background: {
analysisContrast: backgroundAnalysisContrastColour(),
analysisContrastHover: backgroundAnalysisContrastHoverColour(),
bullet: backgroundBullet(format),
bulletStandfirst: backgroundBulletStandfirst(format),
filterButton: backgroundFilterButton(),
filterButtonHover: backgroundFilterButtonHover(format),
Expand Down
33 changes: 31 additions & 2 deletions dotcom-rendering/src/paletteDeclarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,33 @@ const pillarPalette = (
}
};

const textblockTextLight: PaletteFunction = (format: ArticleFormat) => {
switch (format.design) {
const textblockBulletLight: PaletteFunction = ({ theme, design }) => {
switch (theme) {
case Pillar.News: {
return design === ArticleDesign.Analysis
? sourcePalette.news[300]
: sourcePalette.news[400];
}
case Pillar.Opinion:
case Pillar.Sport:
case Pillar.Culture:
case Pillar.Lifestyle: {
return pillarPalette(theme, 400);
}
case ArticleSpecial.Labs: {
return sourcePalette.neutral[7];
}
case ArticleSpecial.SpecialReport: {
return sourcePalette.specialReport[300];
}
case ArticleSpecial.SpecialReportAlt: {
return sourcePalette.specialReportAlt[200];
}
}
};

const textblockTextLight: PaletteFunction = ({ design }) => {
switch (design) {
case ArticleDesign.Audio:
return sourcePalette.neutral[97];
default:
Expand Down Expand Up @@ -7102,6 +7127,10 @@ const paletteColours = {
light: () => sourcePalette.neutral[0],
dark: () => sourcePalette.neutral[86],
},
'--textblock-bullet-background': {
light: textblockBulletLight,
dark: textblockBulletLight,
},
'--textblock-text': {
light: textblockTextLight,
dark: textblockTextDark,
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 @@ -16,7 +16,6 @@ export type Palette = {
background: {
analysisContrast: Colour;
analysisContrastHover: Colour;
bullet: Colour;
bulletStandfirst: Colour;
filterButton: Colour;
filterButtonHover: Colour;
Expand Down
Loading