Fix various problems with print styles

These styles have drifted away from the HTML structure since they were
written in 2017.

General:
* Add some comments
* Replace complicated selectors with simple class selectors

styles.less:
* Hide section edit links (previously we relied on MobileFrontend
  styles, which one handled some cases - removing them in I9a88b80c2a)
* Show print footer, hide Minerva footer

header.less:
* Remove FIXME (resolved in c323c6858a).
* Fix hiding the search box. In 0bee6a1eb6 a <form> for the search box
  was added to the header, and these styles (using tag selectors) were
  not updated. Use class selectors instead.
* Remove styles for <h1>. The element was changed to <a> in
  a905b1c161, styles to override font-size etc. are no longer needed.
* Consolidate 'padding' rules and remove unneeded !important.

article.less:
* Replace the `[ class|='mw-content' ]` selector, which was not
  matching anything. It would match elements with `class="mw-content"`
  or `class="mw-content-…"`, but the node we're trying to style has
  `class="mw-body-content mw-content-ltr"` (since 7cda5b0bf8 in
  MediaWiki core). Use a class selector instead.
* Replace the `.mw-body > .content` selector too. While this one
  works, it is also needlessly complicated.

footer.less:
* Fix and simplify how last-modified info and license text is unhidden
  (while other parts of the footer remain hidden).
* Remove styles for .license. Unused since 1f2b7dff15, use the desktop
  footer added in that commit instead.
* Use the desktop footer for last-modified info, since it's more
  suitable for "archiving" (it has a date rather than time ago).

Bug: T323636
Change-Id: I21ef26355e3e6dd8b0c34ae933b7f5b0b222655c
This commit is contained in:
Bartosz Dziewoński 2022-11-23 13:06:18 +01:00
parent 0017d7e03c
commit 50fc799b07
4 changed files with 46 additions and 68 deletions

View file

@ -30,8 +30,7 @@
} }
} }
// Prefer class & direct child selector `.mw-body > .content` over `#bodyContent`. .content {
.mw-body > .content {
padding-top: 55px; padding-top: 55px;
position: relative; position: relative;
@ -60,9 +59,8 @@
} }
} }
// Prefer class & direct child selector `.mw-body > .content` over `#bodyContent`.
.thumb:after, .thumb:after,
.mw-body > .content:before { .content:before {
position: absolute; position: absolute;
left: 0; left: 0;
content: ''; content: '';
@ -79,9 +77,7 @@
font-size: 28px; font-size: 28px;
} }
// `#mw-content-text` doesn't feature universal class selector. .mw-body-content {
// `class|='mw-content'` catches `.mw-content`, but also `.mw-content-rtl`.
[ class|='mw-content' ] {
font-size: 36px; font-size: 36px;
a { a {

View file

@ -8,48 +8,40 @@
} }
// stylelint-disable selector-max-id // stylelint-disable selector-max-id
#mw-mf-page-center > footer { .minerva-footer {
border-top: solid 4px #000; border-top: solid 4px #000;
// Un-hide the last-modified info and license text
display: block;
padding-top: 23px; padding-top: 23px;
background: #fff !important; background: #fff !important;
.mw-ui-icon:before { .footer-content {
display: none !important; display: block !important;
}
.last-modified-bar { #footer-info,
background: none !important; #footer-info-lastmod,
border: 0 !important; #footer-info-copyright {
} display: block !important;
.last-modifier-tagline {
font-size: 36px;
padding-top: 0 !important;
padding-bottom: 16px !important;
}
.last-modified-bar,
.last-modified-bar a {
font-weight: bold !important;
color: #000 !important;
}
.post-content {
margin-top: 15px !important;
display: block;
// ... and add these instead.
.hlist,
h2 {
display: none;
}
.license a,
.license {
font-size: 30px; font-size: 30px;
color: @colorPrintSubtle; color: @colorPrintSubtle;
font-weight: normal; font-weight: normal;
} }
.minerva-footer-logo {
margin: 0 !important;
border: 0 !important;
padding: 0 !important;
}
// Hide everything else once again
#mw-data-after-content,
#footer-places {
display: none;
}
}
.last-modified-bar {
display: none;
} }
} }
// stylelint-enable selector-max-id // stylelint-enable selector-max-id

View file

@ -1,4 +1,3 @@
// FIXME: Ensure resources/skins.minerva.base.styles/print.less is removed when promoting
.header-container, .header-container,
.header-container.header-chrome { .header-container.header-chrome {
background: @background-color-base; background: @background-color-base;
@ -7,42 +6,26 @@
.minerva-header { .minerva-header {
border-top: 0; border-top: 0;
// Un-hide the wordmark logo
display: block; display: block;
height: auto; height: auto;
padding: 0 @contentPadding; padding: 0 @contentPadding;
// Hide everything else once again
.navigation-drawer,
.minerva-search-form,
.minerva-user-navigation {
display: none !important;
}
.branding-box { .branding-box {
padding-left: 0 !important; height: auto;
display: block !important;
padding: 0 0 51px 0;
// Beta indication is hidden in print mode // Beta indication is hidden in print mode
sup { sup {
display: none !important; display: none !important;
} }
} }
> nav,
> div {
display: none !important;
}
> .branding-box {
height: auto;
display: block !important;
padding: 0 0 51px 50px;
h1 {
font-size: inherit;
> * {
float: none;
}
// assumes SVG...
img {
height: 41px;
width: auto;
vertical-align: inherit;
}
}
}
} }

View file

@ -2,15 +2,22 @@
@import '../../../minerva.less/minerva.mixins.less'; @import '../../../minerva.less/minerva.mixins.less';
@media print { @media print {
.mw-editsection,
.noprint, .noprint,
.banner-container, .banner-container,
.minerva-header, .minerva-header,
.minerva-footer,
.minerva__tab-container, .minerva__tab-container,
.page-actions-menu, .page-actions-menu,
.post-content { .post-content {
display: none; display: none;
} }
.printfooter {
display: block;
padding-top: 1em;
}
h1, h1,
h2, h2,
h3, h3,