Skip to content

Commit 8777744

Browse files
committed
MAINT: various fixes to print CSS.
This should among other fix #1745 When printing this hides - The pydata navbar - The announcement banner. - The "skip to main content" link. - The location breadcrumbs (in bd-header-article), without also hiding the container the full content is shifted by a dozen pixel hight and the end of the content get hidden behind the footer when printing. - The prev.next buttons a bottom of page. This does not hide the version warning banner as this is currently being worked on in another PR. I went the route of adding the bootstrat `d-print-none`, instead of adding custom css rules, I'm happy to do the opposite, but it seem the using bootstrap classes as that seems what is done in other places. I've also added a break-inside avoid in a few places, mostly to try-to avoid page breaks in the middle of codeblocks.
1 parent 1ca89ee commit 8777744

File tree

6 files changed

+11
-6
lines changed

6 files changed

+11
-6
lines changed

src/pydata_sphinx_theme/assets/styles/components/_versionmodified.scss

+2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ div.deprecated {
55
margin: 1.5625em auto;
66
padding: 0 0.6rem 0 0.6rem;
77
overflow: hidden;
8+
/* break-inside has replaced page-break-inside and is widely usable since 2019 */
89
page-break-inside: avoid;
10+
break-inside: avoid;
911
border-left: 0.2rem solid;
1012
border-color: var(--pst-color-info);
1113
border-radius: $admonition-border-radius;

src/pydata_sphinx_theme/assets/styles/content/_admonitions.scss

+2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ div.admonition,
99
margin: 1.5625em auto;
1010
padding: 0 0.6rem 0.8rem 0.6rem;
1111
overflow: hidden;
12+
/* break-inside has replaced page-break-inside and is widely usable since 2019 */
1213
page-break-inside: avoid;
14+
break-inside: avoid;
1315
border-left: $admonition-left-border-width solid;
1416
border-color: var(--pst-color-info);
1517
border-radius: $admonition-border-radius;

src/pydata_sphinx_theme/assets/styles/content/_code.scss

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ div.literal-block-wrapper {
1212
flex-direction: column;
1313
width: unset;
1414
border-radius: $admonition-border-radius;
15+
break-inside: avoid;
1516
}
1617

1718
// Code blocks with captions

src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/breadcrumbs.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
{#- Hide breadcrumbs on the home page #}
1212
{% if title and pagename != root_doc %}
13-
<nav aria-label="{{ _('Breadcrumb') }}">
13+
<nav aria-label="{{ _('Breadcrumb') }}" class="d-print-none">
1414
<ul class="bd-breadcrumbs">
1515
{# Home icon #}
1616
<li class="breadcrumb-item breadcrumb-home">

src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
{# A button hidden by default to help assistive devices quickly jump to main content #}
3838
{# ref: https://www.youtube.com/watch?v=VUR0I5mqq7I #}
39-
<div id="pst-skip-link" class="skip-link"><a href="#main-content">{{ _("Skip to main content") }}</a></div>
39+
<div id="pst-skip-link" class="skip-link d-print-none"><a href="#main-content">{{ _("Skip to main content") }}</a></div>
4040

4141
{%- endblock %}
4242

@@ -72,7 +72,7 @@
7272
{% include "sections/announcement.html" %}
7373
{%- endif %}
7474
{% block docs_navbar %}
75-
<header class="bd-header navbar navbar-expand-lg bd-navbar">
75+
<header class="bd-header navbar navbar-expand-lg bd-navbar d-print-none">
7676
{%- include "sections/header.html" %}
7777
</header>
7878
{% endblock docs_navbar %}
@@ -94,7 +94,7 @@
9494
<div class="bd-content">
9595
<div class="bd-article-container">
9696
{# Article header #}
97-
<div class="bd-header-article">{% include "sections/header-article.html" %}</div>
97+
<div class="bd-header-article d-print-none">{% include "sections/header-article.html" %}</div>
9898
{# Article content #}
9999
{% block docs_body %}
100100
{# This is empty and only shows up if text has been highlighted by the URL #}
@@ -111,7 +111,7 @@
111111
{% endif %}
112112
{# prev-next buttons #}
113113
{% if theme_show_prev_next %}
114-
<footer class="prev-next-footer">
114+
<footer class="prev-next-footer d-print-none">
115115
{% include "components/prev-next.html" %}
116116
</footer>
117117
{% endif %}

src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/announcement.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{# If we are remote, add a script to make an HTTP request for the value on page load #}
44
{%- if is_remote %}
55
<script>
6-
document.write(`<div class="bd-header-announcement"></div>`);
6+
document.write(`<div class="bd-header-announcement d-print-none"></div>`);
77
fetch("{{ theme_announcement }}")
88
.then(res => {return res.text();})
99
.then(data => {

0 commit comments

Comments
 (0)