Compare commits
2 commits
c0ae48b064
...
ac794d5ff1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac794d5ff1 | ||
|
|
857506abb7 |
2 changed files with 54 additions and 10 deletions
|
|
@ -38,7 +38,7 @@
|
|||
/>
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { useEffect, type ReactNode } from "react";
|
||||
import { useEffect, useRef, useState, type ReactNode } from "react";
|
||||
|
||||
import { documentTitle } from "../lib/site.ts";
|
||||
import { accentText, BRAND } from '../lib/color.ts'
|
||||
|
|
@ -101,7 +101,32 @@ export function Section({ section }: { section: ShellSection }) {
|
|||
);
|
||||
}
|
||||
|
||||
/* The side nav's circle: half again the list's width (or a little
|
||||
more than its height, if taller), at most 22rem. */
|
||||
const circleSize = (box: { width: number; height: number }) =>
|
||||
Math.min(Math.max(box.width * 1.5, box.height * 1.1), 22 * 16);
|
||||
|
||||
/* Where the side nav sticks, and how far its list sits in from the
|
||||
column's top and left (pt-8, pl-4): the circle centers on that. */
|
||||
const STICK = "calc(var(--header-h, 5rem) + 1rem)";
|
||||
const LIST_TOP = 32;
|
||||
const LIST_LEFT = 16;
|
||||
|
||||
export default function PageShell({ title, intro, sections, sideNav = false }: PageShellProps) {
|
||||
// The list's measured box, so its circle can center on it from a
|
||||
// layer of its own (below).
|
||||
const listRef = useRef<HTMLDivElement>(null);
|
||||
const [listBox, setListBox] = useState<{ width: number; height: number } | null>(null);
|
||||
useEffect(() => {
|
||||
const el = listRef.current;
|
||||
if (!el) return;
|
||||
const ro = new ResizeObserver(([entry]) =>
|
||||
setListBox({ width: entry.borderBoxSize[0].inlineSize, height: entry.borderBoxSize[0].blockSize }),
|
||||
);
|
||||
ro.observe(el);
|
||||
return () => ro.disconnect();
|
||||
}, [sideNav]);
|
||||
|
||||
// The tab's title as the visitor moves around. The first load's
|
||||
// comes from the server (pageMeta.js), which also sets the page's
|
||||
// description and preview for search and link sharing.
|
||||
|
|
@ -134,19 +159,38 @@ export default function PageShell({ title, intro, sections, sideNav = false }: P
|
|||
|
||||
{sideNav ? (
|
||||
<div className="relative">
|
||||
{/* The margin left of the content (72rem, its text 1.5rem in). */}
|
||||
{/* The margin left of the content (72rem, its text 1.5rem in),
|
||||
clipping anything wider so the circle never reaches the
|
||||
content. clip, not hidden: hidden would make it a scroll
|
||||
container, and the sticky layers in it would stop
|
||||
sticking. */}
|
||||
<aside
|
||||
className="absolute inset-y-0 left-0 z-10 hidden min-[88rem]:block"
|
||||
className="absolute inset-y-0 left-0 hidden overflow-clip min-[88rem]:block"
|
||||
style={{ width: "calc((100% - 72rem) / 2 + 1rem)" }}
|
||||
>
|
||||
<div className="sticky pt-8 pl-4 pr-2" style={{ top: "calc(var(--header-h, 5rem) + 1rem)" }}>
|
||||
<div className="relative">
|
||||
{/* A solid circle behind the list, centered on it: the
|
||||
tint, which the nav's text reads on in either mode. */}
|
||||
{/* A solid circle centered on the list, in the tint the
|
||||
nav's text reads on in either mode. Its own sticky layer
|
||||
(a sticky box is a layer of its own, so it couldn't sit
|
||||
inside the list's): z-index -1 puts it behind the
|
||||
section lines, and after the page backdrop (also -1)
|
||||
so in front of that. Height 0, so the list's layer
|
||||
below starts, and sticks, at the same place. */}
|
||||
{listBox && (
|
||||
<div aria-hidden="true" className="pointer-events-none sticky h-0" style={{ top: STICK, zIndex: -1 }}>
|
||||
<div
|
||||
aria-hidden="true"
|
||||
className="absolute top-1/2 left-1/2 -z-10 aspect-square w-[min(150%,22rem)] -translate-x-1/2 -translate-y-1/2 rounded-full bg-tint"
|
||||
className="absolute rounded-full bg-tint"
|
||||
style={{
|
||||
width: circleSize(listBox),
|
||||
height: circleSize(listBox),
|
||||
left: LIST_LEFT + listBox.width / 2 - circleSize(listBox) / 2,
|
||||
top: LIST_TOP + listBox.height / 2 - circleSize(listBox) / 2,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{/* The list, in front of the section lines. */}
|
||||
<div className="sticky z-10 pt-8 pl-4 pr-2" style={{ top: STICK }}>
|
||||
<div ref={listRef} className="w-fit max-w-full">
|
||||
<SectionNav sections={sections.map((s) => ({ id: s.id, label: s.title }))} wrap />
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -7,4 +7,4 @@
|
|||
box or a build banner can read the same value later.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
export const SITE_VERSION = "NGU-Web.v1.10.8";
|
||||
export const SITE_VERSION = "NGU-Web.v1.10.9";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue