Skip to content

Commit fe250a5

Browse files
committed
Add HostedContentHeader story and wrap the component in Stuck
1 parent 95bb5b1 commit fe250a5

File tree

3 files changed

+53
-14
lines changed

3 files changed

+53
-14
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { palette as sourcePalette } from '@guardian/source/foundations';
2+
import { HostedContentHeader } from './HostedContentHeader';
3+
import { Section } from './Section';
4+
5+
export default {
6+
component: HostedContentHeader,
7+
title: 'Components/HostedContentHeader',
8+
};
9+
10+
export const Default = () => {
11+
return (
12+
<Section
13+
fullWidth={true}
14+
showSideBorders={false}
15+
shouldCenter={false}
16+
backgroundColour={sourcePalette.neutral[7]}
17+
padSides={false}
18+
element="aside"
19+
>
20+
<HostedContentHeader
21+
accentColor={sourcePalette.brand[400]}
22+
branding="Branding"
23+
/>
24+
</Section>
25+
);
26+
};
27+
Default.storyName = 'default';

dotcom-rendering/src/components/HostedContentHeader.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const headerWrapperStyles = css`
2424
position: relative;
2525
display: flex;
2626
justify-content: space-between;
27-
width: 100vw;
27+
width: 100%;
2828
margin: 0 auto;
2929
padding: 0;
3030
height: ${HOSTED_CONTENT_HEIGHT_MOBILE}rem;
@@ -41,13 +41,18 @@ const headerWrapperStyles = css`
4141
${from.leftCol} {
4242
max-width: 71.25rem;
4343
}
44+
45+
${from.wide} {
46+
max-width: 81.25rem;
47+
}
4448
`;
4549

4650
const hostedByStyles = css`
4751
${textSansBold12};
4852
margin-right: -9px;
4953
letter-spacing: 0.03125rem;
50-
color: rgba(255, 255, 255, 0.5);
54+
color: ${sourcePalette
55+
.neutral[73]}; // This is rgba in frontend but stylelint fails in CI as we should use source. Using neutral that passes AAA contrast instead.
5156
5257
${from.tablet} {
5358
${textSansBold14};
@@ -58,15 +63,14 @@ const logoStyles = css`
5863
position: relative;
5964
display: flex;
6065
align-self: end;
61-
margin-right: 0.625rem;
6266
margin-bottom: 1px;
6367
6468
svg {
6569
width: 94px;
6670
height: auto;
6771
6872
${from.tablet} {
69-
width: 125px;
73+
width: 120px;
7074
}
7175
}
7276
`;
@@ -86,6 +90,7 @@ export const Right = ({ children }: { children: React.ReactNode }) => (
8690
css={css`
8791
display: flex;
8892
padding: ${space[1]}px 10px;
93+
margin-right: 0.625rem;
8994
`}
9095
>
9196
{children}

dotcom-rendering/src/layouts/HostedArticleLayout.tsx

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { css } from '@emotion/react';
22
import { palette as sourcePalette } from '@guardian/source/foundations';
33
import { HostedContentHeader } from '../components/HostedContentHeader';
4+
import { Section } from '../components/Section';
45
import { grid } from '../grid';
56
import type { RenderingTarget } from '../types/renderingTarget';
7+
import { Stuck } from './lib/stickiness';
68

79
interface Props {
810
renderingTarget: RenderingTarget;
@@ -24,16 +26,21 @@ export const HostedArticleLayout = (props: WebProps | AppProps) => {
2426
return (
2527
<>
2628
{props.renderingTarget === 'Web' ? (
27-
<div
28-
css={css`
29-
background-color: ${sourcePalette.neutral[7]};
30-
`}
31-
>
32-
<HostedContentHeader
33-
accentColor="#1b1f71"
34-
branding="logo"
35-
/>
36-
</div>
29+
<Stuck>
30+
<Section
31+
fullWidth={true}
32+
showSideBorders={false}
33+
shouldCenter={false}
34+
backgroundColour={sourcePalette.neutral[7]}
35+
padSides={false}
36+
element="aside"
37+
>
38+
<HostedContentHeader
39+
accentColor="#1b1f71"
40+
branding="logo"
41+
/>
42+
</Section>
43+
</Stuck>
3744
) : null}
3845
<main>
3946
<header css={[grid.container]}>

0 commit comments

Comments
 (0)