diff --git a/src/components/PageShell.tsx b/src/components/PageShell.tsx index 096f007..65f4676 100644 --- a/src/components/PageShell.tsx +++ b/src/components/PageShell.tsx @@ -107,16 +107,17 @@ export function Section({ section }: { section: ShellSection }) { const circleSize = (box: { width: number; height: number }) => 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 / a)^2 + (down / b)^2 <= 1. Equal to the width when a circle - that wide would do; taller when the list is too tall for one. A - box as wide as the ellipse can't be taken in, so it stops at 95% - (about three times the box's height). */ + the corner must sit inside an end's circle, so the straight part + reaches down - sqrt(r^2 - across^2). Equal to the width when a + circle that wide would do; taller when the list is too tall for + 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 a = width / 2; - const ratio = Math.min(across / a, 0.95); - return Math.max(width, (2 * down) / Math.sqrt(1 - ratio * ratio)); + const r = width / 2; + const ratio = Math.min(across / r, 0.95); + 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 @@ -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, // 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). // 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 @@ -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 // the content): held narrower by the window, it stays centered on // 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 = (() => { if (!listBox || !rest) return null; if (stuck) {