Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions dotcom-rendering/src/components/Masthead/Masthead.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { breakpoints } from '@guardian/source/foundations';
import type { Meta } from '@storybook/react';
import { Masthead } from './Masthead';
import { nav } from './Titlepiece/Nav.mock';
Expand All @@ -19,6 +20,15 @@ const meta = {
hasPageSkin: false,
hasPageSkinContentSelfConstrain: false,
},
parameters: {
chromatic: {
viewports: [
breakpoints.mobileMedium,
breakpoints.desktop,
breakpoints.wide,
],
},
},
} satisfies Meta<typeof Masthead>;
export default meta;

Expand Down
160 changes: 24 additions & 136 deletions dotcom-rendering/src/components/Masthead/Titlepiece/Logo.tsx
Original file line number Diff line number Diff line change
@@ -1,152 +1,40 @@
import { css } from '@emotion/react';
import { from, space, visuallyHidden } from '@guardian/source/foundations';
import { visuallyHidden } from '@guardian/source/foundations';
import { Hide, SvgGuardianLogo } from '@guardian/source/react-components';
import { nestedOphanComponents } from '../../../lib/ophan-helpers';
import { palette } from '../../../palette';
import TheWholePictureGuardianLogoSmall from '../../../static/icons/the-guardian-whole-picture-logo-small.svg';
import TheWholePictureGuardianLogo from '../../../static/icons/the-guardian-whole-picture-logo.svg';

const gridMainColumn = css`
grid-column: main-column-start / main-column-end;
`;

const veggieBurgerDiameter = 40;

const logoStyles = css`
${gridMainColumn}
grid-row: 1;
position: relative;
display: flex;
justify-self: end;
align-self: end;
margin-top: ${space[2]}px;
margin-bottom: 6px;
right: ${veggieBurgerDiameter + space[3]}px;

${from.mobileMedium} {
right: 0;
}
${from.mobileLandscape} {
margin-bottom: ${space[2]}px;
}

svg {
width: 152px;
${from.mobileMedium} {
width: 207px;
}
${from.tablet} {
width: 252px;
}
${from.desktop} {
width: 291px;
}
}
`;

const logoStylesFromLeftCol = css`
svg {
${from.leftCol} {
width: 324px;
}
}
`;

const theWholePictureStyles = css`
margin-bottom: 2px;
${from.tablet} {
margin-top: 10px;
margin-bottom: 6px;
}

svg {
height: auto;
width: 173px;
${from.tablet} {
width: 246px;
}
}
`;

const slimNavLogoOverrides = css`
position: relative;
margin-top: ${space[2]}px;
margin-bottom: ${space[2]}px;
right: ${veggieBurgerDiameter + 6}px;

${from.mobileLandscape} {
margin-top: ${space[1]}px;
margin-bottom: ${space[2]}px;
}
${from.tablet} {
right: ${space[8]}px;
}
${from.desktop} {
right: ${space[10]}px;
}
svg {
width: 130px;
${from.tablet} {
width: 86px;
}
${from.desktop} {
width: 130px;
}
${from.leftCol} {
width: 140px;
}
${from.wide} {
width: 145px;
}
}
`;

type Props = {
/**
* We are running a campaign in the US called "The Whole Picture"
* We will use a different logo for the US edition for the duration of this campaign.
*/
showWholePictureLogo: boolean;
hasPageSkin: boolean;
showSlimNav: boolean;
};

