Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print stylesheets and WHCM improvements #461

Merged
merged 2 commits into from
Feb 25, 2024
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
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) ")";
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️


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;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think those kinds of overrides would be easier to manage in component stylesheets? As-is, I can see this getting out of date with other styles over time.

}
8 changes: 8 additions & 0 deletions wagtailio/static/sass/components/_burger.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
&:focus {
#{$root}__line {
background-color: var(--color--interaction);

@media (forced-colors: active) {
background-color: ButtonText;
}
}
}

Expand All @@ -27,6 +31,10 @@
transform: translateX(-50%) rotate(0deg);
transition: top $transition, width $transition, opacity $transition, transform $transition, background-color $transition, left $transition;

@media (forced-colors: active) {
background-color: ButtonText;
}

.is-open & {
width: 27px;
height: 4px;
Expand Down
19 changes: 17 additions & 2 deletions wagtailio/static/sass/components/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
transition: transform 0.3s;
margin: 0 0 0 15px;
fill: $color--teal;

@media (forced-colors: active) {
fill: currentColor;
}
}

&:hover {
Expand All @@ -27,6 +31,10 @@
> svg {
transform: translateX(6px) scale(1.05);
fill: $color--teal-100;

@media (forced-colors: active) {
fill: currentColor;
}
}
}

Expand All @@ -38,6 +46,10 @@

> svg {
fill: $color--teal-100;

@media (forced-colors: active) {
fill: currentColor;
}
}

&:hover,
Expand All @@ -48,6 +60,11 @@

> svg {
fill: $color--teal;

// stylelint-disable-next-line max-nesting-depth
@media (forced-colors: active) {
fill: currentColor;
}
}
}
}
Expand Down Expand Up @@ -103,6 +120,4 @@
font-weight: $weight--bold;
line-height: 1.25rem;
}


}
18 changes: 10 additions & 8 deletions wagtailio/static/sass/components/_code-snippet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,26 @@
width: 20px;
height: 20px;
transition: color 0.3s;
}

&__button {
padding: 0;

&:focus {
outline-color: var(--color--heading);
@media (forced-colors: active) {
fill: currentColor;
}

&:hover,
&:active,
&:focus {
#{$root}__icon {
fill: $color--white;
}

@media (forced-colors: active) {
fill: currentColor;
}
}
}

&__button {
padding: 0;
}

&__confirmation {
background-color: var(--color--highlight);
position: absolute;
Expand Down
22 changes: 14 additions & 8 deletions wagtailio/static/sass/components/_modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@
width: 30px;
height: 30px;
border: 3px solid $color--white;
}

#{$root}__close-icon {
fill: $color--white;
width: 12px;
height: 22px;

svg {
fill: $color--white;
width: 12px;
height: 22px;
@media (forced-colors: active) {
fill: currentColor;
}
}
}
Expand Down Expand Up @@ -113,10 +117,12 @@
}
}

&:hover,
&:focus {
#{$root}__close-icon {
fill: var(--color--interaction);
.theme-dark & {
&:hover,
&:focus {
#{$root}__close-icon {
fill: $color--teal-100;
}
}
}
}
Expand Down
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
Loading