Skip to content

Commit fb0f74f

Browse files
authored
Fix labs front containers for pageskins (#15077)
1 parent 4c25252 commit fb0f74f

File tree

3 files changed

+76
-18
lines changed

3 files changed

+76
-18
lines changed

dotcom-rendering/src/components/FrontSection.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,9 @@ const labsSectionHeaderStyles = css`
487487
grid-row: headline;
488488
grid-column: title;
489489
margin-top: ${space[2]}px;
490+
`;
491+
492+
const labsSectionHeaderStylesFromLeftCol = css`
490493
${from.leftCol} {
491494
grid-row: content;
492495
grid-column: title;
@@ -698,11 +701,17 @@ export const FrontSection = ({
698701
/>
699702

700703
{isLabs ? (
701-
<div css={labsSectionHeaderStyles}>
704+
<div
705+
css={[
706+
labsSectionHeaderStyles,
707+
!hasPageSkin && labsSectionHeaderStylesFromLeftCol,
708+
]}
709+
>
702710
<LabsSectionHeader
703711
title={title}
704712
url={url}
705713
editionId={editionId}
714+
hasPageSkin={hasPageSkin}
706715
/>
707716
</div>
708717
) : (

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const meta = {
1515
title: 'Container Title',
1616
url: '/',
1717
editionId: 'AU',
18+
hasPageSkin: false,
1819
},
1920
render: (args) => (
2021
<div
@@ -53,3 +54,19 @@ export const WithDetailsOpen: Story = {
5354
);
5455
},
5556
};
57+
58+
export const WithPageSkin: Story = {
59+
args: {
60+
hasPageSkin: true,
61+
},
62+
render: (args) => (
63+
<div
64+
css={css`
65+
margin: 20px auto 100px;
66+
width: 600px;
67+
`}
68+
>
69+
<LabsSectionHeader {...args} />
70+
</div>
71+
),
72+
};

dotcom-rendering/src/components/LabsSectionHeader.tsx

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
space,
66
textSans14,
77
textSansBold15,
8-
until,
98
} from '@guardian/source/foundations';
109
import {
1110
Link,
@@ -26,6 +25,7 @@ type Props = {
2625
url?: string;
2726
/** The ID of the edition, used to construct the Labs front URL */
2827
editionId: EditionId;
28+
hasPageSkin: boolean;
2929
};
3030

3131
const headerStyles = css`
@@ -36,6 +36,9 @@ const headerStyles = css`
3636
display: flex;
3737
flex-grow: 1;
3838
flex-direction: row;
39+
`;
40+
41+
const headerStylesFromLeftCol = css`
3942
${from.leftCol} {
4043
flex-direction: column;
4144
}
@@ -47,15 +50,22 @@ const logoStyles = css`
4750

4851
const dividerStylesUntilLeftCol = css`
4952
position: relative;
50-
${until.leftCol} {
51-
margin-right: ${space[4]}px;
53+
margin-right: ${space[4]}px;
54+
::after {
55+
content: '';
56+
position: absolute;
57+
top: 0;
58+
bottom: 0;
59+
right: -${space[2]}px;
60+
border-right: 1px solid ${schemePalette('--section-border')};
61+
}
62+
`;
63+
64+
const dividerStylesFromLeftCol = css`
65+
${from.leftCol} {
66+
margin-right: unset;
5267
::after {
53-
content: '';
54-
position: absolute;
55-
top: 0;
56-
bottom: 0;
57-
right: -${space[2]}px;
58-
border-right: 1px solid ${schemePalette('--section-border')};
68+
display: none;
5969
}
6070
}
6171
`;
@@ -76,7 +86,9 @@ const labelAndAboutStyles = css`
7686
display: flex;
7787
flex-direction: row;
7888
justify-content: space-between;
89+
`;
7990

91+
const labelAndAboutStylesFromLeftCol = css`
8092
${between.leftCol.and.wide} {
8193
flex-direction: column;
8294
}
@@ -90,15 +102,17 @@ const labelStyles = css`
90102
const aboutStyles = css`
91103
justify-self: end;
92104
${textSans14}
105+
`;
93106

107+
const aboutStylesFromLeftCol = css`
94108
${between.leftCol.and.wide} {
95109
margin-top: ${space[1]}px;
96110
}
97111
`;
98112

99-
const positionStyles = css`
113+
const positionStyles = (hasPageSkin: boolean) => css`
100114
right: 0;
101-
${from.leftCol} {
115+
${!hasPageSkin && from.leftCol} {
102116
left: 0;
103117
right: auto;
104118
}
@@ -113,9 +127,20 @@ const detailsStyles = css`
113127
}
114128
`;
115129

116-
export const LabsSectionHeader = ({ title, url, editionId }: Props) => (
117-
<div css={headerStyles}>
118-
<div css={[logoStyles, dividerStylesUntilLeftCol]}>
130+
export const LabsSectionHeader = ({
131+
title,
132+
url,
133+
editionId,
134+
hasPageSkin,
135+
}: Props) => (
136+
<div css={[headerStyles, !hasPageSkin && headerStylesFromLeftCol]}>
137+
<div
138+
css={[
139+
logoStyles,
140+
dividerStylesUntilLeftCol,
141+
!hasPageSkin && dividerStylesFromLeftCol,
142+
]}
143+
>
119144
<Link
120145
href={`https://www.theguardian.com/guardian-labs${getLabsUrlSuffix(
121146
editionId,
@@ -126,13 +151,20 @@ export const LabsSectionHeader = ({ title, url, editionId }: Props) => (
126151
</div>
127152

128153
<div css={textLayoutStyles}>
129-
<div css={labelAndAboutStyles}>
154+
<div
155+
css={[
156+
labelAndAboutStyles,
157+
!hasPageSkin && labelAndAboutStylesFromLeftCol,
158+
]}
159+
>
130160
<span css={labelStyles}>Paid content</span>
131-
<div css={aboutStyles}>
161+
<div
162+
css={[aboutStyles, !hasPageSkin && aboutStylesFromLeftCol]}
163+
>
132164
<Details
133165
label="About"
134166
labelSize="xsmall"
135-
positionStyles={positionStyles}
167+
positionStyles={positionStyles(hasPageSkin)}
136168
>
137169
<div css={detailsStyles}>
138170
<p>

0 commit comments

Comments
 (0)