Side nav: size the pill as the pill it is, not an ellipse

rounded-full draws straight sides with round ends, but its height was
worked out for an ellipse, so a narrow window made it about three times
the list's height, running down over the content.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-10-06 04:28:45 -05:00
parent de6d70a0d0
commit 915a7bb570

View file

@ -107,16 +107,17 @@ export function Section({ section }: { section: ShellSection }) {
const circleSize = (box: { width: number; height: number }) => const circleSize = (box: { width: number; height: number }) =>
Math.min(Math.max(box.width * 1.5, box.height * 1.1), 22 * 16); Math.min(Math.max(box.width * 1.5, box.height * 1.1), 22 * 16);
/* The height an ellipse `width` wide needs to take in a box reaching /* The height a pill `width` wide (rounded-full: straight sides, round
ends of radius r = width / 2) needs to take in a box reaching
`across` and `down` from its center (or a corner it's centered on): `across` and `down` from its center (or a corner it's centered on):
(across / a)^2 + (down / b)^2 <= 1. Equal to the width when a circle the corner must sit inside an end's circle, so the straight part
that wide would do; taller when the list is too tall for one. A reaches down - sqrt(r^2 - across^2). Equal to the width when a
box as wide as the ellipse can't be taken in, so it stops at 95% circle that wide would do; taller when the list is too tall for
(about three times the box's height). */ one. A box as wide as the pill can't be taken in, so it stops at 95%. */
const coverHeight = (width: number, across: number, down: number) => { const coverHeight = (width: number, across: number, down: number) => {
const a = width / 2; const r = width / 2;
const ratio = Math.min(across / a, 0.95); const ratio = Math.min(across / r, 0.95);
return Math.max(width, (2 * down) / Math.sqrt(1 - ratio * ratio)); return Math.max(width, 2 * (down - r * Math.sqrt(1 - ratio * ratio) + r));
}; };
/* How far the list sits in from the column's top and left: the /* How far the list sits in from the column's top and left: the
@ -184,7 +185,7 @@ export default function PageShell({ title, intro, sections, sideNav = false }: P
// The shape at rest: a circle centered on the list (a little left, // The shape at rest: a circle centered on the list (a little left,
// never left of the heading's center), CIRCLE_EDGE clear of the // never left of the heading's center), CIRCLE_EDGE clear of the
// section's edge, made an ellipse as tall as it takes when the list // section's edge, made a pill as tall as it takes when the list
// is too tall for the circle (10 sections of two-line titles). // is too tall for the circle (10 sections of two-line titles).
// The shape at a given width: its center as near the list's as the // The shape at a given width: its center as near the list's as the
// section's edge allows (it may run off the screen's left edge), and // section's edge allows (it may run off the screen's left edge), and
@ -244,7 +245,7 @@ export default function PageShell({ title, intro, sections, sideNav = false }: P
// far corner. Never wider than the column (it'd show a cut edge at // far corner. Never wider than the column (it'd show a cut edge at
// the content): held narrower by the window, it stays centered on // the content): held narrower by the window, it stays centered on
// the header's edge (so below it, it only ever curves inward) and // the header's edge (so below it, it only ever curves inward) and
// becomes an ellipse, as tall as it takes to take the list in. // becomes a pill, as tall as it takes to take the list in.
const circleBox = (() => { const circleBox = (() => {
if (!listBox || !rest) return null; if (!listBox || !rest) return null;
if (stuck) { if (stuck) {