Skip to content

Commit ebd3e91

Browse files
Puzzle Page Print only Logo
1 parent fb5ebcd commit ebd3e91

2 files changed

Lines changed: 51 additions & 26 deletions

File tree

dotcom-rendering/src/layouts/PuzzlePageLayout.tsx

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { GridItem } from '../components/GridItem';
2020
import { HeaderAdSlot } from '../components/HeaderAdSlot';
2121
import { Island } from '../components/Island';
2222
import { Masthead } from '../components/Masthead/Masthead';
23+
import { Logo } from '../components/Masthead/Titlepiece/Logo';
2324
import { PrintButton } from '../components/PrintButton.island';
2425
import { Rows } from '../components/PuzzleCard';
2526
import { PuzzleIframe } from '../components/PuzzleIframe.island';
@@ -300,6 +301,32 @@ const maxWidth = css`
300301
}
301302
`;
302303

304+
/**
305+
* The real `Masthead` (sign-in state, edition switcher, pillar nav links)
306+
* is hidden entirely for print (see `data-print-layout="hide"` below) -
307+
* none of that is meaningful on a printed page, and its blue background
308+
* would waste ink. This is a standalone, print-only stand-in: just the
309+
* logo, in black, on white. `display: none` on screen; `print.css` flips
310+
* it to visible only for `@media print`.
311+
*/
312+
const printOnlyLogoContainerStyles = css`
313+
display: none;
314+
padding: ${remSpace[2]} 0;
315+
316+
svg {
317+
width: 180px;
318+
fill: #000000;
319+
}
320+
`;
321+
322+
const printOnlyLogoStyles = css`
323+
display: flex;
324+
flex-direction: row;
325+
justify-content: flex-end;
326+
align-items: flex-end;
327+
padding-top: ${remSpace[6]};
328+
`;
329+
303330
const frameContainerStyles = css`
304331
margin-top: 16px;
305332
margin-bottom: 16px;
@@ -496,7 +523,7 @@ export const PuzzlePageLayout = ({
496523
</Stuck>
497524
)}
498525

499-
<div data-print-layout="masthead-print-mono">
526+
<div data-print-layout="hide">
500527
<Masthead
501528
nav={puzzleNAV}
502529
editionId={editionId}
@@ -522,6 +549,15 @@ export const PuzzlePageLayout = ({
522549
/>
523550
</div>
524551

552+
<div
553+
data-print-layout="print-only"
554+
css={printOnlyLogoContainerStyles}
555+
>
556+
<div css={printOnlyLogoStyles}>
557+
<Logo />
558+
</div>
559+
</div>
560+
525561
<div data-print-layout="hide">
526562
{renderAds && hasSurveyAd && (
527563
<AdSlot
@@ -542,15 +578,13 @@ export const PuzzlePageLayout = ({
542578
<div>
543579
<PuzzleGrid>
544580
<GridItem area="title" element="aside">
545-
<div data-print-layout="masthead-print-mono">
546-
<ArticleTitle
547-
format={puzzlePageFormat}
548-
tags={puzzleFamilyTag}
549-
sectionLabel={labelText}
550-
sectionUrl={`puzzles-and-games/${puzzleConfig.puzzleGroup}`}
551-
guardianBaseURL={GUARDIAN_BASE_URL}
552-
/>
553-
</div>
581+
<ArticleTitle
582+
format={puzzlePageFormat}
583+
tags={puzzleFamilyTag}
584+
sectionLabel={labelText}
585+
sectionUrl={`puzzles-and-games/${puzzleConfig.puzzleGroup}`}
586+
guardianBaseURL={GUARDIAN_BASE_URL}
587+
/>
554588
</GridItem>
555589
<GridItem area="headline">
556590
<div css={maxWidth}>

dotcom-rendering/src/static/css/print.css

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,13 @@
33
color: #000000;
44
}
55

6-
[data-print-layout='show-background'] {
7-
print-color-adjust: exact;
8-
-webkit-print-color-adjust: exact;
9-
}
10-
116
/*
12-
* The Masthead's logo/top-bar/nav text is white by design, meant to sit on
13-
* the dark blue masthead background. Browsers don't print background
14-
* colours by default (ink-saving "economy" print mode), so without this
15-
* override the white text/logo would be invisible on the white page - this
16-
* swaps those tokens to black for print instead of forcing the blue
17-
* background to print (product direction: no ink-heavy background, just a
18-
* legible black logo/nav on white).
7+
* The reverse of `hide`: elements that only make sense on a printed page
8+
* (e.g. a print-only black-on-white logo standing in for the real, hidden
9+
* Masthead - sign-in state/edition switcher/pillar nav aren't meaningful on
10+
* paper, and the Masthead's blue background wastes ink). Kept `display:
11+
* none` outside of print by the element's own styles.
1912
*/
20-
[data-print-layout='masthead-print-mono'] {
21-
--masthead-top-bar-text: #000000;
22-
--masthead-top-bar-link-text: #000000;
23-
--masthead-nav-link-text: #000000;
13+
[data-print-layout='print-only'] {
14+
display: block !important;
2415
}

0 commit comments

Comments
 (0)