Skip to content

Commit 5a97cd7

Browse files
committed
refactor
1 parent 08fc679 commit 5a97cd7

File tree

1 file changed

+35
-29
lines changed

1 file changed

+35
-29
lines changed

dotcom-rendering/src/components/FrontSection.tsx

Lines changed: 35 additions & 29 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) {
@@ -404,21 +438,10 @@ const bottomPaddingBetaContainer = (
404438
const primaryLevelTopBorder = (title?: string) => css`
405439
grid-row: 1;
406440
grid-column: 1 / -1;
441+
border-top: 2px solid ${borderColourStyles(title)};
407442
/** Ensures the top border sits above the side borders */
408443
z-index: 1;
409444
height: fit-content;
410-
411-
border-top: 2px solid ${schemePalette('--section-border-primary')};
412-
${title === 'News' &&
413-
`border-top: 2px solid ${schemePalette('--section-border-news')};`}
414-
${title === 'Opinion' &&
415-
`border-top: 2px solid ${schemePalette('--section-border-opinion')};`}
416-
${title === 'Sport' &&
417-
`border-top: 2px solid ${schemePalette('--section-border-sport')};`}
418-
${title === 'Lifestyle' &&
419-
`border-top: 2px solid ${schemePalette('--section-border-lifestyle')};`}
420-
${title === 'Culture' &&
421-
`border-top: 2px solid ${schemePalette('--section-border-culture')};`}
422445
`;
423446

424447
const secondaryLevelTopBorder = css`
@@ -436,23 +459,6 @@ const carouselNavigationPlaceholder = css`
436459
}
437460
`;
438461

439-
const articleSectionTitleStyles = (title?: string): string => {
440-
switch (title) {
441-
case 'News':
442-
return schemePalette('--article-section-title-news');
443-
case 'Opinion':
444-
return schemePalette('--article-section-title-opinion');
445-
case 'Sport':
446-
return schemePalette('--article-section-title-sport');
447-
case 'Lifestyle':
448-
return schemePalette('--article-section-title-lifestyle');
449-
case 'Culture':
450-
return schemePalette('--article-section-title-culture');
451-
default:
452-
return schemePalette('--article-section-title');
453-
}
454-
};
455-
456462
/**
457463
* # Front Container
458464
*

0 commit comments

Comments
 (0)