Page fixes: v1.10.7 to v1.10.10 #21

Merged
ngu-git-admin merged 17 commits from page-fixes into main 2026-10-01 10:53:41 +01:00
2 changed files with 62 additions and 10 deletions
Showing only changes of commit c335774db5 - Show all commits

View file

@ -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;

View file

@ -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 ? (
<div aria-hidden="true" className="pointer-events-none sticky z-10 h-0" style={{ top: stickAt(listTop) }}>
<div
className="side-nav-circle absolute rounded-full"
data-family={circleFamily(activeAccent)}
style={{
width: circle,
height: 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,
width: circleBox.size,
height: circleBox.size,
left: circleBox.left,
top: circleBox.top,
}}
/>
</div>