Skip to content

Commit

Permalink
Remove decidePalette from TextBlock component
Browse files Browse the repository at this point in the history
  • Loading branch information
domlander committed Dec 12, 2024
1 parent 5adba30 commit e5f02cc
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 22 deletions.
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

0 comments on commit e5f02cc

Please sign in to comment.