Style: Reduce size of code font and improve responsiveness at narrow screen widths (#2439)

This commit is contained in:
CAM Gerlach 2022-03-22 16:14:36 -05:00 committed by GitHub
parent 3b879ddaa0
commit f30bc4caa8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 86 additions and 22 deletions

View File

@ -1,7 +1,27 @@
@charset "UTF-8"; @charset "UTF-8";
/* Media Queries */ /* Media Queries */
@media (max-width: 32.5em) {
/* Reduce padding & margins for the smallest screens */ /* Further reduce width of fixed elements for smallest screens */
@media (max-width: 32em) {
section#pep-page-section {
padding: 0.25rem;
}
dl.footnote > dt,
dl.footnote > dd {
padding-left: 0;
padding-right: 0;
}
pre {
font-size: 0.75rem;
}
}
/* Reduce padding & margins for smaller screens */
@media (max-width: 40em) {
section#pep-page-section {
padding: 0.5rem;
}
section#pep-page-section > header > h1 { section#pep-page-section > header > h1 {
padding-right: 0; padding-right: 0;
border-right: none; border-right: none;
@ -12,22 +32,22 @@
nav#pep-sidebar { nav#pep-sidebar {
display: none; display: none;
} }
pre {
font-size: 0.8175rem;
}
table th, table th,
table td { table td {
padding: 0 0.1rem; padding: 0 0.1rem;
} }
} }
@media (min-width: 32.5em) {
@media (min-width: 40em) {
section#pep-page-section { section#pep-page-section {
max-width: 40em; display: table;
width: 100%;
margin: 0 auto; margin: 0 auto;
padding: .5rem 1rem 0;
}
}
@media (min-width: 54em) {
section#pep-page-section {
max-width: 75em; max-width: 75em;
padding: 0.5rem 1rem 0;
width: 100%;
} }
section#pep-page-section > article { section#pep-page-section > article {
max-width: 40em; max-width: 40em;
@ -41,6 +61,11 @@
float: left; float: left;
margin-right: 2%; margin-right: 2%;
} }
/* Make less prominent when sidebar ToC is available */
details > summary {
font-size: 1rem;
width: max-content;
}
} }
@media (min-width: 60em) { @media (min-width: 60em) {
section#pep-page-section > article { section#pep-page-section > article {

View File

@ -19,7 +19,6 @@
:root {color-scheme: light dark} :root {color-scheme: light dark}
html { html {
overflow-y: scroll; overflow-y: scroll;
-webkit-font-smoothing: antialiased;
margin: 0; margin: 0;
line-height: 1.4; line-height: 1.4;
font-weight: normal; font-weight: normal;
@ -32,8 +31,7 @@ body {
background-color: var(--colour-background); background-color: var(--colour-background);
} }
section#pep-page-section { section#pep-page-section {
padding: 0.25rem 0.25rem 0; padding: 0.25rem;
display: table;
} }
/* Reduce margin sizes for body text */ /* Reduce margin sizes for body text */
@ -41,7 +39,6 @@ p {margin: .5rem 0}
/* Header rules */ /* Header rules */
h1 { h1 {
line-height: 2.3;
font-size: 2rem; font-size: 2rem;
font-weight: bold; font-weight: bold;
margin-top: 2rem; margin-top: 2rem;
@ -78,8 +75,10 @@ a,
a:active, a:active,
a:visited { a:visited {
color: var(--colour-links); color: var(--colour-links);
text-decoration-color: var(--colour-background-accent);
display: inline; display: inline;
overflow-wrap: break-word;
overflow-wrap: anywhere;
text-decoration-color: var(--colour-background-accent);
} }
a:hover, a:hover,
a:focus { a:focus {
@ -105,22 +104,33 @@ cite {
pre, pre,
code { code {
font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", "DejaVu Sans Mono", Consolas, monospace; font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", "DejaVu Sans Mono", Consolas, monospace;
font-size: 0.875rem;
white-space: pre-wrap; white-space: pre-wrap;
word-wrap: break-word;
-webkit-hyphens: none; -webkit-hyphens: none;
hyphens: none; hyphens: none;
} }
code {
overflow-wrap: break-word;
overflow-wrap: anywhere;
}
code.literal { code.literal {
font-size: .8em; font-size: .8em;
background-color: var(--colour-inline-code); background-color: var(--colour-inline-code);
} }
pre { pre {
padding: .5rem .75rem; padding: .5rem .75rem;
word-break: break-all;
} }
/* Contents rules */ /* Contents rules */
details > summary { details > summary {
cursor: pointer;
font-size: 1.6rem;
font-weight: bold; font-weight: bold;
margin-bottom: 1em;
}
details > summary:hover {
text-decoration: underline;
} }
/* Definition list rules */ /* Definition list rules */
@ -171,6 +181,9 @@ sup {top: -0.5em}
sub {bottom: -0.25em} sub {bottom: -0.25em}
/* Table rules */ /* Table rules */
div.table-wrapper {
overflow-x: auto;
}
table { table {
width: 100%; width: 100%;
border-collapse: collapse; border-collapse: collapse;
@ -270,16 +283,11 @@ dl.footnote dd {
/* Sidebar formatting */ /* Sidebar formatting */
#pep-sidebar { #pep-sidebar {
overflow-y: scroll; overflow-y: auto;
position: sticky; position: sticky;
top: 0; top: 0;
height: 100vh; height: 100vh;
scrollbar-width: thin; /* CSS Standards, not *yet* widely supported */
scrollbar-color: var(--colour-scrollbar) transparent;
} }
#pep-sidebar::-webkit-scrollbar {width: 6px}
#pep-sidebar::-webkit-scrollbar-track {background: transparent}
#pep-sidebar::-webkit-scrollbar-thumb {background: var(--colour-scrollbar)}
#pep-sidebar > h2 { #pep-sidebar > h2 {
font-size: 1.4rem; font-size: 1.4rem;
} }

View File

@ -0,0 +1,30 @@
// Wrap the tables in PEP bodies in a div, to allow for responsive scrolling
"use strict";
const pepContentId = "pep-content";
// Wrap passed table element in wrapper divs
function wrapTable (table) {
const wrapper = document.createElement("div");
wrapper.classList.add("table-wrapper");
table.parentNode.insertBefore(wrapper, table);
wrapper.appendChild(table);
}
// Wrap all tables in the PEP content in wrapper divs
function wrapPepContentTables () {
const pepContent = document.getElementById(pepContentId);
const bodyTables = pepContent.getElementsByTagName("table");
Array.from(bodyTables).forEach(wrapTable);
}
// Wrap the tables as soon as the DOM is loaded
document.addEventListener("DOMContentLoaded", () => {
if (document.getElementById(pepContentId)) {
wrapPepContentTables();
}
})

View File

@ -41,5 +41,6 @@
</nav> </nav>
</section> </section>
<script src="{{ pathto('_static/colour_scheme.js', resource=True) }}"></script> <script src="{{ pathto('_static/colour_scheme.js', resource=True) }}"></script>
<script src="{{ pathto('_static/wrap_tables.js', resource=True) }}"></script>
</body> </body>
</html> </html>