Merge pull request #7377 from gamebox/new-docs-template

This commit is contained in:
Anthony Bullard 2024-12-18 18:45:39 -06:00 committed by GitHub
commit c9a1ca84b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 628 additions and 502 deletions

View file

@ -156,6 +156,7 @@ pub fn generate_docs_html(root_file: PathBuf, build_dir: &Path) {
"<!-- Package Name -->", "<!-- Package Name -->",
render_name_link(package_name.as_str()).as_str(), render_name_link(package_name.as_str()).as_str(),
) )
.replace("<!-- Package Name String -->", package_name.as_str())
.replace( .replace(
"<!-- Module Docs -->", "<!-- Module Docs -->",
render_package_index(&exposed_module_docs).as_str(), render_package_index(&exposed_module_docs).as_str(),
@ -183,6 +184,7 @@ pub fn generate_docs_html(root_file: PathBuf, build_dir: &Path) {
"<!-- Package Name -->", "<!-- Package Name -->",
render_name_link(package_name.as_str()).as_str(), render_name_link(package_name.as_str()).as_str(),
) )
.replace("<!-- Package Name String -->", package_name.as_str())
.replace( .replace(
"<!-- Module Docs -->", "<!-- Module Docs -->",
render_module_documentation( render_module_documentation(

View file

@ -1,5 +1,6 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<!-- Page title --> <!-- Page title -->
@ -18,90 +19,96 @@
<body> <body>
<nav id="sidebar-nav"> <nav id="sidebar-nav">
<div class="module-links">
<!-- Module links -->
</div>
</nav>
<div class="header-start-extension">
<!-- if the window gets big, this extends the purple bar on the top header to the left edge of the window -->
</div>
<header class="top-header">
<div class="pkg-and-logo"> <div class="pkg-and-logo">
<a class="logo" href="/" aria-labelledby="logo-link"> <a class="logo" href="/" aria-labelledby="logo-link">
<svg <svg viewBox="0 -6 51 58" fill="none" xmlns="http://www.w3.org/2000/svg" aria-labelledby="logo-link"
viewBox="0 -6 51 58" role="img">
fill="none"
xmlns="http://www.w3.org/2000/svg"
aria-labelledby="logo-link"
role="img"
>
<title id="logo-link">Return to Roc packages</title> <title id="logo-link">Return to Roc packages</title>
<polygon <polygon role="presentation"
role="presentation" points="0,0 23.8834,3.21052 37.2438,19.0101 45.9665,16.6324 50.5,22 45,22 44.0315,26.3689 26.4673,39.3424 27.4527,45.2132 17.655,53 23.6751,22.7086" />
points="0,0 23.8834,3.21052 37.2438,19.0101 45.9665,16.6324 50.5,22 45,22 44.0315,26.3689 26.4673,39.3424 27.4527,45.2132 17.655,53 23.6751,22.7086"
/>
</svg> </svg>
</a> </a>
<!-- Package Name --> <!-- Package Name -->
<button class="menu-toggle" aria-label="Toggle sidebar">
<svg viewBox="0 0 72 72" id="emoji" xmlns="http://www.w3.org/2000/svg" fill="currentcolor">
<g id="SVGRepo_iconCarrier">
<g id="color"></g>
<g id="hair"></g>
<g id="skin"></g>
<g id="skin-shadow"></g>
<g id="line">
<line x1="16" x2="56" y1="26" y2="26" fill="none" stroke="currentColor"
stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2">
</line>
<line x1="16" x2="56" y1="36" y2="36" fill="none" stroke="currentColor"
stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2">
</line>
<line x1="16" x2="56" y1="46" y2="46" fill="none" stroke="currentColor"
stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2">
</line>
</g>
</g>
</svg>
</button>
</div> </div>
<div class="module-links-container">
<div class="module-links">
<!-- Module links -->
</div>
</div>
</nav>
<main>
<form id="module-search-form"> <form id="module-search-form">
<input <button class="menu-toggle" aria-label="Toggle sidebar">
id="module-search" <svg viewBox="0 0 72 72" id="emoji" xmlns="http://www.w3.org/2000/svg" fill="currentcolor">
aria-labelledby="search-label" <g id="SVGRepo_iconCarrier">
type="text" <g id="color"></g>
placeholder="Search" <g id="hair"></g>
role="combobox" <g id="skin"></g>
aria-autocomplete="list" <g id="skin-shadow"></g>
aria-expanded="false" <g id="line">
aria-controls="search-type-ahead" <line x1="16" x2="56" y1="26" y2="26" fill="none" stroke="currentColor"
/> stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2">
<label for="module-search" id="search-label" </line>
>(press <line x1="16" x2="56" y1="36" y2="36" fill="none" stroke="currentColor"
<span id="search-shortcut-key" aria-hidden="true">s</span stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2">
>)</label </line>
> <line x1="16" x2="56" y1="46" y2="46" fill="none" stroke="currentColor"
stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2">
</line>
</g>
</g>
</svg>
</button>
<input id="module-search" aria-labelledby="search-label" type="text"
placeholder="Search <!-- Package Name String -->" role="combobox" aria-autocomplete="list"
aria-expanded="false" aria-controls="search-type-ahead" />
<label for="module-search" id="search-label">(press
<span id="search-shortcut-key" aria-hidden="true">s</span>)</label>
<!-- Magnifying Glass icon --> <!-- Magnifying Glass icon -->
<svg <svg version="1.1" xmlns="http://www.w3.org/2000/svg" class="search-icon"
version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" width="24px" height="24px" viewBox="0 0 512 512"
xmlns="http://www.w3.org/2000/svg" xml:space="preserve">
class="search-icon"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="24px"
height="24px"
viewBox="0 0 512 512"
xml:space="preserve"
>
<g> <g>
<path <path d="M449.803,62.197C408.443,20.807,353.85-0.037,299.646-0.006C245.428-0.037,190.85,20.807,149.49,62.197
d="M449.803,62.197C408.443,20.807,353.85-0.037,299.646-0.006C245.428-0.037,190.85,20.807,149.49,62.197
C108.1,103.557,87.24,158.15,87.303,212.338c-0.047,37.859,10.359,75.766,30.547,109.359L15.021,424.525 C108.1,103.557,87.24,158.15,87.303,212.338c-0.047,37.859,10.359,75.766,30.547,109.359L15.021,424.525
c-20.016,20.016-20.016,52.453,0,72.469c20,20.016,52.453,20.016,72.453,0L190.318,394.15 c-20.016,20.016-20.016,52.453,0,72.469c20,20.016,52.453,20.016,72.453,0L190.318,394.15
c33.578,20.203,71.5,30.594,109.328,30.547c54.203,0.047,108.797-20.797,150.156-62.188 c33.578,20.203,71.5,30.594,109.328,30.547c54.203,0.047,108.797-20.797,150.156-62.188
c41.375-41.359,62.234-95.938,62.188-150.172C512.053,158.15,491.178,103.557,449.803,62.197z M391.818,304.541 c41.375-41.359,62.234-95.938,62.188-150.172C512.053,158.15,491.178,103.557,449.803,62.197z M391.818,304.541
c-25.547,25.531-58.672,38.125-92.172,38.188c-33.5-0.063-66.609-12.656-92.188-38.188c-25.531-25.578-38.125-58.688-38.188-92.203 c-25.547,25.531-58.672,38.125-92.172,38.188c-33.5-0.063-66.609-12.656-92.188-38.188c-25.531-25.578-38.125-58.688-38.188-92.203
c0.063-33.484,12.656-66.609,38.188-92.172c25.578-25.531,58.688-38.125,92.188-38.188c33.5,0.063,66.625,12.656,92.188,38.188 c0.063-33.484,12.656-66.609,38.188-92.172c25.578-25.531,58.688-38.125,92.188-38.188c33.5,0.063,66.625,12.656,92.188,38.188
c25.531,25.563,38.125,58.688,38.188,92.172C429.959,245.854,417.365,278.963,391.818,304.541z" c25.531,25.563,38.125,58.688,38.188,92.172C429.959,245.854,417.365,278.963,391.818,304.541z"></path>
></path>
</g> </g>
</svg> </svg>
<ul <ul id="search-type-ahead" role="listbox" aria-label="Search Results" class="hidden">
id="search-type-ahead"
role="listbox"
aria-label="Search Results"
class="hidden"
>
<!-- Search Type Ahead --> <!-- Search Type Ahead -->
</ul> </ul>
</form> </form>
</header>
<div class="header-end-extension">
<!-- if the window gets big, this extends the purple bar on the top header to the right edge of the window -->
</div>
<main>
<!-- Module Docs --> <!-- Module Docs -->
</main>
<footer> <footer>
<p>Made by people who like to make nice things.</p> <p>Made by people who like to make nice things.</p>
</footer> </footer>
</main>
</body> </body>
</html> </html>

View file

@ -40,19 +40,28 @@
case "ArrowDown": { case "ArrowDown": {
event.preventDefault(); event.preventDefault();
const focused = document.querySelector("#search-type-ahead > li:not([class*='hidden']) > a:focus"); const focused = document.querySelector(
"#search-type-ahead > li:not([class*='hidden']) > a:focus",
);
// Find the next element to focus. // Find the next element to focus.
let nextToFocus = focused?.parentElement?.nextElementSibling; let nextToFocus = focused?.parentElement?.nextElementSibling;
while (nextToFocus != null && nextToFocus.classList.contains("hidden")) { while (
nextToFocus != null &&
nextToFocus.classList.contains("hidden")
) {
nextToFocus = nextToFocus.nextElementSibling; nextToFocus = nextToFocus.nextElementSibling;
} }
if (nextToFocus == null) { if (nextToFocus == null) {
// If none of the links were focused, focus the first one. // If none of the links were focused, focus the first one.
// Also if we've reached the last one in the list, wrap around to the first. // Also if we've reached the last one in the list, wrap around to the first.
document.querySelector("#search-type-ahead > li:not([class*='hidden']) > a")?.focus(); document
.querySelector(
"#search-type-ahead > li:not([class*='hidden']) > a",
)
?.focus();
} else { } else {
nextToFocus.querySelector("a").focus(); nextToFocus.querySelector("a").focus();
} }
@ -62,11 +71,16 @@
case "ArrowUp": { case "ArrowUp": {
event.preventDefault(); event.preventDefault();
const focused = document.querySelector("#search-type-ahead > li:not([class*='hidden']) > a:focus"); const focused = document.querySelector(
"#search-type-ahead > li:not([class*='hidden']) > a:focus",
);
// Find the next element to focus. // Find the next element to focus.
let nextToFocus = focused?.parentElement?.previousElementSibling; let nextToFocus = focused?.parentElement?.previousElementSibling;
while (nextToFocus != null && nextToFocus.classList.contains("hidden")) { while (
nextToFocus != null &&
nextToFocus.classList.contains("hidden")
) {
nextToFocus = nextToFocus.previousElementSibling; nextToFocus = nextToFocus.previousElementSibling;
} }
@ -97,7 +111,7 @@
searchTypeAhead.querySelectorAll("li").forEach((entry) => { searchTypeAhead.querySelectorAll("li").forEach((entry) => {
const entryModule = entry const entryModule = entry
.querySelector(".type-ahead-module-name") .querySelector(".type-ahead-module-name")
.textContent.toLowerCase() .textContent.toLowerCase();
const entryName = entry const entryName = entry
.querySelector(".type-ahead-def-name") .querySelector(".type-ahead-def-name")
.textContent.toLowerCase(); .textContent.toLowerCase();
@ -106,9 +120,12 @@
?.textContent?.toLowerCase() ?.textContent?.toLowerCase()
?.replace(/\s+/g, ""); ?.replace(/\s+/g, "");
const qualifiedEntryName = `${entryModule}.${entryName}` const qualifiedEntryName = `${entryModule}.${entryName}`;
if ((qualifiedEntryName.includes(text) || entrySignature?.includes(text.replace(/\s+/g, "")))) { if (
qualifiedEntryName.includes(text) ||
entrySignature?.includes(text.replace(/\s+/g, ""))
) {
totalResults++; totalResults++;
entry.classList.remove("hidden"); entry.classList.remove("hidden");
if (topSearchResultListItem === undefined) { if (topSearchResultListItem === undefined) {
@ -229,3 +246,25 @@
} }
}); });
})(); })();
(() => {
let body = document.body;
const sidebarOpen = "sidebar-open";
const removeOpenClass = () => {
body.classList.remove(sidebarOpen);
document.body
.querySelector("main")
.removeEventListener("click", removeOpenClass);
};
Array.from(document.body.querySelectorAll(".menu-toggle")).forEach(
(menuToggle) => {
menuToggle.addEventListener("click", (e) => {
body.classList.toggle(sidebarOpen);
e.stopPropagation();
if (body.classList.contains(sidebarOpen)) {
document.body.addEventListener("click", removeOpenClass);
}
});
},
);
})();

View file

@ -1,16 +1,15 @@
:root { :root {
/* WCAG AAA Compliant colors */ /* WCAG AAA Compliant colors - important that luminence (the l in hsl) is 18% for font colors against the bg's luminence of 96-97% when the font-size is at least 14pt */
--code-bg: #f4f8f9; --code-bg: hsl(262 33% 96% / 1);
--gray: #717171; --gray: hsl(0 0% 18% / 1);
--orange: #bf5000; --orange: hsl(25 100% 18% / 1);
--green: #0b8400; --green: hsl(115 100% 18% / 1);
--cyan: #067c94; --cyan: hsl(190 100% 18% / 1);
--blue: #05006d; --blue: #05006d;
--violet: #7c38f5; --violet: #7c38f5;
--violet-bg: #ece2fd; --violet-bg: hsl(262.22deg 87.1% 93.92%);
--magenta: #a20031; --magenta: #a20031;
--link-hover-color: #333; --link-hover-color: #333;
--link-color: var(--violet); --link-color: var(--violet);
--code-link-color: var(--violet); --code-link-color: var(--violet);
--text-color: #000; --text-color: #000;
@ -18,17 +17,17 @@
--body-bg-color: #ffffff; --body-bg-color: #ffffff;
--border-color: #717171; --border-color: #717171;
--faded-color: #4c4c4c; --faded-color: #4c4c4c;
--font-sans: -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, --font-sans: -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
sans-serif; --font-mono: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace;
--font-mono: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier,
monospace;
--top-header-height: 67px; --top-header-height: 67px;
--sidebar-width: 280px; --sidebar-width: clamp(280px, 25dvw, 500px);
--module-search-height: 48px; --module-search-height: 48px;
--module-search-padding-height: 12px; --module-search-padding-height: 12px;
--module-search-form-padding-width: 20px; --module-search-form-padding-width: 20px;
--sidebar-bg-color: hsl(from var(--violet-bg) h calc(s * 1.05) calc(l * 0.95));
} }
a { a {
color: var(--violet); color: var(--violet);
} }
@ -63,26 +62,30 @@ table tr td {
.pkg-full-name { .pkg-full-name {
display: flex; display: flex;
align-items: center; align-items: center;
font-size: 32px; font-size: 24px;
margin: 0 8px; margin: 0 8px;
font-weight: normal; font-weight: normal;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
height: 100%;
} }
.entry-name { .entry-name {
white-space: pre-wrap; white-space: pre-wrap;
font-family: var(--font-mono); font-family: var(--font-mono);
font-size: 18px; font-size: 16px;
font-weight: normal; font-weight: normal;
color: var(--violet); background-color: var(--violet-bg);
color: var(--text-color);
width: auto; width: auto;
margin-top: 0; margin-top: 0;
margin-bottom: 24px; margin-bottom: 24px;
padding: 8px 16px; padding: 12px 16px;
border-left: 2px solid var(--violet); border: 2px solid var(--violet);
}
.entry-name strong {
color: var(--text-color);
} }
.entry-name:target { .entry-name:target {
@ -113,6 +116,9 @@ table tr td {
.pkg-full-name a { .pkg-full-name a {
padding-top: 12px; padding-top: 12px;
padding-bottom: 16px; padding-bottom: 16px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
} }
a { a {
@ -128,8 +134,12 @@ a:hover code {
min-width: 0; /* necessary for text-overflow: ellipsis to work in descendants */ min-width: 0; /* necessary for text-overflow: ellipsis to work in descendants */
display: flex; display: flex;
align-items: center; align-items: center;
height: 100%; justify-content: flex-start;
gap: 8px;
background-color: var(--violet-bg); background-color: var(--violet-bg);
padding-block: 16px;
position: sticky;
top: 0px;
} }
.pkg-and-logo a, .pkg-and-logo a,
@ -158,36 +168,49 @@ a:hover code {
body { body {
display: grid; display: grid;
grid-template-columns: grid-template-columns:
[before-sidebar] 1fr [sidebar] var(--sidebar-width) [sidebar] var(--sidebar-width)
[main-content] fit-content(calc(1280px - var(--sidebar-width))) [main-content] 1fr
[end] 1fr; [content-end];
grid-template-rows: [top-header] var(--top-header-height) [above-footer] auto [footer] auto; grid-template-rows: 1fr;
height: 100dvh;
box-sizing: border-box; box-sizing: border-box;
margin: 0; margin: 0;
padding: 0; padding: 0;
font-family: var(--font-sans); font-family: var(--font-sans);
color: var(--text-color); color: var(--text-color);
background-color: var(--body-bg-color); background-color: var(--body-bg-color);
overflow: hidden;
} }
main { main {
grid-column-start: main-content; grid-column-start: main-content;
grid-column-end: main-content; grid-column-end: content-end;
grid-row-start: above-footer;
grid-row-end: above-footer;
box-sizing: border-box; box-sizing: border-box;
position: relative; position: relative;
font-size: 18px; font-size: 14pt; /* This keeps links AAA compliant while still making the links distinctly colored. */
line-height: 1.85em; line-height: 1.85em;
margin-top: 2px; margin-top: 2px;
padding: 48px; padding: 16px;
max-width: 740px; padding-top: 0px;
/* necessary for text-overflow: ellipsis to work in descendants */ /* necessary for text-overflow: ellipsis to work in descendants */
min-width: 0; min-width: 0;
overflow-x: auto; overflow-x: auto;
/* fixes issues with horizonatal scroll in cases where word is too long, /* fixes issues with horizonatal scroll in cases where word is too long,
like in one of the examples at https://www.roc-lang.org/builtins/Num#Dec */ like in one of the examples at https://www.roc-lang.org/builtins/Num#Dec */
overflow-wrap: break-word; overflow-wrap: break-word;
overflow-y: auto;
display: grid;
grid-template-columns: [main-start] 1fr [main-content-start] 60ch [main-content-end] 1fr [main-end];
grid-template-rows: auto;
flex-direction: column;
scrollbar-color: var(--violet) var(--body-bg-color);
scrollbar-gutter: stable both-edges;
scroll-padding-top: calc(16px + 16px + 1lh + 16px + 16px);
}
main > * {
grid-column-start: main-content-start;
grid-column-end: main-content-end;
} }
/* Module links on the package index page (/index.html) */ /* Module links on the package index page (/index.html) */
@ -199,7 +222,7 @@ main {
section { section {
padding: 0px 0px 16px 0px; padding: 0px 0px 16px 0px;
margin: 72px 0px; margin: 36px 0px;
} }
section blockquote { section blockquote {
@ -234,32 +257,29 @@ padding: 0px 16px;
#sidebar-nav { #sidebar-nav {
grid-column-start: sidebar; grid-column-start: sidebar;
grid-column-end: sidebar; grid-column-end: main-content;
grid-row-start: above-footer;
grid-row-end: above-footer;
position: relative; position: relative;
display: flex; display: grid;
flex-direction: column; grid-template-rows: min-content 1fr;
box-sizing: border-box; box-sizing: border-box;
padding-left: 56px;
padding-top: 6px;
width: 100%; width: 100%;
background-color: var(--sidebar-bg-color);
transition: all 1s linear;
} }
.header-start-extension { #sidebar-nav .module-links-container {
grid-column-start: before-sidebar; position: relative;
grid-column-end: sidebar;
grid-row-start: top-header;
grid-row-end: top-header;
background-color: var(--violet-bg);
} }
.header-end-extension {
grid-column-start: end; #sidebar-nav .module-links {
grid-column-end: end; position: absolute;
grid-row-start: top-header; inset: 0;
grid-row-end: top-header; overflow-y: auto;
background-color: var(--violet-bg); overflow-x: hidden;
scrollbar-color: var(--violet) var(--sidebar-bg-color);
scrollbar-gutter: stable both-edges;
padding-block: 1rem;
} }
.top-header { .top-header {
@ -273,7 +293,7 @@ padding: 0px 16px;
flex-wrap: nowrap; flex-wrap: nowrap;
box-sizing: border-box; box-sizing: border-box;
font-family: var(--font-sans); font-family: var(--font-sans);
font-size: 24px; font-size: 20px;
height: 100%; height: 100%;
background-color: var(--violet-bg); background-color: var(--violet-bg);
/* min-width must be set to something (even 0) for text-overflow: ellipsis to work in descendants, but we want this anyway. */ /* min-width must be set to something (even 0) for text-overflow: ellipsis to work in descendants, but we want this anyway. */
@ -286,10 +306,6 @@ p {
} }
footer { footer {
grid-column-start: main-content;
grid-column-end: main-content;
grid-row-start: footer;
grid-row-end: footer;
max-width: var(--main-content-max-width); max-width: var(--main-content-max-width);
font-size: 14px; font-size: 14px;
box-sizing: border-box; box-sizing: border-box;
@ -316,9 +332,9 @@ footer p {
.sidebar-entry a { .sidebar-entry a {
box-sizing: border-box; box-sizing: border-box;
min-height: 48px; min-height: 40px;
min-width: 48px; min-width: 48px;
padding: 12px 16px; padding: 8px 16px;
font-family: var(--font-mono); font-family: var(--font-mono);
} }
@ -327,6 +343,10 @@ footer p {
color: var(--text-color); color: var(--text-color);
} }
.sidebar-sub-entries {
font-size: 12pt;
}
.sidebar-sub-entries a { .sidebar-sub-entries a {
display: block; display: block;
line-height: 24px; line-height: 24px;
@ -334,20 +354,37 @@ footer p {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
margin-left: 14px; margin-left: 14px;
padding-left: 26px; padding-left: 27px;
border-left: 2px solid var(--violet); border-left: 2px solid rgb(from var(--gray) r g b / .30);
white-space: nowrap;
}
.sidebar-sub-entries a:hover {
border-left-color: rgb(from var(--violet) r g b / .60);
color: hsl(from var(--text-color) h s calc(l * 1.5));
background-color: rgb(from white r g b / .10);
} }
.module-name { .module-name {
font-size: 56px; font-size: 40pt;
line-height: 1em; line-height: 1em;
font-family: var(--font-mono); font-family: var(--font-mono);
font-weight: bold; font-weight: bold;
margin-top: 18px; margin-top: 36px;
margin-bottom: 48px; margin-bottom: 16px;
color: var(--violet); color: var(--violet);
} }
main h2 {
font-size: 28pt;
}
main h3 {
font-size: 24pt;
}
main h4 {
font-size: 20pt;
}
.module-name a, .module-name a,
.module-name a:visited { .module-name a:visited {
color: inherit; color: inherit;
@ -359,7 +396,7 @@ color: inherit;
.sidebar-module-link { .sidebar-module-link {
box-sizing: border-box; box-sizing: border-box;
font-size: 18px; font-size: 14pt;
line-height: 24px; line-height: 24px;
font-family: var(--font-mono); font-family: var(--font-mono);
display: block; display: block;
@ -418,6 +455,7 @@ a code {
color: var(--code-link-color); color: var(--code-link-color);
background: none; background: none;
padding: 0; padding: 0;
font-weight: bold; /* Important for AAA compliance while keeping color distinct */
} }
code a:visited, code a:visited,
@ -430,7 +468,6 @@ pre {
padding: 8px 16px; padding: 8px 16px;
box-sizing: border-box; box-sizing: border-box;
background-color: var(--code-bg); background-color: var(--code-bg);
overflow-x: hidden;
position: relative; position: relative;
word-wrap: normal; word-wrap: normal;
} }
@ -450,13 +487,33 @@ pre>samp {
align-items: center; align-items: center;
align-content: center; align-content: center;
height: 100%; height: 100%;
background-color: var(--violet-bg); position: sticky;
position: relative;
flex-grow: 1; flex-grow: 1;
box-sizing: border-box; box-sizing: border-box;
padding: 0px var(--module-search-form-padding-width); padding-top: 16px;
background-color: var(--body-bg-color);
top: 0;
z-index: 1;
} }
.menu-toggle {
display: none;
margin-right: 8px;
appearance: none;
background-color: transparent;
outline: none;
border: none;
color: var(--violet);
padding: 0;
cursor: pointer;
}
.menu-toggle svg {
height: 48px;
width: 48px;
}
#module-search, #module-search,
#module-search:focus { #module-search:focus {
opacity: 1; opacity: 1;
@ -471,12 +528,19 @@ pre>samp {
box-sizing: border-box; box-sizing: border-box;
width: 100%; width: 100%;
box-sizing: border-box; box-sizing: border-box;
font-size: 18px; font-size: 16px;
line-height: 18px; line-height: 18px;
border: none; border: none;
color: var(--faded-color); color: var(--faded-color);
background-color: var(--body-bg-color); background-color: var(--body-bg-color);
font-family: var(--font-serif); font-family: var(--font-serif);
border: 2px solid var(--violet-bg);
}
@media (prefers-color-scheme: light) {
#module-search {
outline: 1px solid var(--gray);
}
} }
#module-search::placeholder { #module-search::placeholder {
@ -485,7 +549,7 @@ pre>samp {
} }
#module-search:focus, #module-search:hover { #module-search:focus, #module-search:hover {
outline: 2px solid var(--faded-color); outline: 2px solid var(--violet);
} }
#search-type-ahead { #search-type-ahead {
@ -567,13 +631,9 @@ pre>samp {
box-sizing: border-box; box-sizing: border-box;
align-items: center; align-items: center;
font-size: 18px; font-size: 18px;
line-height: 18px;
padding: 12px 16px;
height: 48px;
pointer-events: none; pointer-events: none;
position: absolute; position: absolute;
top: 12px; right: 72px;
left: 96px;
} }
#search-shortcut-key { #search-shortcut-key {
@ -583,7 +643,6 @@ pre>samp {
padding: 1px 3px 3px; padding: 1px 3px 3px;
font-style: normal; font-style: normal;
line-height: 15px; line-height: 15px;
opacity: 0.6;
pointer-events: none; pointer-events: none;
} }
@ -606,32 +665,31 @@ pre>samp {
.module-name { .module-name {
flex-grow: 1; flex-grow: 1;
margin-bottom: 0;
} }
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
:root { :root {
/* WCAG AAA Compliant colors */ /* WCAG AAA Compliant colors */
--code-bg: #202746; --code-bg: hsl(228.95deg 37.25% 15%);
--gray: #b6b6b6; --gray: hsl(0 0% 70% / 1);
--orange: #fd6e08; --orange: hsl(25 98% 70% / 1);
--green: #8ecc88; --green: hsl(115 40% 70% / 1);
--cyan: #12c9be; --cyan: hsl(176 84% 70% / 1);
--blue: #b1afdf; --blue: hsl(243 43% 80% / 1);
--violet: #CAADFB; --violet: #caadfb;
--violet-bg: #332944; --violet-bg: #332944;
--magenta: #f39bac; --magenta: hsl(348 79% 80% / 1);
--link-hover-color: #fff; --link-hover-color: #fff;
--link-color: var(--violet); --link-color: var(--violet);
--code-link-color: var(--violet); --code-link-color: var(--violet);
--text-color: #eaeaea; --text-color: #eaeaea;
--body-bg-color: #0e0e0f; --body-bg-color: hsl(from var(--violet-bg) h s calc(l * .5));
--border-color: var(--gray); --border-color: var(--gray);
--code-color: #eeeeee; --code-color: #eeeeee;
--logo-solid: #8f8f8f; --logo-solid: #8f8f8f;
--faded-color: #bbbbbb; --faded-color: #bbbbbb;
--gray: #6e6e6e; --sidebar-bg-color: hsl(from var(--violet-bg) h calc(s * 1.1) calc(l * 0.75));
} }
html { html {
@ -641,28 +699,29 @@ pre>samp {
@media only screen and (max-device-width: 480px) and (orientation: portrait) { @media only screen and (max-device-width: 480px) and (orientation: portrait) {
body { body {
grid-template-areas: display: block;
"header" overflow-y: auto;
"main" overflow-x: hidden;
"sidebar"
"footer";
} }
#sidebar-nav { #sidebar-nav {
grid-area: sidebar; left: calc(-1 * var(--sidebar-width));
top: 0;
bottom: 0;
position: fixed;
z-index: 2;
transition: all .2s linear;
}
body.sidebar-open #sidebar-nav {
left: 0;
} }
main { main {
grid-area: main; display: block;
margin: 0 16px;
} }
.top-header {
grid-area: header;
}
footer {
grid-area: footer;
}
:root { :root {
--top-header-height: 160px; --top-header-height: 160px;
} }
@ -672,10 +731,30 @@ pre>samp {
} }
#module-search-form { #module-search-form {
padding: 0 16px; padding: 16px 16px;
width: 100%;
height: auto; height: auto;
margin-bottom: 16px; margin-bottom: 16px;
grid-column-start: main-content-start;
grid-column-end: main-content-end;
position: fixed;
left: 0;
right: 0;
}
.menu-toggle {
display: inline-block;
margin-right: 8px;
appearance: none;
background-color: transparent;
outline: none;
border: none;
color: var(--text-color);
padding: 0;
}
.menu-toggle svg {
height: 48px;
width: 48px;
} }
/* Hide the Copy Link button on mobile. */ /* Hide the Copy Link button on mobile. */
@ -683,8 +762,9 @@ pre>samp {
display: none; display: none;
} }
.search-button { .search-icon {
display: block; /* This is only visible in mobile. */ display: block; /* This is only visible in mobile. */
top: calc(1lh / 2 + 16px);
} }
.top-header { .top-header {
@ -696,9 +776,7 @@ pre>samp {
} }
.pkg-full-name { .pkg-full-name {
margin-left: 8px; font-size: 20px;
margin-right: 12px;
font-size: 24px;
padding-bottom: 14px; padding-bottom: 14px;
} }
@ -708,7 +786,6 @@ pre>samp {
} }
.logo { .logo {
padding-left: 2px;
width: 50px; width: 50px;
height: 54px; height: 54px;
} }
@ -721,7 +798,7 @@ pre>samp {
} }
.module-name { .module-name {
font-size: 36px; font-size: 24px;
margin-top: 8px; margin-top: 8px;
margin-bottom: 8px; margin-bottom: 8px;
overflow: hidden; overflow: hidden;
@ -731,13 +808,13 @@ pre>samp {
main { main {
padding: 18px; padding: 18px;
font-size: 16px; font-size: 16px;
max-width: 480px; padding-top: calc(16px + 16px + 1lh + 16px);
} }
#sidebar-nav { #sidebar-nav {
margin-top: 0; margin-top: 0;
padding-left: 0; padding-left: 0;
width: auto; width: var(--sidebar-width);
} }
#sidebar-heading { #sidebar-heading {
@ -756,10 +833,9 @@ pre>samp {
} }
body { body {
grid-template-columns: auto;
margin: 0; margin: 0;
min-width: 320px; min-width: 320px;
max-width: 100%; max-width: 100dvw;
} }
.top-header-triangle { .top-header-triangle {
@ -768,6 +844,8 @@ pre>samp {
.pkg-and-logo { .pkg-and-logo {
width: 100%; width: 100%;
padding-block: 4px;
align-items: space-between;
} }
.pkg-full-name { .pkg-full-name {