diff --git a/src/components/PageShell.css b/src/components/PageShell.css index 1a39ea3..812fdb0 100644 --- a/src/components/PageShell.css +++ b/src/components/PageShell.css @@ -6,6 +6,8 @@ .side-nav-circle { background: #d6f5fa; + /* A slight drop shadow, as the cards have: down and soft, no glow. */ + box-shadow: 0 4px 12px rgb(0 16 17 / 0.14); /* Color by section; size and place between centered on the list and the corner sun once it sticks. */ transition: @@ -25,6 +27,7 @@ /* Dark mode: the toggle's choice, or the system's when there is none. */ :root[data-theme="dark"] .side-nav-circle { background: #003a45; + box-shadow: 0 4px 12px rgb(0 0 0 / 0.45); } :root[data-theme="dark"] .side-nav-circle[data-family="green"] { background: #23361a; @@ -35,6 +38,7 @@ @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .side-nav-circle { background: #003a45; + box-shadow: 0 4px 12px rgb(0 0 0 / 0.45); } :root:not([data-theme="light"]) .side-nav-circle[data-family="green"] { background: #23361a; diff --git a/src/components/PageShell.tsx b/src/components/PageShell.tsx index c7e7c6f..8e897a5 100644 --- a/src/components/PageShell.tsx +++ b/src/components/PageShell.tsx @@ -124,6 +124,9 @@ const STUCK_TOP = 16; const stickAt = (listTop: number) => `calc(var(--header-h, 5rem) + ${STUCK_TOP - listTop}px)`; const LIST_LEFT = 16; const CIRCLE_GAP = 8 + 4; +/* How far off the screen's left edge the stuck circle's center may + go to take in a long list on a narrow window. */ +const MAX_BACK = 1200; /* The circle's color family for a section's accent (PageShell.css): green and amber their own, teal and deep teal (and any other) teal. */ @@ -198,15 +201,37 @@ export default function PageShell({ title, intro, sections, sideNav = false }: P // 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). + // (it'd show a cut edge at the content). When a narrow window holds + // it smaller than that, it moves to take the whole list in anyway: + // first its center down the screen's edge, then (if that isn't + // enough) off the screen to the left, growing by as much, so its + // right edge stays put while its arc flattens over the list. 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 }; + const edge = columnWidth - 8; // the furthest right it may reach + const roomy = Math.hypot(LIST_LEFT + listBox.width + 24, STUCK_TOP + listBox.height + 24); + if (roomy <= edge) return { size: roomy * 2, left: -roomy, top: listTop - STUCK_TOP - roomy }; + + // From the header's bottom left, with a slim margin: how far + // right the list reaches, and its top and bottom. + const right = LIST_LEFT + listBox.width + 8; + const top = STUCK_TOP - 4; + const bottom = STUCK_TOP + listBox.height + 8; + const reach = Math.sqrt(Math.max(edge * edge - right * right, 0)); + const drop = Math.min(Math.max(0, bottom - reach), (top + bottom) / 2); + // Off screen by `back`, if the list's corners are still out; at + // most MAX_BACK, since a list as wide as its column can't be + // taken in without crossing into the content (it nearly can't + // happen: titles wrap first). + const half = (bottom - top) / 2; + const gap = Math.max(edge - right, 1); + const back = + Math.hypot(right, Math.max(bottom - drop, drop - top)) <= edge + ? 0 + : Math.min(MAX_BACK, Math.max(0, (half * half - gap * gap) / (2 * gap) - right)); + const radius = edge + back; + return { size: radius * 2, left: -back - radius, top: listTop - STUCK_TOP + drop - radius }; } return { size: circle,