Skip to content

Commit c42fe86

Browse files
committed
use ContainerTitle to ensure use of h2 consistently as well as automatically inheriting the ability to click through to the section front using the url
1 parent 256c84d commit c42fe86

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

dotcom-rendering/src/components/ContainerTitle.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type Props = {
2626
editionId?: EditionId;
2727
lightweightHeader?: boolean;
2828
containerLevel?: DCRContainerLevel;
29+
isLabs?: boolean;
2930
};
3031

3132
const linkStyles = css`
@@ -49,6 +50,11 @@ const secondaryTitleStyles = css`
4950
}
5051
`;
5152

53+
const labsTitleStyles = css`
54+
${textSansBold20};
55+
color: ${schemePalette('--labs-header-title')};
56+
`;
57+
5258
const headerStylesWithUrl = css`
5359
:hover {
5460
text-decoration: underline;
@@ -111,6 +117,7 @@ export const ContainerTitle = ({
111117
editionId,
112118
fontColour = schemePalette('--article-section-title'),
113119
containerLevel,
120+
isLabs = false,
114121
}: Props) => {
115122
if (!title) return null;
116123

@@ -135,6 +142,7 @@ export const ContainerTitle = ({
135142
containerLevel === 'Primary' && primaryTitleStyles,
136143
containerLevel === 'Secondary' &&
137144
secondaryTitleStyles,
145+
isLabs && labsTitleStyles,
138146
]}
139147
>
140148
{localisedTitle(title, editionId)}
@@ -148,6 +156,7 @@ export const ContainerTitle = ({
148156
lightweightHeader && article17,
149157
containerLevel === 'Primary' && primaryTitleStyles,
150158
containerLevel === 'Secondary' && secondaryTitleStyles,
159+
isLabs && labsTitleStyles,
151160
]}
152161
>
153162
{localisedTitle(title, editionId)}

dotcom-rendering/src/components/FrontSection.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export default {
8787
discussionApiUrl,
8888
editionId: 'UK',
8989
children: <Placeholder />,
90+
url: '/',
9091
},
9192
render: (args) => <FrontSection {...args} />,
9293
} satisfies Meta<typeof FrontSection>;

dotcom-rendering/src/components/FrontSection.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ export const FrontSection = ({
721721
showDateHeader={showDateHeader}
722722
editionId={editionId}
723723
containerLevel={containerLevel}
724+
isLabs={isLabs && showLabsRedesign}
724725
/>
725726
}
726727
collectionBranding={collectionBranding}

dotcom-rendering/src/components/LabsSectionHeader.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const meta = {
1313
title: 'Components/LabsSectionHeader',
1414
args: {
1515
title: 'Container Title',
16+
url: '/',
1617
},
1718
render: (args) => <LabsSectionHeader {...args} />,
1819
decorators: [

dotcom-rendering/src/components/LabsSectionHeader.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@ import {
44
space,
55
textSans14,
66
textSansBold15,
7-
textSansBold20,
87
until,
98
} from '@guardian/source/foundations';
109
import {
1110
LinkButton,
1211
SvgArrowRightStraight,
1312
} from '@guardian/source/react-components';
1413
import { palette as schemePalette } from '../palette';
14+
import { ContainerTitle } from './ContainerTitle';
1515
import { Details } from './Details';
1616
import { LabsLogo } from './LabsLogo';
1717

1818
type Props = {
19-
title: string;
19+
/** This text will be used as the h2 shown in the left column for the section */
20+
title?: string;
21+
/** The title can be made into a link using this property */
22+
url?: string;
2023
};
2124

2225
const headerStyles = css`
@@ -79,18 +82,13 @@ const aboutStyles = css`
7982
${textSans14}
8083
`;
8184

82-
const titleStyles = css`
83-
${textSansBold20};
84-
color: ${schemePalette('--labs-header-title')};
85-
`;
86-
8785
const detailsStyles = css`
8886
background-color: ${schemePalette('--labs-about-dropdown-background')};
8987
color: ${schemePalette('--labs-about-dropdown-text')};
9088
padding: ${space[5]}px;
9189
`;
9290

93-
export const LabsSectionHeader = ({ title }: Props) => (
91+
export const LabsSectionHeader = ({ title, url }: Props) => (
9492
<div css={headerStyles}>
9593
<div css={[logoStyles, dividerStylesUntilLeftCol]}>
9694
<LabsLogo />
@@ -133,7 +131,12 @@ export const LabsSectionHeader = ({ title }: Props) => (
133131
</div>
134132
</div>
135133

136-
<div css={titleStyles}>{title}</div>
134+
<ContainerTitle
135+
title={title}
136+
url={url}
137+
fontColour={schemePalette('--labs-header-title')}
138+
isLabs={true}
139+
/>
137140
</div>
138141
</div>
139142
);

0 commit comments

Comments
 (0)