Skip to content

Commit 5993924

Browse files
authored
Crosswords: improved print layout (#13632)
* Ensure clue list gradient hidden when printed * Update Section to support hiding from print layout * Hide scroll depth marker elements in print layout * Add explanatory comment to print scroll depth marker style
1 parent 756667e commit 5993924

File tree

5 files changed

+26
-10
lines changed

5 files changed

+26
-10
lines changed

dotcom-rendering/src/components/CrosswordComponent.importable.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ const Layout: CrosswordProps['Layout'] = ({
181181
background-image: none;
182182
}
183183
}
184+
@media print {
185+
max-height: none;
186+
::after {
187+
background-image: none;
188+
}
189+
}
184190
`}
185191
>
186192
<div

dotcom-rendering/src/components/ElementContainer.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ type Props = {
5757
containerName?: string;
5858
hasPageSkin?: boolean;
5959
hasPageSkinContentSelfConstrain?: boolean;
60+
hideFromPrintLayout?: boolean;
6061
};
6162

6263
/**
@@ -83,12 +84,14 @@ export const ElementContainer = ({
8384
containerName,
8485
hasPageSkin = false,
8586
hasPageSkinContentSelfConstrain = false,
87+
hideFromPrintLayout = false,
8688
}: Props) =>
8789
jsx(element, {
8890
id: ophanComponentName,
8991
'data-link-name': ophanComponentLink,
9092
'data-component': ophanComponentName,
9193
'data-container-name': containerName,
94+
'data-print-layout': hideFromPrintLayout ? 'hide' : undefined,
9295
style: {
9396
backgroundColor: backgroundColour,
9497
},

dotcom-rendering/src/components/Section.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ type Props = {
107107
/** When there is a page skin in some special cases we still want the container to take full
108108
* width but the content to constrain itself e.g. Header */
109109
hasPageSkinContentSelfConstrain?: boolean;
110+
/** Defaults to `false`. Indicates section should be hidden when printed */
111+
hideFromPrintLayout?: boolean;
110112
/**
111113
* @deprecated Do not use
112114
*
@@ -254,6 +256,7 @@ export const Section = ({
254256
shouldCenter,
255257
hasPageSkin = false,
256258
hasPageSkinContentSelfConstrain = false,
259+
hideFromPrintLayout = false,
257260
className,
258261
}: Props) => {
259262
if (fullWidth) {
@@ -279,6 +282,7 @@ export const Section = ({
279282
hasPageSkinContentSelfConstrain={
280283
hasPageSkinContentSelfConstrain
281284
}
285+
hideFromPrintLayout={hideFromPrintLayout}
282286
>
283287
{children}
284288
</ElementContainer>
@@ -302,6 +306,7 @@ export const Section = ({
302306
innerBackgroundColour={innerBackgroundColour}
303307
hasPageSkin={hasPageSkin}
304308
hasPageSkinContentSelfConstrain={hasPageSkinContentSelfConstrain}
309+
hideFromPrintLayout={hideFromPrintLayout}
305310
>
306311
<Flex>
307312
<LeftColumn

dotcom-rendering/src/layouts/CrosswordLayout.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ export const CrosswordLayout = (props: Props) => {
165165
<main data-layout="InteractiveLayout">
166166
<Section
167167
fullWidth={true}
168-
data-print-layout="hide"
169168
showTopBorder={false}
170169
backgroundColour={themePalette('--article-background')}
171170
borderColour={themePalette('--article-border')}
@@ -359,6 +358,7 @@ export const CrosswordLayout = (props: Props) => {
359358
showTopBorder={false}
360359
padSides={false}
361360
backgroundColour={themePalette('--article-background')}
361+
hideFromPrintLayout={true}
362362
>
363363
<StraightLines
364364
count={4}
@@ -407,13 +407,13 @@ export const CrosswordLayout = (props: Props) => {
407407
<Section
408408
fullWidth={true}
409409
sectionId="comments"
410-
data-print-layout="hide"
411410
element="section"
412411
backgroundColour={themePalette(
413412
'--discussion-section-background',
414413
)}
415414
borderColour={themePalette('--article-border')}
416415
fontColour={themePalette('--discussion-text')}
416+
hideFromPrintLayout={true}
417417
>
418418
<DiscussionLayout
419419
discussionApiUrl={article.config.discussionApiUrl}
@@ -436,7 +436,6 @@ export const CrosswordLayout = (props: Props) => {
436436
{renderAds && (
437437
<Section
438438
fullWidth={true}
439-
data-print-layout="hide"
440439
padSides={false}
441440
showTopBorder={false}
442441
showSideBorders={false}
@@ -452,12 +451,7 @@ export const CrosswordLayout = (props: Props) => {
452451
</main>
453452

454453
{props.NAV.subNavSections && (
455-
<Section
456-
fullWidth={true}
457-
data-print-layout="hide"
458-
padSides={false}
459-
element="aside"
460-
>
454+
<Section fullWidth={true} padSides={false} element="aside">
461455
<Island priority="enhancement" defer={{ until: 'visible' }}>
462456
<SubNav
463457
subNavSections={props.NAV.subNavSections}
@@ -470,7 +464,6 @@ export const CrosswordLayout = (props: Props) => {
470464

471465
<Section
472466
fullWidth={true}
473-
data-print-layout="hide"
474467
padSides={false}
475468
backgroundColour={sourcePalette.brand[400]}
476469
borderColour={sourcePalette.brand[600]}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,12 @@
22
display: none !important;
33
color: #000000;
44
}
5+
6+
/**
7+
* Hide scroll depth markers when printing as these are absolutely positioned
8+
* based on the initial content height and are still present when content has
9+
* been hidden in the print layout, causing blank pages to be printed.
10+
*/
11+
.scroll-depth-marker {
12+
display: none;
13+
}

0 commit comments

Comments
 (0)