/* ═══════════════════════════════════════════════════════════════ PAGE SHELL Just the chrome that makes pages look alike: a page header, then sections with a thin accent banner between them and a left-aligned heading with a blurb and rule. Sections paint no background of their own: the page's (PageBackdrop.tsx) runs behind all of them. `sideNav` adds an "On this page" list in the left margin, the admin editors' own (SectionNav), sticky under the header, listing the sections with the one being read lit. It sits beside the sections rather than taking a column from them, so they stay where they'd be without it; it shows once the margin beside the 72rem content is wide enough for it (88rem screens up, titles wrapping onto a second line). Narrower, the header's dropdowns list the sections instead. Whatever goes inside a section is passed as `content`, the shell doesn't care what it is. No
and no footer here, Layout provides both, so a page using this shell drops straight into the router's Outlet. Usage: , // optional, right of the heading content: , }, ]} /> ═══════════════════════════════════════════════════════════════ */ import { useEffect, useRef, useState, type ReactNode } from "react"; import { documentTitle } from "../lib/site.ts"; import { accentText, BRAND } from '../lib/color.ts' import { SectionNav } from "./admin/SectionNav.tsx"; export type ShellSection = { id: string; title: string; blurb?: string; accent: string; actions?: ReactNode; content: ReactNode; }; type PageShellProps = { title: ReactNode; intro?: ReactNode; sections: ShellSection[]; /** An "On this page" column beside the sections, from lg up. */ sideNav?: boolean; }; export function Section({ section }: { section: ShellSection }) { const { id, title, blurb, accent, // Optional action bar for this section's heading row, a view // toggle, a filter, a link. Whatever the section needs; the // shell just gives it a place to sit. actions, content, } = section; return (
{/* Heading, left aligned, optional actions on the right */}

{title}

{blurb &&

{blurb}

}
{actions}
{content}
); } /* 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(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. useEffect(() => { if (typeof title === "string") document.title = documentTitle(title); }, [title]); // The thin solid banner between sections, the page's full width // (behind the side nav). const banner = (accent: string) =>
; const bands = sections.map((section, i) => (
{banner(section.accent)}
{i === sections.length - 1 && banner(section.accent)}
)); return ( <> {/* Page header */}

{title}

{intro &&

{intro}

}
{sideNav ? (
{/* 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. */} {bands}
) : ( bands )} ); }