From c335774db5f0ef0836bb2845256c66b6a2374c52 Mon Sep 17 00:00:00 2001 From: Zaldimmar Date: Thu, 1 Oct 2026 04:22:46 -0500 Subject: [PATCH] Side nav circle becomes a quarter-circle sun in the corner once the nav sticks Stuck, it centers on the header's bottom left and grows to reach past the list's far corner (never wider than the nav column), easing between that and its starting place on the list. Co-Authored-By: Claude Opus 5.5 --- src/components/PageShell.css | 12 ++++++-- src/components/PageShell.tsx | 60 +++++++++++++++++++++++++++++++----- 2 files changed, 62 insertions(+), 10 deletions(-) diff --git a/src/components/PageShell.css b/src/components/PageShell.css index 779797d..1a39ea3 100644 --- a/src/components/PageShell.css +++ b/src/components/PageShell.css @@ -1,11 +1,19 @@ -/* The side nav's circle (PageShell.tsx): the light fill of the color +/* The side nav's circle (PageShell.tsx), a sun in the corner once + the nav sticks: the light fill of the color family of the section being read (its darkest in dark mode), the palette shades every text color reads on at 4.5:1 or better, as on the page backdrop (PageBackdrop.css). */ .side-nav-circle { background: #d6f5fa; - transition: background-color 0.8s ease-in-out; + /* Color by section; size and place between centered on the list + and the corner sun once it sticks. */ + transition: + background-color 0.8s ease-in-out, + width 0.6s ease-in-out, + height 0.6s ease-in-out, + left 0.6s ease-in-out, + top 0.6s ease-in-out; } .side-nav-circle[data-family="green"] { background: #e6f0dd; diff --git a/src/components/PageShell.tsx b/src/components/PageShell.tsx index 2ee6c58..c7e7c6f 100644 --- a/src/components/PageShell.tsx +++ b/src/components/PageShell.tsx @@ -168,6 +168,53 @@ export default function PageShell({ title, intro, sections, sideNav = false }: P const activeAccent = sections.find((s) => s.id === active)?.accent; const listTop = listBox && circle ? Math.max(LIST_TOP, CIRCLE_GAP + circle / 2 - listBox.height / 2) : LIST_TOP; + // Stuck: the page has scrolled the list up to its place under the + // header. The circle then becomes the corner sun (below). + const [stuck, setStuck] = useState(false); + useEffect(() => { + const column = columnRef.current; + if (!sideNav || !column) return; + let frame = 0; + const measure = () => { + frame = 0; + const header = parseFloat(getComputedStyle(column).getPropertyValue("--header-h")) || 80; + setStuck(column.getBoundingClientRect().top + listTop <= header + STUCK_TOP + 1); + }; + const onScroll = () => { + if (!frame) frame = requestAnimationFrame(measure); + }; + measure(); + window.addEventListener("scroll", onScroll, { passive: true }); + window.addEventListener("resize", onScroll); + return () => { + window.removeEventListener("scroll", onScroll); + window.removeEventListener("resize", onScroll); + if (frame) cancelAnimationFrame(frame); + }; + }, [sideNav, listTop]); + + // The circle's box, from its layer's top left (which sticks with + // the list). Before sticking: centered on the list. Stuck: a sun in + // the corner, centered on the header's bottom left so the header + // and the screen's edge hide three quarters of it, big enough to + // reach past the list's far corner, but never wider than the column + // (it'd show a cut edge at the content). + const circleBox = (() => { + if (!listBox || !circle) return null; + if (stuck) { + const radius = Math.min( + Math.hypot(LIST_LEFT + listBox.width + 24, STUCK_TOP + listBox.height + 24), + columnWidth - 8, + ); + return { size: radius * 2, left: -radius, top: listTop - STUCK_TOP - radius }; + } + return { + size: circle, + left: Math.min(LIST_LEFT + Math.max(listBox.width / 2 - CIRCLE_SHIFT, listBox.heading) - circle / 2, columnWidth - circle), + top: listTop + listBox.height / 2 - circle / 2, + }; + })(); + // 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. @@ -216,19 +263,16 @@ export default function PageShell({ title, intro, sections, sideNav = false }: P which comes after it and so draws over it. Height 0, so the list's layer below starts, and sticks, at the same place. */} - {listBox && circle ? ( + {circleBox ? (