-
Notifications
You must be signed in to change notification settings - Fork 123
FE-1455: Tighten the docs site chrome #9268
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
Open
kube
wants to merge
1
commit into
cf/fe-1457-arch-docs-point-source-links-at-the-branch-being-built
from
cf/fe-1455-petrinaut-docs-site-tighter-chrome-and-more-room-for-content
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| --- | ||
| /** | ||
| * Starlight's head, plus the font faces and preload links for the code font. | ||
| * | ||
| * Astro's `<Font>` emits both, so the family has to be requested from a | ||
| * component in the head rather than from configuration alone. | ||
| */ | ||
|
|
||
| import Default from "@astrojs/starlight/components/Head.astro"; | ||
| import { Font } from "astro:assets"; | ||
| --- | ||
|
|
||
| <Default><slot /></Default> | ||
| <Font cssVariable="--pnd-font-mono" preload /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| --- | ||
| import Default from "@astrojs/starlight/components/SiteTitle.astro"; | ||
|
|
||
| /** | ||
| * Adds the desktop sidebar collapse toggle and resize handle beside the title. | ||
| * | ||
| * They hang off `SiteTitle` because it is the header's leftmost slot, next to | ||
| * the rail's edge where the controls act, and the fixed header is the only | ||
| * chrome still on screen once the sidebar pane itself is collapsed away. Both | ||
| * are display: none unless the page has a sidebar (see `chrome.css`), so the | ||
| * splash-template 404 page does not grow controls with nothing to control. | ||
| */ | ||
| --- | ||
|
|
||
| <button | ||
| class="pnd-sidebar-toggle" | ||
| type="button" | ||
| aria-controls="starlight__sidebar" | ||
| aria-expanded="true" | ||
| aria-label="Toggle sidebar" | ||
| > | ||
| <svg | ||
| aria-hidden="true" | ||
| width="16" | ||
| height="16" | ||
| viewBox="0 0 24 24" | ||
| fill="none" | ||
| stroke="currentColor" | ||
| stroke-width="2" | ||
| stroke-linejoin="round" | ||
| > | ||
| <rect x="3" y="3" width="18" height="18" rx="2"></rect> | ||
| <path d="M9 3v18"></path> | ||
| </svg> | ||
| </button> | ||
|
|
||
| <Default><slot /></Default> | ||
|
|
||
| <div | ||
| class="pnd-sidebar-resize" | ||
| role="separator" | ||
| aria-orientation="vertical" | ||
| aria-label="Resize sidebar" | ||
| tabindex="0" | ||
| > | ||
| </div> | ||
|
|
||
| <script is:inline> | ||
| (() => { | ||
| const root = document.documentElement; | ||
| const toggle = /** @type {HTMLButtonElement | null} */ ( | ||
| document.querySelector(".pnd-sidebar-toggle") | ||
| ); | ||
| const handle = /** @type {HTMLElement | null} */ ( | ||
| document.querySelector(".pnd-sidebar-resize") | ||
| ); | ||
|
|
||
| if (!toggle || !handle) { | ||
| return; | ||
| } | ||
|
|
||
| /** | ||
| * @param {string} key | ||
| * @param {string} value | ||
| */ | ||
| const remember = (key, value) => { | ||
| try { | ||
| localStorage.setItem(key, value); | ||
| } catch { | ||
| // Private browsing denies storage; the control still works this session. | ||
| } | ||
| }; | ||
|
|
||
| toggle.setAttribute( | ||
| "aria-expanded", | ||
| String(root.dataset.pndSidebar !== "collapsed"), | ||
| ); | ||
|
|
||
| toggle.addEventListener("click", () => { | ||
| const collapsed = root.dataset.pndSidebar !== "collapsed"; | ||
|
|
||
| if (collapsed) { | ||
| root.dataset.pndSidebar = "collapsed"; | ||
| } else { | ||
| delete root.dataset.pndSidebar; | ||
| } | ||
|
|
||
| toggle.setAttribute("aria-expanded", String(!collapsed)); | ||
| remember("pnd:sidebar", collapsed ? "collapsed" : "expanded"); | ||
| }); | ||
|
|
||
| /** @param {number} edge Where the pane's trailing edge should land, in px. */ | ||
| const resizeTo = (edge) => { | ||
| const width = `${Math.round(Math.min(Math.max(edge, 224), 480))}px`; | ||
|
|
||
| root.style.setProperty("--pnd-sidebar-open-width", width); | ||
| remember("pnd:sidebar-width", width); | ||
| }; | ||
|
|
||
| handle.addEventListener("pointerdown", (event) => { | ||
| handle.setPointerCapture(event.pointerId); | ||
|
|
||
| /** @param {PointerEvent} move */ | ||
| const onMove = (move) => resizeTo(move.clientX); | ||
|
|
||
| handle.addEventListener("pointermove", onMove); | ||
| handle.addEventListener( | ||
| "pointerup", | ||
| () => handle.removeEventListener("pointermove", onMove), | ||
| { once: true }, | ||
| ); | ||
| }); | ||
|
|
||
| handle.addEventListener("keydown", (event) => { | ||
| const step = | ||
| event.key === "ArrowLeft" ? -16 : event.key === "ArrowRight" ? 16 : 0; | ||
|
|
||
| if (step !== 0) { | ||
| event.preventDefault(); | ||
| resizeTo(handle.getBoundingClientRect().left + 3 + step); | ||
| } | ||
| }); | ||
|
|
||
| // A gradient cannot ask whether the text fits, so the labels that do not | ||
| // fit are marked here and the fade keys off the mark. Deferred because this | ||
| // script is in the header, which the browser parses before the sidebar. | ||
| const markLabels = () => { | ||
| const pane = document.querySelector(".sidebar-content"); | ||
|
|
||
| if (!pane) { | ||
| return; | ||
| } | ||
|
|
||
| const labels = pane.querySelectorAll("a > span, .group-label > span"); | ||
|
|
||
| const markClipped = () => { | ||
| for (const label of labels) { | ||
| label.toggleAttribute( | ||
| "data-pnd-clipped", | ||
| label.scrollWidth > label.clientWidth + 1, | ||
| ); | ||
| } | ||
| }; | ||
|
|
||
| markClipped(); | ||
| // Fires on the pane's own resize and when expanding a group changes it. | ||
| new ResizeObserver(markClipped).observe(pane); | ||
| pane.addEventListener("toggle", markClipped, { capture: true }); | ||
| }; | ||
|
|
||
| if (document.readyState === "loading") { | ||
| document.addEventListener("DOMContentLoaded", markLabels, { once: true }); | ||
| } else { | ||
| markLabels(); | ||
| } | ||
| })(); | ||
| </script> | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.