export const Logo = ({
showWholePictureLogo,
hasPageSkin,
showSlimNav,
}: Props) => (
<div
css={[
logoStyles,
!hasPageSkin && logoStylesFromLeftCol,
showWholePictureLogo && theWholePictureStyles,
showSlimNav && slimNavLogoOverrides,
]}
>
<a href="/" data-link-name={nestedOphanComponents('header', 'logo')}>
<span
css={css`
${visuallyHidden};
`}
>
The Guardian - Back to home
</span>

{showWholePictureLogo ? (
<>
<Hide from="tablet">
<TheWholePictureGuardianLogoSmall />
</Hide>
<Hide until="tablet">
<TheWholePictureGuardianLogo />
</Hide>
</>
) : (
<SvgGuardianLogo
textColor={palette('--masthead-nav-link-text')}
/>
)}
</a>
</div>
export const Logo = ({ showWholePictureLogo }: Props) => (
<a href="/" data-link-name={nestedOphanComponents('header', 'logo')}>
<span
css={css`
${visuallyHidden};
`}
>
The Guardian - Back to home
</span>

{showWholePictureLogo ? (
<>
<Hide from="tablet">
<TheWholePictureGuardianLogoSmall />
</Hide>
<Hide until="tablet">
<TheWholePictureGuardianLogo />
</Hide>
</>
) : (
<SvgGuardianLogo textColor={palette('--masthead-nav-link-text')} />
)}
</a>
);
118 changes: 111 additions & 7 deletions dotcom-rendering/src/components/Titlepiece.importable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,104 @@ const slimNavEditionSwitcherOverrides = css`
}
`;

const veggieBurgerDiameter = 40;

const logoStyles = css`
${gridMainColumn}
grid-row: 1;
position: relative;
display: flex;
justify-self: end;
align-self: end;
margin-top: ${space[2]}px;
margin-bottom: 6px;
right: ${veggieBurgerDiameter + space[3]}px;

${from.mobileMedium} {
right: 0;
}
${from.mobileLandscape} {
margin-bottom: ${space[2]}px;
}

svg {
width: 152px;
${from.mobileMedium} {
width: 207px;
}
${from.tablet} {
width: 252px;
}
${from.desktop} {
width: 291px;
}
}
`;

const logoStylesFromLeftCol = css`
svg {
${from.leftCol} {
width: 324px;
}
}
`;

const theWholePictureStyles = css`
margin-bottom: 2px;
${from.tablet} {
margin-top: 10px;
margin-bottom: 6px;
}

svg {
height: auto;
width: 173px;
${from.tablet} {
width: 246px;
}
}
`;

const slimNavLogoOverrides = css`
position: relative;
margin-top: ${space[2]}px;
margin-bottom: ${space[2]}px;
right: ${veggieBurgerDiameter + 6}px;

/** Intentionally duplicated as this needs to _override_ the standard logo styles */
${from.mobileMedium} {
right: ${veggieBurgerDiameter + 6}px;
}
${from.mobileLandscape} {
margin-top: ${space[1]}px;
margin-bottom: ${space[2]}px;
}
${from.tablet} {
right: ${space[8]}px;
}
${from.desktop} {
right: ${space[10]}px;
}
svg {
width: 130px;
${from.mobile} {
width: 130px;
}
${from.tablet} {
width: 86px;
}
${from.desktop} {
width: 130px;
}
${from.leftCol} {
width: 140px;
}
${from.wide} {
width: 145px;
}
}
`;

const pillarsNavStyles = css`
${gridContent}
grid-row: 2;
Expand Down Expand Up @@ -243,6 +341,9 @@ export const Titlepiece = ({
}: Props) => {
const { showBanner } = useEditionSwitcherBanner(pageId, editionId);

const showWholePictureLogo =
!!wholePictureLogoSwitch && !showSlimNav && editionId === 'US';

return (
<Grid
type="nav"
Expand Down Expand Up @@ -421,13 +522,16 @@ export const Titlepiece = ({
</div>

{/* Guardian logo */}
<Logo
showWholePictureLogo={
!!wholePictureLogoSwitch && editionId === 'US'
}
hasPageSkin={!!hasPageSkin}
showSlimNav={!!showSlimNav}
/>
<div
css={[
logoStyles,
!hasPageSkin && logoStylesFromLeftCol,
showSlimNav && slimNavLogoOverrides,
showWholePictureLogo && theWholePictureStyles,
]}
>
<Logo showWholePictureLogo={showWholePictureLogo} />
</div>

{/** Expanded menu checkbox */}
<input
Expand Down
Loading