Merge page-fixes (v1.10.7 to v1.10.10)

This commit is contained in:
ngu-git-admin 2026-10-01 10:53:40 +01:00
commit 0bb4b8685f
11 changed files with 353 additions and 61 deletions

View file

@ -30,7 +30,7 @@ what a dropdown in the admin editor says.
| A record: an event, organization, person, team, award, timeline entry | the database | editing it in the admin |
| The front page's words, photos, bands, stats and paths | the database | Admin → Pages → Front page |
| Blog posts, and the Community page's blog settings (headings, pins, feeds) | the database | Admin → Data → Blog posts, and Admin → Pages → Community |
| The sections of Retreats, Community, Resources, Organization and History: titles, blurbs, accents, their content blocks and presets (the blog, groups map, regions, partners, events, timeline, NGU's details) | the database | Admin → Pages → the page. A section title is 30 characters at most (it's listed in the side nav); a front page heading fits about 60. Preset names: `PRESETS` in `src/lib/adminSchema/sitePages.ts`, what each draws: `PRESETS` in `src/pages/SitePage.tsx` |
| The sections of Retreats, Community, Resources, Organization and History: titles, blurbs, accents, their content blocks and presets (the blog, groups map, regions, partners, events, timeline) | the database | Admin → Pages → the page. A section title is 30 characters at most (it's listed in the side nav); a front page heading fits about 60. Preset names: `PRESETS` in `src/lib/adminSchema/sitePages.ts`, what each draws: `PRESETS` in `src/pages/SitePage.tsx` |
| The **label** a dropdown shows in the admin | code | [one file](#renaming-what-a-dropdown-shows) |
| The **list of allowed values** behind a fixed dropdown | database CHECK + code | [a migration and three files](#adding-removing-or-renaming-a-stored-value) |
| Navigation, colors, the site banner, history decades, the map grid | code | [the file named below](#other-content-that-lives-in-code) |

View file

@ -30,7 +30,6 @@ const sectionsChild = {
"partner_list",
"events",
"timeline",
"organization_details",
]),
text("scope_id"),
enumeration("event_type", ["retreat", "class", "workshop", "meeting", "other"]),

View file

@ -0,0 +1,73 @@
-- ═══════════════════════════════════════════════════════════════
-- 058 DETAILS & CONTACT AS BLOCKS
--
-- The Organization page's Details & Contact section was a preset
-- (organization_details) drawing NGU's address, tax ID and email
-- from code. It's ordinary content now, edited like any section's:
-- each section that used the preset gets those details as blocks
-- (the address, the nonprofit line with the tax ID, an email
-- button), and the preset leaves page_sections' CHECK.
--
-- page_sections is rebuilt for that CHECK, keeping its ids (its
-- blocks are owned by them), with its index and cleanup trigger.
-- ═══════════════════════════════════════════════════════════════
INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text, href)
SELECT 'page_section', CAST(s.id AS TEXT), 'body', b.sort_order, b.type, b.text, b.href
FROM page_sections s
CROSS JOIN (
SELECT 1000 AS sort_order, 'paragraph' AS type,
'1901 NW Blue Parkway' || char(10) || 'Unity Village, MO 64065' || char(10) ||
'*(Physical address, not for mail)*' AS text,
NULL AS href
UNION ALL
SELECT 1001, 'paragraph',
'Next Generation of Unity is a qualified 501(c)(3) nonprofit organization. Tax ID: 33-2819320.', NULL
UNION ALL
SELECT 1002, 'button', 'info@nextgenerationofunity.org', 'mailto:info@nextgenerationofunity.org'
) b
WHERE s.preset = 'organization_details';
UPDATE page_sections SET preset = NULL WHERE preset = 'organization_details';
CREATE TABLE page_sections_new (
id INTEGER PRIMARY KEY AUTOINCREMENT,
page_id TEXT NOT NULL REFERENCES site_pages (id) ON DELETE CASCADE,
sort_order INTEGER NOT NULL DEFAULT 0,
anchor TEXT NOT NULL
CONSTRAINT "A section's URL ID can use only lowercase letters, numbers and hyphens, eg. leadership."
CHECK (anchor <> '' AND anchor NOT GLOB '*[^a-z0-9-]*'),
title TEXT NOT NULL
CONSTRAINT "A section title can be 30 characters at most (it's listed in the page's side nav)."
CHECK (length(title) <= 30),
blurb TEXT,
accent TEXT CHECK (accent IN ('teal', 'deep', 'green', 'amber')),
preset TEXT CHECK (preset IN ('community_blog', 'group_map', 'region_list', 'partner_list',
'events', 'timeline')),
-- An events preset's filter and first view.
scope_id TEXT REFERENCES event_scopes (id) ON DELETE SET NULL,
event_type TEXT CHECK (event_type IN ('retreat', 'class', 'workshop', 'meeting', 'other')),
view TEXT CHECK (view IN ('carousel', 'grid', 'map')),
UNIQUE (page_id, anchor)
) STRICT;
INSERT INTO page_sections_new
(id, page_id, sort_order, anchor, title, blurb, accent, preset, scope_id, event_type, view)
SELECT id, page_id, sort_order, anchor, title, blurb, accent, preset, scope_id, event_type, view
FROM page_sections;
PRAGMA legacy_alter_table = ON;
DROP TABLE page_sections;
ALTER TABLE page_sections_new RENAME TO page_sections;
PRAGMA legacy_alter_table = OFF;
CREATE INDEX page_sections_page_idx ON page_sections (page_id, sort_order);
-- ── Triggers last (see CLAUDE.md, Migrations) ──
CREATE TRIGGER page_sections_cleanup
AFTER DELETE ON page_sections
BEGIN
DELETE FROM content_blocks WHERE owner_kind = 'page_section' AND owner_id = CAST(old.id AS TEXT);
END;

View file

@ -189,8 +189,12 @@ export default function Layout() {
</NavLink>
{pageSections.length > 0 && (
// pt-3 is the bridge the pointer crosses from the
// link into the menu without it closing.
<div className="invisible absolute top-full left-0 z-10 pt-3 opacity-0 transition-opacity duration-150 group-hover:visible group-hover:opacity-100 group-focus-within:visible group-focus-within:opacity-100">
// link into the menu without it closing. Keyboard
// focus opens it too, but only keyboard focus
// (:focus-visible): a click leaves focus on the
// link, which held the menu open after the
// pointer had gone.
<div className="invisible absolute top-full left-0 z-10 pt-3 opacity-0 transition-opacity duration-150 group-hover:visible group-hover:opacity-100 group-has-[:focus-visible]:visible group-has-[:focus-visible]:opacity-100">
<ul
className="min-w-56 py-2 shadow-xl"
style={{ background: "rgba(0, 16, 17, 0.97)", borderTop: "2px solid #9cc47c" }}

View file

@ -0,0 +1,49 @@
/* 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;
/* 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:
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;
}
.side-nav-circle[data-family="amber"] {
background: #fdf1d6;
}
/* 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;
}
:root[data-theme="dark"] .side-nav-circle[data-family="amber"] {
background: #4a2e00;
}
@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;
}
:root:not([data-theme="light"]) .side-nav-circle[data-family="amber"] {
background: #4a2e00;
}
}

View file

@ -5,10 +5,15 @@
heading with a blurb and rule. Sections paint no background of
their own: the page's (PageBackdrop.tsx) runs behind all of them.
`sideNav` adds an "On this page" column at the left from lg up, the
`sideNav` adds an "On this page" list in the left margin, the
admin editors' own (SectionNav), sticky under the header, listing
the sections with the one being read lit. Below lg the menu lists
the sections instead.
the sections with the one being read lit. It sits beside the
sections rather than taking a column from them, so they stay where
they'd be without it; it shows once the margin beside the 72rem
content is wide enough for it and its circle to take in the
longest list a page may have, 10 sections of two-line titles (30
characters, 15 a line): 2xl (96rem, 1536px) screens up. Narrower,
the header's dropdowns list the sections instead.
Whatever goes inside a section is passed as `content`, the shell
doesn't care what it is.
@ -34,11 +39,12 @@
/>
═══════════════════════════════════════════════════════════════ */
import { useEffect, type ReactNode } from "react";
import { useEffect, useRef, useState, type ReactNode } from "react";
import { documentTitle } from "../lib/site.ts";
import { accentText, BRAND } from '../lib/color.ts'
import { SectionNav } from "./admin/SectionNav.tsx";
import { accentText, ACCENTS, BRAND } from '../lib/color.ts'
import { SectionNav, useActiveSection } from "./admin/SectionNav.tsx";
import "./PageShell.css";
export type ShellSection = {
@ -97,7 +103,161 @@ export function Section({ section }: { section: ShellSection }) {
);
}
/* The side nav's circle at rest: half again the list's width (or a
little more than its height, if taller), at most 22rem. */
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
`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). */
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));
};
/* How far the list sits in from the column's top and left: the
circle centers on that. LIST_TOP puts "On this page" level with
the first section's title: the line (h-2, 8px), the section's
py-20 (80px), then half the difference between the title's 40px
line (md:text-4xl) and the heading's 16px one. Lower still if its
circle needs the room to start CIRCLE_GAP below that first line
rather than over it.
Once the page scrolls, the list sticks just STUCK_TOP under the
header, so its circle rises up behind the header like a sun in the
corner; the sticky offset takes back whatever the list sits lower
than that. */
const LIST_TOP = 8 + 100 + (40 - 16) / 2;
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;
/* Room the circle keeps: from the section's edge at rest, and around
the list it takes in. */
const CIRCLE_EDGE = 16;
const CIRCLE_MARGIN = 12;
/* 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. */
const circleFamily = (accent?: string) =>
accent === ACCENTS.green ? "green" : accent === ACCENTS.amber ? "amber" : "teal";
/* How far left of the list's center the circle sits, at most: never
left of the "On this page" heading's own center, so a list of short
titles keeps it on the heading. */
const CIRCLE_SHIFT = 24;
export default function PageShell({ title, intro, sections, sideNav = false }: PageShellProps) {
// The list's measured box, so its circle can center on it from a
// layer of its own (below).
// The column's width too: the circle keeps its right edge inside
// it, sliding off the screen's left edge instead when the window
// narrows.
const listRef = useRef<HTMLDivElement>(null);
const columnRef = useRef<HTMLElement>(null);
const [listBox, setListBox] = useState<{ width: number; height: number; heading: number } | null>(null);
const [columnWidth, setColumnWidth] = useState(0);
useEffect(() => {
const list = listRef.current;
const column = columnRef.current;
if (!list || !column) return;
const ro = new ResizeObserver(() => {
const heading = list.querySelector<HTMLElement>("[data-nav-heading]");
setListBox({
width: list.offsetWidth,
height: list.offsetHeight,
// The heading's center, from the list's left.
heading: heading ? heading.offsetLeft + heading.offsetWidth / 2 : 0,
});
setColumnWidth(column.offsetWidth);
});
ro.observe(list);
ro.observe(column);
return () => ro.disconnect();
}, [sideNav]);
const navSections = sideNav ? sections.map((s) => ({ id: s.id, label: s.title, accent: s.accent })) : [];
const active = useActiveSection(navSections);
const activeAccent = sections.find((s) => s.id === active)?.accent;
// 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
// 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
// the height it then takes.
const restAt = (width: number, box: { width: number; height: number; heading: number }) => {
const center = Math.min(
LIST_LEFT + Math.max(box.width / 2 - CIRCLE_SHIFT, box.heading),
columnWidth - CIRCLE_EDGE - width / 2,
);
const across = Math.max(center - LIST_LEFT, LIST_LEFT + box.width - center) + CIRCLE_MARGIN;
return { width, height: coverHeight(width, across, box.height / 2 + CIRCLE_MARGIN), left: center - width / 2 };
};
const rest = (() => {
if (!listBox) return null;
const circle = restAt(circleSize(listBox), listBox);
if (circle.height <= circle.width) return circle;
// Too tall a list for the circle: the width, up to 22rem, that
// needs the least height.
let best = circle;
for (let width = listBox.width + 2 * CIRCLE_MARGIN; width <= 22 * 16; width += 8) {
const shape = restAt(width, listBox);
if (shape.height < best.height) best = shape;
}
return best;
})();
const listTop = listBox && rest ? Math.max(LIST_TOP, CIRCLE_GAP + rest.height / 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). At rest: `rest` above. 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, reaching past the list's
// 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.
const circleBox = (() => {
if (!listBox || !rest) return null;
if (stuck) {
const across = LIST_LEFT + listBox.width + CIRCLE_MARGIN;
const down = STUCK_TOP + listBox.height + CIRCLE_MARGIN;
const width = 2 * Math.min(Math.hypot(across, down), columnWidth - 8);
const height = coverHeight(width, across, down);
return { width, height, left: -width / 2, top: listTop - STUCK_TOP - height / 2 };
}
return { width: rest.width, height: rest.height, left: rest.left, top: listTop + listBox.height / 2 - rest.height / 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.
@ -105,12 +265,9 @@ export default function PageShell({ title, intro, sections, sideNav = false }: P
if (typeof title === "string") document.title = documentTitle(title);
}, [title]);
// The thin solid banner between sections. With the side nav it runs
// the page's full width, under the nav column, rather than stopping
// at the content's edge.
const banner = (accent: string) => (
<div className={`h-2 ${sideNav ? "lg:-ml-[var(--side-nav-w)]" : ""}`} style={{ background: accent }} />
);
// The thin solid banner between sections, the page's full width
// (behind the side nav).
const banner = (accent: string) => <div className="h-2" style={{ background: accent }} />;
const bands = sections.map((section, i) => (
<div key={section.id}>
{banner(section.accent)}
@ -132,13 +289,45 @@ export default function PageShell({ title, intro, sections, sideNav = false }: P
</div>
{sideNav ? (
<div className="[--side-nav-w:16rem] lg:grid lg:grid-cols-[var(--side-nav-w)_minmax(0,1fr)]">
<aside className="relative z-10 hidden lg:block">
<div className="sticky pt-8 pl-6 pr-2" style={{ top: "calc(var(--header-h, 5rem) + 1rem)" }}>
<SectionNav sections={sections.map((s) => ({ id: s.id, label: s.title }))} wrap />
<div className="relative">
{/* The margin left of the content (72rem, its text 1.5rem in),
clipping sideways only, so nothing reaches the
content or the screen's edge. clip, not hidden: hidden
would make it a scroll container, and the sticky layers in
it would stop sticking. */}
<aside
ref={columnRef}
className="absolute inset-y-0 left-0 hidden overflow-x-clip 2xl:block"
style={{ width: "calc((100% - 72rem) / 2 + 1rem)" }}
>
{/* A solid circle centered on the list, in the light shade
of the section being read (PageShell.css): a sticky layer of
its own, in front of the section lines like the list,
which comes after it and so draws over it. Height 0, so
the list's layer below starts, and sticks, at the same
place. */}
{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: circleBox.width,
height: circleBox.height,
left: circleBox.left,
top: circleBox.top,
}}
/>
</div>
) : null}
{/* The list, in front of the section lines and its circle. */}
<div className="sticky z-10 pl-4 pr-2" style={{ top: stickAt(listTop), paddingTop: listTop }}>
<div ref={listRef} className="w-fit max-w-full">
<SectionNav sections={navSections} wrap />
</div>
</div>
</aside>
<div className="min-w-0">{bands}</div>
{bands}
</div>
) : (
bands

View file

@ -18,17 +18,21 @@
import { useEffect, useState } from "react";
import { scrollBehavior } from "../../lib/motion.ts";
import { accentText } from "../../lib/color.ts";
export type EditorSection = {
id: string;
label: string;
/** The public pages' section color: its entry takes it when hovered
or lit. Without one (the editors), the link teal. */
accent?: string;
count?: number;
hasError?: boolean;
};
const ACTIVE_LINE = 140;
function useActiveSection(sections: EditorSection[]) {
export function useActiveSection(sections: EditorSection[]) {
const [active, setActive] = useState<string | null>(sections[0]?.id ?? null);
const ids = sections.map((section) => section.id).join("|");
@ -91,7 +95,7 @@ export function SectionNav({ sections, wrap = false }: { sections: EditorSection
return (
<nav aria-label="Sections" className="hidden max-h-[calc(100vh-8rem)] overflow-y-auto lg:block">
<p className="mb-2 px-3 text-xs font-semibold uppercase tracking-wider text-muted/70">
<p data-nav-heading className="mb-2 w-fit px-3 text-xs font-semibold uppercase tracking-wider text-muted/70">
On this page
</p>
<ul className="space-y-0.5 border-l border-brand/15">
@ -103,10 +107,15 @@ export function SectionNav({ sections, wrap = false }: { sections: EditorSection
type="button"
onClick={() => jump(section.id)}
aria-current={lit ? "location" : undefined}
style={section.accent ? ({ "--nav-accent": accentText(section.accent) } as React.CSSProperties) : undefined}
className={`-ml-px flex w-full items-center gap-1.5 border-l-2 px-3 py-1.5 text-left text-sm transition-colors ${
lit
? "border-brand font-semibold text-link"
: "border-transparent text-muted hover:border-brand/40 hover:text-link"
section.accent
? lit
? "border-[var(--nav-accent)] font-semibold text-[var(--nav-accent)]"
: "border-transparent text-muted hover:border-[var(--nav-accent)]/40 hover:text-[var(--nav-accent)]"
: lit
? "border-brand font-semibold text-link"
: "border-transparent text-muted hover:border-brand/40 hover:text-link"
}`}
>
<Label section={section} wrap={wrap} />

View file

@ -2,7 +2,8 @@
ORGANIZATION DETAILS
NGU's own address, nonprofit status and contact email, shown in
the footer and in the Organization page's Details & Contact. The
the footer (the Organization page's Details & Contact is its own
blocks, Pages → Organization, seeded from these by migration 058). The
street address is where NGU is, not where to send post, and says
so.
═══════════════════════════════════════════════════════════════ */

View file

@ -18,7 +18,6 @@ const PRESETS = {
partner_list: "Partner organization cards",
events: "Event carousel or grid",
timeline: "Timeline",
organization_details: "Address, tax ID and email",
};
const ACCENT_OPTIONS = [
@ -211,5 +210,5 @@ export const communityPage = sitePage(
export const retreatsPage = sitePage("retreats", "Retreats page", ["events"]);
export const resourcesPage = sitePage("resources", "Resources page", []);
export const organizationPage = sitePage("organization", "Organization page", ["organization_details"]);
export const organizationPage = sitePage("organization", "Organization page", []);
export const historyPage = sitePage("history", "History page", ["timeline"]);

View file

@ -7,4 +7,4 @@
box or a build banner can read the same value later.
═══════════════════════════════════════════════════════════════ */
export const SITE_VERSION = "NGU-Web.v1.10.6";
export const SITE_VERSION = "NGU-Web.v1.10.10";

View file

@ -22,7 +22,6 @@ import { sitePage } from '../lib/site.ts'
import { useSectionManifest } from '../lib/sections.tsx'
import { useSitePage, type SitePageSection } from '../lib/useSitePages.ts'
import { useHistory } from '../lib/useHistory.ts'
import { ORGANIZATION_DETAILS } from '../data/organizationDetails.ts'
import { HISTORY_DECADES } from '../data/historyDecades.ts'
import { ACCENTS, BRAND } from '../lib/color.ts'
import { scrollBehavior } from '../lib/motion.ts'
@ -79,7 +78,6 @@ const PRESETS: Record<string, (section: SitePageSection) => Record<string, any>>
},
}),
timeline: () => ({ Component: Timeline }),
organization_details: () => ({ Component: OrganizationDetails }),
}
export default function SitePage({ id }: { id: string }) {
@ -185,32 +183,3 @@ function Timeline({ accent = BRAND }: { accent?: string }) {
</div>
)
}
/* NGU's address, nonprofit status and email (src/data/organizationDetails.ts). */
function OrganizationDetails() {
const details = ORGANIZATION_DETAILS
return (
<div className="mx-auto grid max-w-6xl gap-8 px-6 md:grid-cols-2">
<div className="space-y-3 text-body">
<address className="not-italic leading-relaxed">
{details.street}
<br />
{details.cityLine}
<br />
<span className="text-sm text-muted">({details.addressNote})</span>
</address>
<p className="text-sm text-muted">
{details.nonprofit} Tax ID: {details.taxId}.
</p>
</div>
<div>
<a
href={`mailto:${details.email}`}
className="btn inline-block border border-link px-6 py-2.5 text-link transition-colors hover:bg-tint"
>
{details.email}
</a>
</div>
</div>
)
}