From 29202f2eb1b3e8cec9aa477292fc1b5d3872362c Mon Sep 17 00:00:00 2001 From: Zaldimmar Date: Sun, 27 Sep 2026 20:56:16 -0500 Subject: [PATCH 01/14] Group the admin nav into Data, Pages, Forms, Tools and Panel The header now has one menu per group: its name opens the first item, and hovering or tabbing into it drops down the rest. The strip under the header lists the open group's items, which is also the way around on a touch screen. The admin home shows the same groups as card blocks, from the same list in adminNav.ts. Data holds the record types, Pages the front page, timeline, blog posts and the Community blog section, Tools the media library and QR codes. Docs and comments name the new menu paths. Co-Authored-By: Claude Opus 5.5 --- docs/updating-data-in-code.md | 14 +-- server/src/seed-showcase.js | 2 +- src/pages/Community.tsx | 2 +- src/pages/admin/AdminHome.tsx | 36 +++--- src/pages/admin/AdminLayout.tsx | 69 ++++++++--- src/pages/admin/adminNav.ts | 169 +++++++++++++++------------ src/pages/sections/CommunityBlog.tsx | 2 +- 7 files changed, 173 insertions(+), 121 deletions(-) diff --git a/docs/updating-data-in-code.md b/docs/updating-data-in-code.md index 8c09e41..e876f9f 100644 --- a/docs/updating-data-in-code.md +++ b/docs/updating-data-in-code.md @@ -28,12 +28,12 @@ what a dropdown in the admin editor says. | If it's… | It lives in… | Change it by… | | ------------------------------------------------------------ | ---------------- | ------------------------------------ | | A record: an event, organization, person, team, award, timeline entry | the database | editing it in the admin | -| The front page's words, photos, bands, stats and paths | the database | Admin → Front page | -| Blog posts, and the Community page's blog section (headings, pins, feeds) | the database | Admin → Blog | +| The front page's words, photos, bands, stats and paths | the database | Admin → Pages → Front page | +| Blog posts, and the Community page's blog section (headings, pins, feeds) | the database | Admin → Pages → Blog posts, and Community blog section | | The **label** a dropdown shows in the admin | code | [one file](#renaming-what-a-dropdown-shows) | | The **list of allowed values** behind a fixed dropdown | database CHECK + code | [a migration and three files](#adding-removing-or-renaming-a-stored-value) | | Navigation, page section titles, colours, the site banner, history decades, the map grid | code | [the file named below](#other-content-that-lives-in-code) | -| Uploaded images | disk + the `media` table | Admin → Media, or any image field. See `docs/media-uploads.md` | +| Uploaded images | disk + the `media` table | Admin → Tools → Media, or any image field. See `docs/media-uploads.md` | The rule of thumb from `CLAUDE.md`: data belongs in the database, presentation belongs in code. A dropdown's *values* are data the @@ -184,7 +184,7 @@ also in `admin-schema.js` and a CHECK): | Front page → Feature | none, livestream, video | **yes** | `HeroStage.tsx` | | Front page → Sections → Section | countdown, retreats, calendar, stats, timeline, connect, featured | **yes**, `FRONT_PAGE_SECTIONS` | `SECTIONS` in `src/pages/Home.tsx`; see [below](#front-page-section-names) | | Front page → Stats → Number Source | manual, years_since, regions, … | **yes**, `STAT_SOURCES` | `STAT_QUERIES` in `server/src/routes/home.js`; see [below](#front-page-stat-sources) | -| Front page → Featured cards → Card type (Blog → Community section → Pinned community posts offers link and video only) | record, link, video | **yes**, `FEATURED_KINDS` | `FeaturedCards.tsx` (how each kind draws), `loadFeaturedCards` in `server/src/shape.js` | +| Front page → Featured cards → Card type (Community blog section → Pinned community posts offers link and video only) | record, link, video | **yes**, `FEATURED_KINDS` | `FeaturedCards.tsx` (how each kind draws), `loadFeaturedCards` in `server/src/shape.js` | | Front page → Featured cards → Record type | event, organization, person, team, award | no | `FEATURED_REFS` in `server/src/shape.js` (what each fills the card with); the triggers in `030_featured_cards.sql` | | Every list → Published / Listed / Featured filter | 1, 0 | **yes** | n/a | @@ -200,7 +200,7 @@ code): | Event → Scope (+ list filter); Front page → Countdown → Only this scope | `event_scopes` | the `event_scopes` table (migration only) | | Event hosts → Organization; affiliations; team and award "Organization" / "Awarded by"; person → Home organization | `organizations` | organizations, labelled by name | | Event hosts / event people / team members / timeline people → Person | `people` | people | -| Blog → Community section → Pinned posts → Post | `blog_posts` | blog posts, newest first | +| Community blog section → Pinned posts → Post | `blog_posts` | blog posts, newest first | | Timeline → Record; Featured cards → Record | `record_refs` | every event, organization, award, person and team, narrowed by the type picked beside it | | Affiliations → Team | `teams` | teams, filtered to the chosen organization | | Person awards → Award | `awards` | awards, labelled "Award (Organization)" | @@ -216,7 +216,7 @@ each is changed in a different place: | What you see | Where it's set | | --- | --- | -| **The heading on the page** ("National Retreats", "What's on") | **Admin → Front page → Page sections → Heading.** Blank uses the default below. | +| **The heading on the page** ("National Retreats", "What's on") | **Admin → Pages → Front page → Page sections → Heading.** Blank uses the default below. | | The default heading when that field is blank | `SECTIONS` in `src/pages/Home.tsx`, the `title` of each entry | | **The name in the admin's Section dropdown** ("Events Carousel (National Retreats)") | `FRONT_PAGE_SECTIONS` in `src/lib/adminSchema.ts` | | The subnav links under the header ("#Retreats", "#Calendar") | `PAGE_SECTIONS["/"]` in `src/navConfig.ts` | @@ -271,7 +271,7 @@ The numbers band's "Number Source" dropdown works the same way: | Section titles, blurbs and colours on Retreats, Community, Leadership, Resources, Feedback, Privacy, Terms | the page file in `src/pages/` | the `SECTIONS` array at the top. A section's `id` must match its subnav `hash`. | | Site-wide announcement banner | `src/data/bannerConfig.ts` | `enabled: false` hides it. Bump `id` when the message changes, so people who dismissed the old one see the new one. | | History page decade headers | `src/data/historyDecades.ts` | Title, tagline and blurb per decade. | -| Chapter map tiles and area names | `src/data/mapGrid.ts` | `AREAS` (tile positions) and `AREA_NAMES`. Which region paints which tile is in the database (Admin → Organizations → a region → Map areas). | +| Chapter map tiles and area names | `src/data/mapGrid.ts` | `AREAS` (tile positions) and `AREA_NAMES`. Which region paints which tile is in the database (Admin → Data → Organizations → a region → Map areas). | | Feedback form types | `src/data/feedbackTypes.ts` **and** `TYPES` in `server/src/routes/feedback.js` | Keep the ids identical in both; the server stores unknown ids as `general`. Labels and hints are client-only. | | Event type labels and plurals (public site) | `src/lib/eventTypes.ts` | Also the order of the type filter chips. | | Event and person role labels (public site) | `ROLE_LABEL` in `src/pages/EventDetail.tsx` and `src/pages/PersonDetail.tsx` | | diff --git a/server/src/seed-showcase.js b/server/src/seed-showcase.js index 616fc47..747f7e4 100644 --- a/server/src/seed-showcase.js +++ b/server/src/seed-showcase.js @@ -37,7 +37,7 @@ Run without it again to take them back out. Images point at /uploads/showcase.jpg. Upload any photo in - Admin → Media and copy it to that name in the uploads directory, + Admin → Tools → Media and copy it to that name in the uploads directory, or leave it missing to check how each page copes without one. A database under /var/lib/ngu (where the deployed service keeps diff --git a/src/pages/Community.tsx b/src/pages/Community.tsx index fd0e449..f516c1a 100644 --- a/src/pages/Community.tsx +++ b/src/pages/Community.tsx @@ -13,7 +13,7 @@ import { useCommunityBlog } from "../lib/useBlog.ts"; map is filtered to chapters; the vertical list is filtered to regions. Same rows, same endpoint, different shape on the page. - The blog's heading and blurb are the admin's (Blog → Community + The blog's heading and blurb are the admin's (Pages → Community blog section), so that one entry is built here from the same cached request CommunityBlog makes for its posts. ═══════════════════════════════════════════════════════════════ */ diff --git a/src/pages/admin/AdminHome.tsx b/src/pages/admin/AdminHome.tsx index c1312ce..d21c1f6 100644 --- a/src/pages/admin/AdminHome.tsx +++ b/src/pages/admin/AdminHome.tsx @@ -7,10 +7,8 @@ The cards come from adminNav.ts, the same list the CMS header reads, so a new entity shows up here the moment it's registered. - Forms sit in their own block below: they're submissions coming - in rather than content going out, and there'll be more of them - than the feedback queue eventually. Tools come next, and the - Panel block below that only exists for superadmins. + One block per header group, in the same order: Data, Pages, + Forms, Tools, and Panel, which only exists for superadmins. The right-hand panel is deliberately inert. Nothing here fetches, so the landing page can't be slow or half-broken on @@ -22,7 +20,7 @@ import { Link } from "react-router-dom"; import { useAuth } from "../../lib/auth.tsx"; import { SITE_VERSION } from "../../lib/version.ts"; import { ROLE_LABELS, isSuper } from "../../lib/roles.ts"; -import { CMS_NAV, FORMS_NAV, PANEL_NAV, TOOLS_NAV, target } from "./adminNav.ts"; +import { DATA_NAV, FORMS_NAV, PAGES_NAV, PANEL_NAV, TOOLS_NAV, target } from "./adminNav.ts"; /* One card. The title link is stretched over the whole card with `after:absolute`, which makes the card clickable without nesting @@ -98,6 +96,10 @@ function PanelSection({ title, children }) { ); } +/* The header's groups, in its order. Panel is drawn separately + below, since only superadmins get it. */ +const GROUPS = [DATA_NAV, PAGES_NAV, FORMS_NAV, TOOLS_NAV]; + const QUICK_ADD = [ { to: "/admin/events/new", label: "New event" }, { to: "/admin/people/new", label: "New person" }, @@ -117,23 +119,13 @@ export default function AdminHome() {

Pick a section to work in.

-
- {CMS_NAV.map((item) => ( - - ))} -
- - - {FORMS_NAV.children.map((form) => ( - - ))} - - - - {TOOLS_NAV.children.map((tool) => ( - - ))} - + {GROUPS.map((group) => ( + + {group.children.map((item) => ( + + ))} + + ))} {isSuper(user) && ( diff --git a/src/pages/admin/AdminLayout.tsx b/src/pages/admin/AdminLayout.tsx index a3b5d2d..e68b59b 100644 --- a/src/pages/admin/AdminLayout.tsx +++ b/src/pages/admin/AdminLayout.tsx @@ -9,10 +9,14 @@ wordmark names whichever one you're in, and from anywhere but Home it's the way back to Home. - The tab row is drawn everywhere except Home, where the card grid - is the navigation and drawing both would say the same thing - twice. Which tabs appear depends on the signed-in user - (navFor() drops the superadmin-only ones), but that's cosmetics. + The group menus (Data, Pages, Forms, Tools, Panel: adminNav.ts) + are drawn everywhere except Home, where the card grid is the + navigation and drawing both would say the same thing twice. Each + group's name opens its first item and hovering it lists the rest; + the strip under the header lists the open group's items, which is + also the way around on a touch screen. Which groups appear depends + on the signed-in user (navFor() drops the superadmin-only ones), + but that's cosmetics. The route guard and the API are what actually say no. ═══════════════════════════════════════════════════════════════ */ @@ -33,6 +37,52 @@ import { target, } from "./adminNav.ts"; +/* One group in the header. The name opens the group's first item; + hovering it, or tabbing into it, drops down the rest. The menu is + CSS only (group-hover, group-focus-within), so it can't get stuck + open, and a keyboard reaches every item by tabbing on from the + name. A group of one has nothing to drop down. */ +function GroupMenu({ item, lit, pathname }) { + const children = item.children ?? []; + const link = lit + ? "font-semibold text-[#138ba0]" + : "text-[#4a6b72] transition-colors hover:text-[#138ba0]"; + + return ( +
+ + {item.label} + {children.length > 1 && ( + + )} + + + {children.length > 1 && ( +
+
    + {children.map((child) => ( +
  • + + {child.label} + +
  • + ))} +
+
+ )} +
+ ); +} + export default function AdminLayout() { const { user, logout } = useAuth(); const navigate = useNavigate(); @@ -109,16 +159,7 @@ export default function AdminLayout() { className="h-4 w-px bg-[#4a6b72]/25" /> )} - - {item.label} - + ))} diff --git a/src/pages/admin/adminNav.ts b/src/pages/admin/adminNav.ts index d300267..40f7dc5 100644 --- a/src/pages/admin/adminNav.ts +++ b/src/pages/admin/adminNav.ts @@ -1,11 +1,26 @@ /* ═══════════════════════════════════════════════════════════════ ADMIN NAVIGATION: src/pages/admin/adminNav.ts - Lifted out of AdminLayout because two things read it now: the - header tabs and the card grid on the home page. Adding an entity - stays one entry here plus a descriptor; there's still no second - list to keep in step, it just isn't inside the layout file - any more. + One list, read by two things: the header (a menu per group, its + items on hover or focus, and the open group's items in the strip + below) and the admin home page (a block of cards per group). + Adding an entity stays one entry here plus a descriptor; there's + no second list to keep in step. + + Five groups, each a menu in the header and a block on the home + page: + + Data the records: events, organizations, teams, awards, people + Pages what edits a page rather than a record type: the front + page, the history timeline, the blog and its Community + section + Forms what the public site has sent us + Tools pages that make something: the media library, QR codes + Panel accounts and the server (superadmins only) + + Clicking a group's name opens its first item. That's also the + touch path, where hover doesn't exist: the strip under the header + lists the rest of the open group. `blurb` is only read by the home cards. The header ignores it. @@ -31,73 +46,72 @@ export const AREA_TITLES = { panel: "NGU Admin Panel", }; -/* The CMS tabs. Teams and Awards live under Organizations because - that's where they belong conceptually (a team is part of an org, - an award is given by one), even though each is its own table and - its own page. */ -export const CMS_NAV = [ - { - to: "/admin/events", - label: "Events", - blurb: "Retreats, conferences and gatherings, with their sections and rosters.", - }, - { - to: "/admin/organizations", - label: "Organizations", - blurb: "Regions, chapters and partners, plus the teams and awards they own.", - children: [ - { to: "/admin/organizations", label: "All organizations" }, - { to: "/admin/teams", label: "Teams" }, - { to: "/admin/awards", label: "Awards" }, - ], - }, - { - to: "/admin/people", - label: "People", - blurb: "Bios, contact details, affiliations and awards received.", - }, - // Its own tab rather than a child of anything: a timeline entry can - // point at an event, an organization, an award, a person or a team, - // so filing it under one of them would be arbitrary. - { - to: "/admin/timeline", - label: "Timeline", - blurb: "What the history page shows, and the order it shows it in.", - }, - // One record, not a list: the tab opens it directly. - { - to: "/admin/front_page", - label: "Front page", - blurb: "The hero, its photos or livestream, and which bands the home page draws.", - }, - // Posts, and the Community page section that lists them. Two - // entities, one tab, like Organizations with Teams and Awards. - { - to: "/admin/blog_posts", - label: "Blog", - blurb: "Posts of our own, and the Community page's blog section.", - children: [ - { to: "/admin/blog_posts", label: "Posts" }, - { to: "/admin/community_page", label: "Community section" }, - ], - }, - // Not an entity: the uploaded-image library every image field - // picks from. Its own page, AdminMedia.tsx. - { - to: "/admin/media", - label: "Media", - blurb: "Uploaded images: logos, photos and backgrounds, ready to reuse.", - }, -]; +export const DATA_NAV = { + label: "Data", + blurb: "The records the site is built from.", + children: [ + { + to: "/admin/events", + label: "Events", + blurb: "Retreats, conferences and gatherings, with their sections and rosters.", + }, + { + to: "/admin/organizations", + label: "Organizations", + blurb: "The national organization, regions, chapters and partners.", + }, + { + to: "/admin/teams", + label: "Teams", + blurb: "Boards, committees and leadership teams within an organization.", + }, + { + to: "/admin/awards", + label: "Awards", + blurb: "Awards an organization gives. Who received one is edited on the person.", + }, + { + to: "/admin/people", + label: "People", + blurb: "Bios, contact details, affiliations and awards received.", + }, + ], +}; -/* Forms are submissions coming in rather than content going out, so - they get their own group in the header and their own block on the - home page. A group with no `to` of its own opens its first child, - so clicking the word Forms goes somewhere rather than nowhere. */ +export const PAGES_NAV = { + label: "Pages", + blurb: "What a page shows and in what order.", + children: [ + // One record, not a list: the item opens it directly. + { + to: "/admin/front_page", + label: "Front page", + blurb: "The hero, its photos or livestream, and which bands the home page draws.", + }, + // A timeline entry can point at an event, an organization, an + // award, a person or a team, so it isn't filed under any of them. + { + to: "/admin/timeline", + label: "Timeline", + blurb: "What the history page shows, and the order it shows it in.", + }, + { + to: "/admin/blog_posts", + label: "Blog posts", + blurb: "Posts of our own, each at /blog/…", + }, + { + to: "/admin/community_page", + label: "Community blog section", + blurb: "The Community page's blog: headings, pinned posts and feeds.", + }, + ], +}; + +/* Submissions coming in rather than content going out. */ export const FORMS_NAV = { label: "Forms", blurb: "Whatever the public site has sent us.", - separated: true, children: [ { to: "/admin/feedback", @@ -107,13 +121,17 @@ export const FORMS_NAV = { ], }; -/* Tools are pages that make something rather than edit a record. - They live on the public site, so they're on the home page only: - a header tab would leave the admin area. */ +/* Pages that make something rather than edit a record. The QR page + lives on the public site, so opening it leaves the admin. */ export const TOOLS_NAV = { label: "Tools", blurb: "Handy pages for making things.", children: [ + { + to: "/admin/media", + label: "Media", + blurb: "Uploaded images: logos, photos and backgrounds, ready to reuse.", + }, { to: "/qr", label: "QR code generator", @@ -122,8 +140,8 @@ export const TOOLS_NAV = { ], }; -/* Accounts and server state, not content, which is why it sits - outside the CMS rather than as another tab within it. */ +/* Accounts and server state, not content, which is why it's its + own area rather than a group of CMS pages. */ export const PANEL_NAV = { to: ADMIN_PANEL, label: "Panel", @@ -132,18 +150,19 @@ export const PANEL_NAV = { superOnly: true, }; -export const NAV: any[] = [...CMS_NAV, FORMS_NAV, PANEL_NAV]; +export const NAV: any[] = [DATA_NAV, PAGES_NAV, FORMS_NAV, TOOLS_NAV, PANEL_NAV]; /* What this user may see. Call it with the user from useAuth. */ export function navFor(user) { return NAV.filter((item) => !item.superOnly || isSuper(user)); } -/* A tab owns its own page and everything below it, so editing +/* An item owns its own page and everything below it, so editing /admin/teams/ngu-board keeps Teams lit. */ export const matches = (pathname, to) => Boolean(to) && (pathname === to || pathname.startsWith(`${to}/`)); +/* Where a group's name goes: its own page, else its first item. */ export const target = (item) => item.to ?? item.children?.[0]?.to; export function areaFor(pathname) { diff --git a/src/pages/sections/CommunityBlog.tsx b/src/pages/sections/CommunityBlog.tsx index bb0916c..dacf3cf 100644 --- a/src/pages/sections/CommunityBlog.tsx +++ b/src/pages/sections/CommunityBlog.tsx @@ -1,7 +1,7 @@ /* ═══════════════════════════════════════════════════════════════ COMMUNITY BLOG - The Community page's blog section (Admin → Blog → Community + The Community page's blog section (Admin → Pages → Community blog section). Two halves, each pinned first and then newest, as routes/blog.js decides: From d6477b6d306a3a4d6286015e9b8ded880e1c7da2 Mon Sep 17 00:00:00 2001 From: Zaldimmar Date: Sun, 27 Sep 2026 20:58:37 -0500 Subject: [PATCH 02/14] Add a featured event as a hero option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Front page → Feature gains "Featured event" (migration 033): the event's card beside the headline, with its photo or colour, dates or schedule, place, tagline, action buttons and a link to its page, under a "Featured event" badge, over either backdrop. Front page → Featured event pins one. Blank uses the countdown's event, and a pinned event that's over or unpublished falls back to it, so the hero and the countdown never disagree. Co-Authored-By: Claude Opus 5.5 --- docs/updating-data-in-code.md | 4 +- server/src/admin-schema.js | 3 +- server/src/migrations/033_hero_event.sql | 34 ++++++++ server/src/routes/home.js | 32 +++++++- src/lib/adminSchema.ts | 12 ++- src/lib/useFrontPage.ts | 13 ++- src/pages/sections/home/HeroStage.tsx | 100 +++++++++++++++++++++-- 7 files changed, 187 insertions(+), 11 deletions(-) create mode 100644 server/src/migrations/033_hero_event.sql diff --git a/docs/updating-data-in-code.md b/docs/updating-data-in-code.md index e876f9f..f96f5b6 100644 --- a/docs/updating-data-in-code.md +++ b/docs/updating-data-in-code.md @@ -181,7 +181,7 @@ also in `admin-schema.js` and a CHECK): | Timeline → Precision (and on events/orgs) | year, month, day | no | the history page's grouping | | Front page → Countdown → Only this type | retreat, class, workshop, meeting, other | **yes** | `server/src/routes/home.js` (picks the countdown event). The same values as Events → Type, so adding a type widens both CHECKs. | | Front page → Background | brand, photos | **yes** | `HeroStage.tsx` | -| Front page → Feature | none, livestream, video | **yes** | `HeroStage.tsx` | +| Front page → Feature | none, livestream, video, event | **yes** | `HeroStage.tsx`; the event is picked in `server/src/routes/home.js` | | Front page → Sections → Section | countdown, retreats, calendar, stats, timeline, connect, featured | **yes**, `FRONT_PAGE_SECTIONS` | `SECTIONS` in `src/pages/Home.tsx`; see [below](#front-page-section-names) | | Front page → Stats → Number Source | manual, years_since, regions, … | **yes**, `STAT_SOURCES` | `STAT_QUERIES` in `server/src/routes/home.js`; see [below](#front-page-stat-sources) | | Front page → Featured cards → Card type (Community blog section → Pinned community posts offers link and video only) | record, link, video | **yes**, `FEATURED_KINDS` | `FeaturedCards.tsx` (how each kind draws), `loadFeaturedCards` in `server/src/shape.js` | @@ -204,7 +204,7 @@ code): | Timeline → Record; Featured cards → Record | `record_refs` | every event, organization, award, person and team, narrowed by the type picked beside it | | Affiliations → Team | `teams` | teams, filtered to the chosen organization | | Person awards → Award | `awards` | awards, labelled "Award (Organization)" | -| Person awards → Presented at; Front page → Count down to | `events` | events | +| Person awards → Presented at; Front page → Count down to; Front page → Featured event | `events` | events | | Timeline → Record | `timeline_refs` | all five kinds, filtered by "Points at" | --- diff --git a/server/src/admin-schema.js b/server/src/admin-schema.js index fafa531..e8a5ac1 100644 --- a/server/src/admin-schema.js +++ b/server/src/admin-schema.js @@ -710,7 +710,8 @@ const frontPage = { columns: [ enumeration("hero_backdrop", ["brand", "photos"]), - enumeration("hero_feature", ["none", "livestream", "video"]), + enumeration("hero_feature", ["none", "livestream", "video", "event"]), + text("hero_event_id"), text("eyebrow"), text("headline"), text("subhead"), diff --git a/server/src/migrations/033_hero_event.sql b/server/src/migrations/033_hero_event.sql new file mode 100644 index 0000000..ae50122 --- /dev/null +++ b/server/src/migrations/033_hero_event.sql @@ -0,0 +1,34 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 033 HERO: A FEATURED EVENT +-- +-- A fourth hero feature, 'event': an event's card beside the +-- headline, over whichever backdrop is chosen. +-- +-- hero_event_id the event to feature. Null means the event the +-- countdown shows (its pin, or the next one that +-- hasn't ended, narrowed by its scope and type), +-- so the hero and the countdown can't disagree. +-- A pinned event that is over, unpublished or +-- deleted falls back the same way; ON DELETE SET +-- NULL does the last one. +-- +-- hero_feature's CHECK gains 'event'. A CHECK can't be altered in +-- place, so the column is replaced the way 025 did it: a new column +-- with the new CHECK, the values copied across, the old one dropped +-- and the new one renamed into its place. Nothing else names the +-- column, so front_page itself needn't be rebuilt. +-- +-- PRAGMA user_version; -- reads 32 before this file +-- ═══════════════════════════════════════════════════════════════ + +ALTER TABLE front_page ADD COLUMN hero_feature_new TEXT NOT NULL DEFAULT 'none' + CHECK (hero_feature_new IN ('none', 'livestream', 'video', 'event')); + +UPDATE front_page SET hero_feature_new = hero_feature; + +ALTER TABLE front_page DROP COLUMN hero_feature; + +ALTER TABLE front_page RENAME COLUMN hero_feature_new TO hero_feature; + +ALTER TABLE front_page ADD COLUMN hero_event_id TEXT + REFERENCES events (id) ON DELETE SET NULL; diff --git a/server/src/routes/home.js b/server/src/routes/home.js index d09a465..bd5824d 100644 --- a/server/src/routes/home.js +++ b/server/src/routes/home.js @@ -34,6 +34,12 @@ means any. They don't apply to a pinned event: the admin chose that one by name. + ── Hero event ── + With the 'event' feature, the hero draws the pinned hero_event_id + if it's still published and not over, else the countdown's event + (above), so the two never disagree. Its action links ride along + for the card's buttons. + ── Featured ── The featured band's cards, record cards filled in from their records (loadFeaturedCards in shape.js, which the Community @@ -42,7 +48,7 @@ import { Hono } from "hono"; -import { asBool, loadFeaturedCards, shapeSeries } from "../shape.js"; +import { asBool, loadFeaturedCards, loadLinks, shapeSeries, splitLinks } from "../shape.js"; const home = new Hono(); @@ -84,6 +90,20 @@ function statValue(db, row) { return sql ? String(db.prepare(sql).get().n) : null; } +/* The countdown's fields plus what the hero's event card also draws: + its tagline, place, card background and buttons. */ +function shapeHeroEvent(db, row) { + if (!row) return null; + const { actions } = splitLinks(loadLinks(db, "event", [row.id]).get(row.id) ?? []); + return { + ...shapeCountdown(row), + tagline: row.tagline, + card_image: row.card_image, + org_logo: row.effective_org_logo, + links: actions, + }; +} + function shapeCountdown(row) { if (!row) return null; return { @@ -179,6 +199,15 @@ home.get("/front-page", (c) => { ) .get(...params); + const heroEvent = + page.hero_feature === "event" + ? (page.hero_event_id + ? db + .prepare(`SELECT * FROM v_events WHERE id = ? AND ${notOver}`) + .get(page.hero_event_id) + : null) ?? next + : null; + return json(c, { front_page: { hero: { @@ -201,6 +230,7 @@ home.get("/front-page", (c) => { video: page.video_url ? { url: page.video_url, title: page.video_title } : null, + event: shapeHeroEvent(db, heroEvent), }, sections, stats, diff --git a/src/lib/adminSchema.ts b/src/lib/adminSchema.ts index f035adf..fe3d299 100644 --- a/src/lib/adminSchema.ts +++ b/src/lib/adminSchema.ts @@ -1218,6 +1218,7 @@ const frontPage = { ["none", "Nothing: No additional overlay"], ["livestream", "Livestream: the stream, with a LIVE badge"], ["video", "Featured video: click to play"], + ["event", "Featured event: an event's card"], ], blankLabel: "Default: nothing", help: "Switch to Livestream when you go live, and back when you're done", @@ -1232,7 +1233,7 @@ const frontPage = { ], }, { - legend: "Photos, livestream and video", + legend: "Photos, livestream, video and event", fields: [ { path: "slide_seconds", @@ -1256,6 +1257,15 @@ const frontPage = { "/front-page/ or a link ending in .mp4 or .webm", }, { path: "video_title", label: "Video title", full: true, help: "Shown after \"Featured video\" above the headline" }, + { + path: "hero_event_id", + label: "Featured event", + widget: "select", + optionsFrom: "events", + blankLabel: "Default: the countdown's event", + full: true, + help: "For the Featured event feature. A pinned event that's over falls back to the countdown's", + }, ], }, { diff --git a/src/lib/useFrontPage.ts b/src/lib/useFrontPage.ts index a1bba44..094137d 100644 --- a/src/lib/useFrontPage.ts +++ b/src/lib/useFrontPage.ts @@ -12,12 +12,13 @@ import { useRecord, type Resource } from './useRecord.ts' import type { EventSeries } from './eventSeries.ts' +import type { Link } from './useContent.ts' /** What fills the hero's background. */ export type HeroBackdrop = 'brand' | 'photos' /** What sits beside the words, over the backdrop. */ -export type HeroFeature = 'none' | 'livestream' | 'video' +export type HeroFeature = 'none' | 'livestream' | 'video' | 'event' /** The CHECK list on front_page_sections.section. */ export type FrontPageSectionKey = @@ -51,6 +52,8 @@ export type Hero = { livestream: { url: string; title?: string | null } | null /** A link to embed or a video file; see videoSource in embeds.ts. */ video: { url: string; title?: string | null } | null + /** With the 'event' feature: the pinned event, else the countdown's. */ + event: HeroEvent | null } export type FrontPageSection = { @@ -105,6 +108,14 @@ export type FeaturedCard = { image: { file: string; kind: string } | null } +/** The countdown's event plus what the hero's event card draws. */ +export type HeroEvent = CountdownEvent & { + tagline?: string | null + card_image?: string | null + org_logo?: string | null + links: Link[] +} + export type FrontPage = { hero: Hero sections: FrontPageSection[] diff --git a/src/pages/sections/home/HeroStage.tsx b/src/pages/sections/home/HeroStage.tsx index 172f585..ff9467b 100644 --- a/src/pages/sections/home/HeroStage.tsx +++ b/src/pages/sections/home/HeroStage.tsx @@ -20,9 +20,13 @@ video a featured video under a "Featured video" badge. Never autoplays: an embed waits for play, a file shows the browser's player + event an event's card under a "Featured event" badge: + its photo, dates, place and buttons. The API picks + the event (pinned, else the countdown's) A choice with nothing to show falls back: photos with no photos - to brand, a feature with no link set to none. A link that can't + to brand, a feature with no link set (or no event to show) to + none. A link that can't be framed still gets a "Watch live" or "Watch the video" button, so switching a feature on is never a no-op. @@ -33,11 +37,16 @@ import { useEffect, useState, type CSSProperties } from 'react' +import { Link } from 'react-router-dom' + import HomeLink from './HomeLink.tsx' import DoveMark from '../../../components/DoveMark.tsx' +import PlatformIcon from '../../../components/PlatformIcon.tsx' import { livestreamEmbedUrl, videoSource, type VideoSource } from '../../../lib/embeds.ts' -import { heroPhoto } from '../../../lib/media.ts' -import type { Hero, HeroBackdrop, HeroFeature, HeroSlide } from '../../../lib/useFrontPage.ts' +import { eventBackground, heroPhoto } from '../../../lib/media.ts' +import { eventHref } from '../../../lib/hrefs.ts' +import { seriesLabel } from '../../../lib/eventSeries.ts' +import type { Hero, HeroBackdrop, HeroEvent, HeroFeature, HeroSlide } from '../../../lib/useFrontPage.ts' const DEEP = '#04262e' @@ -54,9 +63,11 @@ export default function HeroStage({ hero }: { hero: Hero | null }) { ? 'livestream' : hero?.feature === 'video' && hero.video ? 'video' - : 'none' + : hero?.feature === 'event' && hero.event + ? 'event' + : 'none' - // Both features share a layout: words left, player right. + // Every feature shares a layout: words left, feature right. const beside = feature !== 'none' return ( @@ -87,6 +98,12 @@ export default function HeroStage({ hero }: { hero: Hero | null }) { )} + + {feature === 'event' && hero?.event && ( +
+ +
+ )} ) @@ -111,6 +128,11 @@ function Words({ hero, feature }: { hero: Hero; feature: HeroFeature }) { )}

