Clean up code found in the audit

- Replace every em-dash in src and server/src with a colon, comma or hyphen
- Give every relative import its file extension (.jsx imports of .tsx fixed)
- Delete old-historyMock.ts, unused exports, unused CSS utilities, the
  unused @ alias and the fallback option nothing passed
- One copy each of initials, capitalize, byName and the server's marks()
- Move the organization, chapter and event hooks from src/data to src/lib
- Schema sync always throws on a mismatch (strict was never turned off)
- Replace the placeholder README

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-28 22:02:03 -05:00
parent 4066e9ec61
commit 5274e09571
75 changed files with 282 additions and 688 deletions

View file

@ -1 +1,8 @@
Test line added by Claude Code. # NGU-Web
Website for NGU (Next Generation of Unity): a public site and a role-based admin panel.
- Frontend: React, TypeScript, Tailwind, Vite (`src/`). `pnpm dev`, `pnpm build`.
- API: Hono on Node 22.13+, SQLite (`server/`). `DB_PATH=./dev.db pnpm dev`.
- Accounts are made with `server/src/admin-cli.js`.
- Deployment and setup notes are in `docs/`; working notes for contributors are in `CLAUDE.md`.

View file

@ -28,7 +28,7 @@
The list comes from auth.js rather than being repeated here, so The list comes from auth.js rather than being repeated here, so
the CLI can't drift from what requireRole will actually accept. the CLI can't drift from what requireRole will actually accept.
This is also how the first superadmin is made — there's no This is also how the first superadmin is made, there's no
bootstrap path in the web interface, on purpose: bootstrap path in the web interface, on purpose:
node src/admin-cli.js role you@ngu.org superadmin node src/admin-cli.js role you@ngu.org superadmin
@ -82,7 +82,7 @@ async function readPassword() {
if (first === "") { if (first === "") {
const generated = randomBytes(12).toString("base64url"); const generated = randomBytes(12).toString("base64url");
console.log(`\nGenerated password: ${generated}`); console.log(`\nGenerated password: ${generated}`);
console.log("Copy it now — it isn't stored anywhere readable.\n"); console.log("Copy it now, it isn't stored anywhere readable.\n");
return generated; return generated;
} }
@ -116,7 +116,7 @@ function checkRole(role) {
return role; return role;
} }
/* Printed, never enforced — see the note at the top of the file. /* Printed, never enforced, see the note at the top of the file.
Worth saying out loud, because the person doing it is usually Worth saying out loud, because the person doing it is usually
tidying up accounts rather than thinking about lockouts. */ tidying up accounts rather than thinking about lockouts. */
function warnIfLastSuper(db, user) { function warnIfLastSuper(db, user) {
@ -183,7 +183,7 @@ function setRole(db, email, role) {
db.prepare("UPDATE admin_users SET role = ? WHERE id = ?").run(role, user.id); db.prepare("UPDATE admin_users SET role = ? WHERE id = ?").run(role, user.id);
// The session they're holding was issued against the old role. // The session they're holding was issued against the old role.
// Every check reads the row fresh, so it isn't a security hole — // Every check reads the row fresh, so it isn't a security hole,
// but their open tab would keep drawing buttons that now 403. // but their open tab would keep drawing buttons that now 403.
destroyAllSessionsFor(db, user.id); destroyAllSessionsFor(db, user.id);

View file

@ -18,7 +18,7 @@
ever set it, so every insert through the admin will fail. ever set it, so every insert through the admin will fail.
The first is a silent repair. The other two are deployment bugs, The first is a silent repair. The other two are deployment bugs,
so with { strict: true } they stop the service starting rather so they stop the service starting rather
than waiting to surface one row at a time. than waiting to surface one row at a time.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
@ -84,7 +84,7 @@ function collectGroups(entity) {
return groups; return groups;
} }
export function syncDescriptorsWithSchema(db, entities, { strict = true } = {}) { export function syncDescriptorsWithSchema(db, entities) {
const list = Array.isArray(entities) ? entities.map((e) => [e.name ?? e.table, e]) : Object.entries(entities); const list = Array.isArray(entities) ? entities.map((e) => [e.name ?? e.table, e]) : Object.entries(entities);
const inferred = []; const inferred = [];
@ -136,8 +136,7 @@ export function syncDescriptorsWithSchema(db, entities, { strict = true } = {})
if (problems.length) { if (problems.length) {
const report = `[admin-schema] descriptor does not match the database:\n ${problems.join("\n ")}`; const report = `[admin-schema] descriptor does not match the database:\n ${problems.join("\n ")}`;
if (strict) throw new Error(report); throw new Error(report);
console.error(report);
} }
return { inferred, problems }; return { inferred, problems };

View file

@ -3,7 +3,7 @@
Binds to localhost only. nginx is the only thing that talks to Binds to localhost only. nginx is the only thing that talks to
it, which is what lets the routes trust X-Forwarded-For and skip it, which is what lets the routes trust X-Forwarded-For and skip
CORS entirely — in production the API and the site share an CORS entirely, in production the API and the site share an
origin, and in development Vite proxies /api so they share one origin, and in development Vite proxies /api so they share one
there too. there too.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
@ -174,7 +174,7 @@ const server = serve({ fetch: app.fetch, hostname: HOST, port: PORT }, (info) =>
for (const signal of ["SIGTERM", "SIGINT"]) { for (const signal of ["SIGTERM", "SIGINT"]) {
process.on(signal, () => { process.on(signal, () => {
console.log(`${signal} — shutting down`); console.log(`${signal}, shutting down`);
server.close(() => { server.close(() => {
try { try {
db.close(); db.close();

View file

@ -180,7 +180,7 @@ CREATE TABLE event_scopes (
-- an every-other-week series is "on", which day -- an every-other-week series is "on", which day
-- of the month a monthly one keeps, and the -- of the month a monthly one keeps, and the
-- weekday used when none is ticked -- weekday used when none is ticked
-- ends_on when set, the last day it can meet — which -- ends_on when set, the last day it can meet, which
-- also keeps effective_status right -- also keeps effective_status right
-- series_count when set, stops it after that many meetings, -- series_count when set, stops it after that many meetings,
-- whichever comes first -- whichever comes first
@ -297,7 +297,7 @@ CREATE UNIQUE INDEX event_hosts_person_uniq
-- --
-- Public by design. Everything in this table can appear on a card, -- Public by design. Everything in this table can appear on a card,
-- and is_published = 0 is the only thing between a row and the open -- and is_published = 0 is the only thing between a row and the open
-- web — hence the default of 0, unlike organizations. Anything that -- web, hence the default of 0, unlike organizations. Anything that
-- must never be served lives in person_private, so a careless -- must never be served lives in person_private, so a careless
-- SELECT * can't leak it. Bios and pages go in content_blocks, -- SELECT * can't leak it. Bios and pages go in content_blocks,
-- socials in links. People sort by sort_name; there is no -- socials in links. People sort by sort_name; there is no
@ -306,7 +306,7 @@ CREATE UNIQUE INDEX event_hosts_person_uniq
CREATE TABLE people ( CREATE TABLE people (
id TEXT PRIMARY KEY, -- slug: 'jane-doe' id TEXT PRIMARY KEY, -- slug: 'jane-doe'
display_name TEXT NOT NULL, -- 'Jane Doe' display_name TEXT NOT NULL, -- 'Jane Doe'
sort_name TEXT, -- 'Doe, Jane' — list ordering sort_name TEXT, -- 'Doe, Jane', list ordering
pronouns TEXT, -- 'she/her' pronouns TEXT, -- 'she/her'
tagline TEXT, -- fallback when no title applies tagline TEXT, -- fallback when no title applies
photo TEXT, -- filename in public/people/ photo TEXT, -- filename in public/people/
@ -346,7 +346,7 @@ CREATE TABLE person_private (
-- A team belongs to exactly one organization: NGU national has a -- A team belongs to exactly one organization: NGU national has a
-- Board and a Leadership Team, a region or chapter can have its own. -- Board and a Leadership Team, a region or chapter can have its own.
-- UNIQUE (id, org_id) looks redundant against the primary key, and -- UNIQUE (id, org_id) looks redundant against the primary key, and
-- is — except that it gives affiliations a composite foreign key to -- is, except that it gives affiliations a composite foreign key to
-- point at, which stops someone filing a person under a team -- point at, which stops someone filing a person under a team
-- belonging to a different organization. -- belonging to a different organization.
CREATE TABLE teams ( CREATE TABLE teams (
@ -548,7 +548,7 @@ CREATE TABLE timeline_entries (
-- Null inherits from the referenced row: an event's starts_on. A -- Null inherits from the referenced row: an event's starts_on. A
-- hand-authored entry has to supply its own, which the descriptor -- hand-authored entry has to supply its own, which the descriptor
-- can't require conditionally — the read layer reports an entry -- can't require conditionally, the read layer reports an entry
-- with neither rather than the table refusing it. -- with neither rather than the table refusing it.
occurred_on TEXT, occurred_on TEXT,
@ -604,9 +604,9 @@ CREATE INDEX timeline_entry_people_person_idx
-- FRONT PAGE -- FRONT PAGE
-- ═══════════════════════════════════════════════════════════════ -- ═══════════════════════════════════════════════════════════════
-- --
-- The home page's editable half. One row in front_page — the CHECK -- The home page's editable half. One row in front_page, the CHECK
-- on id makes a second one impossible, and the admin engine treats -- on id makes a second one impossible, and the admin engine treats
-- it as a singleton — and ordered collections hanging off it, each -- it as a singleton, and ordered collections hanging off it, each
-- replaced wholesale on save. Nothing has a foreign key into them, -- replaced wholesale on save. Nothing has a foreign key into them,
-- which is what makes that safe. -- which is what makes that safe.
-- --
@ -759,7 +759,7 @@ CREATE TABLE admin_users (
-- password at all. A row with both can use either route in. -- password at all. A row with both can use either route in.
password_hash TEXT, password_hash TEXT,
-- Google's stable subject id. Nullable, unique when present — -- Google's stable subject id. Nullable, unique when present,
-- SQLite allows any number of NULLs in a unique index. -- SQLite allows any number of NULLs in a unique index.
google_sub TEXT UNIQUE, google_sub TEXT UNIQUE,
@ -935,7 +935,7 @@ SELECT
tm.name AS team_name, tm.name AS team_name,
-- Whether the referenced record is itself visible. An entry must not -- Whether the referenced record is itself visible. An entry must not
-- outlive the thing it points at being unpublished — a draft event -- outlive the thing it points at being unpublished, a draft event
-- would otherwise leak its title and date onto a public page. Null -- would otherwise leak its title and date onto a public page. Null
-- for a standalone milestone, which answers to nothing but its own -- for a standalone milestone, which answers to nothing but its own
-- is_published. -- is_published.
@ -964,7 +964,7 @@ LEFT JOIN person_awards pa ON t.ref_kind = 'award' AND pa.award_id = t.re
-- ═══════════════════════════════════════════════════════════════ -- ═══════════════════════════════════════════════════════════════
-- --
-- What a new database needs before anyone signs in: the scopes an -- What a new database needs before anyone signs in: the scopes an
-- event can be filed under, and the front page as it ships — every -- event can be filed under, and the front page as it ships, every
-- section, the stats that need no typing, and the Church Center -- section, the stats that need no typing, and the Church Center
-- forms sorted into paths. Everything else comes in through the -- forms sorted into paths. Everything else comes in through the
-- admin. -- admin.

View file

@ -7,7 +7,7 @@
The client IP comes from clientIp() in auth.js (the entry nginx The client IP comes from clientIp() in auth.js (the entry nginx
adds to X-Forwarded-For). That is only trustworthy because adds to X-Forwarded-For). That is only trustworthy because
nothing but nginx can reach this port — it binds to 127.0.0.1. Don't expose the port. nothing but nginx can reach this port, it binds to 127.0.0.1. Don't expose the port.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
import { clientIp } from "./auth.js"; import { clientIp } from "./auth.js";

View file

@ -24,7 +24,7 @@
import { Hono } from "hono"; import { Hono } from "hono";
import { asBool, loadBlocks, loadFeaturedCards, paragraphs } from "../shape.js"; import { asBool, loadBlocks, marks, loadFeaturedCards, paragraphs } from "../shape.js";
import { readFeeds } from "../feeds.js"; import { readFeeds } from "../feeds.js";
const blog = new Hono(); const blog = new Hono();
@ -33,7 +33,6 @@ const CACHE = "public, max-age=60, stale-while-revalidate=300";
const json = (c, body) => c.json(body, 200, { "Cache-Control": CACHE }); const json = (c, body) => c.json(body, 200, { "Cache-Control": CACHE });
const marks = (n) => Array(n).fill("?").join(",");
const PAGE_ID = "community"; const PAGE_ID = "community";

View file

@ -1,5 +1,5 @@
/* ═══════════════════════════════════════════════════════════════ /* ═══════════════════════════════════════════════════════════════
CONTENT ROUTES — read-only, mounted under /api CONTENT ROUTES: read-only, mounted under /api
GET /events list + the event scopes GET /events list + the event scopes
GET /events/:id one event, full body, people GET /events/:id one event, full body, people
@ -12,7 +12,7 @@
Organizations are one table, so they're one endpoint. A region Organizations are one table, so they're one endpoint. A region
and a chapter differ by a handful of fields, which arrive under and a chapter differ by a handful of fields, which arrive under
`details` rather than as separate routes — that's what lets a `details` rather than as separate routes, that's what lets a
list component be written once and pointed at any kind. list component be written once and pointed at any kind.
The lists leave out unlisted records (is_listed = 0); the The lists leave out unlisted records (is_listed = 0); the
@ -32,7 +32,7 @@
every event. every event.
An event's hosts are a list, in billing order, and each one is An event's hosts are a list, in billing order, and each one is
either an organization or a person — `kind` says which, and either an organization or a person, `kind` says which, and
`org_kind` is there for the three organization routes. The `org_kind` is there for the three organization routes. The
first is the one the colour and logo fell back to, which is why first is the one the colour and logo fell back to, which is why
order is data and not a display choice. order is data and not a display choice.
@ -56,6 +56,7 @@ import {
asBool, asBool,
loadBlocks, loadBlocks,
loadLinks, loadLinks,
marks,
paragraphs, paragraphs,
shapeSeries, shapeSeries,
splitLinks, splitLinks,
@ -72,7 +73,6 @@ const json = (c, body) => c.json(body, 200, { "Cache-Control": CACHE });
const ORG_KINDS = ["national", "region", "chapter", "partner"]; const ORG_KINDS = ["national", "region", "chapter", "partner"];
const marks = (n) => Array(n).fill("?").join(",");
/* ── Loaders ───────────────────────────────────────────────── */ /* ── Loaders ───────────────────────────────────────────────── */
@ -83,7 +83,7 @@ const marks = (n) => Array(n).fill("?").join(",");
Unpublished hosts are dropped here rather than in the view: the Unpublished hosts are dropped here rather than in the view: the
admin reads the same view and needs to see them. An event whose admin reads the same view and needs to see them. An event whose
only host is unpublished comes back with an empty list, which is only host is unpublished comes back with an empty list, which is
the right answer — there is nobody to name and nowhere to link. */ the right answer, there is nobody to name and nowhere to link. */
function loadHosts(db, ids) { function loadHosts(db, ids) {
const byEvent = new Map(); const byEvent = new Map();
if (ids.length === 0) return byEvent; if (ids.length === 0) return byEvent;
@ -230,8 +230,8 @@ function shapeTeam(row, links, cardBlocks) {
}; };
} }
/* awards.org_id is nullable — an award can predate any decision /* awards.org_id is nullable, an award can predate any decision
about which organization owns it — so `org` genuinely can be about which organization owns it, so `org` genuinely can be
null, and is also null when the awarding org is unpublished. */ null, and is also null when the awarding org is unpublished. */
function shapeAward(row) { function shapeAward(row) {
return { return {
@ -372,7 +372,7 @@ function attachLeadership(db, orgs) {
/* Every team this organization has, including ones with nobody /* Every team this organization has, including ones with nobody
currently filed under them. `leadership` already carries team_id currently filed under them. `leadership` already carries team_id
and team_name, so the page can group people without this — but and team_name, so the page can group people without this, but
grouping alone would make an empty team invisible rather than grouping alone would make an empty team invisible rather than
listed, which is the wrong answer for a team that exists. */ listed, which is the wrong answer for a team that exists. */
function attachTeams(db, orgs) { function attachTeams(db, orgs) {

View file

@ -1,5 +1,5 @@
/* ═══════════════════════════════════════════════════════════════ /* ═══════════════════════════════════════════════════════════════
FEEDBACK ROUTE — the only public write on the site FEEDBACK ROUTE: the only public write on the site
Everything hostile that will ever reach this service arrives Everything hostile that will ever reach this service arrives
here, so the defences live here rather than being sprinkled here, so the defences live here rather than being sprinkled
@ -30,7 +30,7 @@ const LIMITS = {
const MIN_MESSAGE = 10; const MIN_MESSAGE = 10;
// Must match FEEDBACK_TYPES in src/pages/sections/FeedbackForm.jsx. // Must match FEEDBACK_TYPES in src/pages/sections/FeedbackForm.jsx.
// Anything else falls back to 'general' rather than being rejected — // Anything else falls back to 'general' rather than being rejected,
// a renamed option shouldn't lose someone's submission. // a renamed option shouldn't lose someone's submission.
const TYPES = ["broken", "confusing", "outdated", "request", "praise", "other"]; const TYPES = ["broken", "confusing", "outdated", "request", "praise", "other"];

View file

@ -1,5 +1,5 @@
/* ═══════════════════════════════════════════════════════════════ /* ═══════════════════════════════════════════════════════════════
HISTORY ROUTE — read-only, mounted under /api HISTORY ROUTE: read-only, mounted under /api
GET /history every published timeline entry GET /history every published timeline entry
@ -17,7 +17,7 @@
queries doesn't grow with the number of entries. queries doesn't grow with the number of entries.
· precision that outruns the date. An entry can hold '2012' with · precision that outruns the date. An entry can hold '2012' with
precision 'day' — the admin doesn't stop you. Trusting that precision 'day', the admin doesn't stop you. Trusting that
pair would put the entry in a month node built from a month pair would put the entry in a month node built from a month
that isn't there, so precision is capped at what the string that isn't there, so precision is capped at what the string
actually carries. actually carries.
@ -31,6 +31,7 @@
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
import { Hono } from "hono"; import { Hono } from "hono";
import { marks } from "../shape.js";
const history = new Hono(); const history = new Hono();
@ -38,7 +39,6 @@ const CACHE = "public, max-age=60, stale-while-revalidate=300";
const json = (c, body) => c.json(body, 200, { "Cache-Control": CACHE }); const json = (c, body) => c.json(body, 200, { "Cache-Control": CACHE });
const marks = (n) => Array(n).fill("?").join(",");
/* 'YYYY' → year, 'YYYY-MM' → month, 'YYYY-MM-DD' → day. */ /* 'YYYY' → year, 'YYYY-MM' → month, 'YYYY-MM-DD' → day. */
function precisionOfString(date) { function precisionOfString(date) {
@ -115,7 +115,7 @@ history.get("/history", (c) => {
) )
.all(); .all();
// How many entries exist but can't be placed. Worth knowing about — // How many entries exist but can't be placed. Worth knowing about,
// an entry nobody gave a date to is invisible, and silence is how it // an entry nobody gave a date to is invisible, and silence is how it
// stays that way. // stays that way.
const undated = db const undated = db
@ -153,7 +153,7 @@ function loadRosters(db, rows) {
const teamIds = [...new Set(teamEntries.map((row) => row.ref_id))]; const teamIds = [...new Set(teamEntries.map((row) => row.ref_id))];
// v_org_leadership already decides who counts as current and // v_org_leadership already decides who counts as current and
// public — affiliation still open, marked public, person // public, affiliation still open, marked public, person
// published. Restating those conditions here is how they drift. // published. Restating those conditions here is how they drift.
const members = db const members = db
.prepare( .prepare(

View file

@ -1,12 +1,12 @@
/* ═══════════════════════════════════════════════════════════════ /* ═══════════════════════════════════════════════════════════════
PEOPLE ROUTES — read-only, mounted under /api PEOPLE ROUTES: read-only, mounted under /api
GET /teams/:id/people current public members of a team GET /teams/:id/people current public members of a team
GET /people?ids=a,b,c named people, any order GET /people?ids=a,b,c named people, any order
GET /people/:id one person's page GET /people/:id one person's page
The team route reads v_org_leadership, which already decides who The team route reads v_org_leadership, which already decides who
counts as current and public — affiliation still open, marked counts as current and public, affiliation still open, marked
public, person published. Restating those conditions here is how public, person published. Restating those conditions here is how
they drift apart. they drift apart.
@ -21,7 +21,7 @@
import { Hono } from "hono"; import { Hono } from "hono";
import { asBool, loadBlocks, loadLinks, paragraphs, splitLinks } from "../shape.js"; import { asBool, loadBlocks, loadLinks, marks, paragraphs, splitLinks } from "../shape.js";
const people = new Hono(); const people = new Hono();
@ -29,7 +29,6 @@ const CACHE = "public, max-age=60, stale-while-revalidate=300";
const json = (c, body) => c.json(body, 200, { "Cache-Control": CACHE }); const json = (c, body) => c.json(body, 200, { "Cache-Control": CACHE });
const marks = (n) => Array(n).fill("?").join(",");
/* How many slugs one request may name. Keeps the URL sane. */ /* How many slugs one request may name. Keeps the URL sane. */
const MAX_IDS = 50; const MAX_IDS = 50;
@ -55,7 +54,7 @@ function shapePerson(row) {
} }
/* people.bio is one run of prose with blank lines between /* people.bio is one run of prose with blank lines between
paragraphs — unrelated to shape.js's paragraphs(), which turns paragraphs, unrelated to shape.js's paragraphs(), which turns
content_block rows into text. */ content_block rows into text. */
function splitParagraphs(text) { function splitParagraphs(text) {
if (!text) return null; if (!text) return null;
@ -144,7 +143,7 @@ people.get("/people", (c) => {
the same visibility rules its own page applies: a role needs a the same visibility rules its own page applies: a role needs a
public affiliation and a published organization, an event must public affiliation and a published organization, an event must
be published, an award must be published and the citation be published, an award must be published and the citation
public. A hidden team drops its name rather than the role — public. A hidden team drops its name rather than the role,
the seat is still real, it just has no page to link to. the seat is still real, it just has no page to link to.
Roles are current and past. v_org_leadership only knows Roles are current and past. v_org_leadership only knows

View file

@ -3,7 +3,7 @@
Blocks and links are polymorphic: any organization, event, person Blocks and links are polymorphic: any organization, event, person
or team can own them. Every list endpoint therefore needs the or team can own them. Every list endpoint therefore needs the
same move — fetch the parent rows, then fetch all their children same move, fetch the parent rows, then fetch all their children
in one query each and stitch. in one query each and stitch.
The alternative is a query per row, which at a dozen events is The alternative is a query per row, which at a dozen events is
@ -139,7 +139,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
/* ── Card description ────────────────────────────────────────── /* ── Card description ──────────────────────────────────────────
The card slot is paragraphs by convention, so it collapses to The card slot is paragraphs by convention, so it collapses to
an array of strings — desc_a and desc_b become description[0] an array of strings, desc_a and desc_b become description[0]
and description[1]. A non-paragraph block in the card slot is and description[1]. A non-paragraph block in the card slot is
ignored here; put it in the body slot instead. ignored here; put it in the body slot instead.
───────────────────────────────────────────────────────────── */ ───────────────────────────────────────────────────────────── */
@ -172,7 +172,7 @@ export function splitLinks(links = []) {
collapse from seven flags to a list of the ticked ones, Sunday collapse from seven flags to a list of the ticked ones, Sunday
first; an empty list means "starts_on's weekday", which the first; an empty list means "starts_on's weekday", which the
client resolves since it already holds starts_on. Occurrences client resolves since it already holds starts_on. Occurrences
are not sent — they are derived, and the client derives them are not sent, they are derived, and the client derives them
against its own today. Shared by /events and /front-page. against its own today. Shared by /events and /front-page.
───────────────────────────────────────────────────────────── */ ───────────────────────────────────────────────────────────── */
const SERIES_WEEKDAYS = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]; const SERIES_WEEKDAYS = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
@ -300,3 +300,6 @@ export function loadFeaturedCards(db, ownerKind, ownerId) {
} }
export { asBool }; export { asBool };
// "?,?,?" for an IN (...) list of n values.
export const marks = (n) => Array(n).fill("?").join(",");

View file

@ -12,7 +12,7 @@ export default function Banner() {
try { try {
if (!localStorage.getItem(storageKey)) setVisible(true); if (!localStorage.getItem(storageKey)) setVisible(true);
} catch { } catch {
setVisible(true); // storage blocked — show it anyway setVisible(true); // storage blocked, show it anyway
} }
}, [storageKey]); }, [storageKey]);

View file

@ -3,7 +3,7 @@
NGU's dove, lifted from the original home page. The path and its NGU's dove, lifted from the original home page. The path and its
two transforms are the drawing as exported, untouched; only the two transforms are the drawing as exported, untouched; only the
wrapper changed — sized by the caller, coloured by currentColor, wrapper changed, sized by the caller, coloured by currentColor,
and hidden from screen readers since it's decoration wherever and hidden from screen readers since it's decoration wherever
it appears. it appears.

View file

@ -1,7 +1,7 @@
import { useState, useEffect, useRef } from "react"; import { useState, useEffect, useRef } from "react";
import { NavLink, Link, Outlet, useLocation } from "react-router-dom"; import { NavLink, Link, Outlet, useLocation } from "react-router-dom";
import { PAGE_LINKS, PAGE_SECTIONS, NAV_ACTIONS } from "../navConfig.ts"; import { PAGE_LINKS, PAGE_SECTIONS, NAV_ACTIONS } from "../navConfig.ts";
import Banner from "./Banner.jsx"; import Banner from "./Banner.tsx";
import nguLogo from "../assets/logos/NGU_Logo.svg"; import nguLogo from "../assets/logos/NGU_Logo.svg";
import Footer from "./Footer.tsx"; import Footer from "./Footer.tsx";
@ -147,10 +147,10 @@ export default function Layout() {
className="fixed top-0 left-0 right-0 z-50 backdrop-blur-md" className="fixed top-0 left-0 right-0 z-50 backdrop-blur-md"
> >
{/* Tier 0 — site-wide announcement */} {/* Tier 0, site-wide announcement */}
<Banner /> <Banner />
{/* Tier 1 — site navigation */} {/* Tier 1, site navigation */}
<nav <nav
className="flex items-center justify-between px-6 py-4" className="flex items-center justify-between px-6 py-4"
aria-label="Site" aria-label="Site"
@ -201,7 +201,7 @@ export default function Layout() {
</div> </div>
</nav> </nav>
{/* Tier 2 — sections of the current page */} {/* Tier 2, sections of the current page */}
{sections.length > 0 && ( {sections.length > 0 && (
<nav <nav
className="hidden md:flex items-center px-6 py-2" className="hidden md:flex items-center px-6 py-2"

View file

@ -4,10 +4,10 @@
sections with a thin accent banner between them, alternating sections with a thin accent banner between them, alternating
backgrounds, and a left-aligned heading with a blurb and rule. backgrounds, and a left-aligned heading with a blurb and rule.
Whatever goes inside a section is passed as `content` — the shell Whatever goes inside a section is passed as `content`, the shell
doesn't care what it is. doesn't care what it is.
No <main> and no footer here — Layout provides both, so a page No <main> and no footer here, Layout provides both, so a page
using this shell drops straight into the router's Outlet. using this shell drops straight into the router's Outlet.
Usage: Usage:
@ -58,7 +58,7 @@ export function Section({ section }: { section: ShellSection }) {
blurb, blurb,
accent, accent,
background, background,
// Optional action bar for this section's heading row — a view // Optional action bar for this section's heading row, a view
// toggle, a filter, a link. Whatever the section needs; the // toggle, a filter, a link. Whatever the section needs; the
// shell just gives it a place to sit. // shell just gives it a place to sit.
actions, actions,
@ -71,7 +71,7 @@ export function Section({ section }: { section: ShellSection }) {
className="py-20" className="py-20"
style={{ background, scrollMarginTop: "5rem" }} style={{ background, scrollMarginTop: "5rem" }}
> >
{/* Heading — left aligned, optional actions on the right */} {/* Heading, left aligned, optional actions on the right */}
<div className="max-w-6xl mx-auto px-6 mb-10"> <div className="max-w-6xl mx-auto px-6 mb-10">
<div className="flex flex-wrap items-end justify-between gap-4"> <div className="flex flex-wrap items-end justify-between gap-4">
<div> <div>

View file

@ -2,8 +2,8 @@
PAGE STATE PAGE STATE
The three ways a detail page can fail to be a detail page. All The three ways a detail page can fail to be a detail page. All
four of them need the same thing, and it should be the same thing four of them need the same thing, and it should be the same thing:
— a visitor who hits a dead retreat link and a dead chapter link a visitor who hits a dead retreat link and a dead chapter link
shouldn't get two different pages. shouldn't get two different pages.
Rendered inside PageShell so the chrome doesn't flicker in and Rendered inside PageShell so the chrome doesn't flicker in and

View file

@ -1,4 +1,4 @@
/* PeopleTiles — polaroid-style people list. /* PeopleTiles, polaroid-style people list.
Everything is scoped under .pl and driven by custom properties, so a section Everything is scoped under .pl and driven by custom properties, so a section
can retune it inline: <PeopleTiles style={{ "--pl-base-w": "150px" }} /> */ can retune it inline: <PeopleTiles style={{ "--pl-base-w": "150px" }} /> */

View file

@ -12,11 +12,11 @@ import { Link } from "react-router-dom";
import { get } from "../lib/api.ts"; import { get } from "../lib/api.ts";
import { isBadId, personHref } from "../lib/hrefs.ts"; import { isBadId, personHref } from "../lib/hrefs.ts";
import { personPhoto } from "../lib/media.ts"; import { initials, personPhoto } from "../lib/media.ts";
import "./PeopleTiles.css"; import "./PeopleTiles.css";
/** /**
* PeopleTiles — a horizontal, polaroid-style people list. * PeopleTiles, a horizontal, polaroid-style people list.
* *
* Supply data any of four ways: * Supply data any of four ways:
* *
@ -33,7 +33,7 @@ import "./PeopleTiles.css";
* is_owner flag. * is_owner flag.
* *
* With `peopleslug`, the person is fetched by id and any other key * With `peopleslug`, the person is fetched by id and any other key
* on the entry overrides what came back — so a title can be given * on the entry overrides what came back, so a title can be given
* per placement, and is blank when it isn't. A slug entry can sit * per placement, and is blank when it isn't. A slug entry can sit
* beside a fully-written person in the same array. * beside a fully-written person in the same array.
* *
@ -42,7 +42,7 @@ import "./PeopleTiles.css";
* md photo + name + title * md photo + name + title
* lg photo + name + title, and a chevron on anyone who has * lg photo + name + title, and a chevron on anyone who has
* something to expand: pronouns, home organization, location, * something to expand: pronouns, home organization, location,
* public email or a bio. Not bio alone — the details panel is * public email or a bio. Not bio alone, the details panel is
* worth opening before anyone has written prose. * worth opening before anyone has written prose.
* *
* Field names follow the API (is_owner, location_label), so a row * Field names follow the API (is_owner, location_label), so a row
@ -51,8 +51,8 @@ import "./PeopleTiles.css";
* Profiles * Profiles
* A person with a string id is taken to be a people row and links * A person with a string id is taken to be a people row and links
* to /people/:id. A tile with nothing to expand is that link; an * to /people/:id. A tile with nothing to expand is that link; an
* expandable one stays the button that opens its panel — a link * expandable one stays the button that opens its panel, a link
* can't sit inside a button — and the panel carries the link * can't sit inside a button, and the panel carries the link
* instead. A hand-written entry with no id links nowhere. * instead. A hand-written entry with no id links nowhere.
*/ */
@ -136,7 +136,7 @@ const SIZE_FEATURES: Record<PeopleTilesSize, { title: boolean; details: boolean
/* ── Data ────────────────────────────────────────────────────── /* ── Data ──────────────────────────────────────────────────────
Fetching lives here rather than in every section, but the view Fetching lives here rather than in every section, but the view
below stays pure — it only ever sees resolved groups, whatever below stays pure, it only ever sees resolved groups, whatever
produced them. produced them.
───────────────────────────────────────────────────────────── */ ───────────────────────────────────────────────────────────── */
@ -290,7 +290,7 @@ function collectSlugs(
} }
/* The fetched record is the base; anything else on the entry wins, /* The fetched record is the base; anything else on the entry wins,
including an explicit null — that's how a title is deliberately including an explicit null, that's how a title is deliberately
left blank rather than inherited. */ left blank rather than inherited. */
function resolveAll( function resolveAll(
list: PersonInput[], list: PersonInput[],
@ -741,7 +741,7 @@ function findByKey(groups: PeopleGroup[], key: string | null) {
} }
/* The seat they hold here, or what they're called when there is no /* The seat they hold here, or what they're called when there is no
seat — the same fallback content.js applies to leadership rows. */ seat, the same fallback content.js applies to leadership rows. */
function titleOf(person: Person): string | null { function titleOf(person: Person): string | null {
return person.title || person.tagline || null; return person.title || person.tagline || null;
} }
@ -762,15 +762,6 @@ function hasDetails(person: Person): boolean {
} }
function initials(name = ""): string {
return name
.trim()
.split(/\s+/)
.slice(0, 2)
.map((word) => word[0] || "")
.join("")
.toUpperCase();
}
function resolveOrg(org: Person["org"]) { function resolveOrg(org: Person["org"]) {
if (!org) return null; if (!org) return null;

View file

@ -1,5 +1,5 @@
// Site-wide announcement banner. Set `enabled: false` to hide it entirely. // Site-wide announcement banner. Set `enabled: false` to hide it entirely.
// Bump `id` whenever the message changes — that re-shows the banner to // Bump `id` whenever the message changes, that re-shows the banner to
// people who dismissed the previous one. // people who dismissed the previous one.
export const SITE_BANNER = { export const SITE_BANNER = {

View file

@ -3,7 +3,7 @@
Used by the public form (to render the tiles) and the admin Used by the public form (to render the tiles) and the admin
triage view (to label them). The ids must match TYPES in triage view (to label them). The ids must match TYPES in
server/src/routes/feedback.js — that list stays separate because server/src/routes/feedback.js, that list stays separate because
the server isn't in this workspace, and it's the thing that the server isn't in this workspace, and it's the thing that
decides what's storable. decides what's storable.

View file

@ -2,7 +2,7 @@
* Decade headers for the history page. * Decade headers for the history page.
* *
* Not in the database on purpose. There are four of them, they change * Not in the database on purpose. There are four of them, they change
* about never, and they're editorial voice rather than record — the same * about never, and they're editorial voice rather than record, the same
* reasoning that keeps the map grid config in code. A table for four * reasoning that keeps the map grid config in code. A table for four
* rows that nobody edits is a migration and an admin page for nothing. * rows that nobody edits is a migration and an admin page for nothing.
* *
@ -12,7 +12,7 @@
* date is ever revised. * date is ever revised.
*/ */
import type { DecadeMeta } from '../lib/timeline' import type { DecadeMeta } from '../lib/timeline.ts'
export const HISTORY_DECADES: DecadeMeta[] = [ export const HISTORY_DECADES: DecadeMeta[] = [
{ {

View file

@ -3,7 +3,7 @@
Pure layout. Where each tile sits, what it's called, and how to Pure layout. Where each tile sits, what it's called, and how to
work out which tile a chapter belongs to. None of this is in the work out which tile a chapter belongs to. None of this is in the
database because none of it changes — Rhode Island will not be database because none of it changes, Rhode Island will not be
moving, and no admin form should offer to move it. moving, and no admin form should offer to move it.
What IS in the database is which regions cover which areas, and What IS in the database is which regions cover which areas, and
@ -13,8 +13,6 @@
as regions with no tile. as regions with no tile.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
export const GRID_COLS = 13;
export const GRID_ROWS = 7;
/* ── States ──────────────────────────────────────────────────── /* ── States ────────────────────────────────────────────────────
[column, row], both 1-based. A tile grid rather than true [column, row], both 1-based. A tile grid rather than true
@ -86,8 +84,8 @@ export const AREAS = Object.freeze([
export const AREA_BY_CODE = Object.fromEntries(AREAS.map((a) => [a.code, a])); export const AREA_BY_CODE = Object.fromEntries(AREAS.map((a) => [a.code, a]));
/* ── Which tile a chapter sits on ────────────────────────────── /* ── Which tile a chapter sits on ──────────────────────────────
The database stores a real address — state_code for US, and a The database stores a real address, state_code for US, and a
country code otherwise — rather than a tile name. This is the country code otherwise, rather than a tile name. This is the
one place that translates between the two, so adding a Mexico one place that translates between the two, so adding a Mexico
band later means a line here and nothing in SQL. band later means a line here and nothing in SQL.
@ -115,7 +113,7 @@ export function areaForChapter(chapter) {
A region with share 1 and no edge fills the tile. A shared A region with share 1 and no edge fills the tile. A shared
tile has one row per region, each declaring its own slice, so tile has one row per region, each declaring its own slice, so
California is two entries of 0.5 rather than a primary plus a California is two entries of 0.5 rather than a primary plus a
remainder — no arithmetic, and the renderer doesn't need to remainder, no arithmetic, and the renderer doesn't need to
know which region "really" owns it. know which region "really" owns it.
regionAreas [{ region_id, area_code, share, edge, note }] regionAreas [{ region_id, area_code, share, edge, note }]
@ -165,10 +163,3 @@ export function countChaptersByArea(chapters: any[] = []) {
from the row rather than being looked up in a splits table and from the row rather than being looked up in a splits table and
branched on whether this region is the primary. branched on whether this region is the primary.
───────────────────────────────────────────────────────────── */ ───────────────────────────────────────────────────────────── */
export function areasLabel(regionId, regionAreas: any[] = []) {
return regionAreas
.filter((row) => row.region_id === regionId && row.area_code !== "CANADA")
.map((row) => (row.note ? `${row.area_code} (${row.note})` : row.area_code))
.sort()
.join(", ");
}

View file

@ -1,299 +0,0 @@
/**
* PLACEHOLDER DATA — delete this file once `GET /api/history` lands.
*
* Shaped exactly like the aggregation route's payload, so swapping it out
* is a two-line change in History.tsx.
*
* Note what is and isn't here. Entries that point at a record carry a
* `ref` and little else: no venue, no host name, no copy that also lives
* in `events`. The few that do carry a title are overriding it on
* purpose. Titles and blurbs below are invented scaffolding, not real NGU
* history — replace them before anyone sees this.
*
* Decade headers are not here — they live in historyDecades.ts and stay
* in code even after the API lands.
*
* Upcoming items are not flagged. `partitionByDate` decides what's
* upcoming by comparing dates to the wall clock, so nothing here needs
* editing as dates pass.
*/
import type { TimelineItem } from '../lib/timeline'
export const MOCK_ITEMS: TimelineItem[] = [
// ——— Upcoming (relative to the wall clock, not a flag) ———
{
id: 'tl-0001',
date: '2027-06',
precision: 'month',
kind: 'event',
title: 'Summer Conference 2027',
meta: 'Unity Village, MO',
ref: { kind: 'event', id: 'summer-2027' },
logo: { file: 'summer-conference.svg', kind: 'event' },
},
{
id: 'tl-0002',
date: '2026-11-14',
precision: 'day',
kind: 'event',
title: 'Fall Regional Rally',
meta: 'Southeast',
ref: { kind: 'event', id: 'fall-rally-2026' },
logo: { file: 'regional-rally.svg', kind: 'event' },
},
{
id: 'tl-0003',
date: '2026-10-03',
precision: 'day',
kind: 'event',
title: 'Chapter Leads Intensive',
meta: 'Online',
ref: { kind: 'event', id: 'leads-intensive-2026' },
},
// ——— 2020s ———
{
id: 'tl-0010',
date: '2026-03',
precision: 'month',
kind: 'organization',
title: 'Twentieth chapter chartered',
blurb:
'The first new charter in the region since 2017, started by three people who met at a rally two summers earlier.',
featured: true,
ref: { kind: 'organization', id: 'boise', orgKind: 'chapter' },
logo: { file: 'boise.svg', kind: 'organization' },
},
{
id: 'tl-0011',
date: '2026-04-17',
precision: 'day',
kind: 'event',
title: 'Spring Regional Rally',
ref: { kind: 'event', id: 'spring-rally-2026' },
logo: { file: 'regional-rally.svg', kind: 'event' },
},
{
id: 'tl-0012',
date: '2026-01',
precision: 'month',
kind: 'people',
title: 'New leadership team seated',
blurb: 'A four-person exec on a two-year term, the first under the 2024 bylaws.',
ref: { kind: 'team', id: 'ngu-leadership' },
team: { id: 'ngu-leadership', name: 'Leadership Team', orgId: 'ngu', orgName: 'NGU National' },
people: [
{ id: 'jane-doe', name: 'Jane Doe', title: 'Chair', photo: 'jane-doe.jpg' },
{ id: 'sam-ruiz', name: 'Sam Ruiz', title: 'Vice Chair', photo: 'sam-ruiz.jpg' },
{ id: 'ada-mensah', name: 'Ada Mensah', title: 'Secretary' },
{ id: 'tom-baird', name: 'Tom Baird', title: 'Treasurer', photo: 'tom-baird.jpg' },
],
},
{
id: 'tl-0013',
date: '2025-12-28',
precision: 'day',
kind: 'event',
title: 'Winter Gathering',
ref: { kind: 'event', id: 'winter-gathering-2025' },
},
{
id: 'tl-0014',
date: '2025-07-19',
precision: 'day',
kind: 'award',
title: 'Service Award',
meta: 'Presented to the Southeast chapter leads',
ref: { kind: 'award', id: 'service' },
logo: { file: 'service-award.svg', kind: 'award' },
},
{
id: 'tl-0015',
date: '2025-07-17',
precision: 'day',
kind: 'event',
title: 'Summer Conference',
meta: 'Three days, 140 attendees',
ref: { kind: 'event', id: 'summer-2025' },
logo: { file: 'summer-conference.svg', kind: 'event' },
},
{
id: 'tl-0016',
date: '2025',
precision: 'year',
kind: 'milestone',
title: 'Photo archive digitized',
blurb: 'Roughly 4,000 images from 2003 onward, scanned by volunteers.',
href: 'https://archive.nextgenerationofunity.org',
},
{
id: 'tl-0017',
date: '2024-09',
precision: 'month',
kind: 'milestone',
title: 'Bylaws rewritten',
blurb:
'Term limits, a defined handoff window, and the first written process for chartering a chapter.',
featured: true,
},
{
id: 'tl-0018',
date: '2024-07-11',
precision: 'day',
kind: 'event',
title: 'Summer Conference',
ref: { kind: 'event', id: 'summer-2024' },
logo: { file: 'summer-conference.svg', kind: 'event' },
},
{
id: 'tl-0019',
date: '2024-07-13',
precision: 'day',
kind: 'award',
title: 'Emerging Leader Award',
meta: 'First year the award was given',
ref: { kind: 'award', id: 'emerging-leader' },
logo: { file: 'emerging-leader.svg', kind: 'award' },
},
{
id: 'tl-0020',
date: '2022-06',
precision: 'month',
kind: 'event',
title: 'First in-person rally since 2019',
blurb: 'Sixty-one people, most of whom had only ever met on a video call.',
featured: true,
ref: { kind: 'event', id: 'return-rally-2022' },
},
{
id: 'tl-0021',
date: '2021-08',
precision: 'month',
kind: 'event',
title: 'Online Summer Intensive',
meta: 'Six sessions across two weeks',
ref: { kind: 'event', id: 'online-intensive-2021' },
},
{
id: 'tl-0022',
date: '2020-03',
precision: 'month',
kind: 'milestone',
title: 'All gatherings suspended',
blurb: 'Weekly online rooms started the following week and ran for 118 weeks.',
},
// ——— 2010s ———
{
id: 'tl-0030',
date: '2018-05',
precision: 'month',
kind: 'organization',
title: 'Eighth region recognized',
featured: true,
ref: { kind: 'organization', id: 'northwest', orgKind: 'region' },
logo: { file: 'northwest.svg', kind: 'organization' },
},
{
id: 'tl-0031',
date: '2018-07-20',
precision: 'day',
kind: 'event',
title: 'Summer Conference',
ref: { kind: 'event', id: 'summer-2018' },
logo: { file: 'summer-conference.svg', kind: 'event' },
},
{
id: 'tl-0032',
date: '2016-02',
precision: 'month',
kind: 'people',
title: 'Retreat Team formed',
blurb:
'Programming had been whoever volunteered. This made it a standing team with a handoff.',
ref: { kind: 'team', id: 'ngu-retreat-team' },
team: { id: 'ngu-retreat-team', name: 'Retreat Team', orgId: 'ngu', orgName: 'NGU National' },
people: [
{ id: 'marcus-hale', name: 'Marcus Hale', title: 'Founding lead', photo: 'marcus-hale.jpg' },
{ id: 'priya-nair', name: 'Priya Nair', photo: 'priya-nair.jpg' },
],
},
{
id: 'tl-0033',
date: '2015-07',
precision: 'month',
kind: 'award',
title: 'First Service Award presented',
blurb: 'Created to name the work that had been going unnamed for a decade.',
featured: true,
ref: { kind: 'award', id: 'service' },
logo: { file: 'service-award.svg', kind: 'award' },
},
{
id: 'tl-0034',
date: '2015-02',
precision: 'month',
kind: 'milestone',
title: 'Shared calendar goes live',
blurb: 'Regions stop scheduling on top of each other.',
},
{
id: 'tl-0035',
date: '2012-06',
precision: 'month',
kind: 'event',
title: 'Summer Conference',
meta: 'The year attendance first passed 100',
ref: { kind: 'event', id: 'summer-2012' },
logo: { file: 'summer-conference.svg', kind: 'event' },
},
{
id: 'tl-0036',
date: '2012',
precision: 'year',
kind: 'milestone',
title: 'Adopted the name Next Generation of Unity',
},
// ——— 2000s ———
{
id: 'tl-0040',
date: '2009',
precision: 'year',
kind: 'milestone',
title: 'Four regions drawn on a map for the first time',
},
{
id: 'tl-0041',
date: '2005-08',
precision: 'month',
kind: 'milestone',
title: 'The gathering becomes annual',
blurb: 'Before this it happened when someone had the energy to organize it.',
featured: true,
},
{
id: 'tl-0042',
date: '2002-08',
precision: 'month',
kind: 'event',
title: 'First young adult retreat',
meta: 'Nineteen attendees',
blurb:
'Organized over six weeks at a borrowed retreat center. Everything else on this page follows from it.',
featured: true,
ref: { kind: 'event', id: 'first-retreat-2002' },
},
// ——— Pre-program ———
{
id: 'tl-0050',
date: '1997',
precision: 'year',
kind: 'milestone',
title: 'Regional youth programs running independently',
blurb:
'Not NGU, and not connected to each other — but the people who started NGU came out of these.',
},
]

View file

@ -30,38 +30,11 @@ h1, h2, h3, h4, h5, h6 {
font-weight: bold; font-weight: bold;
} }
/* Gradient utilities */
.grad-brand {
background: linear-gradient(135deg, #073d4a 0%, #138ba0 45%, #10d48a 100%);
}
.grad-brand-light {
background: linear-gradient(135deg, #0a5260 0%, #17aac4 50%, #00e676 100%);
}
.grad-dark {
background: linear-gradient(135deg, #042f3a 0%, #073d4a 60%, #0a5260 100%);
}
.grad-hero-text {
background: linear-gradient(90deg, #88b668 0%, #008fa8 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
/* Scrollbar hide */ /* Scrollbar hide */
::-webkit-scrollbar { width: 6px; } ::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; } ::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(19, 139, 160, 0.4); border-radius: 3px; } ::-webkit-scrollbar-thumb { background: rgba(19, 139, 160, 0.4); border-radius: 3px; }
/* Float animation */
@keyframes float {
0%, 100% { transform: translateY(0px); }
50% { transform: translateY(-12px); }
}
.float-anim { display: inline-block; animation: float 4s ease-in-out infinite; will-change: transform;}
.ig-icon { fill: currentColor; transition: fill 200ms ease; } .ig-icon { fill: currentColor; transition: fill 200ms ease; }

View file

@ -2,21 +2,14 @@
API CLIENT API CLIENT
One place that knows how to talk to the server, so components One place that knows how to talk to the server, so components
never call fetch directly and swapping the transport later is a never call fetch directly.
single-file change.
Two things worth knowing about the design:
The cache is a module-level Map of in-flight and settled The cache is a module-level Map of in-flight and settled
promises. Two components asking for /events during the same promises. Two components asking for /events during the same
render pass share one request, and a remount inside the TTL render pass share one request, and a remount inside the TTL
costs nothing. It resets on page load, which is the right costs nothing. It resets on page load, which is the right
lifetime for content that changes weekly. lifetime for content that changes weekly. A failure isn't
cached, and surfaces as an error rather than empty data.
Every reader can pass a `fallback`. If the request fails, that
value is used instead. This is what keeps the Figma preview
working: pass the old static module as the fallback and the
preview renders real content with no server in sight.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
const BASE = import.meta.env?.VITE_API_BASE ?? "/api"; const BASE = import.meta.env?.VITE_API_BASE ?? "/api";
@ -68,20 +61,15 @@ async function request(path, options: RequestInit = {}) {
/* ── Reads ───────────────────────────────────────────────────── /* ── Reads ─────────────────────────────────────────────────────
get("/events") → cached for 60s get("/events") → cached for 60s
get("/events", { ttl: 0 }) → always fresh get("/events", { ttl: 0 }) → always fresh
get("/events", { fallback }) → fallback on any failure
───────────────────────────────────────────────────────────── */ ───────────────────────────────────────────────────────────── */
export function get(path, { ttl = DEFAULT_TTL, fallback }: { ttl?: number; fallback?: any } = {}) { export function get(path, { ttl = DEFAULT_TTL }: { ttl?: number } = {}) {
const hit = cache.get(path); const hit = cache.get(path);
if (hit && Date.now() - hit.at < ttl) return hit.promise; if (hit && Date.now() - hit.at < ttl) return hit.promise;
const promise = request(path).catch((err) => { const promise = request(path).catch((err) => {
cache.delete(path); // a failure shouldn't be cached cache.delete(path); // a failure shouldn't be cached
if (fallback !== undefined) {
console.warn(`api: ${path} failed, using fallback`, err);
return fallback;
}
throw err; throw err;
}); });

View file

@ -9,7 +9,7 @@
RequireAuth guards routes. Worth being clear about what that RequireAuth guards routes. Worth being clear about what that
does and doesn't do: it hides the interface, not the data. The does and doesn't do: it hides the interface, not the data. The
protection is the 401 from /api/admin — this only stops someone protection is the 401 from /api/admin, this only stops someone
staring at an empty table. staring at an empty table.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
@ -71,7 +71,7 @@ export function useAuth() {
return value; return value;
} }
/* Signals a session that ended while the page was open — the /* Signals a session that ended while the page was open, the
admin pages call this when a request comes back 401. */ admin pages call this when a request comes back 401. */
export function isUnauthorized(error) { export function isUnauthorized(error) {
return error instanceof ApiError && error.status === 401; return error instanceof ApiError && error.status === 401;

View file

@ -3,7 +3,7 @@
The chapter map's view of the organization list. Regions and The chapter map's view of the organization list. Regions and
chapters are the same table and the same endpoint; this hook chapters are the same table and the same endpoint; this hook
reshapes them into what a map needs — slices per tile, counts reshapes them into what a map needs, slices per tile, counts
per tile, chapters grouped by region. per tile, chapters grouped by region.
Its return shape is unchanged from the version that called Its return shape is unchanged from the version that called
@ -14,7 +14,7 @@
the tile grid src/data/mapGrid.ts. Where a state sits never the tile grid src/data/mapGrid.ts. Where a state sits never
changes, so it isn't worth a round trip. changes, so it isn't worth a round trip.
the fetch src/data/organizations.ts. One endpoint for the fetch src/lib/organizations.ts. One endpoint for
every kind, so a section listing regions and every kind, so a section listing regions and
a section listing partners read alike. a section listing partners read alike.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
@ -23,18 +23,14 @@ import { useMemo } from "react";
import { import {
areasSentence, areasSentence,
initialsFor, byName,
useOrganizations, useOrganizations,
} from "./organizations.ts"; } from "./organizations.ts";
import { import {
areaForChapter, areaForChapter,
buildAreaSlices, buildAreaSlices,
countChaptersByArea, countChaptersByArea,
} from "./mapGrid.ts"; } from "../data/mapGrid.ts";
const byName = (a, b) => a.name.localeCompare(b.name);
export { initialsFor };
export function useCommunity() { export function useCommunity() {
const regionsQuery = useOrganizations("region"); const regionsQuery = useOrganizations("region");

View file

@ -2,7 +2,7 @@
EVENT DATA EVENT DATA
One request, filtered per band. The Retreats page has three One request, filtered per band. The Retreats page has three
bands of events, and all three call this hook — the cache in bands of events, and all three call this hook, the cache in
api.ts keys on the path, so they share a single fetch and each api.ts keys on the path, so they share a single fetch and each
narrows the result to what it shows. narrows the result to what it shows.
@ -33,7 +33,7 @@
import { useMemo } from "react"; import { useMemo } from "react";
import { useResource } from "../lib/useResource.ts"; import { useResource } from "./useResource.ts";
/* One shared empty list, so a memo keyed on `scopes` doesn't /* One shared empty list, so a memo keyed on `scopes` doesn't
restart on every render before the data arrives. */ restart on every render before the data arrives. */
@ -54,7 +54,7 @@ export function useEvents({ scope, host, status, type }: any = {}) {
let list = all ?? []; let list = all ?? [];
if (scope) list = list.filter(e => e.scope_id === scope); if (scope) list = list.filter(e => e.scope_id === scope);
// `host` is an organization or a person slug, and an event can // `host` is an organization or a person slug, and an event can
// have several of either — co-hosting puts one event on both // have several of either, co-hosting puts one event on both
// hosts' lists, which is the point. // hosts' lists, which is the point.
if (host) list = list.filter(e => e.hosts?.some(h => h.id === host)); if (host) list = list.filter(e => e.hosts?.some(h => h.id === host));
if (status) list = list.filter(e => e.status === status); if (status) list = list.filter(e => e.status === status);
@ -68,9 +68,9 @@ export function useEvents({ scope, host, status, type }: any = {}) {
return { events, scopes, loading, error }; return { events, scopes, loading, error };
} }
/* Past and upcoming, split. `status` arrives already resolved — the /* Past and upcoming, split. `status` arrives already resolved, the
explicit value when there is one, otherwise derived from ends_on explicit value when there is one, otherwise derived from ends_on,
— so nothing here needs to know which of the two it got. */ so nothing here needs to know which of the two it got. */
export function splitByStatus(events: any[] = []) { export function splitByStatus(events: any[] = []) {
const upcoming: any[] = []; const upcoming: any[] = [];
const past: any[] = []; const past: any[] = [];

View file

@ -14,7 +14,7 @@
Dates are 'YYYY-MM-DD' and are handled as UTC midnights so that Dates are 'YYYY-MM-DD' and are handled as UTC midnights so that
stepping a day never lands on a DST gap. They are calendar dates, stepping a day never lands on a DST gap. They are calendar dates,
not instants — nothing here converts timezones. not instants, nothing here converts timezones.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
export type SeriesFrequency = 'weekly' | 'monthly_date' | 'monthly_weekday' export type SeriesFrequency = 'weekly' | 'monthly_date' | 'monthly_weekday'
@ -76,7 +76,7 @@ const daysInMonth = (year: number, month: number) =>
new Date(Date.UTC(year, month + 1, 0)).getUTCDate() new Date(Date.UTC(year, month + 1, 0)).getUTCDate()
/* 1st–4th, or 5 for a date in the month's fifth week, which the /* 1st–4th, or 5 for a date in the month's fifth week, which the
schedule treats as "last" — every month has a last Tuesday, not schedule treats as "last", every month has a last Tuesday, not
every month has a fifth. */ every month has a fifth. */
const weekOfMonth = (date: Date) => Math.ceil(date.getUTCDate() / 7) const weekOfMonth = (date: Date) => Math.ceil(date.getUTCDate() / 7)

View file

@ -19,6 +19,8 @@
means the site offers a filter the database will refuse to store. means the site offers a filter the database will refuse to store.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
import { capitalize } from './text.ts'
export type EventType = 'retreat' | 'class' | 'workshop' | 'meeting' | 'other' export type EventType = 'retreat' | 'class' | 'workshop' | 'meeting' | 'other'
export const EVENT_TYPES: { id: EventType; label: string; plural: string }[] = [ export const EVENT_TYPES: { id: EventType; label: string; plural: string }[] = [
@ -29,14 +31,10 @@ export const EVENT_TYPES: { id: EventType; label: string; plural: string }[] = [
{ id: 'other', label: 'Other', plural: 'Other' }, { id: 'other', label: 'Other', plural: 'Other' },
] ]
export const EVENT_TYPE_IDS: EventType[] = EVENT_TYPES.map((entry) => entry.id)
const BY_ID = new Map<string, { label: string; plural: string }>( const BY_ID = new Map<string, { label: string; plural: string }>(
EVENT_TYPES.map((entry) => [entry.id as string, entry]), EVENT_TYPES.map((entry) => [entry.id as string, entry]),
) )
const capitalize = (word: string) =>
word ? word.charAt(0).toUpperCase() + word.slice(1) : ''
/* A value the CHECK has gained since this file was written renders /* A value the CHECK has gained since this file was written renders
as itself rather than vanishing, the same rule EventDetail's as itself rather than vanishing, the same rule EventDetail's
@ -44,5 +42,3 @@ const capitalize = (word: string) =>
export const eventTypeLabel = (id?: string | null): string => export const eventTypeLabel = (id?: string | null): string =>
(id ? BY_ID.get(id)?.label : null) ?? capitalize(id ?? '') (id ? BY_ID.get(id)?.label : null) ?? capitalize(id ?? '')
export const eventTypePlural = (id?: string | null): string =>
(id ? BY_ID.get(id)?.plural : null) ?? capitalize(id ?? '')

View file

@ -2,7 +2,7 @@
PUBLIC HREFS PUBLIC HREFS
One place that turns a record into a URL. The API deliberately One place that turns a record into a URL. The API deliberately
never sends paths — it sends `{ kind, id }` and, for an never sends paths, it sends `{ kind, id }` and, for an
organization, the `org_kind` that decides which of the three organization, the `org_kind` that decides which of the three
routes a slug belongs to. Deciding that in each component is how routes a slug belongs to. Deciding that in each component is how
/regions/x and /chapters/x end up both existing for the same /regions/x and /chapters/x end up both existing for the same
@ -20,7 +20,7 @@
Every builder takes an id the caller believed it had. When it Every builder takes an id the caller believed it had. When it
doesn't, the old behaviour was to interpolate the string doesn't, the old behaviour was to interpolate the string
"undefined" into a path, render a link to it, mount a page and "undefined" into a path, render a link to it, mount a page and
fetch /api/organizations/undefined — four steps between the fetch /api/organizations/undefined, four steps between the
mistake and any sign of it, none of which name the component mistake and any sign of it, none of which name the component
that made it. that made it.
@ -35,7 +35,7 @@ export type RefKind = 'event' | 'organization' | 'team' | 'award' | 'person'
/* A region, a chapter and a partner read as different things to a /* A region, a chapter and a partner read as different things to a
visitor even though they are one table, so they get one route visitor even though they are one table, so they get one route
each. 'national' is NGU itself — one record, no listing to sit each. 'national' is NGU itself, one record, no listing to sit
under, so it falls through to the generic path. */ under, so it falls through to the generic path. */
const ORG_BASE: Record<string, string> = { const ORG_BASE: Record<string, string> = {
region: '/regions', region: '/regions',
@ -49,7 +49,7 @@ const ORG_BASE: Record<string, string> = {
* /events/:id, not /retreats/:id. The listing page is called * /events/:id, not /retreats/:id. The listing page is called
* Retreats because that's what NGU calls the gatherings it hosts, * Retreats because that's what NGU calls the gatherings it hosts,
* but the records are `events`, the API route is /api/events, and * but the records are `events`, the API route is /api/events, and
* plenty of them — partner events, conferences — aren't retreats * plenty of them, partner events, conferences, aren't retreats
* at all. Naming the record route after one page's editorial * at all. Naming the record route after one page's editorial
* framing would have been wrong the first time a non-retreat got * framing would have been wrong the first time a non-retreat got
* its own page. * its own page.
@ -73,7 +73,7 @@ function checkId(id: unknown, what: string): string {
if (DEV) { if (DEV) {
// console.error rather than warn: this is always a bug, and the // console.error rather than warn: this is always a bug, and the
// stack is the whole point — it names the component that passed // stack is the whole point, it names the component that passed
// nothing. // nothing.
console.error( console.error(
`hrefs: ${what}() was given ${JSON.stringify(id)}. ` + `hrefs: ${what}() was given ${JSON.stringify(id)}. ` +
@ -93,7 +93,7 @@ function checkId(id: unknown, what: string): string {
* have to agree about what counts as an id. * have to agree about what counts as an id.
* *
* It lives here rather than next to the hook that calls it because * It lives here rather than next to the hook that calls it because
* it is a path, and paths are this file's job — and because a * it is a path, and paths are this file's job, and because a
* component that interpolates a missing route param produces the * component that interpolates a missing route param produces the
* literal string "undefined", which the server cannot tell apart * literal string "undefined", which the server cannot tell apart
* from a slug somebody genuinely typed. It answers 404 either way, * from a slug somebody genuinely typed. It answers 404 either way,
@ -122,8 +122,8 @@ export function orgHref(id?: string | null, kind?: string | null): string {
return `${ORG_BASE[kind ?? ''] ?? '/organizations'}/${checkId(id, 'orgHref')}` return `${ORG_BASE[kind ?? ''] ?? '/organizations'}/${checkId(id, 'orgHref')}`
} }
/* For anything holding a polymorphic reference — timeline entries, /* For anything holding a polymorphic reference, timeline entries,
content blocks — where the kind arrives as data rather than being content blocks, where the kind arrives as data rather than being
known at the call site. known at the call site.
Returns null for a kind with no page AND for a reference with no Returns null for a kind with no page AND for a reference with no
@ -153,12 +153,6 @@ export function refHref(
} }
/* What to call the kind in a breadcrumb or a back link. */ /* What to call the kind in a breadcrumb or a back link. */
export const ORG_KIND_LABEL: Record<string, string> = {
national: 'Next Generation of Unity',
region: 'Region',
chapter: 'Chapter',
partner: 'Partner organization',
}
/* Where "back" goes from a record page. A chapter belongs to /* Where "back" goes from a record page. A chapter belongs to
/community, a retreat to /retreats. */ /community, a retreat to /retreats. */

View file

@ -24,10 +24,6 @@
const ABSOLUTE = /^(https?:|\/|data:)/ const ABSOLUTE = /^(https?:|\/|data:)/
/* An uploaded file ('/uploads/…'), a path anywhere on the site, or
a full URL: something to use as it is rather than resolve. */
export const isAbsoluteMedia = (file?: string | null) => Boolean(file && ABSOLUTE.test(file))
function inDir(dir: string) { function inDir(dir: string) {
return (file?: string | null): string | null => { return (file?: string | null): string | null => {
if (!file) return null if (!file) return null

View file

@ -9,7 +9,7 @@
const { organizations } = useOrganizations("partner"); const { organizations } = useOrganizations("partner");
const { organizations } = useOrganizations(); // all const { organizations } = useOrganizations(); // all
Every organization has the same card surface — name, colour, Every organization has the same card surface, name, colour,
logo, description, links. What differs by kind sits under logo, description, links. What differs by kind sits under
`details`, so a list component can render the common parts `details`, so a list component can render the common parts
without knowing what it's holding: without knowing what it's holding:
@ -23,9 +23,8 @@
fetch. fetch.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
import { useResource } from "../lib/useResource.ts"; import { useResource } from "./useResource.ts";
const EMPTY = { organizations: [] };
export function useOrganizations(kind) { export function useOrganizations(kind) {
const path = kind const path = kind
@ -79,6 +78,8 @@ export function areasSentence(areas: any[] = []) {
/* Initials for a card with no logo. "NGU Lynnwood" → "NL", dropping /* Initials for a card with no logo. "NGU Lynnwood" → "NL", dropping
the org prefix so every card doesn't read "NG". */ the org prefix so every card doesn't read "NG". */
export const byName = (a, b) => a.name.localeCompare(b.name);
export function initialsFor(name = "") { export function initialsFor(name = "") {
return name return name
.replace(/^NGU\s+/i, "") .replace(/^NGU\s+/i, "")

View file

@ -24,7 +24,7 @@ import { useState } from "react";
} }
Sections fetch their own data. The page never does, which is why Sections fetch their own data. The page never does, which is why
there's no loading or error state here — each view handles its there's no loading or error state here, each view handles its
own, and one section failing doesn't blank the page. own, and one section failing doesn't blank the page.
Every Component receives `accent` so its empty and error notices Every Component receives `accent` so its empty and error notices

View file

@ -40,8 +40,6 @@ export const siteUrl = (path: string): string => new URL(path, SITE_ORIGIN).href
const PAGES: Record<string, PageText> = { ...siteConfiguration.pages, ...fromServer.pages } const PAGES: Record<string, PageText> = { ...siteConfiguration.pages, ...fromServer.pages }
/** The static pages site.json knows, for the admin's page list. */ /** The static pages site.json knows, for the admin's page list. */
export const SITE_PAGE_PATHS: string[] = Object.keys(siteConfiguration.pages)
/** A static page's title and intro, from site.json's "pages". */ /** A static page's title and intro, from site.json's "pages". */
export function sitePage(path: string): PageText { export function sitePage(path: string): PageText {
const page = PAGES[path] const page = PAGES[path]

View file

@ -21,3 +21,6 @@ export function preview(text: string | null | undefined, max: number): string {
const clean = lastSpace > max / 2 ? cut.slice(0, lastSpace) : cut const clean = lastSpace > max / 2 ? cut.slice(0, lastSpace) : cut
return `${clean.replace(/[\s.,;:!?]+$/, '')}…` return `${clean.replace(/[\s.,;:!?]+$/, '')}…`
} }
export const capitalize = (word: string) =>
word ? word.charAt(0).toUpperCase() + word.slice(1) : ''

View file

@ -11,14 +11,14 @@
* date are read back from `events` at query time. Editing the event * date are read back from `events` at query time. Editing the event
* therefore edits the timeline, and there is no second copy to drift. * therefore edits the timeline, and there is no second copy to drift.
* *
* Hand-authored entries — "bylaws rewritten", "the gathering becomes * Hand-authored entries, "bylaws rewritten", "the gathering becomes
* annual" — carry no ref and supply their own title and blurb. An entry * annual", carry no ref and supply their own title and blurb. An entry
* may also do both: reference an event but override its title, for when * may also do both: reference an event but override its title, for when
* the timeline wants to say something the event card doesn't. * the timeline wants to say something the event card doesn't.
* *
* ── What the server resolves, and what it doesn't ────────────────────── * ── What the server resolves, and what it doesn't ──────────────────────
* The server resolves *data*: title, date, logo filename, the members of * The server resolves *data*: title, date, logo filename, the members of
* a referenced team. It does not resolve *routes* or *asset paths* — * a referenced team. It does not resolve *routes* or *asset paths*,
* those are presentation, and live in `timelineRefs.ts` so React Router * those are presentation, and live in `timelineRefs.ts` so React Router
* and the public/ layout stay the frontend's business. * and the public/ layout stay the frontend's business.
*/ */
@ -41,7 +41,7 @@ export type RefKind = 'event' | 'organization' | 'award' | 'person' | 'team'
export type TimelineRef = { export type TimelineRef = {
kind: RefKind kind: RefKind
/** The row's TEXT primary key — an event id, org slug, team slug. */ /** The row's TEXT primary key, an event id, org slug, team slug. */
id: string id: string
/** Only on organizations: history.js copies v_timeline.org_kind. */ /** Only on organizations: history.js copies v_timeline.org_kind. */
orgKind?: OrgKind orgKind?: OrgKind
@ -59,7 +59,7 @@ export type TimelineLogo = {
export type PersonRef = { export type PersonRef = {
id: string id: string
name: string name: string
/** people.photo — filename only. */ /** people.photo, filename only. */
photo?: string photo?: string
/** Their affiliation title at the time, if it's worth printing. */ /** Their affiliation title at the time, if it's worth printing. */
title?: string title?: string
@ -78,7 +78,7 @@ export type TimelineItem = {
id: string id: string
/** "2014" | "2014-06" | "2014-06-12" */ /** "2014" | "2014-06" | "2014-06-12" */
date: string date: string
/** How much of `date` is trustworthy. Authoritative — a backfilled row /** How much of `date` is trustworthy. Authoritative, a backfilled row
* may hold a full date while only the year is actually known. */ * may hold a full date while only the year is actually known. */
precision: DatePrecision precision: DatePrecision
kind: TimelineKind kind: TimelineKind
@ -127,7 +127,7 @@ export type GroupedYear = {
featured: boolean featured: boolean
count: number count: number
featuredItems: TimelineItem[] featuredItems: TimelineItem[]
/** Year-precision items — known to be this year, month unknown. */ /** Year-precision items, known to be this year, month unknown. */
undated: TimelineItem[] undated: TimelineItem[]
months: GroupedMonth[] months: GroupedMonth[]
} }
@ -238,7 +238,7 @@ export type GroupOptions = {
programStartYear?: number programStartYear?: number
/** /**
* Repeat featured items inside their month node as well as in the * Repeat featured items inside their month node as well as in the
* featured block. Off by default — in a sparse year it just prints the * featured block. Off by default, in a sparse year it just prints the
* same line twice. A month left with nothing but featured items drops * same line twice. A month left with nothing but featured items drops
* out entirely. * out entirely.
*/ */

View file

@ -4,7 +4,7 @@
Turns a timeline item into a destination and an image. Both were Turns a timeline item into a destination and an image. Both were
answered locally here before, which is how the timeline came to answered locally here before, which is how the timeline came to
link events at /event/:id while the router only knew about link events at /event/:id while the router only knew about
/retreats/:id — two files holding the same opinion, one of them /retreats/:id, two files holding the same opinion, one of them
wrong, neither aware of the other. wrong, neither aware of the other.
Now this file knows about timeline items and nothing else. Where Now this file knows about timeline items and nothing else. Where
@ -13,9 +13,9 @@
── The shape this reads, from history.js ── ── The shape this reads, from history.js ──
item.href explicit link_url override, may be off-site item.href explicit link_url override, may be off-site
item.ref { kind, id, orgKind? } — orgKind only on item.ref { kind, id, orgKind? }, orgKind only on
organizations, because only they have it organizations, because only they have it
item.logo { file, kind } — v_timeline COALESCEs the item.logo { file, kind }, v_timeline COALESCEs the
filename across five tables, so the kind is filename across five tables, so the kind is
what says which directory it came from what says which directory it came from
item.team { id, name, orgId? } on a team ref item.team { id, name, orgId? } on a team ref
@ -23,7 +23,7 @@
Every one of those is optional. An entry is a standalone Every one of those is optional. An entry is a standalone
milestone until proven otherwise, and the two accessors below milestone until proven otherwise, and the two accessors below
return null rather than assuming a shape that isn't there — return null rather than assuming a shape that isn't there,
which is the other half of the /organizations/undefined bug: which is the other half of the /organizations/undefined bug:
reaching into a ref that wasn't sent yields undefined, and reaching into a ref that wasn't sent yields undefined, and
undefined interpolates into a path perfectly happily. undefined interpolates into a path perfectly happily.
@ -44,7 +44,7 @@ import type { TimelineItem } from './timeline.ts'
* Otherwise the reference decides, and refHref returns null for a * Otherwise the reference decides, and refHref returns null for a
* kind with no page yet ('person', until /people/:id exists) as * kind with no page yet ('person', until /people/:id exists) as
* well as for a ref that didn't resolve. Null means the entry * well as for a ref that didn't resolve. Null means the entry
* renders as a plain <div> — right for a milestone, and right for * renders as a plain <div>, right for a milestone, and right for
* a reference that's missing an id, which used to render as a link * a reference that's missing an id, which used to render as a link
* to a 404. * to a 404.
*/ */
@ -67,7 +67,7 @@ export function logoSrc(item: TimelineItem): string | null {
} }
/** /**
* A roster member's photo. Same rule as everywhere else — the API * A roster member's photo. Same rule as everywhere else, the API
* sends a bare filename. * sends a bare filename.
*/ */
export function photoSrc(photo?: string | null): string | null { export function photoSrc(photo?: string | null): string | null {

View file

@ -1,11 +1,11 @@
/** /**
* The four detail endpoints, typed. * The four detail endpoints, typed.
* *
* Adding a fifth is a type and a one-line hook — useRecord owns * Adding a fifth is a type and a one-line hook, useRecord owns
* the fetching, the caching and the 404. * the fetching, the caching and the 404.
* *
* An id that is missing — or the literal string "undefined", which * An id that is missing, or the literal string "undefined", which
* is what a template literal makes of a missing route param — never * is what a template literal makes of a missing route param, never
* reaches the network. detailPath returns null and the hook reports * reaches the network. detailPath returns null and the hook reports
* notFound, which is what the visitor should see anyway, and * notFound, which is what the visitor should see anyway, and
* hrefs.ts has already logged the component that produced it. * hrefs.ts has already logged the component that produced it.
@ -145,8 +145,6 @@ export type EventListItem = Omit<EventRecord, 'blocks' | 'people' | 'awards'>
/** An event_scopes row, as GET /events sends it beside the list. */ /** An event_scopes row, as GET /events sends it beside the list. */
export type EventScope = { id: string; name: string; sort_order: number } export type EventScope = { id: string; name: string; sort_order: number }
export type EventsResponse = { scopes: EventScope[]; events: EventListItem[] }
export const useEvent = (id?: string): Resource<EventRecord> => export const useEvent = (id?: string): Resource<EventRecord> =>
useRecord<EventRecord>(detailPath('/events', id), 'event') useRecord<EventRecord>(detailPath('/events', id), 'event')
@ -251,14 +249,12 @@ export type OrganizationListItem = Omit<OrganizationRecord, 'teams' | 'awards' |
sort_order: number sort_order: number
} }
export type OrganizationsResponse = { organizations: OrganizationListItem[] }
export const useOrganization = (id?: string): Resource<OrganizationRecord> => export const useOrganization = (id?: string): Resource<OrganizationRecord> =>
useRecord<OrganizationRecord>(detailPath('/organizations', id), 'organization') useRecord<OrganizationRecord>(detailPath('/organizations', id), 'organization')
/* ── Teams ───────────────────────────────────────────────────── */ /* ── Teams ───────────────────────────────────────────────────── */
/** No members here on purpose — PeopleTiles fetches /** No members here on purpose, PeopleTiles fetches
* /teams/:id/people itself. See the note in content.js. */ * /teams/:id/people itself. See the note in content.js. */
export type TeamRecord = { export type TeamRecord = {
id: string id: string

View file

@ -14,20 +14,16 @@
* callers, so aborting on unmount would cancel someone else's * callers, so aborting on unmount would cancel someone else's
* request. The `live` flag drops the result instead. * request. The `live` flag drops the result instead.
* *
* No `fallback` on purpose. Handing this the mock data would render a
* plausible-looking history with no indication the server is down, and
* the wrong history is worse than a visible error — the same reason
* `fallback: EMPTY` came out elsewhere.
* *
* `undated` is the number of published entries the API left out because * `undated` is the number of published entries the API left out because
* nothing gave them a date. Not rendered publicly — a visitor can't act * nothing gave them a date. Not rendered publicly, a visitor can't act
* on it — but returned so it's reachable if you want a warning in the * on it, but returned so it's reachable if you want a warning in the
* admin later. * admin later.
*/ */
import { useCallback, useEffect, useState } from 'react' import { useCallback, useEffect, useState } from 'react'
import { get, invalidate, ApiError } from './api.ts' import { get, invalidate, ApiError } from './api.ts'
import type { TimelineItem } from './timeline' import type { TimelineItem } from './timeline.ts'
const PATH = '/history' const PATH = '/history'

View file

@ -1,10 +1,10 @@
/** /**
* useRecord — one record from one endpoint, on the useHistory * useRecord, one record from one endpoint, on the useHistory
* pattern. * pattern.
* *
* Named for what it returns, and deliberately not useResource: * Named for what it returns, and deliberately not useResource:
* src/lib/useResource.ts is a different hook — it hands back the * src/lib/useResource.ts is a different hook, it hands back the
* whole response body and takes an options object — and a .ts file * whole response body and takes an options object, and a .ts file
* of the same name would sit one extension away from it. An import * of the same name would sit one extension away from it. An import
* whose target goes missing then resolves to the other file without * whose target goes missing then resolves to the other file without
* a word, and every detail page renders the wrapper object instead * a word, and every detail page renders the wrapper object instead
@ -43,7 +43,7 @@
* A null `path` means there is nothing to ask for, and the hook * A null `path` means there is nothing to ask for, and the hook
* reports notFound rather than loading forever. Callers build the * reports notFound rather than loading forever. Callers build the
* path with detailPath() from hrefs.ts, which returns null for an * path with detailPath() from hrefs.ts, which returns null for an
* id that could never be real — "undefined" chief among them. * id that could never be real, "undefined" chief among them.
*/ */
import { useCallback, useEffect, useState } from 'react' import { useCallback, useEffect, useState } from 'react'

View file

@ -3,13 +3,7 @@
The read hook every page uses: The read hook every page uses:
const { data, error, loading } = useResource("/events", { const { data, error, loading } = useResource("/events");
fallback: { events: EVENTS }, // the old static module
});
Deliberately small. If the site ever needs mutation, refetch on
focus, or pagination, that's the point to reach for TanStack
Query rather than growing this file.
Note the `ignore` flag rather than an AbortController: the Note the `ignore` flag rather than an AbortController: the
request is shared and cached, so cancelling it would throw away request is shared and cached, so cancelling it would throw away
@ -20,22 +14,15 @@
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { get } from "./api.ts"; import { get } from "./api.ts";
export function useResource(path, { ttl, fallback }: { ttl?: number; fallback?: any } = {}) { export function useResource(path, { ttl }: { ttl?: number } = {}) {
// Seed with the fallback so the first paint has content when one const [state, setState] = useState<any>({ data: undefined, error: null, loading: true });
// is available, rather than flashing a spinner and then the same
// data a moment later.
const [state, setState] = useState<any>(() => ({
data: fallback,
error: null,
loading: true,
}));
useEffect(() => { useEffect(() => {
let ignore = false; let ignore = false;
setState((prev) => ({ ...prev, loading: true, error: null })); setState((prev) => ({ ...prev, loading: true, error: null }));
get(path, { ttl, fallback }) get(path, { ttl })
.then((data) => { .then((data) => {
if (!ignore) setState({ data, error: null, loading: false }); if (!ignore) setState({ data, error: null, loading: false });
}) })
@ -46,7 +33,7 @@ export function useResource(path, { ttl, fallback }: { ttl?: number; fallback?:
return () => { return () => {
ignore = true; ignore = true;
}; };
}, [path, ttl]); // fallback is intentionally not a dependency }, [path, ttl]);
return state; return state;
} }

View file

@ -1,5 +1,5 @@
/* ═══════════════════════════════════════════════════════════════ /* ═══════════════════════════════════════════════════════════════
SITE VERSION — src/lib/version.ts SITE VERSION: src/lib/version.ts
One string, bumped by hand when the working directory name One string, bumped by hand when the working directory name
changes. The admin footer is the only thing reading it today; changes. The admin footer is the only thing reading it today;

View file

@ -1,6 +1,6 @@
import React from 'react' import React from 'react'
import ReactDOM from 'react-dom/client' import ReactDOM from 'react-dom/client'
import App from './App' import App from './App.tsx'
import './index.css' import './index.css'
ReactDOM.createRoot(document.getElementById('root')!).render( ReactDOM.createRoot(document.getElementById('root')!).render(

View file

@ -1,14 +1,14 @@
/* ═══════════════════════════════════════════════════════════════ /* ═══════════════════════════════════════════════════════════════
AWARD DETAIL — /awards/:id AWARD DETAIL: /awards/:id
The thinnest of the four, by design. `awards` has no links and no The thinnest of the four, by design. `awards` has no links and no
content blocks — 'award' isn't in the owner_kind CHECK on either content blocks, 'award' isn't in the owner_kind CHECK on either
polymorphic table, and widening it means rebuilding two STRICT polymorphic table, and widening it means rebuilding two STRICT
tables. `description` is the prose. tables. `description` is the prose.
So the recipients are the page. They're rendered as a list rather So the recipients are the page. They're rendered as a list rather
than as PeopleTiles because each one carries a citation, and a than as PeopleTiles because each one carries a citation, and a
citation is the point of an award — it doesn't belong folded citation is the point of an award, it doesn't belong folded
behind a chevron. behind a chevron.
Note also that `awards` has no is_published column: every row Note also that `awards` has no is_published column: every row

View file

@ -1,9 +1,9 @@
/* ═══════════════════════════════════════════════════════════════ /* ═══════════════════════════════════════════════════════════════
EVENT DETAIL — /retreats/:id EVENT DETAIL: /retreats/:id
Reached from the cards on Retreats.tsx. The API has already Reached from the cards on Retreats.tsx. The API has already
resolved the fallbacks — `color` is the event's own or its first resolved the fallbacks, `color` is the event's own or its first
host's, `status` is derived from the dates when nobody set it — host's, `status` is derived from the dates when nobody set it,
so nothing here reimplements those rules. so nothing here reimplements those rules.
Hosts arrive as a list in billing order, each one either an Hosts arrive as a list in billing order, each one either an
@ -33,12 +33,13 @@ import { awardHref, personHref, refHref } from '../lib/hrefs.ts'
import { personPhoto } from '../lib/media.ts' import { personPhoto } from '../lib/media.ts'
import { eventTypeLabel } from '../lib/eventTypes.ts' import { eventTypeLabel } from '../lib/eventTypes.ts'
import { occurrenceLabel, seriesLabel, seriesTimes, upcomingOccurrences } from '../lib/eventSeries.ts' import { occurrenceLabel, seriesLabel, seriesTimes, upcomingOccurrences } from '../lib/eventSeries.ts'
import { capitalize } from '../lib/text.ts'
const TEAL = '#138ba0' const TEAL = '#138ba0'
const BODY = '#4a6b72' const BODY = '#4a6b72'
/* Billing order. A role missing from here still renders, at the /* Billing order. A role missing from here still renders, at the
end, under its own name — better than a speaker vanishing end, under its own name, better than a speaker vanishing
because somebody added a role to the CHECK and not to this list. */ because somebody added a role to the CHECK and not to this list. */
const ROLE_ORDER = [ const ROLE_ORDER = [
'speaker', 'speaker',
@ -262,7 +263,7 @@ function Facts({ event, accent }: { event: EventRecord; accent: string }) {
{/* Outlined rather than filled: the status pill is the one {/* Outlined rather than filled: the status pill is the one
thing in this strip that should read as loud, and two thing in this strip that should read as loud, and two
solid blocks side by side would compete. Shown solid blocks side by side would compete. Shown
unconditionally — a card suppresses its own type badge in unconditionally, a card suppresses its own type badge in
a band of one kind, but here there is no band to make it a band of one kind, but here there is no band to make it
redundant. */} redundant. */}
{event.event_type && ( {event.event_type && (
@ -297,7 +298,7 @@ function Facts({ event, accent }: { event: EventRecord; accent: string }) {
/* One host reads as "Hosted by Northwest"; several read as a /* One host reads as "Hosted by Northwest"; several read as a
sentence, so they're joined with commas and an "and" rather than sentence, so they're joined with commas and an "and" rather than
stacked. A host whose id didn't resolve to a route renders as stacked. A host whose id didn't resolve to a route renders as
plain text — refHref returns null for that — because a dead link plain text, refHref returns null for that, because a dead link
is worse than a name. */ is worse than a name. */
function HostList({ hosts, accent }: { hosts: EventHost[]; accent: string }) { function HostList({ hosts, accent }: { hosts: EventHost[]; accent: string }) {
return ( return (
@ -327,7 +328,7 @@ function HostList({ hosts, accent }: { hosts: EventHost[]; accent: string }) {
) )
} }
/* date_label is what a card shows and is free text — "March/April /* date_label is what a card shows and is free text, "March/April
2026" is legitimate. This is only the fallback for an event that 2026" is legitimate. This is only the fallback for an event that
has dates and no label. */ has dates and no label. */
function dateRange(start?: string | null, end?: string | null): string | null { function dateRange(start?: string | null, end?: string | null): string | null {
@ -398,4 +399,3 @@ function peopleGroups(people: EventPerson[], accent: string): PeopleGroupInput[]
})) }))
} }
const capitalize = (word: string) => word.charAt(0).toUpperCase() + word.slice(1)

View file

@ -1,6 +1,6 @@
import PageShell from "../components/PageShell"; import PageShell from "../components/PageShell.tsx";
import { sitePage } from "../lib/site.ts"; import { sitePage } from "../lib/site.ts";
import FeedbackForm from "./sections/FeedbackForm"; import FeedbackForm from "./sections/FeedbackForm.tsx";
/* Title and intro: site.json, which also gives the search metadata. */ /* Title and intro: site.json, which also gives the search metadata. */
const PAGE = sitePage("/feedback"); const PAGE = sitePage("/feedback");
@ -9,7 +9,7 @@ const PAGE = sitePage("/feedback");
Feedback page. Feedback page.
Section ids match the nav hashes. Right now there's one: Section ids match the nav hashes. Right now there's one:
#website. Add more entries to SECTIONS as the page grows — #website. Add more entries to SECTIONS as the page grows,
program feedback, retreat surveys, etc. program feedback, retreat surveys, etc.
The form itself lives in sections/FeedbackForm, including its The form itself lives in sections/FeedbackForm, including its

View file

@ -1,8 +1,8 @@
import PageShell from "../components/PageShell"; import PageShell from "../components/PageShell.tsx";
import { sitePage } from "../lib/site.ts"; import { sitePage } from "../lib/site.ts";
import HistoryTimeline from "./sections/history/HistoryTimeline"; import HistoryTimeline from "./sections/history/HistoryTimeline.tsx";
import { HISTORY_DECADES } from "../data/historyDecades"; import { HISTORY_DECADES } from "../data/historyDecades.ts";
import { useHistory } from "../lib/useHistory"; import { useHistory } from "../lib/useHistory.ts";
/* Title and intro: site.json, which also gives the search metadata. */ /* Title and intro: site.json, which also gives the search metadata. */
const PAGE = sitePage("/history"); const PAGE = sitePage("/history");
@ -10,7 +10,7 @@ const PAGE = sitePage("/history");
/** /**
* Year the program starts. Decades ending before this render with the * Year the program starts. Decades ending before this render with the
* pre-program treatment, so the gap moves if the founding date is ever * pre-program treatment, so the gap moves if the founding date is ever
* corrected — no hardcoded 2000 anywhere in the components. * corrected, no hardcoded 2000 anywhere in the components.
*/ */
const PROGRAM_START_YEAR = 2000; const PROGRAM_START_YEAR = 2000;
@ -22,7 +22,7 @@ export default function History() {
// Section renders `content` outside its own max-width wrapper, so the // Section renders `content` outside its own max-width wrapper, so the
// container lives here. The custom properties bind the timeline to // container lives here. The custom properties bind the timeline to
// this section's accent and background — --tl-surface must match // this section's accent and background, --tl-surface must match
// `background` or the rail will show through the year dots. // `background` or the rail will show through the year dots.
const wrap = (children: React.ReactNode) => ( const wrap = (children: React.ReactNode) => (
<div <div

View file

@ -1,5 +1,5 @@
/* ═══════════════════════════════════════════════════════════════ /* ═══════════════════════════════════════════════════════════════
HOME — / HOME: /
Not a PageShell page: the front page has no title bar, and each Not a PageShell page: the front page has no title bar, and each
band draws its own heading in its own style. band draws its own heading in its own style.
@ -8,7 +8,7 @@
The hero comes first, always. After it, the bands in the order The hero comes first, always. After it, the bands in the order
the admin dragged them into, minus any they hid. Which component the admin dragged them into, minus any they hid. Which component
draws a band is decided here, in SECTIONS, keyed on the same list draws a band is decided here, in SECTIONS, keyed on the same list
the CHECK on front_page_sections holds — the database says "retreats, the CHECK on front_page_sections holds, the database says "retreats,
third, called National Retreats"; this file says what a retreats third, called National Retreats"; this file says what a retreats
band looks like. band looks like.
@ -51,7 +51,7 @@ type BandProps = {
} }
/* Default headings for a band the admin didn't title, and how each /* Default headings for a band the admin didn't title, and how each
one renders. The ids are the page anchors — #connect is what the one renders. The ids are the page anchors, #connect is what the
hero's second button points at out of the box. */ hero's second button points at out of the box. */
const SECTIONS: Record< const SECTIONS: Record<
FrontPageSectionKey, FrontPageSectionKey,

View file

@ -5,8 +5,8 @@
One component behind four routes, because organizations are one One component behind four routes, because organizations are one
table. The kind decides which extras render, not which file runs. table. The kind decides which extras render, not which file runs.
The URL kind is decoration — the slug is what identifies the The URL kind is decoration, the slug is what identifies the
record — so a request for /chapters/great-lakes when that slug is record, so a request for /chapters/great-lakes when that slug is
a region redirects to the canonical path rather than rendering a a region redirects to the canonical path rather than rendering a
correct page at a wrong address. correct page at a wrong address.
@ -57,7 +57,7 @@ export default function OrganizationDetail() {
// /chapters/x when x is a region: same record, wrong address. // /chapters/x when x is a region: same record, wrong address.
// //
// useLocation, not window.location: the latter is outside the // useLocation, not window.location: the latter is outside the
// router's awareness — always "/" under HashRouter, and free to // router's awareness, always "/" under HashRouter, and free to
// be stale mid-navigation, either of which turns this into a // be stale mid-navigation, either of which turns this into a
// redirect loop rather than a one-shot correction. // redirect loop rather than a one-shot correction.
// //
@ -232,7 +232,7 @@ export default function OrganizationDetail() {
}) })
} }
// EventList-Cards fetches and renders this itself — its own // EventList-Cards fetches and renders this itself, its own
// docstring offers `host` for exactly this case, and a card there // docstring offers `host` for exactly this case, and a card there
// already knows about gradients, logos, past-event collapsing and // already knows about gradients, logos, past-event collapsing and
// the carousel. A second grid here was the same component written // the carousel. A second grid here was the same component written
@ -414,7 +414,7 @@ function groupLeadership(org: OrganizationRecord): TeamBlock[] {
const blocks: TeamBlock[] = [] const blocks: TeamBlock[] = []
// People who hold a role in the organization without sitting on a // People who hold a role in the organization without sitting on a
// team. Usually the leads. No heading — they are the page. // team. Usually the leads. No heading, they are the page.
if (loose.length > 0) { if (loose.length > 0) {
blocks.push({ key: 'loose', teamId: null, label: null, people: loose }) blocks.push({ key: 'loose', teamId: null, label: null, people: loose })
} }
@ -432,7 +432,7 @@ function groupLeadership(org: OrganizationRecord): TeamBlock[] {
} }
// Whatever is left is filed under an unpublished team. Its page // Whatever is left is filed under an unpublished team. Its page
// isn't reachable, so the heading is plain text — but the people // isn't reachable, so the heading is plain text, but the people
// are real and shouldn't silently vanish from the org. // are real and shouldn't silently vanish from the org.
for (const [teamId, people] of byTeam) { for (const [teamId, people] of byTeam) {
blocks.push({ blocks.push({

View file

@ -1,5 +1,5 @@
/* ═══════════════════════════════════════════════════════════════ /* ═══════════════════════════════════════════════════════════════
PERSON DETAIL — /people/:id PERSON DETAIL: /people/:id
Everything public that points at one person, gathered by Everything public that points at one person, gathered by
GET /people/:id in people.js. Visibility is decided there, the GET /people/:id in people.js. Visibility is decided there, the
@ -33,6 +33,7 @@ import {
import { awardHref, eventHref, orgHref, teamHref } from '../lib/hrefs.ts' import { awardHref, eventHref, orgHref, teamHref } from '../lib/hrefs.ts'
import { initials, personPhoto } from '../lib/media.ts' import { initials, personPhoto } from '../lib/media.ts'
import { eventTypeLabel } from '../lib/eventTypes.ts' import { eventTypeLabel } from '../lib/eventTypes.ts'
import { capitalize } from '../lib/text.ts'
const TEAL = '#138ba0' const TEAL = '#138ba0'
const BODY = '#4a6b72' const BODY = '#4a6b72'
@ -47,8 +48,6 @@ const ROLE_LABEL: Record<string, string> = {
member: 'Member', member: 'Member',
} }
const capitalize = (word: string) =>
word ? word.charAt(0).toUpperCase() + word.slice(1) : ''
export default function PersonDetail() { export default function PersonDetail() {
const { id } = useParams() const { id } = useParams()

View file

@ -1,4 +1,4 @@
import PageShell from "../components/PageShell.jsx"; import PageShell from "../components/PageShell.tsx";
import { sitePage } from "../lib/site.ts"; import { sitePage } from "../lib/site.ts";
/* Title and intro: site.json, which also gives the search metadata. */ /* Title and intro: site.json, which also gives the search metadata. */

View file

@ -1,4 +1,4 @@
import PageShell from "../components/PageShell.jsx"; import PageShell from "../components/PageShell.tsx";
import { sitePage } from "../lib/site.ts"; import { sitePage } from "../lib/site.ts";
/* Title and intro: site.json, which also gives the search metadata. */ /* Title and intro: site.json, which also gives the search metadata. */

View file

@ -10,7 +10,7 @@ const PAGE = sitePage("/retreats");
RETREATS PAGE RETREATS PAGE
Three bands, all the same view of the same table with a Three bands, all the same view of the same table with a
different filter. The page declares them and does nothing else — different filter. The page declares them and does nothing else,
each section fetches its own slice. each section fetches its own slice.
Two filters per band now, and they answer different questions: Two filters per band now, and they answer different questions:
@ -29,7 +29,7 @@ const PAGE = sitePage("/retreats");
What this page deliberately does not show: local, international What this page deliberately does not show: local, international
and other scopes, and every non-retreat type. Those are reachable and other scopes, and every non-retreat type. Those are reachable
from their host's page and by URL, and get a band here when from their host's page and by URL, and get a band here when
there's enough of them to fill one — see the block at the bottom. there's enough of them to fill one, see the block at the bottom.
To reorder the page, move a line. To add a different kind of To reorder the page, move a line. To add a different kind of
section, add an entry with another Component. section, add an entry with another Component.
@ -74,7 +74,7 @@ const SECTIONS = [
}, },
/* The other three scopes, ready to uncomment. Each needs an accent /* The other three scopes, ready to uncomment. Each needs an accent
and a background of its own — those are presentation and live and a background of its own, those are presentation and live
here, not in event_scopes. here, not in event_scopes.
{ {

View file

@ -1,5 +1,5 @@
/* ═══════════════════════════════════════════════════════════════ /* ═══════════════════════════════════════════════════════════════
TEAM DETAIL — /teams/:id TEAM DETAIL: /teams/:id
teams.id is a global primary key rather than scoped to the teams.id is a global primary key rather than scoped to the
organization, which is what lets this route be flat: 'ngu-board' organization, which is what lets this route be flat: 'ngu-board'

View file

@ -1,4 +1,4 @@
import PageShell from "../components/PageShell.jsx"; import PageShell from "../components/PageShell.tsx";
import { sitePage } from "../lib/site.ts"; import { sitePage } from "../lib/site.ts";
/* Title and intro: site.json, which also gives the search metadata. */ /* Title and intro: site.json, which also gives the search metadata. */

View file

@ -26,7 +26,7 @@
edge and marked as continuing edge and marked as continuing
series every meeting the schedule produces in view (see series every meeting the schedule produces in view (see
eventSeries.ts), one day each, with its time eventSeries.ts), one day each, with its time
undated nowhere — there's no day to put it on. Counted undated nowhere, there's no day to put it on. Counted
under the grid so it doesn't vanish without a word. under the grid so it doesn't vanish without a word.
Bars are laid out per week in lanes, so a long event keeps its Bars are laid out per week in lanes, so a long event keeps its
@ -42,7 +42,7 @@
import { useMemo, useState } from 'react' import { useMemo, useState } from 'react'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import { typesPresent, useEvents } from '../../data/eventData.ts' import { typesPresent, useEvents } from '../../lib/eventData.ts'
import { EVENT_TYPES, eventTypeLabel, type EventType } from '../../lib/eventTypes.ts' import { EVENT_TYPES, eventTypeLabel, type EventType } from '../../lib/eventTypes.ts'
import { firstOccurrenceFrom, occurrencesBetween, seriesTimes } from '../../lib/eventSeries.ts' import { firstOccurrenceFrom, occurrencesBetween, seriesTimes } from '../../lib/eventSeries.ts'
import { eventHref } from '../../lib/hrefs.ts' import { eventHref } from '../../lib/hrefs.ts'

View file

@ -1,6 +1,6 @@
import { useEffect, useMemo, useRef, useState } from "react"; import { useEffect, useMemo, useRef, useState } from "react";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { splitByStatus, typesPresent, useEvents } from "../../data/eventData.ts"; import { splitByStatus, typesPresent, useEvents } from "../../lib/eventData.ts";
import { eventHref } from "../../lib/hrefs.ts"; import { eventHref } from "../../lib/hrefs.ts";
import { EVENT_TYPES, eventTypeLabel } from "../../lib/eventTypes.ts"; import { EVENT_TYPES, eventTypeLabel } from "../../lib/eventTypes.ts";
import { seriesLabel } from "../../lib/eventSeries.ts"; import { seriesLabel } from "../../lib/eventSeries.ts";
@ -8,7 +8,7 @@ import PlatformIcon from "../../components/PlatformIcon.tsx";
import { eventBackground, eventLogo as eventLogoSrc, orgLogo as orgLogoSrc } from "../../lib/media.ts"; import { eventBackground, eventLogo as eventLogoSrc, orgLogo as orgLogoSrc } from "../../lib/media.ts";
/* ═══════════════════════════════════════════════════════════════ /* ═══════════════════════════════════════════════════════════════
EVENT LIST — CARDS EVENT LIST: CARDS
A band of event cards, as a peek carousel or a grid. Self A band of event cards, as a peek carousel or a grid. Self
contained: give it a filter and it fetches, so the same section contained: give it a filter and it fetches, so the same section
@ -23,7 +23,7 @@ import { eventBackground, eventLogo as eventLogoSrc, orgLogo as orgLogoSrc } fro
`type` pre-filters the band the way `scope` and `host` do. Left `type` pre-filters the band the way `scope` and `host` do. Left
off, the band takes every kind it finds and grows a row of chips off, the band takes every kind it finds and grows a row of chips
to narrow by — but only once it holds more than one, so a band of to narrow by, but only once it holds more than one, so a band of
nothing but retreats shows no control at all. nothing but retreats shows no control at all.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
@ -91,7 +91,7 @@ const PAST_FADE = "linear-gradient(to bottom, black 0%, black 45%, transparent 1
/* ── Carousel sizing ────────────────────────────────────────── /* ── Carousel sizing ──────────────────────────────────────────
CARD the card itself CARD the card itself
GAP space between cards — raise to push neighbors out GAP space between cards, raise to push neighbors out
FADE_DIST how far past the card's edge neighbors fade to nothing FADE_DIST how far past the card's edge neighbors fade to nothing
───────────────────────────────────────────────────────────── */ ───────────────────────────────────────────────────────────── */
const CARD = "min(48rem, 90vw)"; const CARD = "min(48rem, 90vw)";
@ -113,7 +113,7 @@ const EDGE_FADE = `linear-gradient(to right,
A link on the title rather than a wrapper around the whole card: A link on the title rather than a wrapper around the whole card:
the footer already holds anchors, and an anchor inside an anchor the footer already holds anchors, and an anchor inside an anchor
is invalid markup that every browser resolves by guessing. The is invalid markup that every browser resolves by guessing. The
carousel has the same constraint — it needs the card's click to carousel has the same constraint, it needs the card's click to
mean "bring this one to the front" on anything that isn't the mean "bring this one to the front" on anything that isn't the
active slide. */ active slide. */
function TitleLink({ ev, linked, children }) { function TitleLink({ ev, linked, children }) {
@ -126,7 +126,7 @@ function TitleLink({ ev, linked, children }) {
} }
/* ═══════════════════════════════════════════════════════════════ /* ═══════════════════════════════════════════════════════════════
EVENT CARD — one component, two sizes. EVENT CARD: one component, two sizes.
compact=false → the full card used in the carousel compact=false → the full card used in the carousel
compact=true → the grid card: details left, text right, and a compact=true → the grid card: details left, text right, and a
footer pinned to the bottom so every card in a footer pinned to the bottom so every card in a
@ -136,9 +136,9 @@ function TitleLink({ ev, linked, children }) {
page or a home strip can render one without the section around page or a home strip can render one without the section around
it. it.
Fields arrive pre-resolved from the API — `color` is the event's Fields arrive pre-resolved from the API: `color` is the event's
own or its host's, `status` is derived from the dates when it own or its host's, `status` is derived from the dates when it
isn't set — so nothing here reimplements those rules. isn't set, so nothing here reimplements those rules.
`linked` is the one thing a caller turns off: a card on the `linked` is the one thing a caller turns off: a card on the
event's own page shouldn't link to the page it's already on. event's own page shouldn't link to the page it's already on.
@ -165,7 +165,7 @@ export function Card({
/* Off unless the caller says the band is mixed. A "Retreat" badge /* Off unless the caller says the band is mixed. A "Retreat" badge
on every card in a row of nothing but retreats is noise, and on every card in a row of nothing but retreats is noise, and
the card can't tell on its own — it only ever sees one event. */ the card can't tell on its own, it only ever sees one event. */
const typeBadge = const typeBadge =
showType && ev.event_type ? ( showType && ev.event_type ? (
<span <span
@ -262,14 +262,14 @@ export function Card({
</> </>
)} )}
{/* Footer — mt-auto pins the whole block to the bottom so {/* Footer, mt-auto pins the whole block to the bottom so
buttons line up across every card in a grid row. buttons line up across every card in a grid row.
Three registration states, as before: links to follow, a Three registration states, as before: links to follow, a
past event, or an announcement still to come. What's new past event, or an announcement still to come. What's new
is that all three end in the same row, because every is that all three end in the same row, because every
event now has a page and a past one is often the more event now has a page and a past one is often the more
worth reading — speakers, awards, what actually worth reading, speakers, awards, what actually
happened. The notice is what changes; the way in happened. The notice is what changes; the way in
doesn't. */} doesn't. */}
<div className={`mt-auto ${compact ? "pt-6" : "pt-8"}`}> <div className={`mt-auto ${compact ? "pt-6" : "pt-8"}`}>
@ -306,7 +306,7 @@ export function Card({
))} ))}
{/* Only when there's nothing to register for and the {/* Only when there's nothing to register for and the
event hasn't happened — the same condition as before, event hasn't happened, the same condition as before,
just no longer nested inside that branch. */} just no longer nested inside that branch. */}
{igHandle && !past && links.length === 0 && ( {igHandle && !past && links.length === 0 && (
<a <a
@ -346,7 +346,7 @@ export function Card({
TYPE FILTER TYPE FILTER
Drawn only when a band actually holds more than one kind, so it Drawn only when a band actually holds more than one kind, so it
costs nothing today — every event is a retreat — and appears on costs nothing today, every event is a retreat, and appears on
its own the first time a class or a workshop lands in that band. its own the first time a class or a workshop lands in that band.
Nothing on Retreats.tsx has to be reconfigured for it. Nothing on Retreats.tsx has to be reconfigured for it.
@ -387,7 +387,7 @@ export function TypeFilter({ types, active, setActive, accent }) {
} }
/* ═══════════════════════════════════════════════════════════════ /* ═══════════════════════════════════════════════════════════════
TOGGLE — the control for the section heading's action bar TOGGLE: the control for the section heading's action bar
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
export function EventCardsToggle({ view, setView, accent }) { export function EventCardsToggle({ view, setView, accent }) {
const btn = active => ({ const btn = active => ({
@ -437,8 +437,8 @@ export function EventCardsToggle({ view, setView, accent }) {
Fetches its own slice of the events, then draws it as a carousel Fetches its own slice of the events, then draws it as a carousel
or a grid. or a grid.
An empty list means three different things now — still loading, An empty list means three different things now, still loading,
failed, or genuinely nothing scheduled — and they read very failed, or genuinely nothing scheduled, and they read very
differently to someone waiting, so they're distinguished rather differently to someone waiting, so they're distinguished rather
than all falling through to "coming soon". than all falling through to "coming soon".
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
@ -464,7 +464,7 @@ export default function EventListCards({
const [showPast, setShowPast] = useState(false); const [showPast, setShowPast] = useState(false);
const [activeType, setActiveType] = useState("all"); const [activeType, setActiveType] = useState("all");
/* What this band holds, which is what the chips offer — not the /* What this band holds, which is what the chips offer, not the
full list of declared types, three quarters of which would be full list of declared types, three quarters of which would be
dead buttons. */ dead buttons. */
const availableTypes = useMemo( const availableTypes = useMemo(
@ -483,7 +483,7 @@ export default function EventListCards({
); );
/* Open on the first upcoming event. The list is empty on the /* Open on the first upcoming event. The list is empty on the
first render, so this can't be a useState initialiser — it has first render, so this can't be a useState initialiser, it has
to wait for the data and then run once. Clearing the guard when to wait for the data and then run once. Clearing the guard when
the list empties means a refetch re-seeds. */ the list empties means a refetch re-seeds. */
const seeded = useRef(false); const seeded = useRef(false);
@ -546,7 +546,7 @@ export default function EventListCards({
if (error && events.length === 0) { if (error && events.length === 0) {
return ( return (
<div className="overflow-hidden"> <div className="overflow-hidden">
{notice("· Events couldn't be loaded just now — please try again shortly ·")} {notice("· Events couldn't be loaded just now, please try again shortly ·")}
</div> </div>
); );
} }
@ -572,7 +572,7 @@ export default function EventListCards({
: `· No ${eventTypeLabel(activeType).toLowerCase()} events in this section yet ·`, : `· No ${eventTypeLabel(activeType).toLowerCase()} events in this section yet ·`,
) )
) : view === "grid" ? ( ) : view === "grid" ? (
/* ── GRID VIEW — upcoming first, past events collapsed below ── */ /* ── GRID VIEW: upcoming first, past events collapsed below ── */
<div className="mx-auto px-8 md:px-12 lg:px-16" style={{ maxWidth: GRID_MAX }}> <div className="mx-auto px-8 md:px-12 lg:px-16" style={{ maxWidth: GRID_MAX }}>
{upcoming.length > 0 && ( {upcoming.length > 0 && (
<div <div

View file

@ -291,7 +291,7 @@ export default function FeedbackForm() {
className="rounded-2xl border border-[#138ba0]/20 bg-white p-8 sm:p-10" className="rounded-2xl border border-[#138ba0]/20 bg-white p-8 sm:p-10"
> >
<h3 className="text-2xl font-bold" style={{ color: ACCENT }}> <h3 className="text-2xl font-bold" style={{ color: ACCENT }}>
Thanks — we've got it Thanks, we've got it
</h3> </h3>
{where && ( {where && (
<p className="mt-3 text-sm" style={{ color: MUTED }}> <p className="mt-3 text-sm" style={{ color: MUTED }}>
@ -301,7 +301,7 @@ export default function FeedbackForm() {
<p className="mt-3 max-w-prose" style={{ color: MUTED }}> <p className="mt-3 max-w-prose" style={{ color: MUTED }}>
{email {email
? `We'll follow up at ${email} if we have questions.` ? `We'll follow up at ${email} if we have questions.`
: "You sent this anonymously, so we won't be able to reply — but we read everything that comes in."} : "You sent this anonymously, so we won't be able to reply, but we read everything that comes in."}
</p> </p>
<button <button
type="button" type="button"
@ -375,7 +375,7 @@ export default function FeedbackForm() {
</div> </div>
<p className="mt-1 max-w-prose text-sm" style={{ color: MUTED }}> <p className="mt-1 max-w-prose text-sm" style={{ color: MUTED }}>
Leave these blank and your feedback comes through anonymously. Fill Leave these blank and your feedback comes through anonymously. Fill
them in only if you'd like a reply — we won't add you to any list. them in only if you'd like a reply, we won't add you to any list.
</p> </p>
<div className="mt-5 grid gap-4 sm:grid-cols-2"> <div className="mt-5 grid gap-4 sm:grid-cols-2">

View file

@ -5,10 +5,11 @@ import {
initialsFor, initialsFor,
orgPath, orgPath,
useOrganizations, useOrganizations,
} from "../../data/organizations.ts"; byName,
} from "../../lib/organizations.ts";
/* ═══════════════════════════════════════════════════════════════ /* ═══════════════════════════════════════════════════════════════
ORGANIZATION LIST — CARDS ORGANIZATION LIST: CARDS
A grid of organization cards. No toggle: this view is the grid, A grid of organization cards. No toggle: this view is the grid,
which is why the section that uses it declares no `views` in the which is why the section that uses it declares no `views` in the
@ -19,7 +20,7 @@ import {
Where the vertical list expands in place, a card links out. The Where the vertical list expands in place, a card links out. The
card carries as much as fits at a glance and the organization's card carries as much as fits at a glance and the organization's
own page carries the rest, so nothing here reads a `blocks` own page carries the rest, so nothing here reads a `blocks`
array — only the short card description. array, only the short card description.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
const MUTED = "#7a9299"; const MUTED = "#7a9299";
@ -87,11 +88,11 @@ function OrgCard({ org, accent, pageLabel, siteLabel }) {
{/* Top-right rather than in the footer: the footer holds {/* Top-right rather than in the footer: the footer holds
outbound links, and the arrow goes somewhere different outbound links, and the arrow goes somewhere different
in kind — deeper into this site. */} in kind, deeper into this site. */}
{path && ( {path && (
<ArrowLink <ArrowLink
to={path} to={path}
label={`${org.name} — ${pageLabel}`} label={`${org.name}: ${pageLabel}`}
color={color} color={color}
/> />
)} )}
@ -166,7 +167,6 @@ function Block({ title, orgs, accent, pageLabel, siteLabel }) {
); );
} }
const byName = (a, b) => a.name.localeCompare(b.name);
export default function OrgListCards({ export default function OrgListCards({
kind, kind,
@ -196,7 +196,7 @@ export default function OrgListCards({
if (error && organizations.length === 0) { if (error && organizations.length === 0) {
return shell( return shell(
<p className="font-600" style={{ color: accent }}> <p className="font-600" style={{ color: accent }}>
· This list couldn't be loaded just now — please try again shortly · · This list couldn't be loaded just now, please try again shortly ·
</p> </p>
); );
} }

View file

@ -1,13 +1,13 @@
import { useEffect, useRef, useState } from "react"; import { useEffect, useRef, useState } from "react";
import { useCommunity } from "../../data/chapters.ts"; import { useCommunity } from "../../lib/chapters.ts";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import ArrowLink from "../../components/ArrowLink.tsx"; import ArrowLink from "../../components/ArrowLink.tsx";
import { orgLogo } from "../../lib/media.ts"; import { orgLogo } from "../../lib/media.ts";
import { initialsFor, orgPath } from "../../data/organizations.ts"; import { initialsFor, orgPath } from "../../lib/organizations.ts";
import { AREAS, AREA_NAMES } from "../../data/mapGrid.ts"; import { AREAS, AREA_NAMES } from "../../data/mapGrid.ts";
/* ═══════════════════════════════════════════════════════════════ /* ═══════════════════════════════════════════════════════════════
ORGANIZATION LIST — MAP ORGANIZATION LIST: MAP
Organizations placed on a tile grid: the map on the left, the Organizations placed on a tile grid: the map on the left, the
list on the right, selecting on either side filtering both. list on the right, selecting on either side filtering both.
@ -15,7 +15,7 @@ import { AREAS, AREA_NAMES } from "../../data/mapGrid.ts";
Filtered to chapters, and unlike the other sections that isn't Filtered to chapters, and unlike the other sections that isn't
a prop. A map only makes sense for organizations that sit a prop. A map only makes sense for organizations that sit
somewhere, and it reads regions off the same data to colour the somewhere, and it reads regions off the same data to colour the
tiles — so "plot partners instead" isn't a filter change, it's a tiles, so "plot partners instead" isn't a filter change, it's a
different component. Named for the view rather than the filter different component. Named for the view rather than the filter
so that stays visible. so that stays visible.
@ -24,7 +24,7 @@ import { AREAS, AREA_NAMES } from "../../data/mapGrid.ts";
stays legible on a phone, it needs no map library or GeoJSON, stays legible on a phone, it needs no map library or GeoJSON,
and a state split between two regions is just a tile painted in and a state split between two regions is just a tile painted in
two colors. If you later want true geography, the swap point is two colors. If you later want true geography, the swap point is
<RegionMap> — everything else works off the data. <RegionMap>, everything else works off the data.
The tile layout comes from mapGrid.ts; who paints what comes The tile layout comes from mapGrid.ts; who paints what comes
from the API. A state and the Canada band are the same shape from the API. A state and the Canada band are the same shape
@ -109,7 +109,7 @@ function Blocks({ blocks = [] as any[], color }) {
{item.detail && ( {item.detail && (
<span className="text-sm" style={{ color: MUTED }}> <span className="text-sm" style={{ color: MUTED }}>
{" "} {" "}
— {item.detail} ({item.detail})
</span> </span>
)} )}
</li> </li>
@ -180,7 +180,7 @@ function Tile({
className="transition-opacity duration-200" className="transition-opacity duration-200"
> >
<title> <title>
{AREA_NAMES[code] || code} — {slices.map(s => s.name).join(" / ")} {AREA_NAMES[code] || code}: {slices.map(s => s.name).join(" / ")}
{count ? ` · ${count} chapter${count > 1 ? "s" : ""}` : ""} {count ? ` · ${count} chapter${count > 1 ? "s" : ""}` : ""}
</title> </title>
@ -257,7 +257,7 @@ function RegionMap({ slices, chapterCounts, ...props }: any) {
role="group" role="group"
aria-label="Chapters by Unity region" aria-label="Chapters by Unity region"
> >
{/* States and bands are the same shape — a tile with a span — {/* States and bands are the same shape, a tile with a span,
so this is one loop rather than two. */} so this is one loop rather than two. */}
{AREAS.map(area => ( {AREAS.map(area => (
<Tile <Tile
@ -386,7 +386,7 @@ function RegionBlock({
{region.name} {region.name}
</h4> </h4>
<span className="text-sm ml-auto" style={{ color: MUTED }}> <span className="text-sm ml-auto" style={{ color: MUTED }}>
{chapters.length || "—"} {chapters.length || "-"}
</span> </span>
</button> </button>
@ -398,7 +398,7 @@ function RegionBlock({
{chapters.length === 0 ? ( {chapters.length === 0 ? (
<p className="text-sm ml-5 mb-4" style={{ color: MUTED }}> <p className="text-sm ml-5 mb-4" style={{ color: MUTED }}>
No chapters yet — interested in starting one? No chapters yet. Interested in starting one?
</p> </p>
) : ( ) : (
<ul className="ml-5 mb-4 flex flex-col gap-3"> <ul className="ml-5 mb-4 flex flex-col gap-3">
@ -444,7 +444,7 @@ function RegionBlock({
{orgPath(c) && ( {orgPath(c) && (
<ArrowLink <ArrowLink
to={orgPath(c)} to={orgPath(c)}
label={`${c.name} — chapter page`} label={`${c.name}: chapter page`}
color={colorOf(region)} color={colorOf(region)}
size="h-8 w-8" size="h-8 w-8"
/> />
@ -545,7 +545,7 @@ function ChapterCard({ chapter, color, open, onOpen }) {
{orgPath(chapter) && ( {orgPath(chapter) && (
<ArrowLink <ArrowLink
to={orgPath(chapter)} to={orgPath(chapter)}
label={`${chapter.name} — chapter page`} label={`${chapter.name}: chapter page`}
color={color} color={color}
/> />
)} )}
@ -711,7 +711,7 @@ function ChapterGrid({ regions, chapters, chaptersIn, subtextFor, openId, setOpe
{empty.length > 0 && ( {empty.length > 0 && (
<p className="text-sm" style={{ color: MUTED }}> <p className="text-sm" style={{ color: MUTED }}>
No chapters yet in {empty.map(r => r.name).join(", ")} — interested in No chapters yet in {empty.map(r => r.name).join(", ")}. Interested in
starting one? starting one?
</p> </p>
)} )}
@ -835,7 +835,7 @@ export default function OrgListMap({ view = "map", accent = FALLBACK_COLOR }) {
if (error && regions.length === 0) { if (error && regions.length === 0) {
return shell( return shell(
<p className="font-600" style={{ color: accent }}> <p className="font-600" style={{ color: accent }}>
· Chapters couldn't be loaded just now — please try again shortly · · Chapters couldn't be loaded just now, please try again shortly ·
</p> </p>
); );
} }
@ -871,7 +871,7 @@ export default function OrgListMap({ view = "map", accent = FALLBACK_COLOR }) {
); );
return ( return (
/* Wider than the section heading above it — the map needs the /* Wider than the section heading above it, the map needs the
room. CONTENT_MAX is the knob; drop it toward 72rem to pull room. CONTENT_MAX is the knob; drop it toward 72rem to pull
the whole block back in line with the heading. */ the whole block back in line with the heading. */
shell( shell(
@ -897,7 +897,7 @@ export default function OrgListMap({ view = "map", accent = FALLBACK_COLOR }) {
</p> </p>
</div> </div>
{/* List — h-0 + min-h-full makes this column take its height {/* List, h-0 + min-h-full makes this column take its height
from the map column rather than the other way round, so a from the map column rather than the other way round, so a
long list scrolls instead of stretching the section. */} long list scrolls instead of stretching the section. */}
<div <div

View file

@ -7,10 +7,11 @@ import {
initialsFor, initialsFor,
orgPath, orgPath,
useOrganizations, useOrganizations,
} from "../../data/organizations.ts"; byName,
} from "../../lib/organizations.ts";
/* ═══════════════════════════════════════════════════════════════ /* ═══════════════════════════════════════════════════════════════
ORGANIZATION LIST — VERTICAL ORGANIZATION LIST: VERTICAL
A stack of organizations, each collapsed to a line and A stack of organizations, each collapsed to a line and
expandable for the rest. Every row carries two ways out: an expandable for the rest. Every row carries two ways out: an
@ -44,7 +45,7 @@ const FALLBACK_COLOR = "#4a6b72";
/* ── Row button ─────────────────────────────────────────────── /* ── Row button ───────────────────────────────────────────────
Deliberately a sibling of the summary button rather than inside Deliberately a sibling of the summary button rather than inside
it — a link nested in a button is invalid, and a screen reader it, a link nested in a button is invalid, and a screen reader
announces the whole row as one confused control. announces the whole row as one confused control.
───────────────────────────────────────────────────────────── */ ───────────────────────────────────────────────────────────── */
function RowButton({ as: As = "button", color, children, ...rest }: any) { function RowButton({ as: As = "button", color, children, ...rest }: any) {
@ -107,7 +108,7 @@ function OrgRow({ org, pageLabel, siteLabel }) {
const chapterCount = (org.details?.chapters ?? []).length; const chapterCount = (org.details?.chapters ?? []).length;
const note = org.details?.map_note; const note = org.details?.map_note;
/* Collapsed, a row says who it is and nothing else — the areas /* Collapsed, a row says who it is and nothing else, the areas
sentence runs long and lives in the panel, where it appears sentence runs long and lives in the panel, where it appears
exactly once rather than in both places. */ exactly once rather than in both places. */
const summary = org.tagline; const summary = org.tagline;
@ -181,7 +182,7 @@ function OrgRow({ org, pageLabel, siteLabel }) {
{path && ( {path && (
<ArrowLink <ArrowLink
to={path} to={path}
label={`${org.name} — ${pageLabel}`} label={`${org.name}: ${pageLabel}`}
color={color} color={color}
/> />
)} )}
@ -263,7 +264,6 @@ function Block({ title, orgs, pageLabel, siteLabel }) {
); );
} }
const byName = (a, b) => a.name.localeCompare(b.name);
export default function OrgListVertical({ export default function OrgListVertical({
kind, kind,
@ -291,7 +291,7 @@ export default function OrgListVertical({
if (error && organizations.length === 0) { if (error && organizations.length === 0) {
return shell( return shell(
<p className="font-600" style={{ color: accent }}> <p className="font-600" style={{ color: accent }}>
· This list couldn't be loaded just now — please try again shortly · · This list couldn't be loaded just now, please try again shortly ·
</p> </p>
); );
} }

View file

@ -8,9 +8,9 @@ import {
type DecadeMeta, type DecadeMeta,
type SortDirection, type SortDirection,
type TimelineItem, type TimelineItem,
} from '../../../lib/timeline' } from '../../../lib/timeline.ts'
import TimelineDecade from './TimelineDecade' import TimelineDecade from './TimelineDecade.tsx'
import TimelineUpcoming from './TimelineUpcoming' import TimelineUpcoming from './TimelineUpcoming.tsx'
import './timeline.css' import './timeline.css'
const PARAM = 'y' const PARAM = 'y'

View file

@ -3,8 +3,8 @@ import {
withGapYears, withGapYears,
type GroupedDecade, type GroupedDecade,
type SortDirection, type SortDirection,
} from '../../../lib/timeline' } from '../../../lib/timeline.ts'
import TimelineYear from './TimelineYear' import TimelineYear from './TimelineYear.tsx'
type Props = { type Props = {
decade: GroupedDecade decade: GroupedDecade
@ -45,7 +45,7 @@ export default function TimelineDecade({
{decade.preProgram ? ( {decade.preProgram ? (
<p className="ngu-tl__gapNote"> <p className="ngu-tl__gapNote">
<span aria-hidden="true">◌</span> <span aria-hidden="true">◌</span>
Before the program — kept for context, not part of our record Before the program, kept for context, not part of our record
</p> </p>
) : null} ) : null}
</div> </div>

View file

@ -1,6 +1,7 @@
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import { MONTH_LABELS, type PersonRef, type TimelineItem } from '../../../lib/timeline' import { MONTH_LABELS, type PersonRef, type TimelineItem } from '../../../lib/timeline.ts'
import { hrefFor, logoSrc, photoSrc } from '../../../lib/timelineRefs' import { hrefFor, logoSrc, photoSrc } from '../../../lib/timelineRefs.ts'
import { initials } from '../../../lib/media.ts'
const KIND_NAMES: Record<TimelineItem['kind'], string> = { const KIND_NAMES: Record<TimelineItem['kind'], string> = {
milestone: 'Milestone', milestone: 'Milestone',
@ -10,7 +11,7 @@ const KIND_NAMES: Record<TimelineItem['kind'], string> = {
people: 'People', people: 'People',
} }
/** Day number only — the month node above already carries the month. */ /** Day number only, the month node above already carries the month. */
function dayMarker(item: TimelineItem): string { function dayMarker(item: TimelineItem): string {
if (item.precision !== 'day') return '' if (item.precision !== 'day') return ''
const day = Number(item.date.split('-')[2]) const day = Number(item.date.split('-')[2])
@ -26,16 +27,6 @@ function fullMarker(item: TimelineItem): string {
return `${month} ${Number(d)}` return `${month} ${Number(d)}`
} }
/** Initials stand in when a person has no photo on file. */
function initials(name: string): string {
return name
.split(/\s+/)
.slice(0, 2)
.map((part) => part[0] ?? '')
.join('')
.toUpperCase()
}
function PersonChip({ person }: { person: PersonRef }) { function PersonChip({ person }: { person: PersonRef }) {
const src = photoSrc(person.photo) const src = photoSrc(person.photo)
return ( return (

View file

@ -1,6 +1,6 @@
import { useState } from 'react' import { useState } from 'react'
import type { GroupedYear, SortDirection } from '../../../lib/timeline' import type { GroupedYear, SortDirection } from '../../../lib/timeline.ts'
import TimelineYear from './TimelineYear' import TimelineYear from './TimelineYear.tsx'
type Props = { type Props = {
years: GroupedYear[] years: GroupedYear[]
@ -17,7 +17,7 @@ type Props = {
* order. That keeps the button anchored next to the decade marker * order. That keeps the button anchored next to the decade marker
* instead of drifting up the page as items appear. * instead of drifting up the page as items appear.
* *
* Membership is decided by date, not by a flag — see partitionByDate. * Membership is decided by date, not by a flag, see partitionByDate.
* An event moves into the record on its own, with nothing to update. * An event moves into the record on its own, with nothing to update.
*/ */
export default function TimelineUpcoming({ export default function TimelineUpcoming({

View file

@ -1,6 +1,6 @@
import type { CSSProperties } from 'react' import type { CSSProperties } from 'react'
import type { GroupedYear } from '../../../lib/timeline' import type { GroupedYear } from '../../../lib/timeline.ts'
import TimelineEntry from './TimelineEntry' import TimelineEntry from './TimelineEntry.tsx'
/** Dot diameter scales with volume, so the rail reads as a density chart. */ /** Dot diameter scales with volume, so the rail reads as a density chart. */
function dotSize(count: number): string { function dotSize(count: number): string {
@ -42,7 +42,7 @@ export default function TimelineYear({ year, open, onToggle }: Props) {
/> />
<span className="ngu-tl__yearLabel">{year.year}</span> <span className="ngu-tl__yearLabel">{year.year}</span>
<span className="ngu-tl__yearCount"> <span className="ngu-tl__yearCount">
{empty ? '—' : `${year.count} ${year.count === 1 ? 'entry' : 'entries'}`} {empty ? '-' : `${year.count} ${year.count === 1 ? 'entry' : 'entries'}`}
</span> </span>
</button> </button>

View file

@ -1,5 +1,5 @@
/** /**
* History timeline — scoped under .ngu-tl. * History timeline, scoped under .ngu-tl.
* *
* Everything themeable is a custom property with a fallback, so rewiring to the * Everything themeable is a custom property with a fallback, so rewiring to the
* site tokens is a one-block edit at the top. Typefaces are deliberately not * site tokens is a one-block edit at the top. Typefaces are deliberately not
@ -32,7 +32,7 @@
} }
} }
/* ——— Decade block ——————————————————————————————————————————————— */ /* --- Decade block ----------------------------------------------- */
.ngu-tl__decade { .ngu-tl__decade {
position: relative; position: relative;
@ -66,7 +66,7 @@
color: var(--tl-muted); color: var(--tl-muted);
} }
/* ——— Decade header ——————————————————————————————————————————————— */ /* --- Decade header ----------------------------------------------- */
.ngu-tl__decadeHead { .ngu-tl__decadeHead {
position: relative; position: relative;
@ -138,7 +138,7 @@
color: var(--tl-faint); color: var(--tl-faint);
} }
/* ——— Year node ———————————————————————————————————————————————— */ /* --- Year node ------------------------------------------------ */
.ngu-tl__year { .ngu-tl__year {
position: relative; position: relative;
@ -231,7 +231,7 @@
font-weight: 450; font-weight: 450;
} }
/* ——— Expanded panel ——————————————————————————————————————————— */ /* --- Expanded panel ------------------------------------------- */
.ngu-tl__panel { .ngu-tl__panel {
padding: 0.25rem 0 1.5rem var(--tl-gutter); padding: 0.25rem 0 1.5rem var(--tl-gutter);
@ -286,7 +286,7 @@
gap: 0.125rem; gap: 0.125rem;
} }
/* ——— Entry ————————————————————————————————————————————————————— */ /* --- Entry ----------------------------------------------------- */
.ngu-tl__entry { .ngu-tl__entry {
display: grid; display: grid;
@ -371,7 +371,7 @@ a.ngu-tl__entry:hover .ngu-tl__entryTitle {
box-shadow: inset 0 0 0 1.5px var(--tl-faint); box-shadow: inset 0 0 0 1.5px var(--tl-faint);
} }
/* ——— Featured entries ————————————————————————————————————————— */ /* --- Featured entries ----------------------------------------- */
.ngu-tl__featured { .ngu-tl__featured {
display: flex; display: flex;
@ -403,7 +403,7 @@ a.ngu-tl__entry--featured:hover {
background: color-mix(in srgb, var(--tl-accent) 18%, transparent); background: color-mix(in srgb, var(--tl-accent) 18%, transparent);
} }
/* ——— Empty state ——————————————————————————————————————————————— */ /* --- Empty state ----------------------------------------------- */
.ngu-tl__empty { .ngu-tl__empty {
padding: 0.5rem 0 1.25rem var(--tl-gutter); padding: 0.5rem 0 1.25rem var(--tl-gutter);
@ -420,7 +420,7 @@ a.ngu-tl__entry--featured:hover {
} }
} }
/* ——— Toolbar + utilities ————————————————————————————————————— */ /* --- Toolbar + utilities ------------------------------------- */
.ngu-tl__toolbar { .ngu-tl__toolbar {
display: flex; display: flex;
@ -468,7 +468,7 @@ a.ngu-tl__entry--featured:hover {
border: 0; border: 0;
} }
/* ——— Upcoming block —————————————————————————————————————————— /* --- Upcoming block ------------------------------------------
Opens upward: the toggle is first in the DOM, column-reverse puts the Opens upward: the toggle is first in the DOM, column-reverse puts the
list above it. Faded because none of it has happened yet. */ list above it. Faded because none of it has happened yet. */
@ -556,7 +556,7 @@ a.ngu-tl__entry--featured:hover {
} }
} }
/* ——— Event / org / award logo ————————————————————————————————— */ /* --- Event / org / award logo --------------------------------- */
.ngu-tl__logo { .ngu-tl__logo {
display: inline-block; display: inline-block;
@ -574,7 +574,7 @@ a.ngu-tl__entry--featured:hover {
vertical-align: -0.3125rem; vertical-align: -0.3125rem;
} }
/* ——— People roster ——————————————————————————————————————————— */ /* --- People roster ------------------------------------------- */
.ngu-tl__entryWrap { .ngu-tl__entryWrap {
display: block; display: block;
@ -643,7 +643,7 @@ a.ngu-tl__entry--featured:hover {
color: var(--tl-faint); color: var(--tl-faint);
} }
/* ——— Kind markers, continued ————————————————————————————————— */ /* --- Kind markers, continued --------------------------------- */
.ngu-tl__kind--organization { .ngu-tl__kind--organization {
border-radius: 2px; border-radius: 2px;

View file

@ -3,8 +3,8 @@
EventCalendar on the front page: every scope and every type, all EventCalendar on the front page: every scope and every type, all
four visitor filters, starting on this month. The same component four visitor filters, starting on this month. The same component
can go on any page with a narrower filter — a region's page would can go on any page with a narrower filter, a region's page would
pass host, a classes page would pass type — and this file only pass host, a classes page would pass type, and this file only
adds the front page's heading around it. adds the front page's heading around it.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */

View file

@ -6,11 +6,11 @@
under the cards with a dot per entry, and a year label wherever under the cards with a dot per entry, and a year label wherever
the year changes. The last card goes to the full history. the year changes. The last card goes to the full history.
Featured is the admin's call — timeline_entries.is_featured, Featured is the admin's call, timeline_entries.is_featured,
"shown large" on the history page. Nothing else is filtered "shown large" on the history page. Nothing else is filtered
here; /history has already decided what's public. here; /history has already decided what's public.
Scrolling is native — touch, trackpad, shift-wheel — with Scrolling is native, touch, trackpad, shift-wheel, with
scroll-snap so it settles on a card. A mouse can also drag it, and scroll-snap so it settles on a card. A mouse can also drag it, and
the arrow buttons step one card. A drag that moved more than a few the arrow buttons step one card. A drag that moved more than a few
pixels swallows the click it ends in, so letting go over a card pixels swallows the click it ends in, so letting go over a card
@ -170,7 +170,7 @@ export default function FeaturedTimelineRail({ id, title, blurb }: RailProps) {
const year = (item: TimelineItem) => item.date.slice(0, 4) const year = (item: TimelineItem) => item.date.slice(0, 4)
/* "June 2014", "2014", "12 June 2014" — only as much as precision /* "June 2014", "2014", "12 June 2014", only as much as precision
says is true. */ says is true. */
function dateLabel(item: TimelineItem): string { function dateLabel(item: TimelineItem): string {
const [y, m, d] = item.date.split('-') const [y, m, d] = item.date.split('-')

View file

@ -5,7 +5,7 @@
The API picks the event (pinned in the admin, or the next one that The API picks the event (pinned in the admin, or the next one that
hasn't ended); this works out the moment to count to. hasn't ended); this works out the moment to count to.
For a one-off event that's local midnight on starts_on — dates For a one-off event that's local midnight on starts_on, dates
here are calendar dates with no time attached. For a series it's here are calendar dates with no time attached. For a series it's
the next meeting, at the series' start time when it has one, so a the next meeting, at the series' start time when it has one, so a
weekly class counts down to Tuesday 7pm rather than to a start weekly class counts down to Tuesday 7pm rather than to a start

View file

@ -1,5 +1,5 @@
/* ═══════════════════════════════════════════════════════════════ /* ═══════════════════════════════════════════════════════════════
PATHFINDER — "Find your way in" PATHFINDER: "Find your way in"
The connect section as a question rather than a wall of forms: The connect section as a question rather than a wall of forms:
pick what you're here for, and that path's actions arrive. Paths pick what you're here for, and that path's actions arrive. Paths

View file

@ -6,10 +6,6 @@
"module": "ESNext", "module": "ESNext",
"skipLibCheck": true, "skipLibCheck": true,
"moduleResolution": "bundler", "moduleResolution": "bundler",
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
},
"allowImportingTsExtensions": true, "allowImportingTsExtensions": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,

View file

@ -1,7 +1,6 @@
import { defineConfig, type HtmlTagDescriptor, type Plugin } from 'vite' import { defineConfig, type HtmlTagDescriptor, type Plugin } from 'vite'
import react from '@vitejs/plugin-react' import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite' import tailwindcss from '@tailwindcss/vite'
import path from 'node:path'
import siteConfiguration from './site.json' import siteConfiguration from './site.json'
@ -12,11 +11,6 @@ export default defineConfig({
tailwindcss(), tailwindcss(),
siteConfigurationPlugin(siteConfiguration), siteConfigurationPlugin(siteConfiguration),
], ],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
server: { server: {
proxy: { proxy: {
"/api": { "/api": {