Skip to content

Commit 1adbeb5

Browse files
authored
Merge pull request #14247 from guardian/doml/section-colours
Add section colours for Pillar sections
2 parents a964e13 + 5a97cd7 commit 1adbeb5

File tree

2 files changed

+138
-11
lines changed

2 files changed

+138
-11
lines changed

dotcom-rendering/src/components/FrontSection.tsx

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,40 @@ type Props = {
9898
const width = (columns: number, columnWidth: number, columnGap: number) =>
9999
`width: ${columns * columnWidth + (columns - 1) * columnGap}px;`;
100100

101+
const borderColourStyles = (title?: string): string => {
102+
switch (title) {
103+
case 'News':
104+
return schemePalette('--section-border-news');
105+
case 'Opinion':
106+
return schemePalette('--section-border-opinion');
107+
case 'Sport':
108+
return schemePalette('--section-border-sport');
109+
case 'Lifestyle':
110+
return schemePalette('--section-border-lifestyle');
111+
case 'Culture':
112+
return schemePalette('--section-border-culture');
113+
default:
114+
return schemePalette('--section-border-primary');
115+
}
116+
};
117+
118+
const articleSectionTitleStyles = (title?: string): string => {
119+
switch (title) {
120+
case 'News':
121+
return schemePalette('--article-section-title-news');
122+
case 'Opinion':
123+
return schemePalette('--article-section-title-opinion');
124+
case 'Sport':
125+
return schemePalette('--article-section-title-sport');
126+
case 'Lifestyle':
127+
return schemePalette('--article-section-title-lifestyle');
128+
case 'Culture':
129+
return schemePalette('--article-section-title-culture');
130+
default:
131+
return schemePalette('--article-section-title');
132+
}
133+
};
134+
101135
/** Not all browsers support CSS grid, so we set explicit width as a fallback */
102136
const fallbackStyles = css`
103137
@supports not (display: grid) {
@@ -401,10 +435,10 @@ const bottomPaddingBetaContainer = (
401435
}
402436
`;
403437

404-
const primaryLevelTopBorder = css`
438+
const primaryLevelTopBorder = (title?: string) => css`
405439
grid-row: 1;
406440
grid-column: 1 / -1;
407-
border-top: 2px solid ${schemePalette('--section-border-primary')};
441+
border-top: 2px solid ${borderColourStyles(title)};
408442
/** Ensures the top border sits above the side borders */
409443
z-index: 1;
410444
height: fit-content;
@@ -590,7 +624,7 @@ export const FrontSection = ({
590624
css={[
591625
containerLevel === 'Secondary'
592626
? secondaryLevelTopBorder
593-
: primaryLevelTopBorder,
627+
: primaryLevelTopBorder(title),
594628
]}
595629
/>
596630
)}
@@ -629,9 +663,7 @@ export const FrontSection = ({
629663
? schemePalette(
630664
'--article-section-secondary-title',
631665
)
632-
: schemePalette(
633-
'--article-section-title',
634-
)
666+
: articleSectionTitleStyles(title)
635667
}
636668
// On paid fronts the title is not treated as a link
637669
url={!isOnPaidContentFront ? url : undefined}

dotcom-rendering/src/paletteDeclarations.ts

Lines changed: 100 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3064,10 +3064,65 @@ const articleSectionBackgroundDark: PaletteFunction = () =>
30643064

30653065
const articleSectionTitleLight: PaletteFunction = () =>
30663066
sourcePalette.neutral[0];
3067-
30683067
const articleSectionTitleDark: PaletteFunction = () =>
30693068
sourcePalette.neutral[86];
30703069

3070+
const articleSectionTitleNewsLight: PaletteFunction = () =>
3071+
sourcePalette.neutral[7];
3072+
const articleSectionTitleNewsDark: PaletteFunction = () =>
3073+
sourcePalette.neutral[86];
3074+
3075+
const articleSectionTitleOpinionLight: PaletteFunction = () =>
3076+
sourcePalette.opinion[400];
3077+
const articleSectionTitleOpinionDark: PaletteFunction = () =>
3078+
sourcePalette.opinion[500];
3079+
3080+
const articleSectionTitleSportLight: PaletteFunction = () =>
3081+
sourcePalette.sport[400];
3082+
const articleSectionTitleSportDark: PaletteFunction = () =>
3083+
sourcePalette.sport[500];
3084+
3085+
const articleSectionTitleLifestyleLight: PaletteFunction = () =>
3086+
sourcePalette.lifestyle[400];
3087+
const articleSectionTitleLifestyleDark: PaletteFunction = () =>
3088+
sourcePalette.lifestyle[450];
3089+
3090+
const articleSectionTitleCultureLight: PaletteFunction = () =>
3091+
sourcePalette.culture[400];
3092+
const articleSectionTitleCultureDark: PaletteFunction = () =>
3093+
sourcePalette.culture[450];
3094+
3095+
const sectionBorderPrimaryLight: PaletteFunction = () =>
3096+
sourcePalette.neutral[20];
3097+
const sectionBorderPrimaryDark: PaletteFunction = () =>
3098+
sourcePalette.neutral[38];
3099+
3100+
const sectionBorderSecondaryLight: PaletteFunction = () =>
3101+
sourcePalette.neutral[73];
3102+
const sectionBorderSecondaryDark: PaletteFunction = () =>
3103+
sourcePalette.neutral[38];
3104+
3105+
const sectionBorderNewsLight: PaletteFunction = () => sourcePalette.neutral[20];
3106+
const sectionBorderNewsDark: PaletteFunction = () => sourcePalette.neutral[38];
3107+
3108+
const sectionBorderOpinionLight: PaletteFunction = () =>
3109+
sourcePalette.opinion[450];
3110+
const sectionBorderOpinionDark: PaletteFunction = () =>
3111+
sourcePalette.opinion[450];
3112+
3113+
const sectionBorderSportLight: PaletteFunction = () => sourcePalette.sport[400];
3114+
const sectionBorderSportDark: PaletteFunction = () => sourcePalette.sport[400];
3115+
3116+
const sectionBorderLifestyleLight: PaletteFunction = () =>
3117+
sourcePalette.lifestyle[400];
3118+
const sectionBorderLifestyleDark: PaletteFunction = () =>
3119+
sourcePalette.lifestyle[400];
3120+
3121+
const sectionBorderCultureLight: PaletteFunction = () =>
3122+
sourcePalette.culture[400];
3123+
const sectionBorderCultureDark: PaletteFunction = () =>
3124+
sourcePalette.culture[400];
3125+
30713126
const articleSectionSecondaryTitleLight: PaletteFunction = () =>
30723127
sourcePalette.neutral[20];
30733128

@@ -6107,6 +6162,26 @@ const paletteColours = {
61076162
light: articleSectionTitleLight,
61086163
dark: articleSectionTitleDark,
61096164
},
6165+
'--article-section-title-culture': {
6166+
light: articleSectionTitleCultureLight,
6167+
dark: articleSectionTitleCultureDark,
6168+
},
6169+
'--article-section-title-lifestyle': {
6170+
light: articleSectionTitleLifestyleLight,
6171+
dark: articleSectionTitleLifestyleDark,
6172+
},
6173+
'--article-section-title-news': {
6174+
light: articleSectionTitleNewsLight,
6175+
dark: articleSectionTitleNewsDark,
6176+
},
6177+
'--article-section-title-opinion': {
6178+
light: articleSectionTitleOpinionLight,
6179+
dark: articleSectionTitleOpinionDark,
6180+
},
6181+
'--article-section-title-sport': {
6182+
light: articleSectionTitleSportLight,
6183+
dark: articleSectionTitleSportDark,
6184+
},
61106185
'--article-text': {
61116186
light: articleTextLight,
61126187
dark: articleTextDark,
@@ -7268,13 +7343,33 @@ const paletteColours = {
72687343
light: () => sourcePalette.neutral[86],
72697344
dark: () => sourcePalette.neutral[20],
72707345
},
7346+
'--section-border-culture': {
7347+
light: sectionBorderCultureLight,
7348+
dark: sectionBorderCultureDark,
7349+
},
7350+
'--section-border-lifestyle': {
7351+
light: sectionBorderLifestyleLight,
7352+
dark: sectionBorderLifestyleDark,
7353+
},
7354+
'--section-border-news': {
7355+
light: sectionBorderNewsLight,
7356+
dark: sectionBorderNewsDark,
7357+
},
7358+
'--section-border-opinion': {
7359+
light: sectionBorderOpinionLight,
7360+
dark: sectionBorderOpinionDark,
7361+
},
72717362
'--section-border-primary': {
7272-
light: () => sourcePalette.neutral[20],
7273-
dark: () => sourcePalette.neutral[86],
7363+
light: sectionBorderPrimaryLight,
7364+
dark: sectionBorderPrimaryDark,
72747365
},
72757366
'--section-border-secondary': {
7276-
light: () => sourcePalette.neutral[73],
7277-
dark: () => sourcePalette.neutral[38],
7367+
light: sectionBorderSecondaryLight,
7368+
dark: sectionBorderSecondaryDark,
7369+
},
7370+
'--section-border-sport': {
7371+
light: sectionBorderSportLight,
7372+
dark: sectionBorderSportDark,
72787373
},
72797374
'--section-date': {
72807375
light: () => sourcePalette.news[400],

0 commit comments

Comments
 (0)