Skip to content

Commit

Permalink
Add print styles
Browse files Browse the repository at this point in the history
  • Loading branch information
shyusu4 authored and thibaudcolas committed Feb 25, 2024
1 parent c1035b6 commit 7241fbd
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 4 deletions.
87 changes: 87 additions & 0 deletions wagtailio/static/sass/base/_print.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Print styles
// stylelint-disable declaration-no-important

@media print {
* {
background: transparent !important;
color: $color--black !important;
border-color: $color--black !important;
box-shadow: none !important;
text-shadow: none !important;
}

.header, .hero {
padding: 0 !important;
margin: 0 !important;
}

a,
a:visited {
text-decoration: underline;
}

a[href^='http']::after {
content: ' (' attr(href) ')'; // Display link URL
}

abbr[title]::after {
content: " (" attr(title) ")";
}

a[href^="#"]::after,
a[href^="javascript:"]::after {
content: "";
}

p a {
word-wrap: break-word;
}

pre {
white-space: pre-wrap !important;
}

thead {
display: table-header-group;
}

tr,
img {
page-break-inside: avoid;
}

img {
width: 50%; // Prevent images from spanning the entire page
}

p,
h2,
h3 {
orphans: 3;
widows: 3;
}

// Hide integrated videos and remove whitespace
iframe, video {
display: none;
width: 0 !important;
height: 0 !important;
overflow: hidden !important;
line-height: 0pt !important;
white-space: nowrap;
}

.embed, .home-embed {
position: absolute;
height: 0;
overflow: hidden;
}

// Hide interactive elements
header .header__actions, footer,
.cookie .cookie__container,
.related-content.grid,
.sign-up-form, .hero__icon, .headline__icon{
display: none;
}
}
4 changes: 0 additions & 4 deletions wagtailio/static/sass/components/_theme-toggle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,4 @@
.no-js & {
display: none;
}

@media print {
display: none;
}
}
1 change: 1 addition & 0 deletions wagtailio/static/sass/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@import 'base/base';
@import 'base/container';
@import 'base/typography';
@import 'base/print';

// Components
@import 'components/app';
Expand Down

0 comments on commit 7241fbd

Please sign in to comment.