+ ) : feature === 'event' ? ( +

+ + Featured event +

) : feature === 'video' ? (

@@ -413,3 +435,71 @@ function VideoFrame({ ) } + +/* ── Featured event ──────────────────────────────────────────── */ + +/* The event's own card for the hero: its background photo (or its + colour), then what, when and where, then its buttons and a way + to its page. The first action link is the filled button, since + it's usually Register. */ +function EventPanel({ event }: { event: HeroEvent }) { + const color = event.color || '#138ba0' + const photo = eventBackground(event.card_image) + const when = seriesLabel(event.series, event.starts_on) ?? event.date_label + const where = event.is_online && !event.location_label ? 'Online' : event.location_label + + return ( +

+ {photo ? ( + + ) : ( + + ) +} From 71a470b66f61192c8d57c92fe840603a46501d16 Mon Sep 17 00:00:00 2001 From: Zaldimmar Date: Sun, 27 Sep 2026 21:12:47 -0500 Subject: [PATCH 03/14] Add a Schedule content block with day tabs A schedule block's entries (migration 034) each have a day, time, title, detail, location, person and link, and fold out for a longer description, the person's photo and page, a graphic and a Google map of a place or address. Entries sit in one tab per day, in the order entered; the tab for today's weekday opens first, and a one-day schedule draws no tabs. In the editor, the entry fields show only under a schedule block: repeater `when` can now look at the parent row (scope "parent"), and a field's label can depend on the row. The block preview names an entry's person. The showcase retreat and post each have a schedule. Co-Authored-By: Claude Opus 5.5 --- docs/updating-data-in-code.md | 2 +- server/src/admin-schema.js | 9 + server/src/migrations/034_schedule_block.sql | 99 +++++++ server/src/seed-showcase.js | 24 +- server/src/shape.js | 29 +- src/components/ContentBlocks.tsx | 9 + src/components/ScheduleBlock.tsx | 270 +++++++++++++++++++ src/components/admin/fields.tsx | 58 +++- src/lib/adminSchema.ts | 67 ++++- src/lib/useContent.ts | 18 +- 10 files changed, 556 insertions(+), 29 deletions(-) create mode 100644 server/src/migrations/034_schedule_block.sql create mode 100644 src/components/ScheduleBlock.tsx diff --git a/docs/updating-data-in-code.md b/docs/updating-data-in-code.md index f96f5b6..5f1ae6e 100644 --- a/docs/updating-data-in-code.md +++ b/docs/updating-data-in-code.md @@ -175,7 +175,7 @@ also in `admin-schema.js` and a CHECK): | Links → Kind (on organizations, events, people, teams) | action, social, website, email | no | `splitLinks` in `server/src/shape.js` | | Links → Platform | instagram, facebook, discord, youtube, tiktok, x, substack, spotify, linkedin | **yes**, `PLATFORMS` | `PlatformIcon.tsx` draws the icon on the button. **No CHECK and no `enumeration`**: the column is plain text, so adding one is an entry in `PLATFORMS` (`src/lib/platforms.ts`) and its icon in `src/components/PlatformIcon.tsx`, no migration. | | Content blocks → Shown in (slot) | card, body | **yes** | `paragraphs()` in `server/src/shape.js` (card), `ContentBlocks.tsx` (body) | -| Content blocks → Type | heading, subheading, paragraph, list, links, quote, image, divider, video, button, callout | **yes**, `BLOCK_TYPES` (with each type's description) | `ContentBlocks.tsx` (one renderer per type). Which fields each type shows is `when` on the fields in `blocksChild` (`src/lib/adminSchema.ts`). | +| Content blocks → Type | heading, subheading, paragraph, list, links, quote, image, divider, video, button, callout, schedule | **yes**, `BLOCK_TYPES` (with each type's description) | `ContentBlocks.tsx` (one renderer per type). Which fields each type shows is `when` on the fields in `blocksChild` (`src/lib/adminSchema.ts`). | | Timeline → Kind (+ list filter) | milestone, event, organization, award, people | no | `KIND_NAMES` in `src/pages/sections/history/TimelineEntry.tsx` | | Timeline → Points at (+ list filter) | event, organization, award, person, team | no | `refHref` in `src/lib/hrefs.ts` | | Timeline → Precision (and on events/orgs) | year, month, day | no | the history page's grouping | diff --git a/server/src/admin-schema.js b/server/src/admin-schema.js index e8a5ac1..edc53a8 100644 --- a/server/src/admin-schema.js +++ b/server/src/admin-schema.js @@ -179,6 +179,7 @@ const blocksChild = (ownerKind) => ({ "video", "button", "callout", + "schedule", ], { required: true }, ), @@ -198,6 +199,14 @@ const blocksChild = (ownerKind) => ({ text("text", { required: true }), text("detail"), text("url"), + // Schedule entries only (034_schedule_block.sql). + text("day"), + text("time"), + text("location"), + text("person_id"), + text("description"), + text("media"), + text("map"), ], }, ], diff --git a/server/src/migrations/034_schedule_block.sql b/server/src/migrations/034_schedule_block.sql new file mode 100644 index 0000000..0655c1a --- /dev/null +++ b/server/src/migrations/034_schedule_block.sql @@ -0,0 +1,99 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 034 CONTENT BLOCKS: SCHEDULE +-- +-- A 'schedule' block: the block's items are its entries, grouped +-- into one tab per day. Each entry says when, what and where, and +-- folds out for more. The block's own text is an optional intro. +-- +-- content_block_items gains the entry's fields. A list or link-row +-- block leaves them empty: +-- +-- day the tab it sits under, eg. 'Friday'. Tabs follow +-- the order entries are in; blank means one untitled +-- day, and a schedule of one day draws no tabs +-- time '7:00pm', '9:00 to 10:30am': shown as typed +-- location where it happens, eg. 'Main Hall' +-- person_id who hosts or speaks: a people row, drawn with its +-- photo and linked to its page. ON DELETE SET NULL, +-- and an unpublished person isn't shown +-- description the fold-out text, formatted like a paragraph +-- media a graphic in the fold-out: '/uploads/…' or a URL +-- map a place or address to show on a Google map in the +-- fold-out, eg. 'Camp Hebron, Halifax PA' +-- +-- text is the entry's title, detail a line under it, url a link on +-- the title, as for list items. +-- +-- The type list is a CHECK, so content_blocks is rebuilt the way +-- 031 and 032 did it (legacy_alter_table around the rename, then +-- the index and the owner trigger again). The item columns are +-- plain ADD COLUMNs. +-- +-- PRAGMA user_version; -- reads 33 before this file +-- ═══════════════════════════════════════════════════════════════ + +CREATE TABLE content_blocks_new ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + owner_kind TEXT NOT NULL + CHECK (owner_kind IN ('organization', 'event', 'person', 'team', 'blog_post')), + owner_id TEXT NOT NULL, + slot TEXT NOT NULL DEFAULT 'body' CHECK (slot IN ('card', 'body')), + sort_order INTEGER NOT NULL DEFAULT 0, + + type TEXT NOT NULL + CHECK (type IN ('heading', 'subheading', 'paragraph', + 'list', 'links', 'quote', 'image', 'divider', + 'video', 'button', 'callout', 'schedule')), + text TEXT, + media TEXT, + href TEXT, + alt TEXT, + cite TEXT +) STRICT; + +INSERT INTO content_blocks_new + (id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite) +SELECT id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite + FROM content_blocks; + +PRAGMA legacy_alter_table = ON; +DROP TABLE content_blocks; +ALTER TABLE content_blocks_new RENAME TO content_blocks; +PRAGMA legacy_alter_table = OFF; + +CREATE INDEX content_blocks_owner_idx + ON content_blocks (owner_kind, owner_id, slot, sort_order); + +ALTER TABLE content_block_items ADD COLUMN day TEXT; +ALTER TABLE content_block_items ADD COLUMN time TEXT; +ALTER TABLE content_block_items ADD COLUMN location TEXT; +ALTER TABLE content_block_items ADD COLUMN person_id TEXT + REFERENCES people (id) ON DELETE SET NULL; +ALTER TABLE content_block_items ADD COLUMN description TEXT; +ALTER TABLE content_block_items ADD COLUMN media TEXT; +ALTER TABLE content_block_items ADD COLUMN map TEXT; + + +-- ── Triggers last (see CLAUDE.md, Migrations) ── + +CREATE TRIGGER content_blocks_owner_exists +BEFORE INSERT ON content_blocks +BEGIN + SELECT CASE + WHEN new.owner_kind = 'event' + AND NOT EXISTS (SELECT 1 FROM events WHERE id = new.owner_id) + THEN RAISE(ABORT, 'content_blocks: no such event') + WHEN new.owner_kind = 'organization' + AND NOT EXISTS (SELECT 1 FROM organizations WHERE id = new.owner_id) + THEN RAISE(ABORT, 'content_blocks: no such organization') + WHEN new.owner_kind = 'person' + AND NOT EXISTS (SELECT 1 FROM people WHERE id = new.owner_id) + THEN RAISE(ABORT, 'content_blocks: no such person') + WHEN new.owner_kind = 'team' + AND NOT EXISTS (SELECT 1 FROM teams WHERE id = new.owner_id) + THEN RAISE(ABORT, 'content_blocks: no such team') + WHEN new.owner_kind = 'blog_post' + AND NOT EXISTS (SELECT 1 FROM blog_posts WHERE id = new.owner_id) + THEN RAISE(ABORT, 'content_blocks: no such blog post') + END; +END; diff --git a/server/src/seed-showcase.js b/server/src/seed-showcase.js index 747f7e4..41bcb3b 100644 --- a/server/src/seed-showcase.js +++ b/server/src/seed-showcase.js @@ -16,7 +16,8 @@ /people/showcase-person person: bio, links, roles past and current, events, awards, private data /events/showcase-event upcoming retreat: hosts, billed - people, links, blocks, background + people, links, blocks, background, + a three-day schedule /events/showcase-series weekly series with times /events/showcase-past-event past event where the award was given /blog/content-block-showcase every content block type @@ -81,6 +82,23 @@ const PAST = "showcase-past-event"; /* ── Content ───────────────────────────────────────────────── */ +/* A schedule over three days, using every entry field: a plain + entry, one with a location and person, one folding out with a + description, graphic and map, one linked, and one with no day + (it lands in a tab of its own). */ +const SCHEDULE = [ + "schedule", + { text: "The weekend at a glance. Tap an entry for more." }, + [ + { day: "Friday", time: "4:00pm", text: "Arrivals and check-in", location: "Front desk" }, + { day: "Friday", time: "7:00 to 8:30pm", text: "Opening session", location: "Main Hall", person_id: "showcase-person", detail: "Welcome and worship", description: "The **opening session** sets the theme for the weekend.\n\nBring a notebook.", media: "/uploads/showcase.jpg", map: "Camp Hebron, Halifax PA" }, + { day: "Saturday", time: "9:00am", text: "Workshops", location: "Classrooms", person_id: "showcase-member-2", detail: "Pick one of three", url: "/blog/content-block-showcase" }, + { day: "Saturday", time: "7:00pm", text: "Talent night", location: "Main Hall", person_id: "showcase-member-3", description: "Sign up at the front desk by noon." }, + { day: "Sunday", time: "10:00am", text: "Closing service", location: "Chapel", map: "Main Street, Halifax PA" }, + { time: "Any time", text: "Quiet room open", location: "Library", detail: "An entry with no day" }, + ], +]; + /* Every block type, for the blog showcase. [type, fields, items?] */ const ALL_BLOCKS = [ ["paragraph", { text: "Every content block type, top to bottom, with each of its options. Use it to check the page after changing how blocks draw." }], @@ -109,6 +127,8 @@ const ALL_BLOCKS = [ ["subheading", { text: "Images" }], ["image", { media: IMAGE, alt: "Describe the picture here", text: "An image with a caption and alt text" }], ["image", { media: IMAGE, alt: "The same picture, linked", href: "/history" }], + ["subheading", { text: "Schedule" }], + SCHEDULE, ["subheading", { text: "Video" }], ["video", { href: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", text: "A YouTube video, with its own thumbnail" }], ["video", { href: "https://vimeo.com/76979871", media: IMAGE, text: "A Vimeo video with an uploaded still" }], @@ -354,7 +374,7 @@ tx(db, () => { { kind: "social", platform: "instagram", label: "@showcaseretreat", url: "https://instagram.com/showcaseretreat" }, ]); blocks("event", EVENT, "card", cardText("event")); - blocks("event", EVENT, "body", pageBody("event")); + blocks("event", EVENT, "body", [...pageBody("event"), ["heading", { text: "Schedule" }], SCHEDULE]); insert("events", { id: SERIES, diff --git a/server/src/shape.js b/server/src/shape.js index 5973156..179d71c 100644 --- a/server/src/shape.js +++ b/server/src/shape.js @@ -98,18 +98,39 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") { const itemRows = db .prepare( - `SELECT block_id, text, detail, url - FROM content_block_items - WHERE block_id IN (${placeholders(blockIds.length)}) - ORDER BY block_id, sort_order`, + `SELECT i.block_id, i.text, i.detail, i.url, + i.day, i.time, i.location, i.description, i.media, i.map, + p.id AS person_id, p.display_name AS person_name, + p.photo AS person_photo, p.tagline AS person_tagline + FROM content_block_items i + LEFT JOIN people p ON p.id = i.person_id AND p.is_published = 1 + WHERE i.block_id IN (${placeholders(blockIds.length)}) + ORDER BY i.block_id, i.sort_order`, ) .all(...blockIds); + // The schedule fields are null on a list or link-row item; they + // ride along anyway rather than branching on the block's type. + // An unpublished person comes back as no person. for (const row of itemRows) { byId.get(row.block_id)?.items.push({ text: row.text, detail: row.detail, url: row.url, + day: row.day, + time: row.time, + location: row.location, + description: row.description, + media: row.media, + map: row.map, + person: row.person_id + ? { + id: row.person_id, + name: row.person_name, + photo: row.person_photo, + tagline: row.person_tagline, + } + : null, }); } diff --git a/src/components/ContentBlocks.tsx b/src/components/ContentBlocks.tsx index d94e4b9..959dcd3 100644 --- a/src/components/ContentBlocks.tsx +++ b/src/components/ContentBlocks.tsx @@ -19,6 +19,10 @@ image media, alt, text is the caption, href video href is the video, media a still, text the caption; click to play + schedule items as entries in day tabs (day, time, + text, detail, url, location, person, and + a fold-out of description, media, map); + text is an optional intro. ScheduleBlock divider nothing "Formatted" is InlineText.tsx: **bold**, *italic*, [text](url), @@ -33,6 +37,7 @@ import { blockMedia } from '../lib/media.ts' import type { ContentBlock } from '../lib/useContent.ts' import { Anchor, Inline, Paragraphs } from './InlineText.tsx' import VideoPlayer from './VideoPlayer.tsx' +import ScheduleBlock from './ScheduleBlock.tsx' const BODY = '#4a6b72' @@ -196,6 +201,10 @@ function Block({ block, accent }: { block: ContentBlock; accent: string }) { ) + case 'schedule': + if (!block.items?.length) return null + return + case 'divider': return
diff --git a/src/components/ScheduleBlock.tsx b/src/components/ScheduleBlock.tsx new file mode 100644 index 0000000..05b6b10 --- /dev/null +++ b/src/components/ScheduleBlock.tsx @@ -0,0 +1,270 @@ +/* ═══════════════════════════════════════════════════════════════ + SCHEDULE BLOCK + + The 'schedule' content block (034_schedule_block.sql): entries + in one tab per day, each a row of time, title, place and person, + folding out for the rest. + + Tabs are the entries' `day` values in the order they first + appear, so the admin's order is the page's. An entry with no day + joins an untitled group; a schedule of one day draws no tabs. The + tab whose name starts with today's weekday opens first ("Friday", + "Fri", "Friday, June 6"), so on the day of an event the visitor + lands on today; otherwise the first tab. + + A row folds out when it has anything more to show: a + description, a graphic, a map, or a person (their photo, tagline + and a link to their page). The map is Google's key-free embed of + the place typed in, with a link out to the full map. + + Tabs follow the ARIA tab pattern: arrow keys move between them. + ═══════════════════════════════════════════════════════════════ */ + +import { useId, useState, type KeyboardEvent } from 'react' +import { Link } from 'react-router-dom' + +import { personHref } from '../lib/hrefs.ts' +import { blockMedia, initials, personPhoto } from '../lib/media.ts' +import type { ContentBlockItem } from '../lib/useContent.ts' +import { Anchor, Paragraphs } from './InlineText.tsx' + +const BODY = '#4a6b72' +const WEEKDAYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'] + +type Day = { name: string; entries: ContentBlockItem[] } + +function groupByDay(items: ContentBlockItem[]): Day[] { + const days: Day[] = [] + for (const item of items) { + const name = item.day?.trim() ?? '' + let day = days.find((d) => d.name === name) + if (!day) { + day = { name, entries: [] } + days.push(day) + } + day.entries.push(item) + } + return days +} + +/* The tab to open with: today's weekday if a tab starts with it (or + its three-letter form), else the first. */ +function todayIndex(days: Day[]): number { + const today = WEEKDAYS[new Date().getDay()] + const found = days.findIndex((day) => { + const name = day.name.toLowerCase() + return name.startsWith(today) || name.startsWith(today.slice(0, 3)) + }) + return found >= 0 ? found : 0 +} + +const mapEmbed = (place: string) => + `https://maps.google.com/maps?q=${encodeURIComponent(place)}&output=embed` +const mapLink = (place: string) => + `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(place)}` + +function Avatar({ person, size }: { person: NonNullable; size: string }) { + const [failed, setFailed] = useState(false) + const src = personPhoto(person.photo) + return src && !failed ? ( + setFailed(true)} className={`${size} shrink-0 rounded-full object-cover`} /> + ) : ( + + ) +} + +function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) { + const [open, setOpen] = useState(false) + const panelId = useId() + const graphic = blockMedia(entry.media) + const place = entry.map?.trim() + const more = Boolean(entry.description || graphic || place || entry.person) + + const title = entry.url ? ( + + {entry.text} + + ) : ( + entry.text + ) + + return ( +
  • +
    +

    + {entry.time} +

    + +
    +

    {title}

    + {(entry.location || entry.person) && ( +

    + {entry.location && {entry.location}} + {entry.person && ( + + + {entry.person.name} + + )} +

    + )} + {entry.detail && ( +

    + {entry.detail} +

    + )} +
    + + {more && ( + + )} +
    + + {more && open && ( +
    + {entry.person && ( +
    + +
    + + {entry.person.name} + + {entry.person.tagline && ( +

    + {entry.person.tagline} +

    + )} +
    +
    + )} + + {entry.description && ( +
    + +
    + )} + + {graphic && } + + {place && ( +
    +