Skip to content

Commit 9c3e6c1

Browse files
committed
Restrict pillar colours for sections and borders to network fronts
1 parent e74bd40 commit 9c3e6c1

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

dotcom-rendering/src/components/FrontSection.tsx

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { css } from '@emotion/react';
22
import { isString } from '@guardian/libs';
33
import { between, from, space, until } from '@guardian/source/foundations';
44
import { pageSkinContainer } from '../layouts/lib/pageSkin';
5-
import type { EditionId } from '../lib/edition';
5+
import { type EditionId, isNetworkFront } from '../lib/edition';
66
import { hideAge } from '../lib/hideAge';
77
import { palette, palette as schemePalette } from '../palette';
88
import type { CollectionBranding } from '../types/branding';
@@ -98,13 +98,21 @@ 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 => {
101+
const borderColourStyles = (
102+
title?: string,
103+
showSectionColours?: boolean,
104+
): string => {
105+
if (!showSectionColours) {
106+
return schemePalette('--section-border-primary');
107+
}
108+
102109
switch (title) {
103110
case 'News':
104111
return schemePalette('--section-border-news');
105112
case 'Opinion':
106113
return schemePalette('--section-border-opinion');
107114
case 'Sport':
115+
case 'Sports':
108116
return schemePalette('--section-border-sport');
109117
case 'Lifestyle':
110118
return schemePalette('--section-border-lifestyle');
@@ -115,13 +123,21 @@ const borderColourStyles = (title?: string): string => {
115123
}
116124
};
117125

118-
const articleSectionTitleStyles = (title?: string): string => {
126+
const articleSectionTitleStyles = (
127+
title?: string,
128+
showSectionColours?: boolean,
129+
): string => {
130+
if (!showSectionColours) {
131+
return schemePalette('--article-section-title');
132+
}
133+
119134
switch (title) {
120135
case 'News':
121136
return schemePalette('--article-section-title-news');
122137
case 'Opinion':
123138
return schemePalette('--article-section-title-opinion');
124139
case 'Sport':
140+
case 'Sports':
125141
return schemePalette('--article-section-title-sport');
126142
case 'Lifestyle':
127143
return schemePalette('--article-section-title-lifestyle');
@@ -435,10 +451,13 @@ const bottomPaddingBetaContainer = (
435451
}
436452
`;
437453

438-
const primaryLevelTopBorder = (title?: string) => css`
454+
const primaryLevelTopBorder = (
455+
title?: string,
456+
showSectionColours?: boolean,
457+
) => css`
439458
grid-row: 1;
440459
grid-column: 1 / -1;
441-
border-top: 2px solid ${borderColourStyles(title)};
460+
border-top: 2px solid ${borderColourStyles(title, showSectionColours)};
442461
/** Ensures the top border sits above the side borders */
443462
z-index: 1;
444463
height: fit-content;
@@ -591,6 +610,8 @@ export const FrontSection = ({
591610
const useLargeSpacingDesktop =
592611
!!isNextCollectionPrimary || isAboveDesktopAd;
593612

613+
const showSectionColours = isNetworkFront(pageId ?? '');
614+
594615
/**
595616
* id is being used to set the containerId in @see {ShowMore.importable.tsx}
596617
* this id pre-existed showMore so is probably also being used for something else.
@@ -624,7 +645,10 @@ export const FrontSection = ({
624645
css={[
625646
containerLevel === 'Secondary'
626647
? secondaryLevelTopBorder
627-
: primaryLevelTopBorder(title),
648+
: primaryLevelTopBorder(
649+
title,
650+
showSectionColours,
651+
),
628652
]}
629653
/>
630654
)}
@@ -663,7 +687,10 @@ export const FrontSection = ({
663687
? schemePalette(
664688
'--article-section-secondary-title',
665689
)
666-
: articleSectionTitleStyles(title)
690+
: articleSectionTitleStyles(
691+
title,
692+
showSectionColours,
693+
)
667694
}
668695
// On paid fronts the title is not treated as a link
669696
url={!isOnPaidContentFront ? url : undefined}

0 commit comments

Comments
 (0)