Compare commits

...

34 commits

Author SHA1 Message Date
13d8489fd4 Merge pull request 'v1.14.2-present: event schedules, venues and map blocks, Present mode and its phone remote' (#33) from event-schedule into main
Reviewed-on: #33
2026-11-21 23:02:04 +00:00
Zaldimmar
48b61e6cc7 Version v1.14.2-present
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 16:57:32 -06:00
Zaldimmar
2d354a35c1 Docs: an nginx /api/admin/ block with a 4m body limit, so big saves don't get a 413
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 16:57:32 -06:00
Aidan Dona
5eebc20c4e Present: a remote, a phone at /remote/<code> drives a presenting screen
The screen shows a code on its setup and with its controls. Anyone with
it can step, pause and jump through the slides, send the screen back to
its setup, or change the setup and play it there. Server-sent events,
held in memory (routes/present.js); X-Accel-Buffering: no, so nginx
needs no block of its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 09:51:27 -06:00
Zaldimmar
3aef3b1c34 Present: dividers left off the slides
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 06:59:58 -06:00
Zaldimmar
b286cbddbf Present: a heading alone as a centered slide; just an events list
- A section left with only its heading and subheadings, and nothing
  after it to title, gets a centered slide of them
- Setup, per events block: A slide per event, so the list slide can
  show alone

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 06:57:38 -06:00
Zaldimmar
b2ef692155 Present: featured events lit on the list slide; schedule row fixes
- An events list slide tints, bars and stars its featured events
- A schedule block's sub-items sit a little in, not under the title
- An entry with no place, person or tags no longer shows a stray 0

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 06:48:53 -06:00
Zaldimmar
7d31b3eea8 Present: Copy link for the setup's current choices
- addressFor builds the playing address from the choices, for Play
  and the new Copy link at the bottom of the setup

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 06:42:40 -06:00
Zaldimmar
f46deac3cc Image block: a dark theme picture; presented pictures centered
- media_dark (102): shown in place of the image while the site is
  dark, the block's alt text and caption shared
- Present: pictures beside text centered on the slide's height, and a
  section of only pictures centered both ways

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 06:40:40 -06:00
Zaldimmar
a59702b7f3 Present: a section's pictures left or right of its text, fitted
- Setup, per section with pictures and text: Pictures in the text,
  left of it or right of it (`pictures`), in a column beside the rest
- That slide shrinks to fit (Fit), measured again as pictures load

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 06:04:48 -06:00
Zaldimmar
a0eb9d7e49 Image block: a Size (small, medium, large), centered
- image_size (101): blank the column's full width, else up to 20, 32
  or 48rem, centered and never wider than the column

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 05:58:49 -06:00
Zaldimmar
c26e662406 Present: a callout slide without its tint and bar
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 05:49:27 -06:00
Zaldimmar
c46a612226 Present: callout slides, Select all and Deselect all on the setup
- Setup, per callout block: a slide of its own, centered under the
  subheading above it (else the section's heading); Callouts seconds
- Select all and Deselect all over each list of the setup's checkboxes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 05:47:35 -06:00
Zaldimmar
afa95179ef Present: people roles picked on setup, an events list that fits
- Setup, per people block: each one's role or title under their name
  (`titles`)
- An events list slide: presenters under the titles, columns that
  flow, shrunk to fit rather than scrolled (Fit)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 05:32:09 -06:00
Zaldimmar
d58f630a8f Present: events picked on the setup screen, a titles list slide, people centered
- Setup, per events block: which events, and what's shown (list
  slide, picture, type and date, presenter, page content)
- An events block's list slide: titles and presenters as rows, not
  cards
- A slide of only people: title and photos centered both ways

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 05:20:42 -06:00
Zaldimmar
c4bb685bc0 Present: a list's slides picked on the setup screen, not the block
- Setup: Overview slide and A slide per item per list (`lists`), its
  items ticked on and off when either is picked
- The block's two fields and 098's columns go (100)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 05:02:06 -06:00
Zaldimmar
ae06cd2b4f Blocks: Shown on the page, in the presentation, or both
- present_show (099) replaces present_hide: only on the page, or only
  in the presentation, kept off the page and its contents list
- Blocks with the old Leave out ticked become Only on the page

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 04:59:11 -06:00
Zaldimmar
2282bee23c Present: list slides, centered people
- A list block's Overview slide and A slide per item (098): its
  items' text on one slide, and each item with its detail, centered
- Setup ticks a list's overview and items on and off; List overview
  and List items seconds
- A presented people row is centered

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 04:57:08 -06:00
Zaldimmar
584340b0ee Present: the logo as a plain image, no dark mode plate, full size
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 04:40:19 -06:00
Zaldimmar
c35e65be63 Present: the logo in the screen's corner, not inset
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 04:34:30 -06:00
Zaldimmar
b76f2a5707 Present: dark theme settings, a Theme pick, and a content inset
- Event Presentation, dark theme (096): background image and color,
  dim, accent, text color and logo for a dark screen; blank takes the
  light one
- Setup's Theme holds a screen light or dark while it plays (`theme=`)
- Inset top, right, bottom and left (097), percent of the screen, so
  the slides sit inside a frame drawn in the background image; with
  any set the image is stretched to the screen

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 04:14:14 -06:00
Zaldimmar
7e21a0dd40 Present: slide order, presentation settings, blocks drawn for a screen
- Setup's Order list: drag or move any slide; saved in the address
- A heading-only section titles the slides after it, no slide of its own
- Event Presentation settings (095): background image and color, dim,
  frame, accent, text color, logo
- Blocks: Presentation text and Leave out of the presentation; map
  blocks get a slide per section, map only, no details, location slides
- Presented, links are plain text, people a row of round photos and
  names, organizations their logos

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 03:41:06 -06:00
Zaldimmar
a79559d290 Admin preview: a map block's sections made as the API makes them
The preview handed MapBlock the form's sections (location_keys text),
so adding one crashed the page on section.keys. It now builds them as
shape.js does: keys the venue still has, empty ones dropped, the
venue cut to them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 03:45:43 -06:00
Zaldimmar
56a6e11655 Map block: sections of its own, shown one at a time
Migration 094 adds content_block_map_sections: a map block groups its
venue's locations for its page, eg. Main spaces, without changing the
venue. With sections the API cuts the block's venue to the locations
they hold, in their order; the list groups under their names, and
buttons (All, then each section) show one section's marks and rows.
A schedule's place links only when a map on the page shows it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 03:42:50 -06:00
Zaldimmar
06bf033448 Organizations block: its picker lists ministries too
The block picked from the `organizations` options, which leave
ministries out for pickers that link to a page. A card needs no page,
so the block has its own `block_orgs`, every kind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 03:32:01 -06:00
Zaldimmar
bd271ef02d Organizations block: the Partners page's cards, picked one by one or every one of a kind
Migration 093 adds the 'organizations' block type (rebuilding
content_blocks for its CHECK, as 088 did), content_blocks.org_kind and
content_block_items.org_id. OrgListCards takes `nested` for a block:
no page gutter, names a level under the block's heading.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 03:23:58 -06:00
Zaldimmar
e9ea75a68d List block: bold text and a plain detail by default, with a Style to keep the old look
Migration 092 adds content_blocks.list_style: blank is bold text and
a detail in the body color, 'plain' the plain text and gray detail
lists had before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 03:20:00 -06:00
Zaldimmar
6a0271efd9 Map block: Google and Apple Maps buttons, a zoomable picture, links land at the map's top
Migration 091 adds google_maps_url and apple_maps_url to
venue_locations, shown as buttons at the right of each location's
row. The picture zooms (1x to 4x) and scrolls in its box. A link to a
location now scrolls to the top of the map block, not the mark.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 03:04:14 -06:00
Zaldimmar
8a79206998 Events block: featured events open in full above the cards, under a heading
Migration 090 adds heading and subheading to content_block_items. An
events block's item ticked Featured shows in full above the cards,
under its heading and subheading when set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 02:57:26 -06:00
Zaldimmar
a7495f09e5 Event page: the photo fills the column, as the blocks do
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 02:48:26 -06:00
Zaldimmar
b8a744cf41 Event page: a contents list, a links heading, full-width blocks; schedule tags in their own row
Migration 089 adds show_contents and links_heading to events (Page
group in the editor). The content blocks fill the column, beside the
contents list when it shows. A schedule's tag tabs sit in a row of
their own under the days, with a note on what they do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 02:44:57 -06:00
Zaldimmar
375c364861 Events block: a card opens the event in full, its own blocks too
An events block's events bring their own page's blocks (one level
deep, so events listing each other stop there), photo and place. A
card opens the event under the cards: photo, type and date, title,
place, person host, its blocks (else its card text) and a link to its
page. Reading mode shows them all in full, and the presentation's
event spotlight shows its blocks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 04:31:34 -06:00
Zaldimmar
df8052c75e Present: the whole event page, in sections at its headings
The presentation (now EventPresent) cuts the event's page into
sections at its Heading blocks: a section's text on one slide, then
its schedules' slides, a map block's map and each location lit up,
and an events block's grid and each event. One Present button on the
event page replaces the schedule's. Setup lists the sections, each
schedule's days and entries under its own; the address keys are now
skip and hide, numbered by schedule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 03:41:21 -06:00
Zaldimmar
818d648e91 Venues, map blocks and event blocks; schedule entries link to them
Data → Venues: a map picture with its locations marked as pins or
boxes (088). A Map block draws a venue with its locations listed;
a schedule names a venue and its entries pick a location, linking to
the map on the page with it lit up. Entries and sub-items can name
an event (a workshop) and take what they leave blank from it, and an
Events block shows event cards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 03:21:18 -06:00
55 changed files with 5235 additions and 1119 deletions

View file

@ -35,6 +35,7 @@ In dev, Vite proxies `/api` to the target set in `vite.config.ts`, so the API mu
- Analytics: self-hosted Plausible, proxied by nginx at `/pa/`. The API adds its script to every page (`analyticsTag` in `server/src/pageMeta.js`), counting under the hostname of `site.json`'s `url`, so each deployment reports as itself. Nothing in `index.html` or the app. Daily and weekly reports go to Discord when Panel → Site settings → Reports turns them on and `PLAUSIBLE_API_KEY` and `DISCORD_WEBHOOK_URL` are set (`server/src/analyticsReport.js`): `docs/analytics-reports.md`. Short links `/go/<id>` (Data → Links/redirects, `server/src/routes/redirects.js`) count clicks, report each to Plausible as a pageview and add the link's UTM tags: `docs/redirects.md`. - Analytics: self-hosted Plausible, proxied by nginx at `/pa/`. The API adds its script to every page (`analyticsTag` in `server/src/pageMeta.js`), counting under the hostname of `site.json`'s `url`, so each deployment reports as itself. Nothing in `index.html` or the app. Daily and weekly reports go to Discord when Panel → Site settings → Reports turns them on and `PLAUSIBLE_API_KEY` and `DISCORD_WEBHOOK_URL` are set (`server/src/analyticsReport.js`): `docs/analytics-reports.md`. Short links `/go/<id>` (Data → Links/redirects, `server/src/routes/redirects.js`) count clicks, report each to Plausible as a pageview and add the link's UTM tags: `docs/redirects.md`.
- Page HTML goes through the API, which fills in each page's title, description, preview image and structured data (`server/src/pageMeta.js`), and serves `/sitemap.xml`. It reads `SITE_CONFIG` (site.json) and `SITE_INDEX` (the built index.html), with Panel → Site settings (the `site_settings` table) laid over site.json, and serves `/robots.txt` from the same merge. nginx setup: `docs/seo.md`. - Page HTML goes through the API, which fills in each page's title, description, preview image and structured data (`server/src/pageMeta.js`), and serves `/sitemap.xml`. It reads `SITE_CONFIG` (site.json) and `SITE_INDEX` (the built index.html), with Panel → Site settings (the `site_settings` table) laid over site.json, and serves `/robots.txt` from the same merge. nginx setup: `docs/seo.md`.
- Video clips (Tools, admins and up): yt-dlp downloads our YouTube/Facebook videos into `CLIPS_DIR`, ffmpeg cuts them; one job at a time, files swept after a day (`server/src/clips.js`). Needs yt-dlp and ffmpeg on the VPS: `docs/video-clips.md`. - Video clips (Tools, admins and up): yt-dlp downloads our YouTube/Facebook videos into `CLIPS_DIR`, ffmpeg cuts them; one job at a time, files swept after a day (`server/src/clips.js`). Needs yt-dlp and ffmpeg on the VPS: `docs/video-clips.md`.
- Present remote: a presenting screen (`/events/:id/present`) shows a code; a phone at `/remote/<code>` steps, pauses, jumps and changes its setup, anyone with the code (`server/src/routes/present.js`, `src/pages/PresentRemote.tsx`). Server-sent events held in memory (one process); the API sends `X-Accel-Buffering: no`, so nginx needs no block of its own.
- Newsletter countdown pictures: `/api/countdown/:id.png` (`server/src/routes/countdown.js`), drawn with sharp when an email is opened; it uses the VPS's fonts, so install Poppins there (eg. into `/usr/local/share/fonts`, then `fc-cache`) or it falls back to a plain sans. The social bar's icons are static files in `public/email/`. - Newsletter countdown pictures: `/api/countdown/:id.png` (`server/src/routes/countdown.js`), drawn with sharp when an email is opened; it uses the VPS's fonts, so install Poppins there (eg. into `/usr/local/share/fonts`, then `fc-cache`) or it falls back to a plain sans. The social bar's icons are static files in `public/email/`.
- Word import: Blog posts → Import from Word turns a .docx into an unpublished post (headings, paragraphs, lists, tables, links); nginx needs a block for `/api/admin/import/docx` with an 11m body limit: `docs/importing.md`. - Word import: Blog posts → Import from Word turns a .docx into an unpublished post (headings, paragraphs, lists, tables, links); nginx needs a block for `/api/admin/import/docx` with an 11m body limit: `docs/importing.md`.
- Speed: nginx must gzip JS/CSS/JSON/SVG and speak HTTP/2; page HTML is `no-cache`; uploads get a `-640.webp` small copy made at upload and at boot: `docs/performance.md`. - Speed: nginx must gzip JS/CSS/JSON/SVG and speak HTTP/2; page HTML is `no-cache`; uploads get a `-640.webp` small copy made at upload and at boot: `docs/performance.md`.

View file

@ -111,6 +111,18 @@ with it off it blocks everything.
client_max_body_size 26m; client_max_body_size 26m;
proxy_read_timeout 60s; proxy_read_timeout 60s;
} }
# The admin's saves send a record whole (every content block,
# schedule entry and sub-item), well over 64k for a big page or
# event: nginx answers 413 "Too large for the web server" without
# this. A longer prefix than /api/, so it wins; the exact and
# longer admin blocks (media, files, import, clips) still win over
# it. Same proxy_set_header lines as /api/.
location /api/admin/ {
proxy_pass http://127.0.0.1:3001;
client_max_body_size 4m;
proxy_read_timeout 30s;
}
``` ```
Keep the existing `/api/` and `/uploads/` blocks; they're more Keep the existing `/api/` and `/uploads/` blocks; they're more

View file

@ -181,8 +181,14 @@ also in `server/src/admin-schema/` and a CHECK):
| Links → Kind (on organizations, events, people, teams) | action, social, website, email | no | `splitLinks` in `server/src/shape.js` | | 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. | | 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 → 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, schedule, table | **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/shared.ts`). | | Content blocks → Type | heading, subheading, paragraph, list, links, quote, image, divider, video, button, callout, schedule, table, cards, people, map, events, organizations | **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/shared.ts`). |
| Content blocks → Schedule items → Type | (blank: normal entry), block, break, heading | **yes**, migration 086 | `SCHEDULE_KINDS` in `src/lib/adminSchema/shared.ts`; drawn by `ScheduleBlock.tsx` and `SchedulePresent.tsx` (which slides each kind gets). A block's sub-items are `content_block_subitems`. A schedule's own tags (087) are `content_block_tags`, rows of the block typed in the admin (not a fixed list); entries name them by `tag_key`, made in the admin as the tag is added. | | Content blocks → Schedule items → Type | (blank: normal entry), block, break, heading | **yes**, migration 086 | `SCHEDULE_KINDS` in `src/lib/adminSchema/shared.ts`; drawn by `ScheduleBlock.tsx` and `EventPresent.tsx` (which slides each kind gets; the presentation cuts the event's page into sections at its Heading blocks). A block's sub-items are `content_block_subitems`. A schedule's own tags (087) are `content_block_tags`, rows of the block typed in the admin (not a fixed list); entries name them by `tag_key`, made in the admin as the tag is added. A schedule's Venue (088) lends its locations (Data → Venues, `venue_locations`) to its entries' Map location, named by `location_key` the same way; an entry's Event (a workshop) fills what it leaves blank in `shape.js` (`attachEvents`). |
| Content blocks → Image → Size | (blank: the column's full width), small (20rem), medium (32rem), large (48rem) | **yes**, migration 101 | The `image_size` field in `src/lib/adminSchema/shared.ts`; `IMAGE_SIZE` in `ContentBlocks.tsx` sets the widths |
| Content blocks → List → Style | (blank: bold text, normal detail), plain (plain text, gray detail) | **yes**, migration 092 | The Style field in `src/lib/adminSchema/shared.ts`; drawn by the `list` case in `ContentBlocks.tsx`. |
| Content blocks (an event's) → Shown | (blank: the page and the presentation), page, presentation | **yes**, migration 099 | `PRESENT_BLOCK_FIELDS` in `src/lib/adminSchema/shared.ts`; `ContentBlocks.tsx` leaves out a presentation-only block on the page and a page-only one presented, `sectionsOf` in `src/pages/EventPresent.tsx` too |
| Content blocks (an event's) → Map → Location slides | (blank: each marked location), picked (the Locations with a slide), none | **yes**, migration 095 | `PRESENT_BLOCK_FIELDS` in `src/lib/adminSchema/shared.ts`; read by `mapSlides` in `src/pages/EventPresent.tsx` |
| Events → Presentation → Frame | (blank: the accent bar, title line and timer), border, none | **yes**, migration 095 | The `present_frame` field in `src/lib/adminSchema/events.ts`; drawn by `Player` in `src/pages/EventPresent.tsx` |
| Content blocks → Organizations → List | (blank: only the picked ones), partner, region, group, ministry | **yes**, migration 093 | The `org_kind` field in `src/lib/adminSchema/shared.ts`; the `organizations` case in `ContentBlocks.tsx` passes it as the kind to `OrgListCards` (`nested`); items picked by `org_id` replace it |
| Timeline → Kind (+ list filter) | milestone, event, organization, award, people | no | `KIND_NAMES` in `src/pages/sections/history/TimelineEntry.tsx` | | 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 → 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 | | Timeline → Precision (and on events/orgs) | year, month, day | no | the history page's grouping |
@ -272,7 +278,7 @@ A Numbers section's "Number Source" dropdown works the same way:
| The icons a Connect nav section's path can pick | `src/data/pathIcons.ts` (keys and labels) **and** `ICONS` in `src/pages/sections/home/Pathfinder.tsx` (the Phosphor icon for each key) | Add a line to both. A path saved with an emoji from before the list shows it as it is. | | The icons a Connect nav section's path can pick | `src/data/pathIcons.ts` (keys and labels) **and** `ICONS` in `src/pages/sections/home/Pathfinder.tsx` (the Phosphor icon for each key) | Add a line to both. A path saved with an emoji from before the list shows it as it is. |
| A page section's accent color | `BRAND` and `ACCENTS` in `src/lib/color.ts` | Pages pick from these (`accent: ACCENTS.green`); add a color there, not a hex in a page. Each is readable as text on white and the tints. | | A page section's accent color | `BRAND` and `ACCENTS` in `src/lib/color.ts` | Pages pick from these (`accent: ACCENTS.green`); add a color there, not a hex in a page. Each is readable as text on white and the tints. |
| The palette (the 16-color grid the theme is drawn from) | `PALETTE` in `src/lib/color.ts` | Four families, a column each. `PALETTE_LIGHT` / `PALETTE_DARK` are the fills things colored by data use (a person's initials tile, `paletteFill`); the page background's layers (how many circles, their sizes and parallax speeds) are `LAYERS` in `src/components/PageBackdrop.tsx` and its shades are in `PageBackdrop.css`; the admin home's two alternating group colors are `BLOCK_COLORS` in `src/pages/admin/AdminHome.tsx`. | | The palette (the 16-color grid the theme is drawn from) | `PALETTE` in `src/lib/color.ts` | Four families, a column each. `PALETTE_LIGHT` / `PALETTE_DARK` are the fills things colored by data use (a person's initials tile, `paletteFill`); the page background's layers (how many circles, their sizes and parallax speeds) are `LAYERS` in `src/components/PageBackdrop.tsx` and its shades are in `PageBackdrop.css`; the admin home's two alternating group colors are `BLOCK_COLORS` in `src/pages/admin/AdminHome.tsx`. |
| The accessibility panel's choices (bottom right of every public page) | `SETTINGS` in `src/components/AccessibilityPanel.tsx`; the color blind modes are `VISIONS` and `SWAPS` in `src/lib/color.ts` | Each choice is an attribute on `<html>` styled in `src/index.css`, and `index.html` sets it again before the first paint, so a new one goes in all three. A color blind mode replaces all three color families, teal, green and amber (`SWAPS`, picked by simulating each type: see the comment there), in code, in data colors as they load (`src/lib/api.ts`, never under /admin), in CSS (the `--pal-*` variables in `src/index.css`, which hold the same values as `SWAPS`: change both) and in the theme tokens drawn from them. A palette hex in a component or CSS file should be `var(--pal-<family>-<shade>)` (eg. `var(--pal-amber-2)`), or a color blind mode won't reach it. Reading mode is `src/components/ReaderView.tsx`, which reads the hidden page and writes out its headings, paragraphs, links and described pictures. A part it can't read well (a carousel, tabs, details behind a click, a map) draws its own text version when `useReadingMode()` (`src/lib/readingMode.ts`) is on: the hero, pathfinder, stats, history rail, event lists, calendar (the next six weeks), featured cards, org lists and groups map, history timeline, schedule, people tiles and video player; the countdown draws nothing. A new component with any of those should do the same. Something saved or sent (the newsletter's colors) is a stored hex, which is never swapped. | | The accessibility panel's choices (bottom right of every public page) | `SETTINGS` in `src/components/AccessibilityPanel.tsx`; the color blind modes are `VISIONS` and `SWAPS` in `src/lib/color.ts` | Each choice is an attribute on `<html>` styled in `src/index.css`, and `index.html` sets it again before the first paint, so a new one goes in all three. A color blind mode replaces all three color families, teal, green and amber (`SWAPS`, picked by simulating each type: see the comment there), in code, in data colors as they load (`src/lib/api.ts`, never under /admin), in CSS (the `--pal-*` variables in `src/index.css`, which hold the same values as `SWAPS`: change both) and in the theme tokens drawn from them. A palette hex in a component or CSS file should be `var(--pal-<family>-<shade>)` (eg. `var(--pal-amber-2)`), or a color blind mode won't reach it. Reading mode is `src/components/ReaderView.tsx`, which reads the hidden page and writes out its headings, paragraphs, links and described pictures. A part it can't read well (a carousel, tabs, details behind a click, a map) draws its own text version when `useReadingMode()` (`src/lib/readingMode.ts`) is on: the hero, pathfinder, stats, history rail, event lists, calendar (the next six weeks), featured cards, org lists and groups map, history timeline, schedule, map block (its list alone), people tiles and video player; the countdown draws nothing. A new component with any of those should do the same. Something saved or sent (the newsletter's colors) is a stored hex, which is never swapped. |
| Privacy Policy and Terms wording | the database (082) | Admin → Pages → Page management → Privacy Policy or Terms of Service: their sections' blocks, and the "Last updated" date in the section's blurb whenever the wording changes. The privacy contact email is in the policy's text. The Privacy page must stay true of the code: what the feedback form stores, what the browser keeps, which embeds wait for a click. | | Privacy Policy and Terms wording | the database (082) | Admin → Pages → Page management → Privacy Policy or Terms of Service: their sections' blocks, and the "Last updated" date in the section's blurb whenever the wording changes. The privacy contact email is in the policy's text. The Privacy page must stay true of the code: what the feedback form stores, what the browser keeps, which embeds wait for a click. |
| Event type labels and plurals (public site) | `src/lib/eventTypes.ts` | Also the order of the type filter chips. | | 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` | | | Event and person role labels (public site) | `ROLE_LABEL` in `src/pages/EventDetail.tsx` and `src/pages/PersonDetail.tsx` | |

View file

@ -64,6 +64,7 @@ import { tags } from "./admin-schema/tags.js";
import { contactTypes } from "./admin-schema/contactTypes.js"; import { contactTypes } from "./admin-schema/contactTypes.js";
import { redirects } from "./admin-schema/redirects.js"; import { redirects } from "./admin-schema/redirects.js";
import { pages } from "./admin-schema/sitePages.js"; import { pages } from "./admin-schema/sitePages.js";
import { venues } from "./admin-schema/venues.js";
export const ENTITIES = { export const ENTITIES = {
organizations, organizations,
@ -73,6 +74,7 @@ export const ENTITIES = {
tags, tags,
contact_types: contactTypes, contact_types: contactTypes,
redirects, redirects,
venues,
teams, teams,
awards, awards,
timeline, timeline,
@ -98,6 +100,10 @@ export const OPTION_QUERIES = {
// What an organization cards section can hand-pick (067). // What an organization cards section can hand-pick (067).
card_orgs: card_orgs:
"SELECT id, name || ' (' || kind || ')' AS label FROM organizations WHERE kind IN ('partner', 'ministry') ORDER BY kind, name", "SELECT id, name || ' (' || kind || ')' AS label FROM organizations WHERE kind IN ('partner', 'ministry') ORDER BY kind, name",
// What an organizations content block can pick (093): every kind,
// a card needing no page of its own.
block_orgs:
"SELECT id, name || ' (' || kind || ')' AS label FROM organizations ORDER BY kind, name",
event_scopes: "SELECT id, name AS label FROM event_scopes ORDER BY sort_order", event_scopes: "SELECT id, name AS label FROM event_scopes ORDER BY sort_order",
events: "SELECT id, title AS label FROM events ORDER BY starts_on DESC, title", events: "SELECT id, title AS label FROM events ORDER BY starts_on DESC, title",
people: "SELECT id, display_name AS label FROM people ORDER BY sort_name, display_name", people: "SELECT id, display_name AS label FROM people ORDER BY sort_name, display_name",
@ -106,6 +112,15 @@ export const OPTION_QUERIES = {
contact_types: "SELECT id, name AS label FROM contact_types ORDER BY sort_order, name", contact_types: "SELECT id, name AS label FROM contact_types ORDER BY sort_order, name",
// Link fields with `redirects: true` pick from these (068). // Link fields with `redirects: true` pick from these (068).
redirects: "SELECT id, id || ' (' || target_url || ')' AS label FROM redirects ORDER BY id", redirects: "SELECT id, id || ' (' || target_url || ')' AS label FROM redirects ORDER BY id",
// A map block's venue; its locations ride along (as JSON) for a
// schedule's entries to pick from and for the block's preview.
venues: `
SELECT v.id, v.name AS label, v.map_image, v.map_alt,
(SELECT json_group_array(json_object('key', l.location_key, 'name', l.name, 'detail', l.detail,
'x', l.x, 'y', l.y, 'w', l.w, 'h', l.h))
FROM (SELECT * FROM venue_locations WHERE venue_id = v.id ORDER BY sort_order) l) AS locations
FROM venues v
ORDER BY v.name`,
blog_posts: "SELECT id, title AS label FROM blog_posts ORDER BY published_on DESC, title", blog_posts: "SELECT id, title AS label FROM blog_posts ORDER BY published_on DESC, title",
// Navigation's Under page: a page by its address (080). // Navigation's Under page: a page by its address (080).
site_pages: "SELECT path AS id, title || ' (' || path || ')' AS label FROM site_pages ORDER BY sort_order, title", site_pages: "SELECT path AS id, title || ' (' || path || ')' AS label FROM site_pages ORDER BY sort_order, title",

View file

@ -154,11 +154,18 @@ export const blocksChild = (ownerKind) => ({
"people", "people",
// A blog post's tab (079): its text is the tab's title. // A blog post's tab (079): its text is the tab's title.
"tab", "tab",
// A venue's map, and event cards (088).
"map",
"events",
// Organization cards (093).
"organizations",
], ],
{ required: true }, { required: true },
), ),
text("text"), text("text"),
text("media"), text("media"),
// Image blocks (102): shown in place of media in the dark theme.
text("media_dark"),
url("href"), url("href"),
text("alt"), text("alt"),
text("cite"), text("cite"),
@ -170,6 +177,23 @@ export const blocksChild = (ownerKind) => ({
int("word_seconds"), int("word_seconds"),
// People blocks only (054): whose team's tiles to show. // People blocks only (054): whose team's tiles to show.
text("team_id"), text("team_id"),
// Map and schedule blocks (088): whose map and locations.
text("venue_id"),
// List blocks (092): null bold text, 'plain' the old look.
enumeration("list_style", ["plain"]),
// Image blocks (101): null full width, else a narrower size.
enumeration("image_size", ["small", "medium", "large"]),
// Organizations blocks (093): the kind listed when none are picked.
enumeration("org_kind", ["region", "group", "partner", "ministry"]),
// How it's presented (095): EventPresent.tsx.
// Where it shows (099): null both, the page or the presentation.
enumeration("present_show", ["page", "presentation"]),
text("present_text"),
bool("present_map_split"),
bool("present_map_no_list"),
bool("present_map_no_details"),
enumeration("present_places", ["picked", "none"]),
text("present_place_keys"),
], ],
children: [ children: [
{ {
@ -198,6 +222,15 @@ export const blocksChild = (ownerKind) => ({
bool("featured"), bool("featured"),
// The block's tags it has, by key, comma-separated (087). // The block's tags it has, by key, comma-separated (087).
text("tags"), text("tags"),
// A workshop or other event it is, and its place on the
// block's venue map (088).
text("event_id"),
text("location_key"),
// A featured event's heading and subheading (090).
text("heading"),
text("subheading"),
// An organizations block's organization (093).
text("org_id"),
], ],
children: [ children: [
{ {
@ -223,6 +256,8 @@ export const blocksChild = (ownerKind) => ({
text("map_image"), text("map_image"),
bool("featured"), bool("featured"),
text("tags"), text("tags"),
text("event_id"),
text("location_key"),
], ],
}, },
], ],
@ -242,6 +277,15 @@ export const blocksChild = (ownerKind) => ({
bool("no_tab"), bool("no_tab"),
], ],
}, },
{
// A map block's own sections of its venue's locations (094).
key: "map_sections",
table: "content_block_map_sections",
owner: { column: "block_id" },
order: "sort_order",
when: { column: "type", value: "map" },
columns: [text("name", { required: true }), text("location_keys")],
},
], ],
}); });

View file

@ -1,4 +1,4 @@
import { text, int, bool, date, time, enumeration, placeColumns, timelineExtension, linksChild, blocksChild, hostsChild } from "./columns.js"; import { text, int, real, bool, date, time, enumeration, placeColumns, timelineExtension, linksChild, blocksChild, hostsChild } from "./columns.js";
import { tagsChild } from "./tags.js"; import { tagsChild } from "./tags.js";
/* ── Events ──────────────────────────────────────────────────── */ /* ── Events ──────────────────────────────────────────────────── */
@ -67,6 +67,28 @@ export const events = {
bool("is_published"), bool("is_published"),
bool("is_listed"), bool("is_listed"),
bool("in_timeline"), bool("in_timeline"),
bool("show_contents"),
text("links_heading"),
// Its page presented (095).
text("present_background"),
text("present_background_color"),
int("present_dim"),
enumeration("present_frame", ["border", "none"]),
text("present_accent"),
text("present_text_color"),
text("present_logo"),
// The same in the dark theme (096), null the above.
text("present_background_dark"),
text("present_background_color_dark"),
int("present_dim_dark"),
text("present_accent_dark"),
text("present_text_color_dark"),
text("present_logo_dark"),
// Room clear at each edge, eg. inside a frame picture (097).
real("present_inset_top"),
real("present_inset_right"),
real("present_inset_bottom"),
real("present_inset_left"),
// A repeating schedule. Columns rather than a side table: the // A repeating schedule. Columns rather than a side table: the
// schedule is always exactly one per event, and the public view // schedule is always exactly one per event, and the public view

View file

@ -214,11 +214,11 @@ const sectionsChild = {
export const CORE_PAGES = { home: "/", give: "/give", feedback: "/feedback", request: "/request", qr: "/qr", privacy: "/privacy", terms: "/terms" }; export const CORE_PAGES = { home: "/", give: "/give", feedback: "/feedback", request: "/request", qr: "/qr", privacy: "/privacy", terms: "/terms" };
/* Addresses a page can't take: the admin, the API, the uploads, the /* Addresses a page can't take: the admin, the API, the uploads, the
records' own pages and the account pages. */ records' own pages, the account pages and the remote. */
const RESERVED = [ const RESERVED = [
"admin", "api", "uploads", "assets", "pa", "go", "admin", "api", "uploads", "assets", "pa", "go",
"events", "regions", "groups", "partners", "organizations", "teams", "awards", "people", "blog", "directory", "events", "regions", "groups", "partners", "organizations", "teams", "awards", "people", "blog", "directory",
"sign-in", "account", "sitemap.xml", "robots.txt", "sign-in", "account", "remote", "sitemap.xml", "robots.txt",
]; ];
/* After a save: the address is one a page may have. */ /* After a save: the address is one a page may have. */

View file

@ -0,0 +1,47 @@
import { text, real, url } from "./columns.js";
/* ── Venues (088_venues.sql) ─────────────────────────────────────
A place we gather, with its map picture and the locations marked
on it. Map blocks draw it, and schedule entries link to its
locations. Its own entity because content_blocks.venue_id points
at it; nothing points at a location's row, entries name one by
location_key, so the locations can be replaced wholesale. */
export const venues = {
key: "venues",
table: "venues",
idColumn: "id",
idKind: "slug",
list: {
columns: ["id", "name", "address"],
filters: [],
search: ["name", "id", "address"],
order: "name",
},
columns: [text("name", { required: true }), text("address"), text("map_image"), text("map_alt")],
children: [
{
key: "locations",
table: "venue_locations",
owner: { column: "venue_id" },
order: "sort_order",
columns: [
// Made by the admin as the row is added, so it isn't input.
text("location_key", { required: true, seeded: true }),
text("name", { required: true }),
text("detail"),
real("x"),
real("y"),
real("w"),
real("h"),
// The place in Google and Apple Maps (091).
url("google_maps_url"),
url("apple_maps_url"),
],
},
],
};

View file

@ -43,6 +43,7 @@ import imports from "./routes/import.js";
import files from "./routes/files.js"; import files from "./routes/files.js";
import countdown from "./routes/countdown.js"; import countdown from "./routes/countdown.js";
import redirects from "./routes/redirects.js"; import redirects from "./routes/redirects.js";
import present from "./routes/present.js";
import { CLIPS_DIR, startClipWorker } from "./clips.js"; import { CLIPS_DIR, startClipWorker } from "./clips.js";
import { UPLOADS_DIR, writeMissingThumbs } from "./media.js"; import { UPLOADS_DIR, writeMissingThumbs } from "./media.js";
import { logSafe, requireStaff, startSessionSweeper } from "./auth.js"; import { logSafe, requireStaff, startSessionSweeper } from "./auth.js";
@ -137,7 +138,7 @@ app.use(
so each is capped well above its longest real body (a 5000 so each is capped well above its longest real body (a 5000
character message) and far below nginx's limit. */ character message) and far below nginx's limit. */
const smallBody = bodyLimit({ maxSize: 64 * 1024, onError: (c) => c.json({ error: "That's too long." }, 413) }); const smallBody = bodyLimit({ maxSize: 64 * 1024, onError: (c) => c.json({ error: "That's too long." }, 413) });
for (const path of ["/api/csp-report", "/api/feedback", "/api/auth/login", "/api/account/accept", "/api/account/claim", "/api/account/profile"]) app.use(path, smallBody); for (const path of ["/api/csp-report", "/api/feedback", "/api/auth/login", "/api/account/accept", "/api/account/claim", "/api/account/profile", "/api/present/*"]) app.use(path, smallBody);
/* What the policy above would have blocked. Browsers post these on /* What the policy above would have blocked. Browsers post these on
their own; a short line per report is plenty to go on. */ their own; a short line per report is plenty to go on. */
@ -202,6 +203,11 @@ app.use("/api/countdown/*", rateLimit({ windowMs: 60_000, max: 600 }));
app.route("/api", countdown); app.route("/api", countdown);
// Tighter limit on the write path than anything else gets. // Tighter limit on the write path than anything else gets.
// A presenting screen and its remotes, by the screen's code
// (routes/present.js): a cap far above tapping, far below guessing.
app.use("/api/present/*", rateLimit({ windowMs: 60_000, max: 300 }));
app.route("/api", present);
app.use("/api/feedback", rateLimit({ windowMs: 60_000, max: 5 })); app.use("/api/feedback", rateLimit({ windowMs: 60_000, max: 5 }));
app.route("/api/feedback", feedback); app.route("/api/feedback", feedback);
// Requests carry files: fewer again. // Requests carry files: fewer again.

View file

@ -0,0 +1,125 @@
-- ═══════════════════════════════════════════════════════════════
-- 088 VENUES, MAP BLOCKS AND EVENT BLOCKS
--
-- Data → Venues: a place we gather (a camp, a church), with one map
-- picture and its marked locations, each a pin (x, y) or a box
-- (x, y, w, h), in percent of the picture from its top left.
--
-- A 'map' content block draws a venue's map with its locations
-- listed beside it; a schedule block names a venue too, and its
-- entries and sub-items pick one of its locations (location_key),
-- which links to the map block on the same page, the location
-- lit up. The venue's locations are rewritten on every save, so an
-- entry names one by `location_key` (made in the admin when the
-- location is added), as schedule tags do (087).
--
-- An 'events' content block shows events as cards, an item each
-- (event_id); a schedule entry or sub-item can name an event too
-- (a workshop), and takes what it leaves blank from it.
--
-- content_blocks.type's CHECK can't change in place, so the table
-- is rebuilt (as in 079), then its index and owner trigger made
-- again.
-- ═══════════════════════════════════════════════════════════════
CREATE TABLE venues (
id TEXT PRIMARY KEY
CONSTRAINT "A venue's URL ID can use only lowercase letters, numbers and hyphens, eg. camp-hebron."
CHECK (id <> '' AND id NOT GLOB '*[^a-z0-9-]*'),
name TEXT NOT NULL,
address TEXT,
map_image TEXT, -- an upload
map_alt TEXT
) STRICT;
CREATE TABLE venue_locations (
id INTEGER PRIMARY KEY AUTOINCREMENT,
venue_id TEXT NOT NULL REFERENCES venues (id) ON DELETE CASCADE,
sort_order INTEGER NOT NULL DEFAULT 0,
location_key TEXT NOT NULL,
name TEXT NOT NULL,
detail TEXT,
x REAL CHECK (x BETWEEN 0 AND 100),
y REAL CHECK (y BETWEEN 0 AND 100),
w REAL CHECK (w > 0 AND w <= 100), -- null: a pin
h REAL CHECK (h > 0 AND h <= 100),
UNIQUE (venue_id, location_key)
) STRICT;
ALTER TABLE content_block_items ADD COLUMN event_id TEXT
REFERENCES events (id) ON DELETE SET NULL;
ALTER TABLE content_block_items ADD COLUMN location_key TEXT;
ALTER TABLE content_block_subitems ADD COLUMN event_id TEXT
REFERENCES events (id) ON DELETE SET NULL;
ALTER TABLE content_block_subitems ADD COLUMN location_key TEXT;
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', 'page_section',
'newsletter')),
owner_id TEXT NOT NULL,
slot TEXT NOT NULL DEFAULT 'body' CHECK (slot IN ('card', 'body', 'both')),
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', 'table', 'cards',
'people', 'tab', 'map', 'events')),
text TEXT,
media TEXT,
href TEXT,
alt TEXT,
cite TEXT,
team_id TEXT REFERENCES teams (id) ON DELETE SET NULL,
captions TEXT,
word_motion TEXT CHECK (word_motion IN ('slide', 'flip', 'fade', 'type', 'mirror')),
word_direction TEXT CHECK (word_direction IN ('top', 'bottom')),
word_seconds INTEGER CHECK (word_seconds BETWEEN 1 AND 20),
-- Map and schedule blocks: whose map, and whose locations.
venue_id TEXT REFERENCES venues (id) ON DELETE SET NULL
) STRICT;
INSERT INTO content_blocks_new
(id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite, team_id, captions,
word_motion, word_direction, word_seconds)
SELECT id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite, team_id, captions,
word_motion, word_direction, word_seconds
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);
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')
WHEN new.owner_kind = 'page_section'
AND NOT EXISTS (SELECT 1 FROM page_sections WHERE CAST(id AS TEXT) = new.owner_id)
THEN RAISE(ABORT, 'content_blocks: no such page section')
WHEN new.owner_kind = 'newsletter'
AND NOT EXISTS (SELECT 1 FROM newsletters WHERE CAST(id AS TEXT) = new.owner_id)
THEN RAISE(ABORT, 'content_blocks: no such newsletter')
END;
END;

View file

@ -0,0 +1,14 @@
-- ═══════════════════════════════════════════════════════════════
-- 089 EVENT PAGE OPTIONS
--
-- show_contents the page's headings listed beside its content
-- blocks, as a blog post's are (PostContents.tsx)
-- links_heading a heading above the event's link buttons; null
-- shows none
--
-- v_events is SELECT e.*, so it carries both with no rebuild.
-- ═══════════════════════════════════════════════════════════════
ALTER TABLE events ADD COLUMN show_contents INTEGER NOT NULL DEFAULT 0
CHECK (show_contents IN (0, 1));
ALTER TABLE events ADD COLUMN links_heading TEXT;

View file

@ -0,0 +1,15 @@
-- ═══════════════════════════════════════════════════════════════
-- 090 FEATURED EVENTS IN AN EVENTS BLOCK
--
-- An events block's item ticked Featured (086's `featured`) shows
-- opened in full above the cards, under its own heading and
-- subheading, both optional:
--
-- heading eg. This year's keynote
-- subheading a line under it
--
-- Other item kinds ignore both.
-- ═══════════════════════════════════════════════════════════════
ALTER TABLE content_block_items ADD COLUMN heading TEXT;
ALTER TABLE content_block_items ADD COLUMN subheading TEXT;

View file

@ -0,0 +1,10 @@
-- ═══════════════════════════════════════════════════════════════
-- 091 A VENUE LOCATION'S MAP LINKS
--
-- Each location on a venue's map can link to the same place in
-- Google Maps and Apple Maps, shown as buttons beside it in a map
-- block's list. Null shows no button.
-- ═══════════════════════════════════════════════════════════════
ALTER TABLE venue_locations ADD COLUMN google_maps_url TEXT;
ALTER TABLE venue_locations ADD COLUMN apple_maps_url TEXT;

View file

@ -0,0 +1,13 @@
-- ═══════════════════════════════════════════════════════════════
-- 092 A LIST BLOCK'S STYLE
--
-- How a list block's items read:
--
-- null the item's text bold, its detail in the body color
-- plain the text plain, the detail gray (the look before 092)
--
-- Other block types ignore it.
-- ═══════════════════════════════════════════════════════════════
ALTER TABLE content_blocks ADD COLUMN list_style TEXT
CHECK (list_style IN ('plain'));

View file

@ -0,0 +1,91 @@
-- ═══════════════════════════════════════════════════════════════
-- 093 ORGANIZATIONS BLOCK
--
-- An 'organizations' content block shows organizations as the
-- Partners page's cards (OrgList-Card.tsx): the ones picked as its
-- items, in their order (content_block_items.org_id), else every
-- published, listed one of its kind (content_blocks.org_kind), by
-- name.
--
-- content_blocks.type's CHECK can't change in place, so the table
-- is rebuilt (as in 088), then its index and owner trigger made
-- again.
-- ═══════════════════════════════════════════════════════════════
ALTER TABLE content_block_items ADD COLUMN org_id TEXT
REFERENCES organizations (id) ON DELETE SET NULL;
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', 'page_section',
'newsletter')),
owner_id TEXT NOT NULL,
slot TEXT NOT NULL DEFAULT 'body' CHECK (slot IN ('card', 'body', 'both')),
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', 'table', 'cards',
'people', 'tab', 'map', 'events', 'organizations')),
text TEXT,
media TEXT,
href TEXT,
alt TEXT,
cite TEXT,
team_id TEXT REFERENCES teams (id) ON DELETE SET NULL,
captions TEXT,
word_motion TEXT CHECK (word_motion IN ('slide', 'flip', 'fade', 'type', 'mirror')),
word_direction TEXT CHECK (word_direction IN ('top', 'bottom')),
word_seconds INTEGER CHECK (word_seconds BETWEEN 1 AND 20),
-- Map and schedule blocks: whose map, and whose locations.
venue_id TEXT REFERENCES venues (id) ON DELETE SET NULL,
-- List blocks (092): null bold text, 'plain' the old look.
list_style TEXT CHECK (list_style IN ('plain')),
-- Organizations blocks: the kind listed when none are picked.
org_kind TEXT CHECK (org_kind IN ('region', 'group', 'partner', 'ministry'))
) STRICT;
INSERT INTO content_blocks_new
(id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite, team_id, captions,
word_motion, word_direction, word_seconds, venue_id, list_style)
SELECT id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite, team_id, captions,
word_motion, word_direction, word_seconds, venue_id, list_style
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);
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')
WHEN new.owner_kind = 'page_section'
AND NOT EXISTS (SELECT 1 FROM page_sections WHERE CAST(id AS TEXT) = new.owner_id)
THEN RAISE(ABORT, 'content_blocks: no such page section')
WHEN new.owner_kind = 'newsletter'
AND NOT EXISTS (SELECT 1 FROM newsletters WHERE CAST(id AS TEXT) = new.owner_id)
THEN RAISE(ABORT, 'content_blocks: no such newsletter')
END;
END;

View file

@ -0,0 +1,27 @@
-- ═══════════════════════════════════════════════════════════════
-- 094 A MAP BLOCK'S SECTIONS
--
-- A map content block can group its venue's locations into
-- sections of its own, eg. Main spaces, Small group spaces: the
-- block's list shows them under those names, and a visitor can pick
-- one to see only its locations on the map. They're the block's,
-- not the venue's, so each event groups the same venue its own way.
--
-- With sections, the block shows only the locations they name (in
-- the sections' order); without, every location, as before.
--
-- location_keys the venue's location_keys (088) it holds,
-- comma-separated, as schedule tags are (087). A
-- key the venue no longer has is skipped.
-- ═══════════════════════════════════════════════════════════════
CREATE TABLE content_block_map_sections (
id INTEGER PRIMARY KEY AUTOINCREMENT,
block_id INTEGER NOT NULL REFERENCES content_blocks (id) ON DELETE CASCADE,
sort_order INTEGER NOT NULL DEFAULT 0,
name TEXT NOT NULL,
location_keys TEXT
) STRICT;
CREATE INDEX content_block_map_sections_block_idx
ON content_block_map_sections (block_id, sort_order);

View file

@ -0,0 +1,56 @@
-- ═══════════════════════════════════════════════════════════════
-- 095 PRESENTATION SETTINGS
--
-- How an event's page looks presented (EventPresent.tsx), set on
-- the event; nothing here changes the page itself.
--
-- On events (v_events is SELECT e.*, so no rebuild):
-- present_background an image behind every slide
-- present_background_color the slides' background color; with an
-- image, laid over it at present_dim
-- present_dim percent of the color over the image,
-- 0 to 90; null 60
-- present_frame null the accent bar, title line and
-- timer; 'border' an accent border around
-- the slide; 'none' the slide alone
-- present_accent in place of the event's color
-- present_text_color the slides' text; null the background
-- color's readable one, else the site's
-- present_logo in the slide's bottom-right corner
--
-- On content blocks (any owner's; only an event's are presented):
-- present_hide left out of the presentation
-- present_text shown presented in place of its text,
-- eg. a shorter heading
-- present_map_split a map: a slide per map section (094)
-- present_map_no_list a map: no locations list beside it
-- present_map_no_details a map: no location detail lines
-- present_places a map: which locations get a slide of
-- their own; null every marked one,
-- 'picked' present_place_keys, 'none'
-- present_place_keys the venue's location_keys (088),
-- comma-separated
-- ═══════════════════════════════════════════════════════════════
ALTER TABLE events ADD COLUMN present_background TEXT;
ALTER TABLE events ADD COLUMN present_background_color TEXT;
ALTER TABLE events ADD COLUMN present_dim INTEGER
CHECK (present_dim BETWEEN 0 AND 90);
ALTER TABLE events ADD COLUMN present_frame TEXT
CHECK (present_frame IN ('border', 'none'));
ALTER TABLE events ADD COLUMN present_accent TEXT;
ALTER TABLE events ADD COLUMN present_text_color TEXT;
ALTER TABLE events ADD COLUMN present_logo TEXT;
ALTER TABLE content_blocks ADD COLUMN present_hide INTEGER NOT NULL DEFAULT 0
CHECK (present_hide IN (0, 1));
ALTER TABLE content_blocks ADD COLUMN present_text TEXT;
ALTER TABLE content_blocks ADD COLUMN present_map_split INTEGER NOT NULL DEFAULT 0
CHECK (present_map_split IN (0, 1));
ALTER TABLE content_blocks ADD COLUMN present_map_no_list INTEGER NOT NULL DEFAULT 0
CHECK (present_map_no_list IN (0, 1));
ALTER TABLE content_blocks ADD COLUMN present_map_no_details INTEGER NOT NULL DEFAULT 0
CHECK (present_map_no_details IN (0, 1));
ALTER TABLE content_blocks ADD COLUMN present_places TEXT
CHECK (present_places IN ('picked', 'none'));
ALTER TABLE content_blocks ADD COLUMN present_place_keys TEXT;

View file

@ -0,0 +1,24 @@
-- ═══════════════════════════════════════════════════════════════
-- 096 PRESENTATION SETTINGS IN THE DARK THEME
--
-- The same as 095's, for a screen in the dark theme (the device's
-- setting, or the setup's Theme pick). Each one null takes the
-- light theme's (095), so only what differs needs setting.
--
-- present_background_dark the image behind every slide
-- present_background_color_dark the slides' background color
-- present_dim_dark percent of the color over the
-- image, 0 to 90
-- present_accent_dark in place of the accent
-- present_text_color_dark the slides' text
-- present_logo_dark the bottom-right logo, eg. a
-- light version
-- ═══════════════════════════════════════════════════════════════
ALTER TABLE events ADD COLUMN present_background_dark TEXT;
ALTER TABLE events ADD COLUMN present_background_color_dark TEXT;
ALTER TABLE events ADD COLUMN present_dim_dark INTEGER
CHECK (present_dim_dark BETWEEN 0 AND 90);
ALTER TABLE events ADD COLUMN present_accent_dark TEXT;
ALTER TABLE events ADD COLUMN present_text_color_dark TEXT;
ALTER TABLE events ADD COLUMN present_logo_dark TEXT;

View file

@ -0,0 +1,20 @@
-- ═══════════════════════════════════════════════════════════════
-- 097 PRESENTATION CONTENT INSET
--
-- Room kept clear at each edge of a presented slide, so its content
-- sits inside a background image that is a frame (eg. a 1920x1080
-- picture with a border drawn in it). Percent of the screen: top
-- and bottom of its height, left and right of its width, 0 to 45.
-- Null is 0. With any set, the background image is stretched to the
-- screen rather than cropped, so the frame stays where the inset
-- expects it. Both themes share them.
-- ═══════════════════════════════════════════════════════════════
ALTER TABLE events ADD COLUMN present_inset_top REAL
CHECK (present_inset_top BETWEEN 0 AND 45);
ALTER TABLE events ADD COLUMN present_inset_right REAL
CHECK (present_inset_right BETWEEN 0 AND 45);
ALTER TABLE events ADD COLUMN present_inset_bottom REAL
CHECK (present_inset_bottom BETWEEN 0 AND 45);
ALTER TABLE events ADD COLUMN present_inset_left REAL
CHECK (present_inset_left BETWEEN 0 AND 45);

View file

@ -0,0 +1,18 @@
-- ═══════════════════════════════════════════════════════════════
-- 098 A LIST BLOCK'S PRESENTATION SLIDES
--
-- A list block presented (EventPresent.tsx) is a section's text,
-- unless it has slides of its own:
--
-- present_list_overview one slide of every item's text, without
-- the detail, centered
-- present_list_items a slide per item: its text the heading,
-- its detail under it, centered
--
-- Either or both. Other block types ignore them.
-- ═══════════════════════════════════════════════════════════════
ALTER TABLE content_blocks ADD COLUMN present_list_overview INTEGER NOT NULL DEFAULT 0
CHECK (present_list_overview IN (0, 1));
ALTER TABLE content_blocks ADD COLUMN present_list_items INTEGER NOT NULL DEFAULT 0
CHECK (present_list_items IN (0, 1));

View file

@ -0,0 +1,20 @@
-- ═══════════════════════════════════════════════════════════════
-- 099 WHERE A BLOCK SHOWS: THE PAGE, THE PRESENTATION OR BOTH
--
-- present_hide (095) could only leave a block out of the
-- presentation. present_show says where it shows instead:
--
-- null the page and the presentation
-- 'page' only on the page (was present_hide = 1)
-- 'presentation' only in the presentation (EventPresent.tsx), eg.
-- a slide's welcome line the page doesn't need
--
-- present_hide is copied over, then dropped.
-- ═══════════════════════════════════════════════════════════════
ALTER TABLE content_blocks ADD COLUMN present_show TEXT
CHECK (present_show IN ('page', 'presentation'));
UPDATE content_blocks SET present_show = 'page' WHERE present_hide = 1;
ALTER TABLE content_blocks DROP COLUMN present_hide;

View file

@ -0,0 +1,10 @@
-- ═══════════════════════════════════════════════════════════════
-- 100 A LIST'S SLIDES PICKED WHEN PRESENTING
--
-- A list block's Overview slide and A slide per item (098) are
-- picked on the Present setup screen (EventPresent.tsx, `lists` in
-- its address) rather than on the block, so 098's columns go.
-- ═══════════════════════════════════════════════════════════════
ALTER TABLE content_blocks DROP COLUMN present_list_overview;
ALTER TABLE content_blocks DROP COLUMN present_list_items;

View file

@ -0,0 +1,15 @@
-- ═══════════════════════════════════════════════════════════════
-- 101 AN IMAGE BLOCK'S SIZE
--
-- How wide an image block shows, centered in the column:
--
-- null the column's full width (as before)
-- small up to 20rem
-- medium up to 32rem
-- large up to 48rem
--
-- Never wider than the column. Other block types ignore it.
-- ═══════════════════════════════════════════════════════════════
ALTER TABLE content_blocks ADD COLUMN image_size TEXT
CHECK (image_size IN ('small', 'medium', 'large'));

View file

@ -0,0 +1,13 @@
-- ═══════════════════════════════════════════════════════════════
-- 102 AN IMAGE BLOCK'S DARK THEME PICTURE
--
-- media_dark shown in place of media while the site is in its
-- dark theme (the visitor's setting, or a presentation
-- held dark), eg. a chart or a logo drawn light on
-- dark. Null shows media in both themes.
--
-- Image blocks only; other types ignore it. Its alt text and caption
-- are the block's, so it should show the same thing.
-- ═══════════════════════════════════════════════════════════════
ALTER TABLE content_blocks ADD COLUMN media_dark TEXT;

View file

@ -413,6 +413,9 @@ export function metaFor(db, rawPath, user = null) {
// in particular, so never indexed or in the sitemap. // in particular, so never indexed or in the sitemap.
if (ACCOUNT_PAGES[pathname]) return { ...meta, title: titled(site, ACCOUNT_PAGES[pathname]), noindex: true }; if (ACCOUNT_PAGES[pathname]) return { ...meta, title: titled(site, ACCOUNT_PAGES[pathname]), noindex: true };
// A presenting screen's remote (src/pages/PresentRemote.tsx).
if (/^\/remote(\/|$)/.test(pathname)) return { ...meta, title: titled(site, "Remote"), noindex: true };
// A page of the site (site_pages): hidden is Not found below // A page of the site (site_pages): hidden is Not found below
// viewer; disabled stays out of search. // viewer; disabled stays out of search.
const page = pageAt(db, pathname); const page = pageAt(db, pathname);
@ -426,7 +429,7 @@ export function metaFor(db, rawPath, user = null) {
}; };
} }
// An event's schedule presentation (SchedulePresent.tsx): the // An event page's presentation (EventPresent.tsx): the
// event's own title and preview, kept out of search, pointing // event's own title and preview, kept out of search, pointing
// search engines at the event page. // search engines at the event page.
const present = pathname.match(/^\/events\/([^/]+)\/present$/); const present = pathname.match(/^\/events\/([^/]+)\/present$/);

View file

@ -591,7 +591,42 @@ content.get("/events/:id", (c) => {
citation: r.citation, citation: r.citation,
})); }));
const event = { ...shapeEvent(row, links, cards, hosts), blocks: body, people, awards }; const event = {
...shapeEvent(row, links, cards, hosts),
show_contents: row.show_contents === 1,
links_heading: row.links_heading,
// Its page presented (095).
present: {
background: row.present_background,
background_color: row.present_background_color,
dim: row.present_dim,
frame: row.present_frame,
accent: row.present_accent,
text_color: row.present_text_color,
logo: row.present_logo,
// Room clear at each edge, percent of the screen (097).
inset: [row.present_inset_top, row.present_inset_right, row.present_inset_bottom, row.present_inset_left].some((n) => n)
? {
top: row.present_inset_top ?? 0,
right: row.present_inset_right ?? 0,
bottom: row.present_inset_bottom ?? 0,
left: row.present_inset_left ?? 0,
}
: null,
// In the dark theme (096); null takes the above.
dark: {
background: row.present_background_dark,
background_color: row.present_background_color_dark,
dim: row.present_dim_dark,
accent: row.present_accent_dark,
text_color: row.present_text_color_dark,
logo: row.present_logo_dark,
},
},
blocks: body,
people,
awards,
};
attachTags(db, "event", [event]); attachTags(db, "event", [event]);
return json(c, { event }); return json(c, { event });

View file

@ -0,0 +1,151 @@
/* ═══════════════════════════════════════════════════════════════
PRESENT REMOTE: a phone drives a presenting screen by its code
A screen (src/pages/EventPresent.tsx) opens /present/screen, a
stream that first says its code and key, then carries commands.
It posts what it shows (state) with the key. A remote
(src/pages/PresentRemote.tsx) opens /present/:code, a stream of
that state, and posts commands. Anyone with the code can drive
the screen: the code is the only lock, so it's long enough not to
guess at the rate limit set where this is mounted.
In memory only: one process, and a restart only makes each screen
reconnect (keeping its code when no one took it) and post its
state again. A screen gone for SWEEP_AFTER is forgotten.
═══════════════════════════════════════════════════════════════ */
import { randomBytes, randomInt } from "node:crypto";
import { Hono } from "hono";
import { streamSSE } from "hono/streaming";
const present = new Hono();
// No 0/O, 1/I/L: read off a screen across a room.
const LETTERS = "ABCDEFGHJKMNPQRSTUVWXYZ23456789";
const CODE = /^[A-Z0-9]{6}$/;
const PING_EVERY = 25_000; // under nginx's 60 second read timeout
const SWEEP_AFTER = 10 * 60_000;
const COMMANDS = ["next", "prev", "pause", "resume", "go", "setup", "start"];
// A screen's state before it first says.
const NOTHING_YET = { event: "", title: "", query: "", playing: false, paused: false, index: 0, slides: [] };
// code → { key, state, screen (its stream, or null), gone (ms), remotes (streams) }
const screens = new Map();
setInterval(() => {
const now = Date.now();
for (const [code, s] of screens) {
if (!s.screen && s.remotes.size === 0 && now - s.gone > SWEEP_AFTER) screens.delete(code);
}
}, 60_000).unref();
function newCode() {
for (;;) {
const code = Array.from({ length: 6 }, () => LETTERS[randomInt(LETTERS.length)]).join("");
// SCREEN would be the screen's own stream's address.
if (!screens.has(code) && code !== "SCREEN") return code;
}
}
const send = (stream, event, data) => stream.writeSSE({ event, data: JSON.stringify(data) }).catch(() => {});
function tellRemotes(s) {
for (const remote of s.remotes) send(remote, "state", { connected: !!s.screen, ...s.state });
}
// Holds a stream open, pinging, until the other end goes.
function hold(stream, onGone) {
return new Promise((resolve) => {
const ping = setInterval(() => stream.write(": ping\n\n").catch(() => {}), PING_EVERY);
stream.onAbort(() => {
clearInterval(ping);
onGone();
resolve();
});
});
}
/* A screen's stream. It asks for the code it had (code and key) and
gets it back unless that's wrong or another screen holds it now. */
present.get("/present/screen", (c) => {
let code = c.req.query("code");
const key = c.req.query("key");
let s = screens.get(code);
if (!s || s.key !== key || s.screen) {
code = newCode();
s = { key: randomBytes(16).toString("hex"), state: NOTHING_YET, screen: null, gone: 0, remotes: new Set() };
screens.set(code, s);
}
// Tells nginx to pass each event on as it's written.
c.header("X-Accel-Buffering", "no");
return streamSSE(c, async (stream) => {
s.screen = stream;
await send(stream, "hello", { code, key: s.key });
tellRemotes(s);
await hold(stream, () => {
if (s.screen !== stream) return;
s.screen = null;
s.gone = Date.now();
tellRemotes(s);
});
});
});
/* What the screen shows, for its remotes: shown as text there, so
only capped here. */
present.post("/present/:code/state", async (c) => {
const s = screens.get(c.req.param("code"));
const body = await c.req.json().catch(() => null);
if (!s || !body || body.key !== s.key) return c.json({ error: "Not found" }, 404);
const text = (v, max) => (typeof v === "string" ? v.slice(0, max) : "");
const count = (v) => (Number.isInteger(v) && v >= 0 ? v : 0);
s.state = {
event: text(body.event, 200),
title: text(body.title, 300),
query: text(body.query, 4000),
playing: body.playing === true,
paused: body.paused === true,
index: count(body.index),
slides: Array.isArray(body.slides) ? body.slides.slice(0, 500).map((name) => text(name, 150)) : [],
};
tellRemotes(s);
return c.body(null, 204);
});
// A remote's stream: the screen's state now and each time it changes.
present.get("/present/:code", (c) => {
const s = screens.get(c.req.param("code").toUpperCase());
if (!s) return c.json({ error: "No screen has that code." }, 404);
c.header("X-Accel-Buffering", "no");
return streamSSE(c, async (stream) => {
s.remotes.add(stream);
await send(stream, "state", { connected: !!s.screen, ...s.state });
await hold(stream, () => s.remotes.delete(stream));
});
});
/* A command for the screen: next, prev, pause, resume, go (to
`index`), setup (back to its setup) or start (playing `query`, the
setup's choices as EventPresent's address reads them). */
present.post("/present/:code/command", async (c) => {
const code = c.req.param("code").toUpperCase();
const s = CODE.test(code) ? screens.get(code) : null;
if (!s) return c.json({ error: "No screen has that code." }, 404);
if (!s.screen) return c.json({ error: "The screen isn't connected right now." }, 409);
const body = await c.req.json().catch(() => null);
if (!body || !COMMANDS.includes(body.do)) return c.json({ error: "Unknown command." }, 400);
const command = { do: body.do };
if (body.do === "go") {
if (!Number.isInteger(body.index) || body.index < 0) return c.json({ error: "Which slide?" }, 400);
command.index = body.index;
}
if (body.do === "start") {
if (typeof body.query !== "string" || body.query.length > 4000) return c.json({ error: "That setup is too long." }, 400);
command.query = body.query;
}
await send(s.screen, "command", command);
return c.body(null, 204);
});
export default present;

View file

@ -79,6 +79,7 @@ const MEMBERS = ["showcase-member-1", "showcase-member-2", "showcase-member-3"];
const EVENT = "showcase-event"; const EVENT = "showcase-event";
const SERIES = "showcase-series"; const SERIES = "showcase-series";
const PAST = "showcase-past-event"; const PAST = "showcase-past-event";
const VENUE = "showcase-venue";
/* ── Content ───────────────────────────────────────────────── */ /* ── Content ───────────────────────────────────────────────── */
@ -87,21 +88,24 @@ const PAST = "showcase-past-event";
a description, graphic and map, one linked, a heading, a featured a description, graphic and map, one linked, a heading, a featured
entry, a block with sub-items, a break, typed and picked times, entry, a block with sub-items, a break, typed and picked times,
tags (one a tab of its own in its color, one with No tab), and one tags (one a tab of its own in its color, one with No tab), and one
with no day (it lands in a tab of its own). */ with no day (it lands in a tab of its own). Its venue's locations
(088) are picked on some entries, one with no typed Location, and
one sub-item is the showcase workshop, filled in from it. */
const SCHEDULE = [ const SCHEDULE = [
"schedule", "schedule",
{ text: "The weekend at a glance. Tap an entry for more." }, { text: "The weekend at a glance. Tap an entry for more.", venue_id: VENUE },
[ [
{ day: "Friday", start_time: "16:00", text: "Arrivals and check-in", location: "Front desk", tags: "showcase-youth,showcase-all" }, { day: "Friday", start_time: "16:00", text: "Arrivals and check-in", location: "Front desk", tags: "showcase-youth,showcase-all" },
{ day: "Friday", kind: "heading", text: "Evening", detail: "A heading across the day" }, { day: "Friday", kind: "heading", text: "Evening", detail: "A heading across the day" },
{ 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", map_image: "/uploads/showcase.jpg" }, { day: "Friday", time: "7:00 to 8:30pm", text: "Opening session", location_key: "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", map_image: "/uploads/showcase.jpg" },
{ day: "Saturday", start_time: "08:00", end_time: "09:00", kind: "break", text: "Breakfast", location: "Dining hall" }, { day: "Saturday", start_time: "08:00", end_time: "09:00", kind: "break", text: "Breakfast", location: "Dining hall" },
{ day: "Saturday", start_time: "09:00", end_time: "10:30", kind: "block", text: "Workshops", location: "Classrooms", detail: "Pick one of three", items: [ { day: "Saturday", start_time: "09:00", end_time: "10:30", kind: "block", text: "Workshops", location: "Classrooms", detail: "Pick one of three", items: [
{ start_time: "09:00", end_time: "09:45", text: "Leading worship", location: "Room A", person_id: "showcase-member-2", url: "/blog/content-block-showcase" }, { start_time: "09:00", end_time: "09:45", text: "Leading worship", location: "Room A", location_key: "rooma", person_id: "showcase-member-2", url: "/blog/content-block-showcase" },
{ start_time: "09:00", end_time: "09:45", text: "Showcase Past Workshop", event_id: PAST, location_key: "rooma" },
{ start_time: "09:00", end_time: "09:45", text: "Speaking with confidence", location: "Room B", featured: 1, tags: "showcase-youth", description: "A featured sub-item that folds out." }, { start_time: "09:00", end_time: "09:45", text: "Speaking with confidence", location: "Room B", featured: 1, tags: "showcase-youth", description: "A featured sub-item that folds out." },
{ time: "After the first round", text: "Open questions", location: "Room C" }, { time: "After the first round", text: "Open questions", location: "Room C" },
] }, ] },
{ day: "Saturday", start_time: "19:00", featured: 1, tags: "showcase-youth", text: "Talent night", location: "Main Hall", person_id: "showcase-member-3", description: "Sign up at the front desk by noon." }, { day: "Saturday", start_time: "19:00", featured: 1, tags: "showcase-youth", text: "Talent night", location: "Main Hall", location_key: "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" }, { 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" }, { time: "Any time", text: "Quiet room open", location: "Library", detail: "An entry with no day" },
], ],
@ -141,6 +145,13 @@ const ALL_BLOCKS = [
["image", { media: IMAGE, alt: "The same picture, linked", href: "/history" }], ["image", { media: IMAGE, alt: "The same picture, linked", href: "/history" }],
["subheading", { text: "Schedule" }], ["subheading", { text: "Schedule" }],
SCHEDULE, SCHEDULE,
["subheading", { text: "Map" }],
["map", { venue_id: VENUE }],
["subheading", { text: "Events" }],
["events", {}, [
{ event_id: PAST, text: "Showcase Past Workshop" },
{ event_id: "showcase-event", text: "A card with its own title", detail: "And its own text in place of the event's." },
]],
["subheading", { text: "Video" }], ["subheading", { text: "Video" }],
["video", { href: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", text: "A YouTube video, with its own thumbnail" }], ["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" }], ["video", { href: "https://vimeo.com/76979871", media: IMAGE, text: "A Vimeo video with an uploaded still" }],
@ -255,6 +266,7 @@ tx(db, () => {
db.prepare(`DELETE FROM awards WHERE id LIKE 'showcase-%'`).run(); db.prepare(`DELETE FROM awards WHERE id LIKE 'showcase-%'`).run();
db.prepare(`DELETE FROM affiliations WHERE person_id LIKE 'showcase-%' OR org_id LIKE 'showcase-%'`).run(); db.prepare(`DELETE FROM affiliations WHERE person_id LIKE 'showcase-%' OR org_id LIKE 'showcase-%'`).run();
db.prepare(`DELETE FROM teams WHERE id LIKE 'showcase-%'`).run(); db.prepare(`DELETE FROM teams WHERE id LIKE 'showcase-%'`).run();
db.prepare(`DELETE FROM venues WHERE id LIKE 'showcase-%'`).run();
db.prepare(`DELETE FROM people WHERE id LIKE 'showcase-%'`).run(); db.prepare(`DELETE FROM people WHERE id LIKE 'showcase-%'`).run();
db.prepare(`DELETE FROM organizations WHERE id = ?`).run(GROUP); db.prepare(`DELETE FROM organizations WHERE id = ?`).run(GROUP);
db.prepare(`DELETE FROM organizations WHERE id LIKE 'showcase-%'`).run(); db.prepare(`DELETE FROM organizations WHERE id LIKE 'showcase-%'`).run();
@ -412,7 +424,6 @@ tx(db, () => {
{ kind: "social", platform: "instagram", label: "@showcaseretreat", url: "https://instagram.com/showcaseretreat" }, { kind: "social", platform: "instagram", label: "@showcaseretreat", url: "https://instagram.com/showcaseretreat" },
]); ]);
blocks("event", EVENT, "both", cardText("event")); blocks("event", EVENT, "both", cardText("event"));
blocks("event", EVENT, "body", [...pageBody("event"), ["heading", { text: "Schedule" }], SCHEDULE]);
insert("events", { insert("events", {
id: SERIES, id: SERIES,
@ -458,6 +469,23 @@ tx(db, () => {
insert("event_people", { event_id: PAST, person_id: PERSON, role: "host", is_public: 1, sort_order: 0 }); insert("event_people", { event_id: PAST, person_id: PERSON, role: "host", is_public: 1, sort_order: 0 });
blocks("event", PAST, "card", cardText("past event")); blocks("event", PAST, "card", cardText("past event"));
/* ── Venue (088): a pin, a box and an unmarked location ── */
insert("venues", { id: VENUE, name: "Showcase Retreat Center", address: "123 Example Road, Exampletown PA", map_image: IMAGE });
[
{ location_key: "hall", name: "Main Hall", detail: "Sessions and talent night", x: 30, y: 40 },
{ location_key: "rooma", name: "Room A", detail: "Workshops", x: 55, y: 20, w: 25, h: 30 },
{ location_key: "desk", name: "Front desk", detail: "Not marked on the map" },
].forEach((location, i) => insert("venue_locations", { venue_id: VENUE, sort_order: i, ...location }));
// The retreat's page, after the workshop and venue its schedule names.
blocks("event", EVENT, "body", [
...pageBody("event"),
["heading", { text: "Schedule" }],
SCHEDULE,
["heading", { text: "Map" }],
["map", { venue_id: VENUE }],
]);
/* ── Award ── */ /* ── Award ── */
insert("awards", { insert("awards", {
id: AWARD, id: AWARD,

View file

@ -64,14 +64,32 @@ export function loadLinks(db, ownerKind, ids) {
rather than no key, so the renderer never has to check. rather than no key, so the renderer never has to check.
───────────────────────────────────────────────────────────── */ ───────────────────────────────────────────────────────────── */
export function loadBlocks(db, ownerKind, ids, slot = "body") { /* A block's presentation settings (095), or null with none set. */
function presentOf(row) {
const present = {
// Where it shows (099).
hide: row.present_show === "page",
only: row.present_show === "presentation",
text: row.present_text,
map_split: row.present_map_split === 1,
map_no_list: row.present_map_no_list === 1,
map_no_details: row.present_map_no_details === 1,
places: row.present_places,
place_keys: row.present_place_keys ? row.present_place_keys.split(",").filter(Boolean) : [],
};
return Object.values(present).some((value) => (Array.isArray(value) ? value.length : value)) ? present : null;
}
export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) {
const out = new Map(); const out = new Map();
if (ids.length === 0) return out; if (ids.length === 0) return out;
const blockRows = db const blockRows = db
.prepare( .prepare(
`SELECT id, owner_id, type, text, media, href, alt, cite, captions, team_id, `SELECT id, owner_id, type, text, media, media_dark, href, alt, cite, captions, team_id, venue_id,
word_motion, word_direction, word_seconds word_motion, word_direction, word_seconds, list_style, image_size, org_kind,
present_show, present_text, present_map_split, present_map_no_list,
present_map_no_details, present_places, present_place_keys
FROM content_blocks FROM content_blocks
WHERE owner_kind = ? AND slot IN (?, 'both') AND owner_id IN (${placeholders(ids.length)}) WHERE owner_kind = ? AND slot IN (?, 'both') AND owner_id IN (${placeholders(ids.length)})
ORDER BY owner_id, sort_order`, ORDER BY owner_id, sort_order`,
@ -87,15 +105,22 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
type: row.type, type: row.type,
text: row.text, text: row.text,
media: row.media, media: row.media,
media_dark: row.media_dark,
href: row.href, href: row.href,
alt: row.alt, alt: row.alt,
cite: row.cite, cite: row.cite,
captions: row.captions, captions: row.captions,
team_id: row.team_id, team_id: row.team_id,
venue_id: row.venue_id,
list_style: row.list_style,
image_size: row.image_size,
org_kind: row.org_kind,
// Its rotating words' motion (084), when it has its own. // Its rotating words' motion (084), when it has its own.
words: row.word_motion || row.word_direction || row.word_seconds words: row.word_motion || row.word_direction || row.word_seconds
? { motion: row.word_motion, direction: row.word_direction, seconds: row.word_seconds } ? { motion: row.word_motion, direction: row.word_direction, seconds: row.word_seconds }
: null, : null,
// How it's presented (095), when anything is set.
present: presentOf(row),
items: [], items: [],
}; };
byId.set(row.id, block); byId.set(row.id, block);
@ -109,12 +134,13 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
const ENTRY_FIELDS = `i.text, i.detail, i.url, i.start_time, i.end_time, i.time, i.location, const ENTRY_FIELDS = `i.text, i.detail, i.url, i.start_time, i.end_time, i.time, i.location,
i.description, i.media, i.media_alt, i.map, i.map_image, i.featured, i.tags, i.description, i.media, i.media_alt, i.map, i.map_image, i.featured, i.tags,
i.event_id, i.location_key,
p.id AS person_id, p.display_name AS person_name, p.id AS person_id, p.display_name AS person_name,
p.photo AS person_photo, p.tagline AS person_tagline`; p.photo AS person_photo, p.tagline AS person_tagline`;
const itemRows = db const itemRows = db
.prepare( .prepare(
`SELECT i.id, i.block_id, i.day, i.kind, ${ENTRY_FIELDS} `SELECT i.id, i.block_id, i.day, i.kind, i.heading, i.subheading, i.org_id, ${ENTRY_FIELDS}
FROM content_block_items i FROM content_block_items i
LEFT JOIN v_people_public p ON p.id = i.person_id AND p.is_published = 1 LEFT JOIN v_people_public p ON p.id = i.person_id AND p.is_published = 1
WHERE i.block_id IN (${placeholders(blockIds.length)}) WHERE i.block_id IN (${placeholders(blockIds.length)})
@ -126,7 +152,15 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
// ride along anyway rather than branching on the block's type. // ride along anyway rather than branching on the block's type.
const itemsById = new Map(); const itemsById = new Map();
for (const row of itemRows) { for (const row of itemRows) {
const item = { ...scheduleEntry(row), day: row.day, kind: row.kind ?? "entry", items: [] }; const item = {
...scheduleEntry(row),
day: row.day,
kind: row.kind ?? "entry",
heading: row.heading,
subheading: row.subheading,
org_id: row.org_id,
items: [],
};
itemsById.set(row.id, item); itemsById.set(row.id, item);
byId.get(row.block_id)?.items.push(item); byId.get(row.block_id)?.items.push(item);
} }
@ -172,9 +206,146 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
block.items.forEach(cut); block.items.forEach(cut);
} }
attachVenues(db, [...byId.values()]);
attachEvents(db, [...byId.values()], depth);
// A map block's sections (094): each names some of its venue's
// locations. With any, the block's venue is cut to the locations
// they name, in their order, so the page, its schedule's links
// and the presentation all see the same places, numbered alike.
const sectionRows = db
.prepare(
`SELECT block_id, name, location_keys
FROM content_block_map_sections
WHERE block_id IN (${placeholders(blockIds.length)})
ORDER BY block_id, sort_order`,
)
.all(...blockIds);
for (const row of sectionRows) {
const block = byId.get(row.block_id);
if (!block?.venue) continue;
const known = new Set(block.venue.locations.map((location) => location.key));
const keys = (row.location_keys ?? "").split(",").filter((key) => known.has(key));
if (keys.length) (block.map_sections ??= []).push({ name: row.name, keys });
}
for (const block of byId.values()) {
if (!block.map_sections) continue;
const byKey = new Map(block.venue.locations.map((location) => [location.key, location]));
const shown = [...new Set(block.map_sections.flatMap((section) => section.keys))];
block.venue = { ...block.venue, locations: shown.map((key) => byKey.get(key)) };
}
return out; return out;
} }
/* A map or schedule block's venue (088), its locations in order,
and each entry's location_key made its place on it: `place` is
the location, and the location's name stands in for a blank
typed Location. A key the venue no longer has is dropped. */
function attachVenues(db, blocks) {
const ids = [...new Set(blocks.map((block) => block.venue_id).filter(Boolean))];
if (ids.length === 0) return;
const venues = new Map(
db
.prepare(`SELECT id, name, address, map_image, map_alt FROM venues WHERE id IN (${placeholders(ids.length)})`)
.all(...ids)
.map((row) => [row.id, { ...row, locations: [] }]),
);
const locationRows = db
.prepare(
`SELECT venue_id, location_key AS key, name, detail, x, y, w, h, google_maps_url, apple_maps_url
FROM venue_locations
WHERE venue_id IN (${placeholders(ids.length)})
ORDER BY venue_id, sort_order`,
)
.all(...ids);
for (const { venue_id, ...location } of locationRows) venues.get(venue_id)?.locations.push(location);
for (const block of blocks) {
const venue = venues.get(block.venue_id);
block.venue = venue ?? null;
const place = (entry) => {
const location = venue?.locations.find((l) => l.key === entry.location_key) ?? null;
entry.place = location ? { venue_id: venue.id, key: location.key, name: location.name } : null;
if (location && !entry.location) entry.location = location.name;
entry.items?.forEach(place);
};
block.items.forEach(place);
}
}
/* The events named by items (088): an events block's cards, and a
schedule entry or sub-item that is a workshop, which takes what
it leaves blank from its event: the link, the description (its
card text), the graphic (its photo) and the person (a person
host). An unpublished event is no event.
An events block's event also brings its own page's blocks
(`blocks`), drawn when its card is opened. Only at the top
(`depth` 0): a workshop's blocks don't bring theirs, so two
events listing each other can't go round forever. */
function attachEvents(db, blocks, depth = 0) {
const entries = [];
const walk = (entry) => {
entries.push(entry);
entry.items?.forEach(walk);
};
blocks.forEach((block) => block.items.forEach(walk));
const ids = [...new Set(entries.map((entry) => entry.event_id).filter(Boolean))];
if (ids.length === 0) return;
const rows = db
.prepare(
`SELECT e.id, e.title, e.tagline, e.event_type, e.starts_on, e.ends_on, e.date_label,
e.effective_color AS color, COALESCE(e.card_image, e.photo) AS image, e.photo, e.photo_alt,
e.location_label,
p.id AS person_id, p.display_name AS person_name, p.photo AS person_photo,
p.tagline AS person_tagline
FROM v_events e
LEFT JOIN v_people_public p ON e.host_kind = 'person' AND p.id = e.host_id AND p.is_published = 1
WHERE e.is_published = 1 AND e.id IN (${placeholders(ids.length)})`,
)
.all(...ids);
const cards = loadBlocks(db, "event", rows.map((row) => row.id), "card");
const events = new Map(rows.map((row) => [row.id, row]));
const shown = blocks.filter((block) => block.type === "events").flatMap((block) => block.items);
const shownIds = [...new Set(shown.map((item) => item.event_id).filter((id) => events.has(id)))];
const bodies = depth === 0 && shownIds.length ? loadBlocks(db, "event", shownIds, "body", depth + 1) : new Map();
for (const entry of entries) {
const row = events.get(entry.event_id);
if (!row) {
entry.event = null;
continue;
}
const blurb = paragraphs(cards.get(row.id) ?? []).join("\n\n") || row.tagline || null;
entry.event = {
id: row.id,
title: row.title,
event_type: row.event_type,
starts_on: row.starts_on,
ends_on: row.ends_on,
date_label: row.date_label,
color: row.color,
image: row.image,
photo: row.photo,
photo_alt: row.photo_alt,
location_label: row.location_label,
blurb,
};
if (shown.includes(entry)) entry.event.blocks = bodies.get(row.id) ?? [];
entry.url ||= `/events/${row.id}`;
entry.description ||= blurb;
if (!entry.media && row.image) {
entry.media = row.image;
entry.media_alt = row.photo_alt;
}
if (!entry.person && row.person_id) {
entry.person = { id: row.person_id, name: row.person_name, photo: row.person_photo, tagline: row.person_tagline };
}
}
}
/* A schedule entry or sub-item as the page gets it. `time` is what /* A schedule entry or sub-item as the page gets it. `time` is what
to show: the typed override, else the picked times (086). An to show: the typed override, else the picked times (086). An
unpublished person comes back as no person. */ unpublished person comes back as no person. */
@ -194,6 +365,8 @@ function scheduleEntry(row) {
map_image: row.map_image, map_image: row.map_image,
featured: row.featured === 1, featured: row.featured === 1,
tags: row.tags ? row.tags.split(",").filter(Boolean) : [], tags: row.tags ? row.tags.split(",").filter(Boolean) : [],
event_id: row.event_id,
location_key: row.location_key,
person: row.person_id person: row.person_id
? { ? {
id: row.person_id, id: row.person_id,

View file

@ -67,7 +67,8 @@ const AwardDetail = lazyPage(() => import("./pages/AwardDetail.tsx"))
const PersonDetail = lazyPage(() => import("./pages/PersonDetail.tsx")) const PersonDetail = lazyPage(() => import("./pages/PersonDetail.tsx"))
const BlogPost = lazyPage(() => import("./pages/BlogPost.tsx")) const BlogPost = lazyPage(() => import("./pages/BlogPost.tsx"))
const DirectoryPage = lazyPage(() => import("./pages/DirectoryPage.tsx")) const DirectoryPage = lazyPage(() => import("./pages/DirectoryPage.tsx"))
const SchedulePresent = lazyPage(() => import("./pages/SchedulePresent.tsx")) const EventPresent = lazyPage(() => import("./pages/EventPresent.tsx"))
const PresentRemote = lazyPage(() => import("./pages/PresentRemote.tsx"))
/*Admin Pages*/ /*Admin Pages*/
const AdminLayout = lazyPage(() => import("./pages/admin/AdminLayout.tsx")) const AdminLayout = lazyPage(() => import("./pages/admin/AdminLayout.tsx"))
@ -110,12 +111,21 @@ export default function App() {
{/* Every page of the site: Pages → Page management (PageAtPath). */} {/* Every page of the site: Pages → Page management (PageAtPath). */}
<Route path="*" element={<PageAtPath />} /> <Route path="*" element={<PageAtPath />} />
</Route> </Route>
{/* A schedule as a slideshow for a screen: full screen, no Layout. */} {/* An event page as a slideshow for a screen: full screen, no Layout. */}
<Route <Route
path="/events/:id/present" path="/events/:id/present"
element={ element={
<Suspense fallback={null}> <Suspense fallback={null}>
<SchedulePresent /> <EventPresent />
</Suspense>
}
/>
{/* A phone driving a presenting screen, by its code. */}
<Route
path="/remote/:code?"
element={
<Suspense fallback={null}>
<PresentRemote />
</Suspense> </Suspense>
} }
/> />

View file

@ -30,6 +30,14 @@
people team_id's members as people tiles, then people team_id's members as people tiles, then
items as more tiles: person, text their items as more tiles: person, text their
title (an unpublished person is left out) title (an unpublished person is left out)
map venue: its map, locations marked and
listed (MapBlock); a schedule's places
link to it
events items as event cards: event (from
event_id), text the title shown, detail
in place of the event's card text; a card
opens the event in full under them, its
own page's blocks too (EventsBlock)
divider nothing divider nothing
"Formatted" is InlineText.tsx: **bold**, *italic*, [text](url), "Formatted" is InlineText.tsx: **bold**, *italic*, [text](url),
@ -44,26 +52,38 @@
visible even if the renderer hasn't caught up with it. visible even if the renderer hasn't caught up with it.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
import { CaretDown } from '@phosphor-icons/react'
import { useEffect, useId, useRef, useState } from 'react'
import { Link } from 'react-router-dom'
import { mediaUrl } from '../lib/media.ts' import { mediaUrl } from '../lib/media.ts'
import PeopleTiles from './PeopleTiles.tsx' import PeopleTiles from './PeopleTiles.tsx'
import type { ContentBlock, ContentBlockItem } from '../lib/useContent.ts' import type { ContentBlock, ContentBlockItem, ItemEvent } from '../lib/useContent.ts'
import { Anchor, Inline, Paragraphs, isExternalUrl } from './InlineText.tsx' import { Anchor, Inline, Paragraphs, isExternalUrl } from './InlineText.tsx'
import VideoPlayer from './VideoPlayer.tsx' import VideoPlayer from './VideoPlayer.tsx'
import ScheduleBlock from './ScheduleBlock.tsx' import ScheduleBlock, { Avatar } from './ScheduleBlock.tsx'
import MapBlock, { PageMaps, mapAnchor } from './MapBlock.tsx'
import { eventHref, personHref } from '../lib/hrefs.ts'
import { occurrenceLabel } from '../lib/eventSeries.ts'
import { accentText, BRAND } from '../lib/color.ts' import { accentText, BRAND } from '../lib/color.ts'
import { headingAnchors } from '../lib/contents.ts' import { headingAnchors } from '../lib/contents.ts'
import { SITE_NAME } from '../lib/site.ts' import { SITE_NAME } from '../lib/site.ts'
import { useSmallImage } from '../lib/useSmallImage.ts' import { useSmallImage } from '../lib/useSmallImage.ts'
import { useReadingMode } from '../lib/readingMode.ts' import { useReadingMode } from '../lib/readingMode.ts'
import { WordMotion, Words } from './RotatingWords.tsx' import { WordMotion, Words } from './RotatingWords.tsx'
import OrgListCards, { OrgLogoRow } from '../pages/sections/OrgList-Card.tsx'
import { usePresenting } from '../lib/presenting.ts'
import { useDarkTheme } from '../lib/darkTheme.ts'
const BODY = 'var(--color-muted)' const BODY = 'var(--color-muted)'
/* An image block's Size (101): its widest, centered. */
const IMAGE_SIZE = { small: 'max-w-[20rem]', medium: 'max-w-[32rem]', large: 'max-w-[48rem]' } as const
export default function ContentBlocks({ export default function ContentBlocks({
blocks, blocks,
accent = BRAND, accent = BRAND,
className = '', className = '',
presentAt,
anchorPrefix = '', anchorPrefix = '',
}: { }: {
blocks?: ContentBlock[] | null blocks?: ContentBlock[] | null
@ -71,10 +91,19 @@ export default function ContentBlocks({
className?: string className?: string
/** Put before each heading's id: a blog post's tab (contents.ts, splitTabs). */ /** Put before each heading's id: a blog post's tab (contents.ts, splitTabs). */
anchorPrefix?: string anchorPrefix?: string
/** An event page's presentation route: each schedule gets a Present
* button to it, `?block=<n>` naming which schedule (from 0). */
presentAt?: string
}) { }) {
const presenting = usePresenting()
// Presented, a block shown only on the page is left out, so is a
// divider (a slide has its own edges), and the rest take their
// Presentation text (095, 099); on the page, a block shown only in
// the presentation is.
if (blocks) {
blocks = presenting
? blocks
.filter((block) => !block.present?.hide && block.type !== 'divider')
.map((block) => (block.present?.text ? { ...block, text: block.present.text } : block))
: blocks.filter((block) => !block.present?.only)
}
if (!blocks?.length) return null if (!blocks?.length) return null
// Headings get ids so a post's contents (PostContents) and a shared // Headings get ids so a post's contents (PostContents) and a shared
// link (#getting-there) can point at them. // link (#getting-there) can point at them.
@ -89,12 +118,19 @@ export default function ContentBlocks({
return level return level
}) })
let schedules = 0
const presentHrefs = blocks.map((block) => // The places mapped here, for a schedule's places to link to: a
presentAt && block.type === 'schedule' ? `${presentAt}?block=${schedules++}` : undefined, // map block's venue's locations (only those its sections show).
const maps = new Set(
blocks.flatMap((block) =>
block.type === 'map' && block.venue
? block.venue.locations.map((location) => mapAnchor(block.venue!.id, location.key))
: [],
),
) )
return ( return (
<PageMaps.Provider value={maps}>
<div className={`space-y-6 ${className}`}> <div className={`space-y-6 ${className}`}>
{blocks.map((block, index) => ( {blocks.map((block, index) => (
<WordMotion key={block.id ?? index} settings={block.words}> <WordMotion key={block.id ?? index} settings={block.words}>
@ -103,11 +139,11 @@ export default function ContentBlocks({
accent={accent} accent={accent}
anchor={idAt.get(index)} anchor={idAt.get(index)}
level={levels[index]} level={levels[index]}
presentHref={presentHrefs[index]}
/> />
</WordMotion> </WordMotion>
))} ))}
</div> </div>
</PageMaps.Provider>
) )
} }
@ -144,6 +180,182 @@ function LinkCard({ item }: { item: ContentBlockItem }) {
) )
} }
/* One event card (088): the event's picture, its type and date,
its title (or the item's text) and card text (or the item's
detail); the whole card links to the event. */
/* An event's type and date, eg. workshop · June 14, 2025 (shown
capitalized), or null with neither. */
export function eventLine(event: ItemEvent): string | null {
const when = event.date_label || (event.starts_on ? occurrenceLabel(event.starts_on) : null)
const kind = event.event_type && event.event_type !== 'other' ? event.event_type : null
return [kind, when].filter(Boolean).join(' · ') || null
}
function EventCard({
item,
accent,
open,
panelId,
onToggle,
}: {
item: ContentBlockItem
accent: string
open: boolean
panelId: string
onToggle: () => void
}) {
const event = item.event!
const img = useSmallImage(mediaUrl(event.image))
const color = event.color || accent
const line = eventLine(event)
return (
<button
type="button"
onClick={onToggle}
aria-expanded={open}
aria-controls={panelId}
className="group flex h-full w-full flex-col overflow-hidden border bg-raised text-left shadow-sm transition-shadow hover:shadow-lg"
style={{
borderColor: open ? accent : 'color-mix(in srgb, var(--color-brand) 15%, transparent)',
boxShadow: open ? `inset 0 -4px 0 ${accent}` : undefined,
}}
>
{!img.failed && (
<img src={img.src} alt="" loading="lazy" onError={img.onError} className="aspect-video w-full object-cover" />
)}
<span className="flex flex-1 flex-col gap-1 p-4">
{line && (
<span className="text-xs font-semibold capitalize" style={{ color: accentText(color) }}>
{line}
</span>
)}
<span className="font-display text-base font-bold leading-snug text-ink group-hover:text-link">
{item.text || event.title}
</span>
{(item.detail || event.blurb) && (
<span className="line-clamp-3 text-sm leading-snug text-body">{item.detail || event.blurb}</span>
)}
<span className="mt-auto inline-flex items-center gap-1 pt-2 text-sm font-semibold" style={{ color: accentText(color) }}>
{open ? 'Close' : 'More'}
<CaretDown aria-hidden="true" weight="bold" className={`h-4 w-4 transition-transform ${open ? 'rotate-180' : ''}`} />
</span>
</span>
</button>
)
}
/* An event in full (088): its photo, type and date, title, place and
person host, then its own page's blocks (else its card text), and
a link to its page. */
function EventInFull({ item, accent, level }: { item: ContentBlockItem; accent: string; level: 3 | 4 | 5 }) {
const event = item.event!
const color = event.color || accent
const photo = mediaUrl(event.photo || event.image)
const line = eventLine(event)
const Title = `h${level}` as 'h3'
const blurb = item.detail || event.blurb
return (
<section aria-label={item.text || event.title} className="space-y-6 bg-raised p-6 shadow-md">
{photo && <img src={photo} alt={event.photo_alt ?? ''} loading="lazy" className="aspect-video w-full object-cover" />}
<div>
{line && (
<p className="text-sm font-semibold capitalize" style={{ color: accentText(color) }}>
{line}
</p>
)}
<Title className="text-2xl font-bold text-ink">{item.text || event.title}</Title>
{(event.location_label || item.person) && (
<p className="mt-2 flex flex-wrap items-center gap-x-4 gap-y-2 text-sm text-muted">
{event.location_label && <span>{event.location_label}</span>}
{item.person && (
<Link to={personHref(item.person.id)} className="inline-flex items-center gap-2 hover:underline">
<Avatar person={item.person} size="h-8 w-8" />
{item.person.name}
</Link>
)}
</p>
)}
</div>
{event.blocks?.length ? (
<ContentBlocks blocks={event.blocks} accent={color} anchorPrefix={`${event.id}-`} />
) : blurb ? (
<div className="space-y-3 leading-relaxed" style={{ color: BODY }}>
<Paragraphs text={blurb} accent={color} />
</div>
) : null}
<Anchor href={eventHref(event.id)} className="inline-block text-sm font-semibold underline" style={{ color: accentText(color) }}>
{event.title}: the event's page
</Anchor>
</section>
)
}
/* An events block (088): its events as cards; one opened shows in
full under them, scrolled into view. A featured one (090) is
already open, above the cards, under its own heading and
subheading. Reading mode has them all in full. */
function EventsBlock({ items, accent, level }: { items: ContentBlockItem[]; accent: string; level: 3 | 4 | 5 }) {
const [open, setOpen] = useState<number | null>(null)
const panelId = useId()
const panel = useRef<HTMLDivElement>(null)
const reading = useReadingMode()
useEffect(() => {
if (open != null) panel.current?.scrollIntoView({ behavior: 'smooth', block: 'nearest' })
}, [open])
const featured = reading ? items : items.filter((item) => item.featured)
const cards = reading ? [] : items.filter((item) => !item.featured)
return (
<div className="space-y-6">
{featured.map((item, i) => (
<FeaturedEvent key={i} item={item} accent={accent} level={level} />
))}
{cards.length > 0 && (
<>
<ul className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
{cards.map((item, i) => (
<li key={i}>
<EventCard
item={item}
accent={accent}
open={open === i}
panelId={panelId}
onToggle={() => setOpen(open === i ? null : i)}
/>
</li>
))}
</ul>
<div ref={panel} id={panelId}>
{open != null && cards[open] && <EventInFull item={cards[open]} accent={accent} level={level} />}
</div>
</>
)}
</div>
)
}
/* A featured event: its heading and subheading, if set, then the
event in full, its title a level under the heading. */
function FeaturedEvent({ item, accent, level }: { item: ContentBlockItem; accent: string; level: 3 | 4 | 5 }) {
if (!item.heading && !item.subheading) return <EventInFull item={item} accent={accent} level={level} />
const Heading = `h${level}` as 'h3'
const color = item.event?.color || accent
return (
<div className="space-y-4">
<div>
{item.heading && (
<Heading className="text-2xl font-bold" style={{ color: accentText(color) }}>
{item.heading}
</Heading>
)}
{item.subheading && <p className="mt-1 text-lg text-body">{item.subheading}</p>}
</div>
<EventInFull item={item} accent={accent} level={item.heading ? (Math.min(level + 1, 5) as 3 | 4 | 5) : level} />
</div>
)
}
/* A table block's text as rows of cells: one row per line, cells /* A table block's text as rows of cells: one row per line, cells
split by "|" (a literal bar is "\|"), blank lines skipped. A split by "|" (a literal bar is "\|"), blank lines skipped. A
leading and trailing bar, as in Markdown, is allowed. */ leading and trailing bar, as in Markdown, is allowed. */
@ -175,16 +387,19 @@ function Block({
accent, accent,
anchor, anchor,
level, level,
presentHref,
}: { }: {
block: ContentBlock block: ContentBlock
accent: string accent: string
anchor?: string anchor?: string
level: 3 | 4 | 5 level: 3 | 4 | 5
presentHref?: string
}) { }) {
const text = block.text ?? '' const text = block.text ?? ''
const reading = useReadingMode() const reading = useReadingMode()
// On a screen: links are their text, people and organizations
// just pictures and names (095).
const presenting = usePresenting()
// An image block's dark theme picture (102).
const dark = useDarkTheme()
switch (block.type) { switch (block.type) {
// A blog post's tab marker (BlogPost.tsx splits the post at // A blog post's tab marker (BlogPost.tsx splits the post at
@ -204,7 +419,10 @@ function Block({
</h4> </h4>
) )
case 'list': case 'list': {
// Bold text and a plain detail, unless the block is set Plain
// (092): plain text, gray detail.
const plain = block.list_style === 'plain'
return ( return (
<ul className="space-y-2"> <ul className="space-y-2">
{(block.items ?? []).map((item, index) => ( {(block.items ?? []).map((item, index) => (
@ -212,20 +430,23 @@ function Block({
<span aria-hidden="true" style={{ color: accentText(accent) }}> <span aria-hidden="true" style={{ color: accentText(accent) }}>
• •
</span> </span>
<span style={{ color: BODY }}> <span style={{ color: plain ? BODY : 'var(--color-body)' }}>
{item.url ? ( <span className={plain ? undefined : 'font-bold'}>
<Anchor href={item.url} className="underline" style={{ color: accentText(accent) }}> {item.url && !presenting ? (
{item.text} <Anchor href={item.url} className="underline" style={{ color: accentText(accent) }}>
</Anchor> {item.text}
) : ( </Anchor>
<Inline text={item.text} accent={accent} /> ) : (
)} <Inline text={item.text} accent={accent} />
{item.detail && <span className="opacity-70">: {item.detail}</span>} )}
</span>
{item.detail && <span className={plain ? 'opacity-70' : undefined}>: {item.detail}</span>}
</span> </span>
</li> </li>
))} ))}
</ul> </ul>
) )
}
case 'links': case 'links':
return ( return (
@ -343,7 +564,7 @@ function Block({
) )
case 'image': { case 'image': {
const src = mediaUrl(block.media) const src = mediaUrl((dark && block.media_dark) || block.media)
if (!src) return null if (!src) return null
// The reader leaves out a picture with no alt, and its link with it. // The reader leaves out a picture with no alt, and its link with it.
if (reading && block.href && !block.alt) { if (reading && block.href && !block.alt) {
@ -365,7 +586,7 @@ function Block({
/> />
) )
return ( return (
<figure> <figure className={block.image_size ? `mx-auto ${IMAGE_SIZE[block.image_size]}` : undefined}>
{block.href ? <Anchor href={block.href}>{img}</Anchor> : img} {block.href ? <Anchor href={block.href}>{img}</Anchor> : img}
<Caption text={text} /> <Caption text={text} />
</figure> </figure>
@ -391,10 +612,36 @@ function Block({
tags={block.tags} tags={block.tags}
intro={block.text} intro={block.text}
accent={accent} accent={accent}
presentHref={presentHref}
/> />
) )
case 'map':
if (!block.venue) return null
return <MapBlock venue={block.venue} sections={block.map_sections} accent={accent} />
case 'events': {
const events = (block.items ?? []).filter((item) => item.event)
if (events.length === 0) return null
return <EventsBlock items={events} accent={accent} level={level} />
}
case 'organizations': {
// Picked ones in their order, else every listed one of its kind.
const ids = (block.items ?? []).map((item) => item.org_id).filter((id): id is string => Boolean(id))
if (ids.length === 0 && !block.org_kind) return null
if (presenting) return <OrgLogoRow kind={block.org_kind} ids={ids} accent={accent} />
return (
<OrgListCards
kind={block.org_kind}
ids={ids}
accent={accent}
pageLabel="Their page"
empty="Organizations coming soon."
nested
/>
)
}
case 'people': { case 'people': {
const picked = (block.items ?? []) const picked = (block.items ?? [])
.filter((item) => item.person) .filter((item) => item.person)
@ -402,8 +649,8 @@ function Block({
if (!block.team_id && picked.length === 0) return null if (!block.team_id && picked.length === 0) return null
return ( return (
<div className="space-y-6"> <div className="space-y-6">
{block.team_id && <PeopleTiles size="lg" teams={block.team_id} accent={accent} headingLevel={level} />} {block.team_id && <PeopleTiles size="lg" teams={block.team_id} accent={accent} headingLevel={level} row={presenting} titles={block.present?.titles} />}
{picked.length > 0 && <PeopleTiles size="lg" people={picked} accent={accent} headingLevel={level} />} {picked.length > 0 && <PeopleTiles size="lg" people={picked} accent={accent} headingLevel={level} row={presenting} titles={block.present?.titles} />}
</div> </div>
) )
} }
@ -414,7 +661,7 @@ function Block({
case 'paragraph': case 'paragraph':
default: default:
if (!text) return null if (!text) return null
return block.href ? ( return block.href && !presenting ? (
<p className="leading-relaxed" style={{ color: BODY }}> <p className="leading-relaxed" style={{ color: BODY }}>
<Anchor href={block.href} className="underline" style={{ color: accentText(accent) }}> <Anchor href={block.href} className="underline" style={{ color: accentText(accent) }}>
{text} {text}

View file

@ -22,6 +22,7 @@ import { Fragment, type CSSProperties, type ReactNode } from 'react'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import { accentText } from '../lib/color.ts' import { accentText } from '../lib/color.ts'
import { RotatingWords } from './RotatingWords.tsx' import { RotatingWords } from './RotatingWords.tsx'
import { usePresenting } from '../lib/presenting.ts'
const TOKEN = /\*\*(.+?)\*\*|\*(.+?)\*|\[([^\]]+)\]\(([^)\s]+)\)|\{([^{}|\n]+(?:\|[^{}|\n]+)+)\}/g const TOKEN = /\*\*(.+?)\*\*|\*(.+?)\*|\[([^\]]+)\]\(([^)\s]+)\)|\{([^{}|\n]+(?:\|[^{}|\n]+)+)\}/g
const SAFE_URL = /^(\/(?!\/)|#|https?:\/\/|mailto:|tel:)/i const SAFE_URL = /^(\/(?!\/)|#|https?:\/\/|mailto:|tel:)/i
@ -77,7 +78,8 @@ export function Anchor({
) )
} }
function line(text: string, accent: string, key: string): ReactNode[] { /* `plain`: a link's text alone, presented (095). */
function line(text: string, accent: string, key: string, plain = false): ReactNode[] {
const out: ReactNode[] = [] const out: ReactNode[] = []
let last = 0 let last = 0
let n = 0 let n = 0
@ -89,6 +91,7 @@ function line(text: string, accent: string, key: string): ReactNode[] {
if (words != null) out.push(<RotatingWords key={k} words={words.split('|').map((word) => word.trim())} />) if (words != null) out.push(<RotatingWords key={k} words={words.split('|').map((word) => word.trim())} />)
else if (bold != null) out.push(<strong key={k} className="font-semibold">{bold}</strong>) else if (bold != null) out.push(<strong key={k} className="font-semibold">{bold}</strong>)
else if (italic != null) out.push(<em key={k}>{italic}</em>) else if (italic != null) out.push(<em key={k}>{italic}</em>)
else if (label != null && plain) out.push(label)
else if (label != null && SAFE_URL.test(url)) { else if (label != null && SAFE_URL.test(url)) {
out.push( out.push(
<Anchor key={k} href={url} className="underline underline-offset-2" style={{ color: accentText(accent) }}> <Anchor key={k} href={url} className="underline underline-offset-2" style={{ color: accentText(accent) }}>
@ -104,13 +107,14 @@ function line(text: string, accent: string, key: string): ReactNode[] {
/** Text inside another element: formatting and line breaks. */ /** Text inside another element: formatting and line breaks. */
export function Inline({ text, accent }: { text?: string | null; accent: string }) { export function Inline({ text, accent }: { text?: string | null; accent: string }) {
const plain = usePresenting()
const lines = (text ?? '').split('\n') const lines = (text ?? '').split('\n')
return ( return (
<> <>
{lines.map((part, i) => ( {lines.map((part, i) => (
<Fragment key={i}> <Fragment key={i}>
{i > 0 && <br />} {i > 0 && <br />}
{line(part, accent, `l${i}`)} {line(part, accent, `l${i}`, plain)}
</Fragment> </Fragment>
))} ))}
</> </>

372
src/components/MapBlock.tsx Normal file
View file

@ -0,0 +1,372 @@
/* ═══════════════════════════════════════════════════════════════
MAP BLOCK
The 'map' content block (088): a venue's map picture with its
locations marked on it, each a numbered pin or a box, and the
locations listed beside it (under it on a phone).
One picture, the marks drawn over it in percent of its size, so
they stay on their places at any width. A location is lit up
(in the accent, the rest dimmed) while its row or mark is hovered
or focused, and when the address points at it: #map-<venue>-<key>,
the link a schedule entry's place makes (mapAnchor). Those ids
sit at the block's top, so Layout's jump to the anchor brings the
whole map into view, not the mark at the top of the screen.
The picture zooms (the buttons over it), scrolling inside its box
when it's bigger than it; the marks are in percent, so they keep
their places. A location's Google and Apple Maps links (091) are
buttons at the right of its row.
MapPicture is the picture and its marks alone; the event's
presentation (EventPresent.tsx) draws it too, with no links.
Reading mode (readingMode.ts) gets the list alone, no picture.
A block's own sections (094), eg. Main spaces, group the list
under their names; the API has already cut the venue to the
locations they hold. Buttons over the list (All, then one per
section) show one section alone, its marks on the map and its
rows in the list. A link to a location outside the section in
view goes back to All.
PageMaps holds the locations mapped by the blocks drawn together
(their anchors, ContentBlocks), so a schedule's places link only
when there's a map on the page showing them.
═══════════════════════════════════════════════════════════════ */
import { createContext, useEffect, useState, type CSSProperties, type ReactNode } from 'react'
import { AppleLogo, ArrowsIn, GoogleLogo, MagnifyingGlassMinus, MagnifyingGlassPlus } from '@phosphor-icons/react'
import { Link, useLocation, type To } from 'react-router-dom'
import { mediaUrl } from '../lib/media.ts'
import type { MapSection, Venue, VenueLocation } from '../lib/useContent.ts'
import { accentText, readableOn, withAlpha } from '../lib/color.ts'
import { useReadingMode } from '../lib/readingMode.ts'
export const PageMaps = createContext<Set<string>>(new Set())
export const mapAnchor = (venueId: string, key: string) => `map-${venueId}-${key}`
/* The picture's zoom steps, 1 the column's width. */
const ZOOMS = [1, 1.5, 2, 3, 4]
const isBox = (location: VenueLocation) => location.w != null && location.h != null
export const isMarked = (location: VenueLocation) => location.x != null && location.y != null
/* A location's number on the map and in the list: its place in the
venue's order. */
export const locationNumber = (venue: Venue, location: VenueLocation) => venue.locations.indexOf(location) + 1
/* A location's numbered dot, in the accent. */
export function LocationNumber({
n,
accent,
className = 'h-6 w-6 text-xs',
style,
}: {
n: number
accent: string
className?: string
style?: CSSProperties
}) {
return (
<span
aria-hidden="true"
className={`flex shrink-0 items-center justify-center rounded-full font-bold ${className}`}
style={{ background: accent, color: readableOn(accent.startsWith('#') ? accent : '#000000'), ...style }}
>
{n}
</span>
)
}
/* The venue's picture with its marks, `active` lit up. With `link`
each mark is a link (and `light` its hover and focus); without,
the marks are only drawn. `className` sizes the picture's box. */
export function MapPicture({
venue,
accent,
active,
link,
light,
className = '',
big = false,
only,
}: {
venue: Venue
accent: string
active: string | null
/** Marks only these locations' keys; all when unset. */
only?: Set<string>
link?: (key: string) => To
light?: (key: string) => object
className?: string
/** Bigger marks, for a screen across a room. */
big?: boolean
}) {
const image = mediaUrl(venue.map_image)
if (!image) return null
return (
<div className={`relative ${className}`}>
<img src={image} alt={venue.map_alt || `Map of ${venue.name}`} className="block w-full" />
{venue.locations.filter((location) => isMarked(location) && (!only || only.has(location.key))).map((location) => {
const on = active === location.key
const dim = active != null && !on
const style: CSSProperties = isBox(location)
? {
left: `${location.x}%`,
top: `${location.y}%`,
width: `${location.w}%`,
height: `${location.h}%`,
border: `${big ? 4 : 2}px solid ${accent}`,
background: withAlpha(accent, on ? 35 : 12),
opacity: dim ? 0.35 : 1,
}
: {
left: `${location.x}%`,
top: `${location.y}%`,
transform: 'translate(-50%, -50%)',
opacity: dim ? 0.35 : 1,
zIndex: on ? 1 : undefined,
}
const dot = big
? isBox(location)
? 'absolute top-[0.5vw] left-[0.5vw] h-[2.6vw] w-[2.6vw] text-[1.3vw]'
: on
? 'h-[4vw] w-[4vw] text-[2vw]'
: 'h-[2.8vw] w-[2.8vw] text-[1.4vw]'
: isBox(location)
? 'absolute top-1 left-1 h-6 w-6 text-xs'
: on
? 'h-9 w-9 text-xs'
: 'h-7 w-7 text-xs'
const inside = (
<>
<LocationNumber
n={locationNumber(venue, location)}
accent={accent}
className={`shadow ${dot}`}
style={on ? { outline: `${big ? 4 : 3}px solid white` } : undefined}
/>
{on && !big && (
<span
aria-hidden="true"
className="absolute top-full left-1/2 mt-1 -translate-x-1/2 whitespace-nowrap bg-raised px-2 py-0.5 text-xs font-semibold text-ink shadow"
>
{location.name}
</span>
)}
</>
)
return link ? (
<Link
key={location.key}
to={link(location.key)}
aria-label={location.name}
{...light?.(location.key)}
className="absolute transition-opacity"
style={style}
>
{inside}
</Link>
) : (
<span key={location.key} aria-hidden="true" className="absolute transition-opacity duration-500" style={style}>
{inside}
</span>
)
})}
</div>
)
}
export default function MapBlock({
venue,
sections = [],
accent,
}: {
venue: Venue
sections?: MapSection[]
accent: string
}) {
const { hash, search } = useLocation()
const [hovered, setHovered] = useState<string | null>(null)
const [zoom, setZoom] = useState(0)
// The section in view, by index; null is All.
const [view, setView] = useState<number | null>(null)
const fromHash = venue.locations.find((location) => hash === `#${mapAnchor(venue.id, location.key)}`)?.key ?? null
const viewed = view != null ? sections[view] : undefined
// A link to a place outside the section in view shows All again.
useEffect(() => {
if (fromHash && viewed && !viewed.keys.includes(fromHash)) setView(null)
}, [fromHash, viewed])
const byKey = new Map(venue.locations.map((location) => [location.key, location]))
const groups: { name?: string; locations: VenueLocation[] }[] = sections.length
? (viewed ? [viewed] : sections).map((section) => ({
name: section.name,
locations: section.keys.flatMap((key) => byKey.get(key) ?? []),
}))
: [{ locations: venue.locations }]
const only = viewed ? new Set(viewed.keys) : undefined
const active = hovered ?? fromHash
const picture = !useReadingMode() && Boolean(venue.map_image)
const to = (key: string) => ({ search, hash: mapAnchor(venue.id, key) })
const light = (key: string) => ({
onMouseEnter: () => setHovered(key),
onMouseLeave: () => setHovered(null),
onFocus: () => setHovered(key),
onBlur: () => setHovered(null),
})
return (
<figure className="relative grid gap-6 md:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]">
{/* Where a link to a location lands: the map's top. */}
{venue.locations.map((location) => (
<span key={location.key} id={mapAnchor(venue.id, location.key)} className="absolute top-0 left-0" />
))}
{picture && (
<div className="relative self-start">
<div className="max-h-[80vh] overflow-auto border border-brand/15">
<div style={{ width: `${ZOOMS[zoom] * 100}%` }}>
<MapPicture venue={venue} accent={accent} active={active} link={to} light={light} only={only} />
</div>
</div>
<div className="absolute top-2 right-2 flex gap-1">
<ZoomButton label="Zoom in" disabled={zoom === ZOOMS.length - 1} onClick={() => setZoom(zoom + 1)}>
<MagnifyingGlassPlus weight="bold" className="h-5 w-5" />
</ZoomButton>
<ZoomButton label="Zoom out" disabled={zoom === 0} onClick={() => setZoom(zoom - 1)}>
<MagnifyingGlassMinus weight="bold" className="h-5 w-5" />
</ZoomButton>
{zoom > 0 && (
<ZoomButton label="Fit the map" onClick={() => setZoom(0)}>
<ArrowsIn weight="bold" className="h-5 w-5" />
</ZoomButton>
)}
</div>
</div>
)}
<figcaption className={picture ? '' : 'md:col-span-2'}>
<p className="font-display font-bold text-ink">{venue.name}</p>
{venue.address && <p className="text-sm text-muted">{venue.address}</p>}
{sections.length > 1 && (
<div role="group" aria-label="Show" className="mt-3 flex flex-wrap gap-2">
{[null, ...sections.map((_, i) => i)].map((i) => {
const selected = view === i
return (
<button
key={i ?? 'all'}
type="button"
aria-pressed={selected}
onClick={() => setView(i)}
className="btn border px-3 py-1 text-xs transition-colors"
style={
selected
? { background: accent, borderColor: accent, color: readableOn(accent) }
: { borderColor: withAlpha(accent, 33), color: accentText(accent) }
}
>
{i == null ? 'All' : sections[i].name}
</button>
)
})}
</div>
)}
{groups.map((group, g) => (
<div key={group.name ?? g} className="mt-3">
{group.name && <p className="px-2 text-sm font-bold text-ink">{group.name}</p>}
<ol className="mt-1 space-y-1">
{group.locations.map((location) => {
const on = active === location.key
const row = (
<>
<LocationNumber n={locationNumber(venue, location)} accent={accent} />
<span className="min-w-0">
<span className="block font-semibold" style={on ? { color: accentText(accent) } : undefined}>
{location.name}
</span>
{location.detail && <span className="block text-sm text-muted">{location.detail}</span>}
</span>
</>
)
const rowClass = 'flex items-start gap-3 px-2 py-1.5 text-body'
const rowStyle = on ? { background: withAlpha(accent, 12) } : undefined
return (
<li key={location.key} className="flex items-start gap-2">
{isMarked(location) ? (
<Link to={to(location.key)} {...light(location.key)} className={`${rowClass} flex-1`} style={rowStyle}>
{row}
</Link>
) : (
<div className={`${rowClass} flex-1`}>{row}</div>
)}
<MapLinks location={location} accent={accent} />
</li>
)
})}
</ol>
</div>
))}
</figcaption>
</figure>
)
}
/* A zoom button over the map picture. */
function ZoomButton({
label,
disabled,
onClick,
children,
}: {
label: string
disabled?: boolean
onClick: () => void
children: ReactNode
}) {
return (
<button
type="button"
aria-label={label}
title={label}
disabled={disabled}
onClick={onClick}
className="btn flex h-9 w-9 items-center justify-center bg-raised text-ink shadow transition-colors hover:text-link disabled:opacity-40"
>
{children}
</button>
)
}
/* A location's Google and Apple Maps links (091), as buttons that
open them in a new tab. */
function MapLinks({ location, accent }: { location: VenueLocation; accent: string }) {
const links = [
{ href: location.google_maps_url, label: 'Google Maps', Icon: GoogleLogo },
{ href: location.apple_maps_url, label: 'Apple Maps', Icon: AppleLogo },
].filter((link) => link.href)
if (links.length === 0) return null
return (
<span className="flex shrink-0 gap-1 py-1.5">
{links.map(({ href, label, Icon }) => (
<a
key={label}
href={href!}
target="_blank"
rel="noreferrer"
aria-label={`${location.name} in ${label} (opens in a new tab)`}
title={label}
className="btn flex h-8 w-8 items-center justify-center border transition-colors hover:bg-tint"
style={{ borderColor: withAlpha(accent, 33), color: accentText(accent) }}
>
<Icon weight="bold" className="h-4 w-4" aria-hidden="true" />
</a>
))}
</span>
)
}

View file

@ -165,6 +165,10 @@ export interface PeopleTilesProps
/** The group labels' heading level, by what they sit under (3 under /** The group labels' heading level, by what they sit under (3 under
* a section's h2). In reading mode the names are one level under. */ * a section's h2). In reading mode the names are one level under. */
headingLevel?: 3 | 4 | 5; headingLevel?: 3 | 4 | 5;
/** Just round photos and names in a row, as presented (095). */
row?: boolean;
/** In the row, each one's role or title under their name. */
titles?: boolean;
/** How long a fetched team or person is reused, in ms. */ /** How long a fetched team or person is reused, in ms. */
ttl?: number; ttl?: number;
emptyMessage?: string; emptyMessage?: string;
@ -195,8 +199,14 @@ export default function PeopleTiles({
ttl = 5 * 60_000, ttl = 5 * 60_000,
loadingMessage = "Loading…", loadingMessage = "Loading…",
errorMessage = "Couldn't load this list right now.", errorMessage = "Couldn't load this list right now.",
row = false,
titles = false,
...view ...view
}: PeopleTilesProps) { }: PeopleTilesProps) {
const View = useMemo(
() => (row ? (props) => <PeopleRow {...props} titles={titles} /> : PeopleTilesView),
[row, titles],
);
const specs = useMemo(() => normalizeTeams(teams), [teams]); const specs = useMemo(() => normalizeTeams(teams), [teams]);
const teamKey = specs.map((spec) => spec.id).join(","); const teamKey = specs.map((spec) => spec.id).join(",");
@ -278,14 +288,14 @@ export default function PeopleTiles({
if (specs.length) { if (specs.length) {
if (failed) return <p className="pl__empty">{errorMessage}</p>; if (failed) return <p className="pl__empty">{errorMessage}</p>;
if (!teamGroups) return <p className="pl__empty">{loadingMessage}</p>; if (!teamGroups) return <p className="pl__empty">{loadingMessage}</p>;
return <PeopleTilesView {...view} groups={teamGroups} />; return <View {...view} groups={teamGroups} />;
} }
if (slugKey) { if (slugKey) {
if (failed) return <p className="pl__empty">{errorMessage}</p>; if (failed) return <p className="pl__empty">{errorMessage}</p>;
if (!directory) return <p className="pl__empty">{loadingMessage}</p>; if (!directory) return <p className="pl__empty">{loadingMessage}</p>;
return ( return (
<PeopleTilesView <View
{...view} {...view}
groups={groups?.map((group) => ({ groups={groups?.map((group) => ({
...group, ...group,
@ -297,7 +307,7 @@ export default function PeopleTiles({
} }
return ( return (
<PeopleTilesView <View
{...view} {...view}
groups={groups as PeopleGroup[] | undefined} groups={groups as PeopleGroup[] | undefined}
people={people as Person[] | undefined} people={people as Person[] | undefined}
@ -768,6 +778,25 @@ function Tile({
); );
} }
/* Everyone in the groups, then the people, as round photos over
their names, left to right: a people block presented (095). */
function PeopleRow({ groups, people, titles = false }: { groups?: PeopleGroup[]; people?: Person[]; titles?: boolean }) {
const everyone = [...(groups ?? []).flatMap((group) => group.people), ...(people ?? [])];
return (
<ul className="flex flex-wrap justify-center gap-6">
{everyone.map((person, i) => (
<li key={person.id ?? i} className="flex w-28 flex-col items-center text-center">
<span className="block h-24 w-24 overflow-hidden rounded-full">
<Photo src={mediaUrl(person.photo)} name={person.name} />
</span>
<span className="mt-2 text-sm font-semibold leading-tight text-ink">{person.name}</span>
{titles && person.title && <span className="mt-0.5 text-xs leading-tight text-muted">{person.title}</span>}
</li>
))}
</ul>
);
}
function Photo({ src, name }: { src?: string | null; name: string }) { function Photo({ src, name }: { src?: string | null; name: string }) {
const img = useSmallImage(src); const img = useSmallImage(src);

View file

@ -28,12 +28,18 @@
Tags (087) are the block's own: an entry or sub-item shows its Tags (087) are the block's own: an entry or sub-item shows its
tags as chips, and each tag (unless it's set No tab) is a tab tags as chips, and each tag (unless it's set No tab) is a tab
after the days, gathering what it's on from every day under the in a row of its own under the days, with a note saying what it
day's name. A tagged entry comes whole; an untagged block comes does, gathering what it's on from every day under the day's name. A tagged entry comes whole; an untagged block comes
with only its tagged sub-items. A tag on nothing draws no tab. with only its tagged sub-items. A tag on nothing draws no tab.
On an event page a Present button opens the schedule as a An entry's place on the block's venue (088) links to the map
slideshow for a screen (SchedulePresent.tsx). block on the same page, the location lit up there (MapBlock);
with no map of that venue on the page it's plain text. An entry
that is an event (a workshop) has already taken what it left
blank from it (shape.js).
The event page's Present button shows it, with the rest of the
page, as a slideshow for a screen (EventPresent.tsx).
Tabs follow the ARIA tab pattern: arrow keys move between them. Tabs follow the ARIA tab pattern: arrow keys move between them.
@ -42,9 +48,9 @@
it, no map frame (ReadingSchedule). it, no map frame (ReadingSchedule).
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
import { CaretDown, Presentation, Star } from '@phosphor-icons/react' import { CaretDown, MapPin, Star, Tag as TagIcon } from '@phosphor-icons/react'
import { Fragment, createContext, useContext, useId, useState, type KeyboardEvent, type ReactNode } from 'react' import { Fragment, createContext, useContext, useId, useState, type KeyboardEvent, type ReactNode } from 'react'
import { Link } from 'react-router-dom' import { Link, useLocation } from 'react-router-dom'
import { personHref } from '../lib/hrefs.ts' import { personHref } from '../lib/hrefs.ts'
import { mediaUrl, initials } from '../lib/media.ts' import { mediaUrl, initials } from '../lib/media.ts'
@ -54,6 +60,7 @@ import { withAlpha, accentText, readableOn } from '../lib/color.ts'
import { useSmallImage } from '../lib/useSmallImage.ts' import { useSmallImage } from '../lib/useSmallImage.ts'
import { focusOnMount } from '../lib/focus.ts' import { focusOnMount } from '../lib/focus.ts'
import { useReadingMode } from '../lib/readingMode.ts' import { useReadingMode } from '../lib/readingMode.ts'
import { PageMaps, mapAnchor } from './MapBlock.tsx'
const BODY = 'var(--color-muted)' const BODY = 'var(--color-muted)'
const WEEKDAYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'] const WEEKDAYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
@ -136,6 +143,26 @@ function todayIndex(days: Day[]): number {
return found >= 0 ? found : 0 return found >= 0 ? found : 0
} }
/* An entry's location, linked to its place on a map block on the
page when there is one (088). */
function Place({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
const maps = useContext(PageMaps)
const { search } = useLocation()
if (!entry.location) return null
if (!entry.place || !maps.has(mapAnchor(entry.place.venue_id, entry.place.key))) return <span>{entry.location}</span>
return (
<Link
to={{ search, hash: mapAnchor(entry.place.venue_id, entry.place.key) }}
className="inline-flex items-center gap-1 underline-offset-2 hover:underline"
style={{ color: accentText(accent) }}
>
<MapPin aria-hidden="true" weight="bold" className="h-4 w-4 shrink-0" />
{entry.location}
<span className="sr-only">, on the map</span>
</Link>
)
}
/* An entry's own map image says what it maps. */ /* An entry's own map image says what it maps. */
export const mapAlt = (entry: ContentBlockItem) => `Map: ${entry.map?.trim() || entry.location || entry.text}` export const mapAlt = (entry: ContentBlockItem) => `Map: ${entry.map?.trim() || entry.location || entry.text}`
@ -240,7 +267,7 @@ function Entry({ entry, accent, sub = false }: { entry: ContentBlockItem; accent
</p> </p>
{(entry.location || entry.person) && ( {(entry.location || entry.person) && (
<p className="mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-sm" style={{ color: BODY }}> <p className="mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-sm" style={{ color: BODY }}>
{entry.location && <span>{entry.location}</span>} <Place entry={entry} accent={accent} />
{entry.person && ( {entry.person && (
<span className="inline-flex items-center gap-2"> <span className="inline-flex items-center gap-2">
<Avatar person={entry.person} size="h-6 w-6" /> <Avatar person={entry.person} size="h-6 w-6" />
@ -448,14 +475,11 @@ export default function ScheduleBlock({
tags = [], tags = [],
intro, intro,
accent, accent,
presentHref,
}: { }: {
items: ContentBlockItem[] items: ContentBlockItem[]
tags?: ScheduleTag[] tags?: ScheduleTag[]
intro?: string | null intro?: string | null
accent: string accent: string
/** Where the Present button goes; no button without it. */
presentHref?: string
}) { }) {
const days = groupByDay(items) const days = groupByDay(items)
const [active, setActive] = useState(() => todayIndex(days)) const [active, setActive] = useState(() => todayIndex(days))
@ -472,9 +496,41 @@ export default function ScheduleBlock({
.map((tag) => ({ label: tag.name, days: daysWithTag(days, tag.key), color: tag.color, tag: true })) .map((tag) => ({ label: tag.name, days: daysWithTag(days, tag.key), color: tag.color, tag: true }))
.filter((tab) => tab.days.length), .filter((tab) => tab.days.length),
] ]
const dayCount = days.length
const at = Math.min(active, tabs.length - 1) const at = Math.min(active, tabs.length - 1)
const current = tabs[at] const current = tabs[at]
// A day's tab, or a tag's: smaller, its tag icon in front.
const tabButton = (tab: Tab, index: number) => {
const selected = index === at
const color = tab.color || accent
return (
<button
key={index}
id={`${baseId}-tab-${index}`}
type="button"
role="tab"
aria-selected={selected}
aria-controls={`${baseId}-panel`}
tabIndex={selected ? 0 : -1}
onClick={() => setActive(index)}
onKeyDown={onKey}
className={
'btn inline-flex items-center gap-1.5 border transition-colors ' +
(tab.tag ? 'px-3 py-1 text-xs' : 'px-5 py-2 text-sm')
}
style={
selected
? { background: color, borderColor: color, color: readableOn(color) }
: { borderColor: withAlpha(color, 33), color: accentText(color) }
}
>
{tab.tag && <TagIcon aria-hidden="true" weight="bold" className="h-3.5 w-3.5" />}
{tab.label}
</button>
)
}
// Arrows move one tab and wrap; Home and End jump to the ends. // Arrows move one tab and wrap; Home and End jump to the ends.
const onKey = (e: KeyboardEvent<HTMLButtonElement>) => { const onKey = (e: KeyboardEvent<HTMLButtonElement>) => {
const last = tabs.length - 1 const last = tabs.length - 1
@ -499,48 +555,29 @@ export default function ScheduleBlock({
</div> </div>
)} )}
{presentHref && (
<div className="flex justify-end">
<Link
to={presentHref}
target="_blank"
className="btn inline-flex items-center gap-2 border px-4 py-2 text-sm transition-colors hover:bg-tint"
style={{ borderColor: `${withAlpha(accent, 33)}`, color: accentText(accent) }}
>
<Presentation aria-hidden="true" weight="bold" className="h-4 w-4" />
Present
<span className="sr-only">(opens in a new tab)</span>
</Link>
</div>
)}
{tabs.length > 1 && ( {tabs.length > 1 && (
<div role="tablist" aria-label="Days and tags" className="flex flex-wrap gap-2"> <div className="space-y-3">
{tabs.map((tab, index) => { {/* Days, then the tags in a row of their own: one tablist,
const selected = index === at so the arrow keys still walk every tab. */}
const color = tab.color || accent <div role="tablist" aria-label="Days and tags" className="space-y-3">
return ( <div role="presentation" className="flex flex-wrap gap-2">
<button {tabs.slice(0, dayCount).map((tab, index) => tabButton(tab, index))}
key={index} </div>
id={`${baseId}-tab-${index}`} {tabs.length > dayCount && (
type="button" <div role="presentation" className="flex flex-wrap items-center gap-2 border-t border-brand/15 pt-3">
role="tab" <span aria-hidden="true" className="mr-1 inline-flex items-center gap-1.5 text-sm font-semibold text-ink">
aria-selected={selected} <TagIcon weight="bold" className="h-4 w-4" />
aria-controls={`${baseId}-panel`} By tag
tabIndex={selected ? 0 : -1} </span>
onClick={() => setActive(index)} {tabs.slice(dayCount).map((tab, i) => tabButton(tab, dayCount + i))}
onKeyDown={onKey} </div>
className="btn border px-5 py-2 text-sm transition-colors" )}
style={ </div>
selected {tabs.length > dayCount && (
? { background: color, borderColor: color, color: readableOn(color) } <p className="text-sm text-muted">
: { borderColor: `${withAlpha(color, 33)}`, color: accentText(color) } Pick a tag to see everything it's on, from every day.
} </p>
> )}
{tab.label}
</button>
)
})}
</div> </div>
)} )}

View file

@ -0,0 +1,130 @@
/* A venue location's mark on the venue's map (088), for the
`mapMarker` widget (fields.tsx): click the picture for a pin, drag
for a box. Saved as x, y (and w, h for a box) in percent of the
picture from its top left, one decimal, through onPatch. The
numbers under it set the same thing by keyboard. */
import { useRef, useState, type PointerEvent } from "react";
type Mark = { x: number | null; y: number | null; w: number | null; h: number | null };
const round = (n: number) => Math.round(Math.min(100, Math.max(0, n)) * 10) / 10;
// Moved less than this (percent) between press and release: a click.
const CLICK = 1.5;
export default function MapMarkerInput({ image, row, locked, onPatch }: any) {
const box = useRef<HTMLDivElement>(null);
const [drag, setDrag] = useState<{ x0: number; y0: number; x1: number; y1: number } | null>(null);
const mark: Mark = { x: row.x ?? null, y: row.y ?? null, w: row.w ?? null, h: row.h ?? null };
const at = (e: PointerEvent) => {
const r = box.current!.getBoundingClientRect();
return { x: round(((e.clientX - r.left) / r.width) * 100), y: round(((e.clientY - r.top) / r.height) * 100) };
};
const up = (e: PointerEvent) => {
if (!drag) return;
const { x, y } = at(e);
setDrag(null);
if (Math.abs(x - drag.x0) < CLICK && Math.abs(y - drag.y0) < CLICK) {
onPatch({ x: drag.x0, y: drag.y0, w: null, h: null });
} else {
onPatch({
x: Math.min(x, drag.x0),
y: Math.min(y, drag.y0),
w: round(Math.abs(x - drag.x0)),
h: round(Math.abs(y - drag.y0)),
});
}
};
const shown = drag
? {
x: Math.min(drag.x0, drag.x1),
y: Math.min(drag.y0, drag.y1),
w: Math.abs(drag.x1 - drag.x0),
h: Math.abs(drag.y1 - drag.y0),
}
: mark;
const number = (key: keyof Mark, label: string) => (
<label className="flex items-center gap-1">
{label}
<input
type="number"
min={0}
max={100}
step={0.1}
value={mark[key] ?? ""}
disabled={locked}
onChange={(e) => onPatch({ [key]: e.target.value === "" ? null : round(Number(e.target.value)) })}
className="w-20 border border-muted/25 bg-surface px-2 py-1 text-body"
/>
</label>
);
return (
<div>
{image ? (
<div
ref={box}
className={`relative select-none ${locked ? "" : "cursor-crosshair"}`}
onPointerDown={(e) => {
if (locked) return;
e.currentTarget.setPointerCapture(e.pointerId);
const { x, y } = at(e);
setDrag({ x0: x, y0: y, x1: x, y1: y });
}}
onPointerMove={(e) => drag && setDrag({ ...drag, x1: at(e).x, y1: at(e).y })}
onPointerUp={up}
>
<img src={image} alt="" draggable={false} className="block w-full" />
{shown.x != null && shown.y != null && (
<span
aria-hidden="true"
className="pointer-events-none absolute"
style={
shown.w && shown.h
? {
left: `${shown.x}%`,
top: `${shown.y}%`,
width: `${shown.w}%`,
height: `${shown.h}%`,
border: "2px solid var(--color-action)",
background: "color-mix(in srgb, var(--color-action) 20%, transparent)",
}
: {
left: `${shown.x}%`,
top: `${shown.y}%`,
width: 16,
height: 16,
transform: "translate(-50%, -50%)",
borderRadius: "50%",
background: "var(--color-action)",
outline: "2px solid white",
}
}
/>
)}
</div>
) : (
<p className="notice p-3 text-sm text-muted">Add the venue's map above, then mark this location on it.</p>
)}
<div className="mt-2 flex flex-wrap items-center gap-3 text-xs text-muted">
{number("x", "Left %")}
{number("y", "Top %")}
{number("w", "Width %")}
{number("h", "Height %")}
{mark.x != null && !locked && (
<button
type="button"
onClick={() => onPatch({ x: null, y: null, w: null, h: null })}
className="text-link hover:underline"
>
Clear mark
</button>
)}
</div>
</div>
);
}

View file

@ -77,6 +77,15 @@
Data → Links/redirects (the `redirects` options) that fills the Data → Links/redirects (the `redirects` options) that fills the
field with the short link's full address, <site>/go/<URL ID>. field with the short link's full address, <site>/go/<URL ID>.
`fills: "text"` on a select fills that field of the row, while
it's empty, with the picked option's label.
`widget: "mapMarker"` (on `x`) marks a venue's location on the
map picture its parent row holds in `imageFrom`: a click is a
pin (x, y), a drag a box (x, y, w, h), in percent (MapMarkerInput
below). `lends` gets the form's options too, so a block can lend
its venue's locations from the venues list.
`widget: "testNotice"` is a text box of email addresses with a `widget: "testNotice"` is a text box of email addresses with a
"Send a test notice" button (TestNoticeInput below), for Site "Send a test notice" button (TestNoticeInput below), for Site
settings → Notices. settings → Notices.
@ -114,6 +123,9 @@ import ContentBlocks from "../ContentBlocks.tsx";
import { FILTER_FROM, OptionFilter, narrow } from "../OptionFilter.tsx"; import { FILTER_FROM, OptionFilter, narrow } from "../OptionFilter.tsx";
import { ImageInput, LinkPreviewInput } from "./MediaLibrary.tsx"; import { ImageInput, LinkPreviewInput } from "./MediaLibrary.tsx";
import { ChooseFileButton } from "./DriveFiles.tsx"; import { ChooseFileButton } from "./DriveFiles.tsx";
import MapMarkerInput from "./MapMarkerInput.tsx";
import { venueFromOption } from "../../lib/adminSchema/shared.ts";
import { mediaUrl } from "../../lib/media.ts";
import { siteUrl } from "../../lib/site.ts"; import { siteUrl } from "../../lib/site.ts";
/* Live previews a collection can name with `preview`. Each gets the /* Live previews a collection can name with `preview`. Each gets the
@ -122,21 +134,41 @@ const PREVIEWS = {
// The form holds an entry's person as person_id; the renderer wants // The form holds an entry's person as person_id; the renderer wants
// the person, so it's looked up in the select options (a name, no // the person, so it's looked up in the select options (a name, no
// photo: the options carry no more). // photo: the options carry no more).
contentBlock: (row, options) => ( // A venue and an item's event and map location come from the
<ContentBlocks // options the same way (088): an event as its title only. A map
blocks={[ // block's sections (094) are made as the API makes them (shape.js):
{ // their keys the venue still has, the venue cut to those.
...row, contentBlock: (row, options) => {
items: (row.items ?? []).map((item) => { const venue = venueFromOption(options?.venues?.find((v) => v.id === row.venue_id));
const person = item.person_id const known = new Map((venue?.locations ?? []).map((l) => [l.key, l]));
? options?.people?.find((p) => p.id === item.person_id) const sections = (row.map_sections ?? [])
: null; .map((section) => ({
return { ...item, person: person ? { id: person.id, name: person.label } : null }; name: section.name,
}), keys: (section.location_keys ?? "").split(",").filter((key) => known.has(key)),
}, }))
]} .filter((section) => section.keys.length);
/> const mapped = venue && sections.length
), ? { ...venue, locations: [...new Set(sections.flatMap((section) => section.keys))].map((key) => known.get(key)) }
: venue;
const shape = (item) => {
const person = item.person_id ? options?.people?.find((p) => p.id === item.person_id) : null;
const event = item.event_id ? options?.events?.find((e) => e.id === item.event_id) : null;
const location = venue?.locations.find((l) => l.key === item.location_key);
return {
...item,
person: person ? { id: person.id, name: person.label } : null,
event: event ? { id: event.id, title: event.label } : null,
place: location ? { venue_id: venue!.id, key: location.key, name: location.name } : null,
location: item.location || location?.name,
items: (item.items ?? []).map(shape),
};
};
return (
<ContentBlocks
blocks={[{ ...row, venue: mapped, map_sections: sections, items: (row.items ?? []).map(shape) }]}
/>
);
},
}; };
const input = const input =
@ -282,7 +314,7 @@ function Checklist({ id, options, value, disabled, empty, onChange }: {
/* ── Field ───────────────────────────────────────────────────── */ /* ── Field ───────────────────────────────────────────────────── */
export function Field({ field, value, row, options, error, onChange, onPatch }: any) { export function Field({ field, value, row, parentRow, options, error, onChange, onPatch }: any) {
const id = `f-${field.path.replace(/\./g, "-")}`; const id = `f-${field.path.replace(/\./g, "-")}`;
const widget = field.widget ?? "text"; const widget = field.widget ?? "text";
// readOnly may be a test of the row (a core page's address). // readOnly may be a test of the row (a core page's address).
@ -397,6 +429,14 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
)} )}
<select <select
{...common} {...common}
onChange={(e) => {
// `fills`: a pick also fills that empty field of the
// row with the option's label (a workshop's title).
const picked = e.target.value;
const label = list?.find(([optionId]) => String(optionId) === picked)?.[1];
if (field.fills && picked && !row?.[field.fills] && onPatch) onPatch({ [field.path]: picked, [field.fills]: label });
else onChange(picked);
}}
disabled={locked} disabled={locked}
className={`${locked ? inputLocked : common.className} ${ className={`${locked ? inputLocked : common.className} ${
orphaned && !locked ? inputError : "" orphaned && !locked ? inputError : ""
@ -440,6 +480,13 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
onChange={onChange} onChange={onChange}
onPatch={onPatch} onPatch={onPatch}
/> />
) : widget === "mapMarker" ? (
<MapMarkerInput
image={field.imageFrom ? mediaUrl(parentRow?.[field.imageFrom]) : null}
row={row}
locked={locked}
onPatch={onPatch}
/>
) : widget === "testNotice" ? ( ) : widget === "testNotice" ? (
<TestNoticeInput <TestNoticeInput
id={id} id={id}
@ -805,8 +852,11 @@ export function Repeater({
key={field.path} key={field.path}
field={field} field={field}
row={row} row={row}
parentRow={parentRow}
value={row[field.path]} value={row[field.path]}
options={options} // Its own lent options too: a map block's
// Locations with a slide (095).
options={spec.lends ? { ...options, ...spec.lends(row, options) } : options}
error={errors?.[`${errorPrefix}${index}.${field.path}`]} error={errors?.[`${errorPrefix}${index}.${field.path}`]}
onChange={(value) => update(index, { ...row, [field.path]: value })} onChange={(value) => update(index, { ...row, [field.path]: value })}
onPatch={(patch) => update(index, { ...row, ...patch })} onPatch={(patch) => update(index, { ...row, ...patch })}
@ -821,7 +871,7 @@ export function Repeater({
<Repeater <Repeater
spec={nested} spec={nested}
rows={row[nested.key]} rows={row[nested.key]}
options={spec.lends ? { ...options, ...spec.lends(row) } : options} options={spec.lends ? { ...options, ...spec.lends(row, options) } : options}
errors={errors} errors={errors}
errorPrefix={`${errorPrefix}${index}.${nested.key}.`} errorPrefix={`${errorPrefix}${index}.${nested.key}.`}
parentRow={row} parentRow={row}

View file

@ -33,6 +33,7 @@ import { tags } from "./adminSchema/tags.ts";
import { contactTypes } from "./adminSchema/contactTypes.ts"; import { contactTypes } from "./adminSchema/contactTypes.ts";
import { redirects } from "./adminSchema/redirects.ts"; import { redirects } from "./adminSchema/redirects.ts";
import { pages } from "./adminSchema/sitePages.ts"; import { pages } from "./adminSchema/sitePages.ts";
import { venues } from "./adminSchema/venues.ts";
export const ADMIN_ENTITIES: Record<string, any> = { export const ADMIN_ENTITIES: Record<string, any> = {
organizations, organizations,
@ -42,6 +43,7 @@ export const ADMIN_ENTITIES: Record<string, any> = {
tags, tags,
contact_types: contactTypes, contact_types: contactTypes,
redirects, redirects,
venues,
teams, teams,
awards, awards,
timeline, timeline,

View file

@ -1,5 +1,8 @@
import { mediaUrl } from "../media.ts"; import { mediaUrl } from "../media.ts";
import { PLACE_FIELDS, PUBLISHED_FIELD, LISTED_FIELD, timelineGroup, timelineDetailGroup, linksChild, hostsChild, blocksChild, tagsChild } from "./shared.ts"; import { PLACE_FIELDS, PUBLISHED_FIELD, LISTED_FIELD, timelineGroup, timelineDetailGroup, linksChild, hostsChild, blocksChild, tagsChild, PRESENT_BLOCK_FIELDS } from "./shared.ts";
/* An event's blocks also say how they're presented (095). */
const eventBlocksChild = { ...blocksChild, fields: [...blocksChild.fields, ...PRESENT_BLOCK_FIELDS] };
/* ── Events ──────────────────────────────────────────────────── */ /* ── Events ──────────────────────────────────────────────────── */
@ -173,6 +176,113 @@ export const events = {
}, },
], ],
}, },
{
legend: "Page",
fields: [
{
path: "show_contents",
label: "Show contents",
widget: "checkbox",
help: "Lists the content blocks' headings beside them, the one being read lit (a fold-out on phones), as on a blog post. Worth it with two or more headings.",
},
{
path: "links_heading",
label: "Links heading",
help: "Above the link buttons, eg. Sign up. Default: no heading.",
},
],
},
{
legend: "Presentation",
fields: [
{
path: "present_background",
label: "Background image",
widget: "image",
crop: "free",
resolve: mediaUrl,
full: true,
help: "Behind every slide when the page is presented, under the background color. Default: none.",
},
{
path: "present_background_color",
label: "Background color",
widget: "color",
help: "The slides' background, laid over the image at Dim. Default: the site's background.",
},
{
path: "present_dim",
label: "Dim",
widget: "number",
help: "How much of the background color covers the image, 0 to 90 percent, so the text stays readable. Default: 60.",
},
{
path: "present_frame",
label: "Frame",
widget: "select",
options: [
["border", "A border around the slide"],
["none", "None: the slide alone"],
],
blankLabel: "Default: a bar on top, the title line and the timer",
},
...([
["top", "Inset top", "of the screen's height"],
["right", "Inset right", "of the screen's width"],
["bottom", "Inset bottom", "of the screen's height"],
["left", "Inset left", "of the screen's width"],
] as const).map(([side, label, of]) => ({
path: `present_inset_${side}`,
label,
widget: "number",
help: `Room kept clear at this edge, in percent ${of} (0 to 45), eg. to keep the slides inside a frame drawn in the background image. With any inset the image is stretched to the screen, not cropped. Default: 0.`,
})),
{ path: "present_accent", label: "Accent", widget: "color", help: "Default: the event's color" },
{
path: "present_text_color",
label: "Text color",
widget: "color",
help: "Default: readable on the background color, else the site's text colors",
},
{
path: "present_logo",
label: "Logo",
widget: "image",
folder: "logos",
resolve: mediaUrl,
full: true,
help: "In the bottom-right corner of every slide. Default: none.",
},
],
},
{
legend: "Presentation, dark theme",
note: "For a screen in the dark theme (its own setting, or the Theme picked when presenting). Each one left blank uses the one above.",
fields: [
{
path: "present_background_dark",
label: "Background image",
widget: "image",
crop: "free",
resolve: mediaUrl,
full: true,
help: "Default: the background image above",
},
{ path: "present_background_color_dark", label: "Background color", widget: "color", help: "Default: the one above, else the site's dark background" },
{ path: "present_dim_dark", label: "Dim", widget: "number", help: "0 to 90 percent. Default: the one above" },
{ path: "present_accent_dark", label: "Accent", widget: "color", help: "Default: the accent above" },
{ path: "present_text_color_dark", label: "Text color", widget: "color", help: "Default: the one above" },
{
path: "present_logo_dark",
label: "Logo",
widget: "image",
folder: "logos",
resolve: mediaUrl,
full: true,
help: "eg. a light version of the logo. Default: the logo above",
},
],
},
timelineGroup("event"), timelineGroup("event"),
timelineDetailGroup("event"), timelineDetailGroup("event"),
{ legend: "Publishing", fields: [PUBLISHED_FIELD, LISTED_FIELD] }, { legend: "Publishing", fields: [PUBLISHED_FIELD, LISTED_FIELD] },
@ -215,6 +325,6 @@ export const events = {
], ],
}, },
linksChild, linksChild,
blocksChild, eventBlocksChild,
], ],
}; };

View file

@ -309,6 +309,9 @@ export const BLOCK_TYPES = [
["table", "Table", "A grid of text, eg. a comparison chart: one row per line, cells split by |, the first row the header."], ["table", "Table", "A grid of text, eg. a comparison chart: one row per line, cells split by |, the first row the header."],
["cards", "Link cards", "Cards with a picture, title and description, each a link to a page or a file, like a link shared in a chat; up to three in a row. Paste a link and press Fetch preview, or Choose a file."], ["cards", "Link cards", "Cards with a picture, title and description, each a link to a page or a file, like a link shared in a chat; up to three in a row. Paste a link and press Fetch preview, or Choose a file."],
["people", "People", "People tiles: a team's members, or people picked one by one as items (each with their title), or both."], ["people", "People", "People tiles: a team's members, or people picked one by one as items (each with their title), or both."],
["map", "Map", "A venue's map with its locations marked and listed beside it (Data → Venues). A schedule on the same page with the same venue links its locations here."],
["events", "Events", "Event cards, eg. the workshops on offer: picture, type, date, title and card text, each linking to the event's page."],
["organizations", "Organizations", "Organization cards, as on the Partners page: picked one by one as items, or every listed one of a kind."],
["divider", "Divider", "A thin line between parts."], ["divider", "Divider", "A thin line between parts."],
]; ];
@ -336,6 +339,44 @@ export const CARD_ITEM = { scope: "parent", path: "type", value: "cards" };
export const NOT_CARD_ITEM = { scope: "parent", path: "type", value: ["list", "links", "schedule"] }; export const NOT_CARD_ITEM = { scope: "parent", path: "type", value: ["list", "links", "schedule"] };
/* An item that's a person on a people block. */ /* An item that's a person on a people block. */
export const PEOPLE_ITEM = { scope: "parent", path: "type", value: "people" }; export const PEOPLE_ITEM = { scope: "parent", path: "type", value: "people" };
/* An item that's an event card on an events block (088). */
export const EVENT_ITEM = { scope: "parent", path: "type", value: "events" };
/* An item that's an organization on an organizations block (093). */
export const ORG_ITEM = { scope: "parent", path: "type", value: "organizations" };
/* A venues option (the /admin/options query) as a Venue: its
locations arrive as JSON. */
export const venueFromOption = (option) =>
option
? {
id: option.id,
name: option.label,
map_image: option.map_image,
map_alt: option.map_alt,
locations: JSON.parse(option.locations || "[]"),
}
: null;
/* A schedule entry's or sub-item's workshop and place (088). */
const eventField = (when?: any) => ({
path: "event_id",
label: "Event",
widget: "select",
optionsFrom: "events",
fills: "text",
blankLabel: "Default: none",
help: "Optional: a workshop or other event this is. Its title fills an empty Title; its card text, photo, person host and page fill what's left blank here.",
when,
});
const placeField = (when?: any) => ({
path: "location_key",
label: "Map location",
widget: "select",
optionsFrom: "mapLocations",
blankLabel: "Default: none",
help: "One of the block's venue's locations (the block's Venue, Data → Venues). Links to the map on the page and fills an empty Location.",
when,
});
export const blockTypeLabel = (type) => BLOCK_TYPES.find(([value]) => value === type)?.[1] ?? type; export const blockTypeLabel = (type) => BLOCK_TYPES.find(([value]) => value === type)?.[1] ?? type;
@ -417,8 +458,10 @@ const TAGS_FIELD = {
block's day. */ block's day. */
const SUB_ITEM_FIELDS = [ const SUB_ITEM_FIELDS = [
...scheduleTimeFields(), ...scheduleTimeFields(),
eventField(),
{ path: "text", label: "Title", required: true }, { path: "text", label: "Title", required: true },
{ path: "location", label: "Location", help: "eg. Room B" }, placeField(),
{ path: "location", label: "Location", help: "eg. Room B. Default: the map location's name" },
{ {
path: "person_id", path: "person_id",
label: "Person", label: "Person",
@ -451,6 +494,70 @@ const SUB_ITEM_FIELDS = [
TAGS_FIELD, TAGS_FIELD,
]; ];
/* An event's blocks' presentation fields (095), EventPresent.tsx. */
export const PRESENT_BLOCK_FIELDS = [
{
path: "present_show",
label: "Shown",
widget: "select",
options: [
["page", "Only on the page"],
["presentation", "Only in the presentation"],
],
blankLabel: "Default: on the page and in the presentation",
help: "Only in the presentation keeps it off the page, eg. a welcome line for the screen.",
},
{
path: "present_text",
label: "Presentation text",
widget: "textarea",
full: true,
when: { path: "type", value: TEXT_TYPES },
help: "Shown in place of the text when the page is presented, eg. a shorter heading. Default: the text.",
},
{
path: "present_map_split",
label: "A slide per section",
widget: "checkbox",
help: "Presented: each of the sections below gets its own map slide with only its locations. Default: one map slide with every location.",
when: { path: "type", value: "map" },
},
{
path: "present_map_no_list",
label: "Map only",
widget: "checkbox",
help: "Presented: no locations list beside the map, so the map fills the slide.",
when: { path: "type", value: "map" },
},
{
path: "present_map_no_details",
label: "No location details",
widget: "checkbox",
help: "Presented: each location's name only, without its detail line.",
when: { path: "type", value: "map" },
},
{
path: "present_places",
label: "Location slides",
widget: "select",
options: [
["picked", "Only the locations picked below"],
["none", "None"],
],
blankLabel: "Default: each marked location, lit up on the map",
when: { path: "type", value: "map" },
},
{
path: "present_place_keys",
label: "Locations with a slide",
widget: "checklist",
optionsFrom: "mapLocations",
full: true,
when: { path: "present_places", value: "picked" },
emptyNote: "No locations yet: pick the block's Venue, and give it locations under Data → Venues.",
},
];
export const blocksChild = { export const blocksChild = {
key: "content_blocks", key: "content_blocks",
label: "Content blocks", label: "Content blocks",
@ -489,6 +596,28 @@ export const blocksChild = {
when: { path: "type", value: TEXT_TYPES }, when: { path: "type", value: TEXT_TYPES },
help: (row) => TEXT_HELP[row?.type], help: (row) => TEXT_HELP[row?.type],
}, },
{
path: "org_kind",
label: "List",
widget: "select",
options: [
["partner", "Partners"],
["region", "Regions"],
["group", "Groups"],
["ministry", "Ministries"],
],
blankLabel: "Default: only the organizations picked below",
help: "Every published, listed one of this kind, by name. Organizations picked as items replace this list.",
when: { path: "type", value: "organizations" },
},
{
path: "list_style",
label: "Style",
widget: "select",
options: [["plain", "Plain text, gray detail"]],
blankLabel: "Default: bold text, normal detail",
when: { path: "type", value: "list" },
},
{ {
path: "cite", path: "cite",
label: "Attribution", label: "Attribution",
@ -530,6 +659,29 @@ export const blocksChild = {
when: { path: "type", value: "video" }, when: { path: "type", value: "video" },
help: "A WebVTT (.vtt) file, for an uploaded video; YouTube, Vimeo and Facebook show their own. Default: none.", help: "A WebVTT (.vtt) file, for an uploaded video; YouTube, Vimeo and Facebook show their own. Default: none.",
}, },
{
path: "media_dark",
label: "Dark theme image",
widget: "image",
crop: "free",
resolve: mediaUrl,
full: true,
when: { path: "type", value: "image" },
help: "Shown in place of the image while the site is dark, eg. a chart drawn light on dark. Same alt text and caption. Default: the image above in both themes.",
},
{
path: "image_size",
label: "Size",
widget: "select",
options: [
["small", "Small (up to 20rem)"],
["medium", "Medium (up to 32rem)"],
["large", "Large (up to 48rem)"],
],
blankLabel: "Default: the column's full width",
help: "A smaller one is centered. Never wider than the column.",
when: { path: "type", value: "image" },
},
{ {
path: "alt", path: "alt",
label: "Alt text", label: "Alt text",
@ -546,13 +698,29 @@ export const blocksChild = {
help: "Shows the team's members as tiles, its leads first. People added as items show after it.", help: "Shows the team's members as tiles, its leads first. People added as items show after it.",
when: { path: "type", value: "people" }, when: { path: "type", value: "people" },
}, },
{
path: "venue_id",
label: "Venue",
widget: "select",
optionsFrom: "venues",
blankLabel: "Default: none",
help: (row) =>
row?.type === "map"
? "Whose map to show (Data → Venues). Without one the block shows nothing."
: "Optional: the venue whose locations entries pick from (Data → Venues). With a Map block of it on the page, they link to it.",
when: { path: "type", value: ["map", "schedule"] },
},
...wordFields("", "", { path: "type", value: ["heading", "subheading", "paragraph", "callout", "quote"] }), ...wordFields("", "", { path: "type", value: ["heading", "subheading", "paragraph", "callout", "quote"] }),
], ],
// A schedule's tags, for its entries' and sub-items' Tags (087). // A schedule's tags, for its entries' and sub-items' Tags (087).
lends: (row) => ({ lends: (row, options) => ({
scheduleTags: (row.tags ?? []) scheduleTags: (row.tags ?? [])
.filter((tag) => tag.name?.trim()) .filter((tag) => tag.name?.trim())
.map((tag) => ({ id: tag.tag_key, label: tag.name })), .map((tag) => ({ id: tag.tag_key, label: tag.name })),
// Its venue's locations, for entries' Map location (088).
mapLocations: (venueFromOption(options?.venues?.find((v) => v.id === row.venue_id))?.locations ?? []).map(
(location) => ({ id: location.key, label: location.name }),
),
}), }),
children: [ children: [
{ {
@ -569,11 +737,31 @@ export const blocksChild = {
{ path: "no_tab", label: "No tab", widget: "checkbox", help: "Leave it out of the tabs (it still shows on entries)" }, { path: "no_tab", label: "No tab", widget: "checkbox", help: "Leave it out of the tabs (it still shows on entries)" },
], ],
}, },
{
key: "map_sections",
label: "Sections",
addLabel: "Add section",
note: "Optional: group the venue's locations for this page, eg. Main spaces, Small group spaces. Visitors can pick one to see only its places on the map. With sections, only the locations they hold are shown. The venue itself is unchanged.",
when: { path: "type", value: "map" },
title: (row) => row.name || "New section",
blank: { name: "" },
fields: [
{ path: "name", label: "Name", required: true, help: "eg. Main spaces" },
{
path: "location_keys",
label: "Locations",
widget: "checklist",
optionsFrom: "mapLocations",
full: true,
emptyNote: "No locations yet: pick the block's Venue, and give it locations under Data → Venues.",
},
],
},
{ {
key: "items", key: "items",
label: "Items", label: "Items",
addLabel: "Add item", addLabel: "Add item",
when: { path: "type", value: ["list", "links", "schedule", "cards", "people"] }, when: { path: "type", value: ["list", "links", "schedule", "cards", "people", "events", "organizations"] },
title: (row) => [row.day, row.time || row.start_time, row.text].filter(Boolean).join(" · ") || "New item", title: (row) => [row.day, row.time || row.start_time, row.text].filter(Boolean).join(" · ") || "New item",
blank: { text: "" }, blank: { text: "" },
fields: [ fields: [
@ -613,11 +801,38 @@ export const blocksChild = {
help: "Shown as a tile with their photo, linked to their page", help: "Shown as a tile with their photo, linked to their page",
when: PEOPLE_ITEM, when: PEOPLE_ITEM,
}, },
{ path: "text", label: "Text", required: true, help: "Schedules: the entry's title. Cards: the card's title. People: their title on the tile, eg. Speaker" }, {
path: "event_id",
label: "Event",
widget: "select",
optionsFrom: "events",
fills: "text",
required: true,
help: "The event the card shows and links to. An unpublished one is left out.",
when: EVENT_ITEM,
},
{
path: "org_id",
label: "Organization",
widget: "select",
optionsFrom: "block_orgs",
fills: "text",
required: true,
help: "Shown as its card, in this order. An unpublished one is left out.",
when: ORG_ITEM,
},
eventField(SCHEDULE_ENTRY),
{
path: "text",
label: "Text",
required: true,
help: "Schedules: the entry's title. Cards: the card's title. Events: the title shown, filled from the event. People: their title on the tile, eg. Speaker. Organizations: filled from it, only the admin shows it",
},
placeField(SCHEDULE_ENTRY),
{ {
path: "location", path: "location",
label: "Location", label: "Location",
help: "eg. Main Hall", help: "eg. Main Hall. Default: the map location's name",
when: SCHEDULE_ENTRY, when: SCHEDULE_ENTRY,
}, },
{ {
@ -631,6 +846,7 @@ export const blocksChild = {
}, },
{ path: "detail", label: "Detail", help: "A line under the text. Lists: shown after the text", when: NOT_CARD_ITEM }, { path: "detail", label: "Detail", help: "A line under the text. Lists: shown after the text", when: NOT_CARD_ITEM },
{ path: "detail", label: "Description", widget: "textarea", full: true, when: CARD_ITEM }, { path: "detail", label: "Description", widget: "textarea", full: true, when: CARD_ITEM },
{ path: "detail", label: "Card text", widget: "textarea", full: true, help: "Default: the event's card text", when: EVENT_ITEM },
{ path: "url", label: "URL", help: "Blank for plain text. Link buttons need one.", files: true, when: NOT_CARD_ITEM }, { path: "url", label: "URL", help: "Blank for plain text. Link buttons need one.", files: true, when: NOT_CARD_ITEM },
{ {
path: "media", path: "media",
@ -686,6 +902,15 @@ export const blocksChild = {
}, },
{ path: "featured", label: "Featured", widget: "checkbox", help: "Makes the row stand out", when: SCHEDULE_ENTRY }, { path: "featured", label: "Featured", widget: "checkbox", help: "Makes the row stand out", when: SCHEDULE_ENTRY },
{ ...TAGS_FIELD, when: SCHEDULE_ENTRY }, { ...TAGS_FIELD, when: SCHEDULE_ENTRY },
{
path: "featured",
label: "Featured",
widget: "checkbox",
help: "Shows it opened in full above the cards, under the heading and subheading below",
when: EVENT_ITEM,
},
{ path: "heading", label: "Heading", help: "Featured only, eg. This year's keynote. Default: none", when: EVENT_ITEM },
{ path: "subheading", label: "Subheading", help: "Featured only: a line under the heading. Default: none", full: true, when: EVENT_ITEM },
], ],
children: [ children: [
{ {

View file

@ -0,0 +1,82 @@
/* ── Venues (088_venues.sql) ─────────────────────────────────────
Data → Venues: a place we gather, with one map picture and the
locations marked on it (a pin or a box each). A Map content block
draws it; a schedule block names it, and its entries pick one of
its locations, linking to the map. Server side:
server/src/admin-schema/venues.js. */
import { mediaUrl } from "../media.ts";
export const venues = {
key: "venues",
label: "Venues",
singular: "venue",
idLabel: "URL ID",
slugFrom: "name",
list: {
columns: [
{ key: "name", label: "Name", primary: true },
{ key: "address", label: "Address" },
],
filters: [],
},
groups: [
{
legend: "Venue",
fields: [
{ path: "name", label: "Name", required: true, help: "eg. Camp Hebron" },
{ path: "address", label: "Address", help: "Shown over the list of locations. Optional." },
{
path: "map_image",
label: "Map",
widget: "image",
crop: "free",
resolve: mediaUrl,
full: true,
help: "One picture of the whole place, eg. the camp's site plan. Locations are marked on it below.",
},
{
path: "map_alt",
label: "Map description",
full: true,
help: "For screen readers. Default: Map of <name>.",
},
],
},
],
children: [
{
key: "locations",
label: "Locations",
addLabel: "Add location",
note: "The places on the map, in the order they're listed. Schedule entries pick one of these.",
title: (row) => row.name || "New location",
blank: () => ({ location_key: crypto.randomUUID().slice(0, 8) }),
fields: [
{ path: "name", label: "Name", required: true, help: "eg. Main Hall" },
{ path: "detail", label: "Detail", help: "A line under the name, eg. Upstairs, by the dining hall" },
{
path: "x",
label: "On the map",
widget: "mapMarker",
imageFrom: "map_image",
full: true,
help: "Click the map for a pin, or drag out a box for an area. Default: listed, not marked.",
},
{
path: "google_maps_url",
label: "Google Maps link",
help: "eg. https://maps.app.goo.gl/... Shown as a button beside it. Default: none",
},
{
path: "apple_maps_url",
label: "Apple Maps link",
help: "eg. https://maps.apple.com/?... Shown as a button beside it. Default: none",
},
],
},
],
};

View file

@ -18,7 +18,7 @@
import { visionColor } from "./color.ts"; import { visionColor } from "./color.ts";
const BASE = import.meta.env?.VITE_API_BASE ?? "/api"; export const BASE = import.meta.env?.VITE_API_BASE ?? "/api";
const DEFAULT_TTL = 60_000; const DEFAULT_TTL = 60_000;
/* A draft's preview (server/src/drafts.js): a tab opened from the /* A draft's preview (server/src/drafts.js): a tab opened from the

15
src/lib/darkTheme.ts Normal file
View file

@ -0,0 +1,15 @@
/* Whether the site is in its dark theme: <html data-theme="dark">,
set before the first paint (index.html) and by ThemeToggle. A
hook, so a page redraws the moment it changes. */
import { useSyncExternalStore } from 'react'
const read = () => document.documentElement.dataset.theme === 'dark'
function subscribe(onChange: () => void) {
const observer = new MutationObserver(onChange)
observer.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] })
return () => observer.disconnect()
}
export const useDarkTheme = (): boolean => useSyncExternalStore(subscribe, read, () => false)

10
src/lib/presenting.ts Normal file
View file

@ -0,0 +1,10 @@
/* Whether the blocks are drawn for a presentation screen
(EventPresent.tsx, 095): ContentBlocks leaves out the blocks set to,
takes their Presentation text, and draws links as plain text,
people as a row of round photos and organizations as logos. */
import { createContext, useContext } from 'react'
export const Presenting = createContext(false)
export const usePresenting = () => useContext(Presenting)

View file

@ -43,6 +43,9 @@ export type ContentBlock = {
| 'tab' | 'tab'
| 'cards' | 'cards'
| 'people' | 'people'
| 'map'
| 'events'
| 'organizations'
text?: string | null text?: string | null
media?: string | null media?: string | null
href?: string | null href?: string | null
@ -52,11 +55,110 @@ export type ContentBlock = {
team_id?: string | null team_id?: string | null
/** Who a quote is by. */ /** Who a quote is by. */
cite?: string | null cite?: string | null
/** A list block's style (092): null bold text, 'plain' the old look. */
list_style?: 'plain' | null
/** An image block's picture for the dark theme (102). */
media_dark?: string | null
/** An image block's size (101): null the column's width. */
image_size?: 'small' | 'medium' | 'large' | null
/** An organizations block's kind, listed when none are picked (093). */
org_kind?: 'region' | 'group' | 'partner' | 'ministry' | null
/** A video block's WebVTT file, for an uploaded video (066). */ /** A video block's WebVTT file, for an uploaded video (066). */
captions?: string | null captions?: string | null
items?: ContentBlockItem[] items?: ContentBlockItem[]
/** A schedule's own tags (087). */ /** A schedule's own tags (087). */
tags?: ScheduleTag[] tags?: ScheduleTag[]
/** A map or schedule block's venue (088). */
venue_id?: string | null
venue?: Venue | null
/** A map block's own sections of its venue's locations, by key
* (094). With any, `venue` holds only the locations they name. */
map_sections?: MapSection[]
/** How it's presented (095); null with nothing set. */
present?: BlockPresent | null
}
/** A block's presentation settings (095), EventPresent.tsx. */
export type BlockPresent = {
/** A people block: each one's role or title under their name, as
* the Present setup picks (not stored). */
titles?: boolean
/** Only on the page: left out of the presentation (099). */
hide: boolean
/** Only in the presentation: left off the page (099). */
only: boolean
/** In place of its text, eg. a shorter heading. */
text: string | null
/** A map: a slide per map section. */
map_split: boolean
map_no_list: boolean
map_no_details: boolean
/** A map: which locations get a slide; null every marked one. */
places: 'picked' | 'none' | null
place_keys: string[]
}
/** An event's presentation look (095). */
export type EventPresentLook = {
background: string | null
background_color: string | null
/** Percent of the color over the image; null 60. */
dim: number | null
/** null the accent bar, title line and timer. */
frame: 'border' | 'none' | null
accent: string | null
text_color: string | null
logo: string | null
/** Room clear at each edge (097): percent of the screen's height
* (top, bottom) and width (left, right); null none. */
inset?: { top: number; right: number; bottom: number; left: number } | null
/** In the dark theme (096); a null one takes the above. */
dark?: Partial<Omit<EventPresentLook, 'frame' | 'dark' | 'inset'>>
}
export type MapSection = { name: string; keys: string[] }
/** A venue (088): its map picture and the locations marked on it,
* each a pin (x, y) or a box (x, y, w, h), in percent. */
export type Venue = {
id: string
name: string
address?: string | null
map_image?: string | null
map_alt?: string | null
locations: VenueLocation[]
}
export type VenueLocation = {
key: string
name: string
detail?: string | null
x?: number | null
y?: number | null
w?: number | null
h?: number | null
/** The place in Google and Apple Maps (091). */
google_maps_url?: string | null
apple_maps_url?: string | null
}
/** An event an item names (088): an events block's card, or the
* workshop a schedule entry is. */
export type ItemEvent = {
id: string
title: string
event_type?: string | null
starts_on?: string | null
ends_on?: string | null
date_label?: string | null
color?: string | null
image?: string | null
/** Its own 16:9 photo, and where it is, for showing it in full. */
photo?: string | null
photo_alt?: string | null
location_label?: string | null
blurb?: string | null
/** Its own page's blocks: an events block's events only. */
blocks?: ContentBlock[]
} }
/** A schedule's tag (087). `tab` is whether it gets a tab of its own. */ /** A schedule's tag (087). `tab` is whether it gets a tab of its own. */
@ -85,10 +187,20 @@ export type ContentBlockItem = {
start_time?: string | null start_time?: string | null
end_time?: string | null end_time?: string | null
featured?: boolean featured?: boolean
/** A featured event's heading and subheading (090). */
heading?: string | null
subheading?: string | null
/** An organizations block's organization (093). */
org_id?: string | null
/** A block entry's sub-items. */ /** A block entry's sub-items. */
items?: ContentBlockItem[] items?: ContentBlockItem[]
/** Its block's tags it has, by key (087). */ /** Its block's tags it has, by key (087). */
tags?: string[] tags?: string[]
/** The event it is, and its place on the block's venue (088). */
event_id?: string | null
event?: ItemEvent | null
location_key?: string | null
place?: { venue_id: string; key: string; name: string } | null
} }
export type Link = { export type Link = {
@ -174,6 +286,12 @@ export type EventRecord = {
links: Link[] links: Link[]
/** The instagram link's label, the handle. See splitLinks in shape.js. */ /** The instagram link's label, the handle. See splitLinks in shape.js. */
instagram?: string | null instagram?: string | null
/** Its headings listed beside the blocks (089). */
show_contents?: boolean
/** Above the link buttons; null shows none (089). */
links_heading?: string | null
/** Its page presented (095). */
present?: EventPresentLook
blocks: ContentBlock[] blocks: ContentBlock[]
people: EventPerson[] people: EventPerson[]
awards: EventAward[] awards: EventAward[]

View file

@ -0,0 +1,88 @@
/* A presenting screen's link to its remotes (server/src/routes/
present.js, src/pages/PresentRemote.tsx): the code to show, the
commands as they come, and `report` for what the screen shows.
The code and its key are kept in this browser, so a reload or a
restart of the server keeps the same code. */
import { useCallback, useEffect, useRef, useState } from 'react'
import { BASE, post } from './api.ts'
export type RemoteCommand = {
do: 'next' | 'prev' | 'pause' | 'resume' | 'go' | 'setup' | 'start'
index?: number
query?: string
}
export type ScreenState = {
event: string
title: string
// EventPresent's address query: the setup's choices.
query: string
playing: boolean
paused: boolean
index: number
// Each slide's name, in order.
slides: string[]
}
const STORE = 'present-remote'
const RETRY = 3000
export function useScreenRemote(onCommand: (command: RemoteCommand) => void) {
const [code, setCode] = useState<string | null>(null)
const link = useRef<{ code: string; key: string } | null>(null)
const last = useRef<ScreenState | null>(null)
const handler = useRef(onCommand)
handler.current = onCommand
const send = (state: ScreenState) => {
const l = link.current
if (l) post(`/present/${l.code}/state`, { key: l.key, ...state }).catch(() => {})
}
useEffect(() => {
let source: EventSource | null = null
let retry = 0
const open = () => {
let saved: Record<string, string> = {}
try {
saved = JSON.parse(localStorage.getItem(STORE) ?? '{}')
} catch {
// Nothing kept: the server gives a new code.
}
source = new EventSource(`${BASE}/present/screen?${new URLSearchParams(saved)}`)
source.addEventListener('hello', (e) => {
link.current = JSON.parse((e as MessageEvent).data)
setCode(link.current!.code)
try {
localStorage.setItem(STORE, JSON.stringify(link.current))
} catch {
// Kept for this visit only.
}
if (last.current) send(last.current)
})
source.addEventListener('command', (e) => handler.current(JSON.parse((e as MessageEvent).data)))
// Reopened by hand, so it asks for its code again.
source.onerror = () => {
source?.close()
link.current = null
retry = window.setTimeout(open, RETRY)
}
}
open()
return () => {
window.clearTimeout(retry)
source?.close()
}
}, [])
const report = useCallback((state: ScreenState) => {
// Unchanged, eg. the page drawn again for something else.
if (JSON.stringify(state) === JSON.stringify(last.current)) return
last.current = state
send(state)
}, [])
return { code, report }
}

View file

@ -10,7 +10,7 @@
A version with no words after its number has no name. A version with no words after its number has no name.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
export const SITE_VERSION = "NGU-Web.v1.14.1-schedule"; export const SITE_VERSION = "NGU-Web.v1.14.2-present";
/** The number, eg. v1.13.2. */ /** The number, eg. v1.13.2. */
export const VERSION_NUMBER: string = SITE_VERSION.match(/v\d+(?:\.\d+)*/)?.[0] ?? SITE_VERSION export const VERSION_NUMBER: string = SITE_VERSION.match(/v\d+(?:\.\d+)*/)?.[0] ?? SITE_VERSION

View file

@ -22,6 +22,8 @@ import PageShell, { type ShellSection } from '../components/PageShell.tsx'
import PageState from '../components/PageState.tsx' import PageState from '../components/PageState.tsx'
import PlatformIcon from '../components/PlatformIcon.tsx' import PlatformIcon from '../components/PlatformIcon.tsx'
import ContentBlocks from '../components/ContentBlocks.tsx' import ContentBlocks from '../components/ContentBlocks.tsx'
import PostContents from '../components/PostContents.tsx'
import { headingAnchors } from '../lib/contents.ts'
import Tags from '../components/Tags.tsx' import Tags from '../components/Tags.tsx'
import PeopleTiles, { type PeopleGroupInput } from '../components/PeopleTiles.tsx' import PeopleTiles, { type PeopleGroupInput } from '../components/PeopleTiles.tsx'
import { import {
@ -35,7 +37,8 @@ import { mediaUrl } 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' import { capitalize } from '../lib/text.ts'
import { accentText, readableOn, BRAND } from '../lib/color.ts' import { accentText, readableOn, withAlpha, BRAND } from '../lib/color.ts'
import { Presentation } from '@phosphor-icons/react'
const BODY = 'var(--color-muted)' const BODY = 'var(--color-muted)'
@ -88,6 +91,12 @@ export default function EventDetail() {
const accent = event.color || BRAND const accent = event.color || BRAND
const groups = peopleGroups(event.people, accent) const groups = peopleGroups(event.people, accent)
// Two headings or more make a list worth showing, as on a post.
// Not a heading shown only in the presentation (099).
const contents = event.show_contents
? headingAnchors(event.blocks.filter((block) => !block.present?.only)).entries
: []
const withContents = contents.length >= 2
const sections: ShellSection[] = [ const sections: ShellSection[] = [
{ {
@ -104,29 +113,56 @@ export default function EventDetail() {
<img <img
src={mediaUrl(event.photo) ?? ''} src={mediaUrl(event.photo) ?? ''}
alt={event.photo_alt ?? ''} alt={event.photo_alt ?? ''}
className="aspect-video w-full max-w-3xl object-cover" className="aspect-video w-full object-cover"
/> />
)} )}
<div className="max-w-3xl"> {/* The blocks take the column's whole width, beside the
<ContentBlocks blocks={event.blocks} accent={accent} presentAt={`/events/${encodeURIComponent(event.id)}/present`} /> contents list when it shows. */}
<div className={withContents ? 'grid gap-8 lg:grid-cols-[14rem_minmax(0,1fr)] lg:gap-12 print:block' : undefined}>
{withContents && <PostContents entries={contents} />}
<div className="min-w-0">
{/* The page as a slideshow for a screen (EventPresent.tsx). */}
{event.blocks.length > 0 && (
<div className="mb-6 flex justify-end">
<Link
to={`/events/${encodeURIComponent(event.id)}/present`}
target="_blank"
className="btn inline-flex items-center gap-2 border px-4 py-2 text-sm transition-colors hover:bg-tint"
style={{ borderColor: withAlpha(accent, 33), color: accentText(accent) }}
>
<Presentation aria-hidden="true" weight="bold" className="h-4 w-4" />
Present
<span className="sr-only">(opens in a new tab)</span>
</Link>
</div>
)}
<ContentBlocks blocks={event.blocks} accent={accent} />
</div>
</div> </div>
{event.links.length > 0 && ( {event.links.length > 0 && (
<div className="flex flex-wrap gap-3"> <div className="space-y-4">
{event.links.map((link) => ( {event.links_heading && (
<a <h3 className="text-2xl font-bold" style={{ color: accentText(accent) }}>
key={link.url} {event.links_heading}
href={link.url} </h3>
target="_blank" )}
rel="noreferrer" <div className="flex flex-wrap gap-3">
className="inline-flex items-center gap-2 btn px-5 py-2 text-sm text-white transition-transform hover:scale-105" {event.links.map((link) => (
style={{ background: accent }} <a
> key={link.url}
<PlatformIcon platform={link.platform} /> href={link.url}
{link.label} target="_blank"
</a> rel="noreferrer"
))} className="inline-flex items-center gap-2 btn px-5 py-2 text-sm text-white transition-transform hover:scale-105"
style={{ background: accent }}
>
<PlatformIcon platform={link.platform} />
{link.label}
</a>
))}
</div>
</div> </div>
)} )}
</div> </div>

View file

@ -1,4 +1,4 @@
/* The schedule presentation's motion (SchedulePresent.tsx). The /* The event presentation's motion (EventPresent.tsx). The
reduced motion rule in index.css stops all of it. */ reduced motion rule in index.css stops all of it. */
.present-in { .present-in {

2200
src/pages/EventPresent.tsx Normal file

File diff suppressed because it is too large Load diff

250
src/pages/PresentRemote.tsx Normal file
View file

@ -0,0 +1,250 @@
/* ═══════════════════════════════════════════════════════════════
PRESENT REMOTE: /remote and /remote/:code
A phone driving a presenting screen (EventPresent.tsx) by the
code the screen shows (server/src/routes/present.js): what's on
it now, back, pause and next, any slide by name, back to its
setup, and the setup itself (EventPresent's Setup), whose Play
starts the screen with those choices. Anyone with the code can.
Outside the site's Layout, like the presentation.
═══════════════════════════════════════════════════════════════ */
import { ArrowLeft, CaretLeft, CaretRight, Gear, Pause, Play, SlidersHorizontal } from '@phosphor-icons/react'
import { useEffect, useMemo, useState } from 'react'
import { useNavigate, useParams } from 'react-router-dom'
import { Setup, addressFor, readSettings, schedulesOf, sectionsOf } from './EventPresent.tsx'
import { BASE, post } from '../lib/api.ts'
import { useEvent } from '../lib/useContent.ts'
import { BRAND, accentText } from '../lib/color.ts'
import { documentTitle } from '../lib/site.ts'
import type { RemoteCommand, ScreenState } from '../lib/useScreenRemote.ts'
type Seen = ScreenState & { connected: boolean }
export default function PresentRemote() {
const { code } = useParams()
useEffect(() => {
document.title = documentTitle('Remote')
}, [])
return code ? <Connected code={code.toUpperCase()} /> : <EnterCode />
}
function EnterCode() {
const navigate = useNavigate()
const [code, setCode] = useState('')
return (
<main className="flex min-h-screen items-center justify-center bg-surface px-4 text-body">
<form
onSubmit={(e) => {
e.preventDefault()
if (code.trim()) navigate(`/remote/${encodeURIComponent(code.trim().toUpperCase())}`)
}}
className="w-full max-w-sm space-y-4 bg-raised p-6 shadow-md"
>
<h1 className="text-2xl font-bold text-ink">Remote</h1>
<label className="block">
<span className="text-sm text-muted">The code on the screen (with its controls, or on its setup)</span>
<input
value={code}
onChange={(e) => setCode(e.target.value)}
autoFocus
autoCapitalize="characters"
autoComplete="off"
maxLength={6}
className="mt-1 w-full border border-muted/25 bg-surface px-3 py-2 font-mono text-2xl tracking-widest uppercase"
/>
</label>
<button type="submit" className="btn w-full bg-action px-5 py-3 text-white">
Connect
</button>
</form>
</main>
)
}
function Connected({ code }: { code: string }) {
const [seen, setSeen] = useState<Seen | null>(null)
const [lost, setLost] = useState(false)
const [tries, setTries] = useState(0)
const [problem, setProblem] = useState('')
const [editing, setEditing] = useState(false)
useEffect(() => {
setLost(false)
const source = new EventSource(`${BASE}/present/${encodeURIComponent(code)}`)
source.addEventListener('state', (e) => setSeen(JSON.parse((e as MessageEvent).data)))
// Closed is the server's no (no such code); otherwise it retries.
source.onerror = () => source.readyState === EventSource.CLOSED && setLost(true)
return () => source.close()
}, [code, tries])
const { data: event } = useEvent(seen?.event || undefined)
const sections = useMemo(() => (event ? sectionsOf(event.blocks ?? [], event.title) : []), [event])
const schedules = useMemo(() => schedulesOf(event?.blocks ?? []), [event])
const send = (command: RemoteCommand) => {
setProblem('')
post(`/present/${encodeURIComponent(code)}/command`, command).catch((err) => setProblem(err.message))
}
if (lost) {
return (
<main className="flex min-h-screen flex-col items-center justify-center gap-4 bg-surface px-4 text-body">
<p className="notice">No screen has the code {code} right now.</p>
<div className="flex gap-3">
<button type="button" onClick={() => setTries((n) => n + 1)} className="btn border border-muted/25 px-5 py-2 text-ink">
Try again
</button>
<a href="/remote" className="btn border border-muted/25 px-5 py-2 text-ink">
Another code
</a>
</div>
</main>
)
}
const accent = event?.present?.accent || event?.color || BRAND
if (editing && seen?.event && event) {
return (
<>
<div className="sticky top-0 z-10 flex items-center gap-3 bg-raised px-4 py-3 shadow-md">
<button type="button" onClick={() => setEditing(false)} className="btn inline-flex items-center gap-2 px-3 py-2 text-ink">
<ArrowLeft aria-hidden="true" weight="bold" className="h-4 w-4" />
Remote
</button>
<span className="text-sm text-muted">Play starts the screen with these choices.</span>
</div>
<Setup
// Fresh choices each time the screen's setup changes.
key={seen.query}
title={event.title}
back={`/events/${encodeURIComponent(event.id)}`}
accent={accent}
sections={sections}
schedules={schedules}
settings={readSettings(new URLSearchParams(seen.query))}
onPlay={(next) => {
send({ do: 'start', query: addressFor(next).toString() })
setEditing(false)
}}
/>
</>
)
}
const control = 'btn flex h-16 flex-1 items-center justify-center bg-raised text-ink shadow-md disabled:opacity-50'
const playing = !!seen?.event && seen.playing
const off = !seen?.connected
return (
<main className="min-h-screen bg-surface text-body">
<div className="h-2" style={{ background: accent }} />
<div className="mx-auto max-w-lg space-y-6 px-4 py-6">
<header>
<p className="text-sm font-semibold text-muted">
Remote <span className="font-mono tracking-widest">{code}</span>
</p>
<h1 className="text-2xl font-bold" style={{ color: accentText(accent) }}>
{seen?.event ? seen.title : 'Connecting…'}
</h1>
</header>
{seen && off && <p className="notice">The screen isn't connected right now. This page carries on when it is.</p>}
{seen?.event && (
<p className="bg-raised p-4 shadow-sm" aria-live="polite">
{playing ? (
<>
<span className="block text-sm text-muted">
Slide {seen.index + 1} of {seen.slides.length}
{seen.paused ? ', paused' : ''}
</span>
<span className="font-semibold text-ink">{seen.slides[seen.index]}</span>
</>
) : (
<span className="text-muted">The screen is on its setup. Change the setup to pick what it plays.</span>
)}
</p>
)}
{seen && playing && (
<div className="flex gap-3">
<button type="button" disabled={off} onClick={() => send({ do: 'prev' })} className={control} aria-label="Previous slide">
<CaretLeft weight="bold" className="h-6 w-6" aria-hidden="true" />
</button>
<button
type="button"
disabled={off}
onClick={() => send({ do: seen.paused ? 'resume' : 'pause' })}
className={control}
aria-label={seen.paused ? 'Play' : 'Pause'}
>
{seen.paused ? (
<Play weight="fill" className="h-6 w-6" aria-hidden="true" />
) : (
<Pause weight="bold" className="h-6 w-6" aria-hidden="true" />
)}
</button>
<button type="button" disabled={off} onClick={() => send({ do: 'next' })} className={control} aria-label="Next slide">
<CaretRight weight="bold" className="h-6 w-6" aria-hidden="true" />
</button>
</div>
)}
{seen?.event && (
<div className="flex flex-wrap gap-3">
<button
type="button"
disabled={off || !event}
onClick={() => setEditing(true)}
className="btn inline-flex items-center gap-2 border border-muted/25 px-4 py-2 text-ink disabled:opacity-50"
>
<SlidersHorizontal aria-hidden="true" weight="bold" className="h-4 w-4" />
Change setup
</button>
{playing && (
<button
type="button"
disabled={off}
onClick={() => send({ do: 'setup' })}
className="btn inline-flex items-center gap-2 border border-muted/25 px-4 py-2 text-ink disabled:opacity-50"
>
<Gear aria-hidden="true" weight="bold" className="h-4 w-4" />
Screen to its setup
</button>
)}
</div>
)}
<p role="status" className="text-sm text-muted">
{problem}
</p>
{seen && playing && seen.slides.length > 0 && (
<section>
<h2 className="mb-2 text-lg font-bold text-ink">Go to a slide</h2>
<ol className="divide-y divide-muted/15 bg-raised shadow-sm">
{seen.slides.map((name, i) => (
<li key={i}>
<button
type="button"
disabled={off}
onClick={() => send({ do: 'go', index: i })}
aria-current={i === seen.index ? 'true' : undefined}
className={`flex w-full gap-3 px-4 py-3 text-left hover:bg-tint ${i === seen.index ? 'bg-tint font-semibold text-ink' : ''}`}
>
<span className="w-6 shrink-0 text-right text-muted">{i + 1}</span>
<span>{name}</span>
</button>
</li>
))}
</ol>
</section>
)}
</div>
</main>
)
}

View file

@ -1,958 +0,0 @@
/* ═══════════════════════════════════════════════════════════════
SCHEDULE PRESENTATION: /events/:id/present?block=<n>
An event's schedule block as an endless slideshow for a screen
(digital signage), opened from the block's Present button. Outside
the site's Layout: no header, footer or backdrop.
First a setup screen: which days and entries, and how many seconds
each kind of slide stays up (0 leaves that kind out). Play writes
the choices into the address, so a signage device can bookmark it
and start the same way every time (`play=1` skips the setup).
The slides, for each day picked, in order:
overview the day's picked entries on one slide
spotlight one entry: its person beside title, time and place
block a block entry (086) and its sub-items on one slide,
in place of its spotlight; then each sub-item gets
the spotlight, graphic and map slides an entry does
graphic an entry's graphic, full screen
map an entry's own map image (069), full screen
tag after the days: each of the schedule's tags (087)
and everything it's on, under each day's name
A heading (086) is only a line on the overview; a break gets no
spotlight. A slide with more than the screen holds waits half its
seconds, scrolls to the end at "Scroll" seconds a screenful
(`screen=`), then waits the other half. "Only entries tagged" (`only=<key>`) cuts every slide
to what one tag is on, eg. for a screen outside the youth room.
Keys while playing: arrows step, Space pauses, Escape leaves full
screen (the browser's), S goes back to the setup.
═══════════════════════════════════════════════════════════════ */
import { ArrowsOut, CaretLeft, CaretRight, Gear, Pause, Play } from '@phosphor-icons/react'
import { createContext, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type ReactNode } from 'react'
import { useParams, useSearchParams } from 'react-router-dom'
import PageState from '../components/PageState.tsx'
import {
Avatar,
FeaturedStar,
ScheduleTags,
TagChips,
daysWithTag,
featuredStyle,
groupByDay,
mapAlt,
withTag,
type Day,
} from '../components/ScheduleBlock.tsx'
import { Paragraphs } from '../components/InlineText.tsx'
import { useEvent, type ContentBlockItem, type ScheduleTag } from '../lib/useContent.ts'
import { mediaUrl } from '../lib/media.ts'
import { BRAND, accentText, readableOn, withAlpha } from '../lib/color.ts'
import { documentTitle } from '../lib/site.ts'
import './SchedulePresent.css'
/* Each kind of slide, its address key and seconds when unset. */
const KINDS = [
{ key: 'overview', label: 'Day overview', help: 'The whole day on one slide', seconds: 20 },
{ key: 'spotlight', label: 'Entry spotlight', help: 'One entry at a time, with its person', seconds: 12 },
{ key: 'block', label: 'Blocks', help: 'A block and the things in it, before each gets a spotlight', seconds: 15 },
{ key: 'graphic', label: 'Graphics', help: "An entry's graphic, full screen", seconds: 10 },
{ key: 'map', label: 'Map images', help: "An entry's own map, full screen", seconds: 10 },
{ key: 'tag', label: 'Tag slides', help: "Each tag and everything it's on, after the days", seconds: 15 },
] as const
type Kind = (typeof KINDS)[number]['key']
/* Seconds a long slide takes to scroll one screenful, when unset. */
const PER_SCREEN = 8
/* An overview with more entries than this goes to two columns. */
const ONE_COLUMN = 8
/* How long the controls stay up after the pointer last moved (ms). */
const CONTROLS_FOR = 2500
/* `parent` is a sub-item's block; a tag slide has its `tag` and the
`days` it gathers from. */
type Slide = {
kind: Kind
seconds: number
day: Day
entry?: ContentBlockItem
parent?: ContentBlockItem
tag?: ScheduleTag
days?: Day[]
}
/* An entry's key in the address: day index, a dot, entry index, and
for a sub-item another dot and its index. */
const entryKey = (...at: number[]) => at.join('.')
/* Lines on an overview: entries and sub-items. */
const lineCount = (entries: ContentBlockItem[]) =>
entries.reduce((n, entry) => n + 1 + (entry.kind === 'block' ? (entry.items?.length ?? 0) : 0), 0)
const list = (value: string | null) => (value ? value.split(',').filter(Boolean) : null)
function readSettings(params: URLSearchParams, days: Day[]) {
const pickedDays = list(params.get('days'))?.map(Number) ?? days.map((_, i) => i)
const hidden = new Set(list(params.get('hide')) ?? [])
const seconds = Object.fromEntries(
KINDS.map((kind) => {
const value = Number(params.get(kind.key) ?? kind.seconds)
return [kind.key, Number.isFinite(value) && value > 0 ? value : 0]
}),
) as Record<Kind, number>
const screen = Number(params.get('screen') ?? PER_SCREEN)
return {
pickedDays: new Set(pickedDays),
hidden,
seconds,
screen: Number.isFinite(screen) && screen > 0 ? screen : PER_SCREEN,
only: params.get('only') || null,
}
}
type Settings = ReturnType<typeof readSettings>
function buildSlides(
days: Day[],
tags: ScheduleTag[],
{ pickedDays, hidden, seconds, only }: Pick<Settings, 'pickedDays' | 'hidden' | 'seconds' | 'only'>,
): Slide[] {
const slides: Slide[] = []
const kept: Day[] = []
days.forEach((all, d) => {
if (!pickedDays.has(d)) return
let entries = all.entries.flatMap((entry, e) => {
if (hidden.has(entryKey(d, e))) return []
if (entry.kind !== 'block') return [entry]
return [{ ...entry, items: (entry.items ?? []).filter((_, i) => !hidden.has(entryKey(d, e, i))) }]
})
if (only) entries = withTag(entries, only)
if (entries.length === 0) return
kept.push({ name: all.name, entries })
const day = { ...all, entries }
if (seconds.overview) slides.push({ kind: 'overview', seconds: seconds.overview, day })
const media = (entry: ContentBlockItem, parent?: ContentBlockItem) => {
if (seconds.graphic && entry.media) slides.push({ kind: 'graphic', seconds: seconds.graphic, day, entry, parent })
if (seconds.map && entry.map_image) slides.push({ kind: 'map', seconds: seconds.map, day, entry, parent })
}
for (const entry of entries) {
if (entry.kind === 'heading') continue
if (entry.kind === 'block') {
if (seconds.block) slides.push({ kind: 'block', seconds: seconds.block, day, entry })
media(entry)
for (const item of entry.items ?? []) {
if (seconds.spotlight) slides.push({ kind: 'spotlight', seconds: seconds.spotlight, day, entry: item, parent: entry })
media(item, entry)
}
continue
}
if (seconds.spotlight && entry.kind !== 'break') slides.push({ kind: 'spotlight', seconds: seconds.spotlight, day, entry })
media(entry)
}
})
if (seconds.tag) {
for (const tag of tags) {
if (only && tag.key !== only) continue
const tagDays = daysWithTag(kept, tag.key)
if (tagDays.length) slides.push({ kind: 'tag', seconds: seconds.tag, day: { name: '', entries: [] }, tag, days: tagDays })
}
}
return slides
}
export default function SchedulePresent() {
const { id } = useParams()
const [params, setParams] = useSearchParams()
const { data: event, loading, error, notFound, reload } = useEvent(id)
const blockIndex = Number(params.get('block') ?? 0)
const schedule = event?.blocks?.filter((block) => block.type === 'schedule')[blockIndex]
const days = useMemo(() => groupByDay(schedule?.items ?? []), [schedule])
const tags = schedule?.tags ?? []
useEffect(() => {
if (event) document.title = documentTitle(`${event.title}: schedule`)
}, [event])
if (!event) {
return (
<PageState
loading={loading}
error={error}
notFound={notFound}
onRetry={reload}
noun="retreat"
backTo="/retreats"
backLabel="All retreats"
/>
)
}
const accent = event.color || BRAND
const back = `/events/${encodeURIComponent(event.id)}`
if (!schedule || days.length === 0) {
return (
<main className="min-h-screen bg-surface p-8">
<p className="notice">This event has no schedule to present.</p>
<a href={back} className="mt-4 inline-block text-link underline">
Back to {event.title}
</a>
</main>
)
}
const settings = readSettings(params, days)
if (params.get('play') === '1') {
return (
<ScheduleTags.Provider value={tags}>
<Player
title={event.title}
accent={accent}
slides={buildSlides(days, tags, settings)}
screen={settings.screen}
onSetup={() => {
const next = new URLSearchParams(params)
next.delete('play')
setParams(next)
}}
/>
</ScheduleTags.Provider>
)
}
return (
<Setup
title={event.title}
back={back}
accent={accent}
days={days}
tags={tags}
settings={settings}
onPlay={(next) => {
// Full screen needs the click itself, so it's asked for here.
document.documentElement.requestFullscreen?.().catch(() => {})
const out = new URLSearchParams({ block: String(blockIndex) })
if (next.pickedDays.size < days.length) out.set('days', [...next.pickedDays].sort((a, b) => a - b).join(','))
if (next.hidden.size) out.set('hide', [...next.hidden].join(','))
for (const kind of KINDS) out.set(kind.key, String(next.seconds[kind.key]))
out.set('screen', String(next.screen))
// Not 'tag': that's the tag slides' seconds.
if (next.only) out.set('only', next.only)
out.set('play', '1')
setParams(out)
}}
/>
)
}
/* ── Setup ──────────────────────────────────────────────────── */
function Setup({
title,
back,
accent,
days,
tags,
settings,
onPlay,
}: {
title: string
back: string
accent: string
days: Day[]
tags: ScheduleTag[]
settings: Settings
onPlay: (settings: Settings) => void
}) {
const [pickedDays, setPickedDays] = useState(settings.pickedDays)
const [hidden, setHidden] = useState(settings.hidden)
const [seconds, setSeconds] = useState(settings.seconds)
const [only, setOnly] = useState(settings.only)
const [screen, setScreen] = useState(settings.screen)
const count = buildSlides(days, tags, { pickedDays, hidden, seconds, only }).length
const toggle = <T,>(set: Set<T>, value: T) => {
const next = new Set(set)
if (next.has(value)) next.delete(value)
else next.add(value)
return next
}
return (
<main className="min-h-screen bg-surface text-body">
<div className="h-2" style={{ background: accent }} />
<div className="mx-auto max-w-4xl space-y-10 px-6 py-12">
<header>
<p className="text-sm font-semibold text-muted">Present the schedule</p>
<h1 className="text-4xl font-bold" style={{ color: accentText(accent) }}>
{title}
</h1>
<p className="mt-2 text-muted">
Pick what to show and for how long, then Play. It loops until you stop it. Bookmark the address after
pressing Play to start a screen the same way next time.
</p>
</header>
<section>
<h2 className="mb-4 text-2xl font-bold text-ink">Slides</h2>
<div className="grid gap-4 sm:grid-cols-2">
{KINDS.map((kind) => (
<label key={kind.key} className="flex items-center gap-4 bg-raised p-4 shadow-sm">
<span className="flex-1">
<span className="block font-semibold text-ink">{kind.label}</span>
<span className="text-sm text-muted">{kind.help}</span>
</span>
<input
type="number"
min={0}
max={600}
value={seconds[kind.key]}
onChange={(e) => setSeconds({ ...seconds, [kind.key]: Math.max(0, Number(e.target.value) || 0) })}
className="w-20 border border-muted/25 bg-surface px-2 py-1 text-right"
aria-describedby={`${kind.key}-unit`}
/>
<span id={`${kind.key}-unit`} className="text-sm text-muted">
sec
</span>
</label>
))}
<label className="flex items-center gap-4 bg-raised p-4 shadow-sm">
<span className="flex-1">
<span className="block font-semibold text-ink">Scroll</span>
<span className="text-sm text-muted">
Seconds to scroll one screenful, on a slide with more than fits. It waits half its own seconds at
the top and half at the end. Default: {PER_SCREEN}
</span>
</span>
<input
type="number"
min={1}
max={120}
value={screen}
onChange={(e) => setScreen(Math.max(1, Number(e.target.value) || PER_SCREEN))}
className="w-20 border border-muted/25 bg-surface px-2 py-1 text-right"
aria-describedby="screen-unit"
/>
<span id="screen-unit" className="text-sm text-muted">
sec
</span>
</label>
</div>
<p className="mt-2 text-sm text-muted">0 leaves that kind of slide out.</p>
</section>
{tags.length > 0 && (
<section>
<h2 className="mb-4 text-2xl font-bold text-ink">Tags</h2>
<label className="flex flex-wrap items-center gap-4 bg-raised p-4 shadow-sm">
<span className="flex-1">
<span className="block font-semibold text-ink">Only entries tagged</span>
<span className="text-sm text-muted">Every slide shows only what this tag is on, eg. for one room's screen</span>
</span>
<select
value={only ?? ''}
onChange={(e) => setOnly(e.target.value || null)}
className="border border-muted/25 bg-surface px-2 py-1"
>
<option value="">Default: every entry</option>
{tags.map((tag) => (
<option key={tag.key} value={tag.key}>
{tag.name}
</option>
))}
</select>
</label>
</section>
)}
<section>
<h2 className="mb-4 text-2xl font-bold text-ink">Days and entries</h2>
<div className="space-y-6">
{days.map((day, d) => (
<fieldset key={d} className="bg-raised p-4 shadow-sm">
<legend className="sr-only">{day.name || 'Schedule'}</legend>
<label className="flex items-center gap-3 font-bold text-ink">
<input type="checkbox" checked={pickedDays.has(d)} onChange={() => setPickedDays(toggle(pickedDays, d))} />
{day.name || 'Schedule'}
</label>
<ul className="mt-3 space-y-2 pl-7">
{day.entries.map((entry, e) => (
<li key={e}>
<PickEntry
entry={entry}
enabled={pickedDays.has(d)}
checked={!hidden.has(entryKey(d, e))}
onToggle={() => setHidden(toggle(hidden, entryKey(d, e)))}
/>
{entry.kind === 'block' && entry.items?.length ? (
<ul className="mt-2 space-y-2 pl-7">
{entry.items.map((item, i) => (
<li key={i}>
<PickEntry
entry={item}
enabled={pickedDays.has(d) && !hidden.has(entryKey(d, e))}
checked={!hidden.has(entryKey(d, e, i))}
onToggle={() => setHidden(toggle(hidden, entryKey(d, e, i)))}
/>
</li>
))}
</ul>
) : null}
</li>
))}
</ul>
</fieldset>
))}
</div>
</section>
<div className="flex flex-wrap items-center gap-4">
<button
type="button"
disabled={count === 0}
onClick={() => onPlay({ pickedDays, hidden, seconds, screen, only })}
className="btn inline-flex items-center gap-2 px-6 py-3 disabled:opacity-50"
style={{ background: accent, color: readableOn(accent) }}
>
<Play aria-hidden="true" weight="fill" className="h-5 w-5" />
Play
</button>
<span className="text-sm text-muted">
{count === 0 ? 'Nothing picked to show.' : `${count} slide${count === 1 ? '' : 's'} in the loop`}
</span>
<a href={back} className="ml-auto text-sm text-link underline">
Back to the event
</a>
</div>
</div>
</main>
)
}
/* One entry's checkbox on the setup screen, its kind beside it. */
const KIND_NOTE = { block: 'Block', break: 'Break', heading: 'Heading' } as const
function PickEntry({
entry,
enabled,
checked,
onToggle,
}: {
entry: ContentBlockItem
enabled: boolean
checked: boolean
onToggle: () => void
}) {
const note = entry.kind && entry.kind !== 'entry' ? KIND_NOTE[entry.kind] : null
return (
<label className={`flex items-baseline gap-3 ${enabled ? '' : 'opacity-50'}`}>
<input type="checkbox" disabled={!enabled} checked={checked} onChange={onToggle} />
<span className="w-32 shrink-0 text-sm text-muted">{entry.time}</span>
<span className={entry.kind === 'heading' ? 'font-semibold' : ''}>
{entry.featured && (
<span className="mr-1 text-link">
<FeaturedStar />
</span>
)}
{entry.text}
</span>
{note && <span className="text-xs text-muted">{note}</span>}
</label>
)
}
/* ── Player ─────────────────────────────────────────────────── */
function Player({
title,
accent,
slides,
screen,
onSetup,
}: {
title: string
accent: string
slides: Slide[]
screen: number
onSetup: () => void
}) {
const [index, setIndex] = useState(0)
// Seconds this slide's scroll adds to it (Scroll), for its index.
const [scroll, setScroll] = useState({ index: -1, seconds: 0 })
const [paused, setPaused] = useState(false)
const [controls, setControls] = useState(true)
const hideTimer = useRef(0)
const slide = slides[index % Math.max(slides.length, 1)]
const step = (by: number) => setIndex((i) => (i + by + slides.length) % slides.length)
const seconds = (slide?.seconds ?? 0) + (scroll.index === index ? scroll.seconds : 0)
// The next slide when this one's time is up.
useEffect(() => {
if (paused || !slide) return
const timer = window.setTimeout(() => step(1), seconds * 1000)
return () => window.clearTimeout(timer)
}, [index, paused, seconds, slides.length])
useEffect(() => {
const onKey = (e: KeyboardEvent) => {
if (e.key === 'ArrowRight') step(1)
else if (e.key === 'ArrowLeft') step(-1)
else if (e.key === ' ') setPaused((p) => !p)
else if (e.key === 's' || e.key === 'S') onSetup()
else return
e.preventDefault()
}
window.addEventListener('keydown', onKey)
return () => window.removeEventListener('keydown', onKey)
})
// Keeps a signage screen from going to sleep, where the browser can.
useEffect(() => {
let lock: { release: () => Promise<void> } | null = null
const ask = () => {
if (document.visibilityState !== 'visible') return
;(navigator as any).wakeLock
?.request('screen')
.then((l: typeof lock) => (lock = l))
.catch(() => {})
}
ask()
document.addEventListener('visibilitychange', ask)
return () => {
document.removeEventListener('visibilitychange', ask)
lock?.release().catch(() => {})
}
}, [])
// The controls show while the pointer moves, then get out of the way.
const wake = () => {
setControls(true)
window.clearTimeout(hideTimer.current)
hideTimer.current = window.setTimeout(() => setControls(false), CONTROLS_FOR)
}
useEffect(() => {
wake()
return () => window.clearTimeout(hideTimer.current)
}, [])
if (!slide) {
return (
<main className="flex min-h-screen flex-col items-center justify-center gap-4 bg-surface">
<p className="notice">Nothing picked to show.</p>
<button type="button" onClick={onSetup} className="btn border border-muted/25 px-5 py-2">
Back to setup
</button>
</main>
)
}
const control = 'btn flex h-12 w-12 items-center justify-center bg-raised text-ink shadow-md'
return (
<main
onMouseMove={wake}
className={`present relative flex h-screen flex-col overflow-hidden bg-surface text-body ${controls ? '' : 'cursor-none'}`}
>
<div className="h-3 shrink-0" style={{ background: accent }} />
<div className="flex shrink-0 items-baseline justify-between gap-6 px-[4vw] pt-[2vh] text-[clamp(1rem,1.6vw,2rem)] text-muted">
<span className="font-semibold">{title}</span>
<span>{slide.day.name}</span>
</div>
{/* Keyed by index, so every slide's entrance animation plays. */}
<div key={index} className="min-h-0 flex-1 px-[4vw] py-[3vh]">
<SlideTime.Provider
value={{ wait: slide.seconds / 2, screen, paused, scrolls: (s) => setScroll({ index, seconds: s }) }}
>
<SlideView slide={slide} accent={accent} />
</SlideTime.Provider>
</div>
{/* How long this slide has left. */}
<div className="h-1.5 shrink-0" style={{ background: `color-mix(in srgb, ${accent} 20%, transparent)` }}>
<div
key={`${index}-${paused}`}
className={paused ? 'h-full w-0' : 'present-timer h-full'}
style={{ background: accent, animationDuration: `${seconds}s` }}
/>
</div>
<div
className={`absolute bottom-6 left-1/2 flex -translate-x-1/2 items-center gap-3 transition-opacity duration-300 ${
controls ? 'opacity-100' : 'pointer-events-none opacity-0'
}`}
>
<button type="button" onClick={() => step(-1)} className={control} aria-label="Previous slide">
<CaretLeft weight="bold" className="h-5 w-5" aria-hidden="true" />
</button>
<button type="button" onClick={() => setPaused((p) => !p)} className={control} aria-label={paused ? 'Play' : 'Pause'}>
{paused ? (
<Play weight="fill" className="h-5 w-5" aria-hidden="true" />
) : (
<Pause weight="bold" className="h-5 w-5" aria-hidden="true" />
)}
</button>
<button type="button" onClick={() => step(1)} className={control} aria-label="Next slide">
<CaretRight weight="bold" className="h-5 w-5" aria-hidden="true" />
</button>
<span className="bg-raised px-3 py-2 text-sm text-muted shadow-md">
{index + 1} / {slides.length}
</span>
<button
type="button"
onClick={() => document.documentElement.requestFullscreen?.().catch(() => {})}
className={control}
aria-label="Full screen"
>
<ArrowsOut weight="bold" className="h-5 w-5" aria-hidden="true" />
</button>
<button type="button" onClick={onSetup} className={control} aria-label="Back to setup">
<Gear weight="bold" className="h-5 w-5" aria-hidden="true" />
</button>
</div>
</main>
)
}
/* ── Slides ─────────────────────────────────────────────────── */
/* Fades and rises in after `order` steps, so a slide's parts arrive
one after another. */
function Rise({ order = 0, from = 'below', className = '', children }: {
order?: number
from?: 'below' | 'left' | 'right'
className?: string
children: ReactNode
}) {
return (
<div className={`present-in present-from-${from} ${className}`} style={{ animationDelay: `${order * 120}ms` }}>
{children}
</div>
)
}
/* What a slide's Scroll needs from the Player: the wait at each end
(half the slide's seconds), seconds a screenful, whether it's
paused, and where to say how many seconds its scroll adds. */
const SlideTime = createContext({ wait: 0, screen: PER_SCREEN, paused: false, scrolls: (_seconds: number) => {} })
/* A slide's part that may not fit: when its content is taller than
the room it has, it waits, scrolls to the end at the Player's
seconds a screenful (making the slide that much longer), then waits
again. `center` puts short content in the middle (and still starts
long content at the top). */
function Scroll({ center = false, className = '', children }: {
center?: boolean
className?: string
children: ReactNode
}) {
const { wait, screen, paused, scrolls } = useContext(SlideTime)
const box = useRef<HTMLDivElement>(null)
const [scrollFor, setScrollFor] = useState({ by: 0, seconds: 0 })
useLayoutEffect(() => {
const outer = box.current
const inner = outer?.firstElementChild as HTMLElement | null
if (!outer || !inner) return
const by = Math.max(0, inner.offsetHeight - outer.clientHeight)
if (!by) return
const seconds = (by / (outer.clientHeight || 1)) * screen
setScrollFor({ by, seconds })
scrolls(seconds)
}, [])
const { by, seconds } = scrollFor
const style = {
'--present-scroll': `-${by}px`,
animationDuration: `${seconds}s`,
animationDelay: `${wait}s`,
animationPlayState: paused ? 'paused' : 'running',
} as CSSProperties
return (
<div ref={box} className={`min-h-0 flex-1 overflow-hidden ${center ? 'flex flex-col' : ''} ${className}`}>
<div className={`${center ? 'my-auto' : ''} ${by ? 'present-scroll' : ''}`} style={by ? style : undefined}>
{children}
</div>
</div>
)
}
/* An overview's rows: each entry, a block's sub-items under it.
`start` is the first row's place in the slide's entrance. */
function OverviewEntries({ entries, accent, start = 1 }: { entries: ContentBlockItem[]; accent: string; start?: number }) {
return (
<>
{entries.map((entry, i) => (
<li key={i} className="even:bg-tint-soft/60" style={entry.featured ? featuredStyle(accent) : undefined}>
<Rise order={start + i} from="left">
<OverviewLine entry={entry} accent={accent} />
{entry.kind === 'block' && entry.items?.length ? (
<ul className="ml-[14vw] pb-[1vh]">
{entry.items.map((item, j) => (
<li key={j} style={item.featured ? featuredStyle(accent) : undefined}>
<OverviewLine entry={item} accent={accent} sub />
</li>
))}
</ul>
) : null}
</Rise>
</li>
))}
</>
)
}
/* One line of the day overview: an entry, or (`sub`) one of a
block's sub-items under it. A heading is a label; a break is
quieter. */
function OverviewLine({ entry, accent, sub = false }: { entry: ContentBlockItem; accent: string; sub?: boolean }) {
const tags = useContext(ScheduleTags)
const color = accentText(accent)
if (entry.kind === 'heading') {
return (
<p
className="px-[1vw] pt-[2vh] pb-[0.6vh] text-[clamp(0.9rem,1.5vw,2rem)] font-bold uppercase tracking-wide"
style={{ color }}
>
{entry.text}
</p>
)
}
const quiet = entry.kind === 'break'
return (
<div className={`flex items-baseline gap-[2vw] px-[1vw] ${sub ? 'py-[0.6vh]' : 'border-b border-brand/15 py-[1.2vh]'}`}>
<span
className={`shrink-0 font-semibold ${sub ? 'w-[10vw] text-[clamp(0.9rem,1.4vw,1.9rem)]' : 'w-[12vw] text-[clamp(1rem,1.8vw,2.4rem)]'}`}
style={{ color: quiet ? undefined : color }}
>
{entry.time}
</span>
<span className="min-w-0 flex-1">
<span
className={`block leading-tight ${
quiet ? 'font-semibold text-muted' : 'font-bold text-ink'
} ${sub ? 'text-[clamp(1rem,1.9vw,2.4rem)]' : 'text-[clamp(1.2rem,2.4vw,3rem)]'}`}
>
{entry.featured && (
<span className="mr-[0.6vw]" style={{ color }}>
<FeaturedStar className="h-[0.8em] w-[0.8em]" />
</span>
)}
{entry.text}
</span>
{(entry.location || entry.person || entry.tags?.length) && (
<span className="mt-1 flex flex-wrap items-center gap-x-[1.5vw] gap-y-1 text-[clamp(0.9rem,1.4vw,1.8rem)] text-muted">
{entry.location && <span>{entry.location}</span>}
{entry.person && <span>{entry.person.name}</span>}
<TagChips keys={entry.tags} tags={tags} accent={accent} className="px-[0.6vw] py-[0.2vh] text-[0.8em]" />
</span>
)}
</span>
</div>
)
}
function SlideView({ slide, accent }: { slide: Slide; accent: string }) {
const tags = useContext(ScheduleTags)
const color = accentText(accent)
if (slide.kind === 'overview') {
const entries = slide.day.entries
const two = lineCount(entries) > ONE_COLUMN
return (
<div className="flex h-full flex-col">
<Rise>
<h1 className="mb-[3vh] text-[clamp(2rem,5vw,6rem)] font-bold leading-none" style={{ color }}>
{slide.day.name || 'Schedule'}
</h1>
</Rise>
<Scroll>
<ul className={`grid content-start gap-x-[4vw] ${two ? 'grid-cols-2' : 'grid-cols-1'}`}>
<OverviewEntries entries={entries} accent={accent} />
</ul>
</Scroll>
</div>
)
}
if (slide.kind === 'tag') {
const tag = slide.tag!
const tagDays = slide.days ?? []
const tagColor = tag.color || accent
const two = tagDays.reduce((n, day) => n + 1 + lineCount(day.entries), 0) > ONE_COLUMN
let order = 1
return (
<div className="flex h-full flex-col">
<Rise>
<h1 className="mb-[3vh] text-[clamp(2rem,5vw,6rem)] font-bold leading-none" style={{ color: accentText(tagColor) }}>
{tag.name}
</h1>
</Rise>
<Scroll>
<ul className={`grid content-start gap-x-[4vw] ${two ? 'grid-cols-2' : 'grid-cols-1'}`}>
{tagDays.map((day, d) => {
const start = order
order += day.entries.length + 1
return (
<li key={d}>
{day.name && (
<Rise order={start} from="left">
<p className="pt-[1.5vh] pb-[0.5vh] text-[clamp(1rem,1.8vw,2.4rem)] font-bold text-ink">{day.name}</p>
</Rise>
)}
<ul>
<OverviewEntries entries={day.entries} accent={accent} start={start + 1} />
</ul>
</li>
)
})}
</ul>
</Scroll>
</div>
)
}
const entry = slide.entry!
if (slide.kind === 'block') {
const items = entry.items ?? []
return (
<div className="flex h-full flex-col">
<Rise>
<p className="text-[clamp(1.2rem,2.4vw,3rem)] font-semibold" style={{ color }}>
{[slide.day.name, entry.time].filter(Boolean).join(' · ')}
</p>
</Rise>
<Rise order={1}>
<h1 className="mt-[1vh] text-[clamp(2.4rem,5vw,6.5rem)] font-bold leading-[1.05] text-ink">
{entry.featured && (
<span className="mr-[1vw]" style={{ color }}>
<FeaturedStar className="h-[0.8em] w-[0.8em]" />
</span>
)}
{entry.text}
</h1>
</Rise>
{(entry.location || entry.person || entry.detail) && (
<Rise order={2}>
<p className="mt-[1vh] flex flex-wrap gap-x-[2vw] text-[clamp(1.1rem,2vw,2.6rem)] text-muted">
{[entry.location, entry.person?.name, entry.detail].filter(Boolean).map((part, i) => (
<span key={i}>{part}</span>
))}
</p>
</Rise>
)}
<Scroll className="mt-[4vh]">
<ul style={{ borderLeft: `0.4vw solid ${withAlpha(accent, 40)}` }}>
{items.map((item, i) => (
<li key={i} className="even:bg-tint-soft/60" style={item.featured ? featuredStyle(accent) : undefined}>
<Rise order={i + 3} from="left" className="flex items-center gap-[2vw] px-[2vw] py-[1.6vh]">
<span className="w-[14vw] shrink-0 text-[clamp(1rem,2vw,2.6rem)] font-semibold" style={{ color }}>
{item.time}
</span>
<span className="min-w-0 flex-1">
<span className="block text-[clamp(1.3rem,2.8vw,3.6rem)] font-bold leading-tight text-ink">
{item.featured && (
<span className="mr-[0.6vw]" style={{ color }}>
<FeaturedStar className="h-[0.8em] w-[0.8em]" />
</span>
)}
{item.text}
</span>
{(item.location || item.detail) && (
<span className="mt-1 block text-[clamp(0.9rem,1.6vw,2rem)] text-muted">
{[item.location, item.detail].filter(Boolean).join(' · ')}
</span>
)}
</span>
{item.person && (
<span className="flex shrink-0 items-center gap-[1vw] text-[clamp(0.9rem,1.6vw,2rem)] text-body">
<Avatar person={item.person} size="h-[5vw] w-[5vw] text-[1.4vw]" />
{item.person.name}
</span>
)}
</Rise>
</li>
))}
</ul>
</Scroll>
</div>
)
}
if (slide.kind === 'graphic' || slide.kind === 'map') {
const src = mediaUrl(slide.kind === 'map' ? entry.map_image : entry.media)
const alt = slide.kind === 'map' ? mapAlt(entry) : (entry.media_alt ?? '')
return (
<div className="flex h-full flex-col gap-[2vh]">
<Rise className="min-h-0 flex-1">
<img src={src ?? ''} alt={alt} className="h-full w-full object-contain" />
</Rise>
<Rise order={2} className="flex items-baseline gap-[2vw] text-[clamp(1.2rem,2.2vw,2.8rem)]">
<span className="font-semibold" style={{ color }}>
{entry.time}
</span>
<span className="font-bold text-ink">{entry.text}</span>
{slide.kind === 'map' && (entry.map || entry.location) && (
<span className="text-muted">{entry.map || entry.location}</span>
)}
</Rise>
</div>
)
}
// Spotlight: the person on the left, when there is one.
return (
<div className="flex h-full items-center gap-[5vw]">
{entry.person && (
<Rise from="left" className="flex w-[28vw] shrink-0 flex-col items-center text-center">
<Avatar person={entry.person} size="aspect-square w-full text-[4vw]" />
<p className="mt-[2vh] text-[clamp(1.4rem,2.6vw,3.2rem)] font-bold text-ink">{entry.person.name}</p>
{entry.person.tagline && (
<p className="text-[clamp(1rem,1.6vw,2rem)] text-muted">{entry.person.tagline}</p>
)}
</Rise>
)}
<Scroll center className="min-w-0 self-stretch">
<Rise from="right">
<p className="text-[clamp(1.2rem,2.4vw,3rem)] font-semibold" style={{ color }}>
{[slide.day.name, slide.parent?.text, entry.time].filter(Boolean).join(' · ')}
</p>
</Rise>
<Rise order={1} from="right">
<h1 className="mt-[1vh] text-[clamp(2.4rem,5.5vw,7rem)] font-bold leading-[1.05] text-ink">
{entry.featured && (
<span className="mr-[1vw]" style={{ color }}>
<FeaturedStar className="h-[0.8em] w-[0.8em]" />
</span>
)}
{entry.text}
</h1>
</Rise>
{entry.tags?.length ? (
<Rise order={2} from="right">
<p className="mt-[2vh]">
<TagChips keys={entry.tags} tags={tags} accent={accent} className="px-[1vw] py-[0.4vh] text-[clamp(0.9rem,1.6vw,2rem)]" />
</p>
</Rise>
) : null}
{entry.location && (
<Rise order={2} from="right">
<p className="mt-[2vh] text-[clamp(1.2rem,2.4vw,3rem)] text-body">{entry.location}</p>
</Rise>
)}
{entry.detail && (
<Rise order={3} from="right">
<p className="mt-[1vh] text-[clamp(1rem,2vw,2.4rem)] text-muted">{entry.detail}</p>
</Rise>
)}
{entry.description && (
<Rise order={4} from="right">
<div className="mt-[3vh] space-y-3 text-[clamp(1rem,1.8vw,2.2rem)] leading-snug text-muted">
<Paragraphs text={entry.description} accent={accent} />
</div>
</Rise>
)}
</Scroll>
</div>
)
}

View file

@ -587,6 +587,7 @@ export default function EntityEdit() {
options={options} options={options}
errors={errors} errors={errors}
errorPrefix={`${child.key}.`} errorPrefix={`${child.key}.`}
parentRow={form}
className="" className=""
onChange={(rows) => setForm((prev) => ({ ...prev, [child.key]: rows }))} onChange={(rows) => setForm((prev) => ({ ...prev, [child.key]: rows }))}
/> />

View file

@ -90,6 +90,11 @@ export const DATA_NAV = {
label: "Tags", label: "Tags",
blurb: "Descriptors for organizations and events, eg. Online, In-Person. Who carries a tag is edited on the record.", blurb: "Descriptors for organizations and events, eg. Online, In-Person. Who carries a tag is edited on the record.",
}, },
{
to: "/admin/venues",
label: "Venues",
blurb: "Places we gather, each with a map and its locations marked, for map blocks and schedules.",
},
{ {
to: "/admin/redirects", to: "/admin/redirects",
label: "Links/redirects", label: "Links/redirects",

View file

@ -19,6 +19,9 @@ import { useReadingMode } from '../../lib/readingMode.ts'
<OrgListCards kind="partner" pageLabel="Partner page" /> <OrgListCards kind="partner" pageLabel="Partner page" />
<OrgListCards ids={["unity-worldwide", "unity-of-x"]} /> in that order <OrgListCards ids={["unity-worldwide", "unity-of-x"]} /> in that order
<OrgListCards ids={...} nested /> inside a content block (093):
no page gutter, names under
the block's heading
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
@ -123,11 +126,11 @@ function OrgCard({ org, accent, pageLabel, siteLabel, titled }) {
); );
} }
function Block({ title, orgs, accent, pageLabel, siteLabel }) { function Block({ title, orgs, accent, pageLabel, siteLabel, nested = false }) {
if (orgs.length === 0) return null; if (orgs.length === 0) return null;
return ( return (
<section className="mb-12"> <section className={nested ? undefined : "mb-12"}>
{title && ( {title && (
<h3 className="text-xl font-bold mb-5" style={{ color: FALLBACK_COLOR }}> <h3 className="text-xl font-bold mb-5" style={{ color: FALLBACK_COLOR }}>
{title} {title}
@ -147,7 +150,7 @@ function Block({ title, orgs, accent, pageLabel, siteLabel }) {
accent={accent} accent={accent}
pageLabel={pageLabel} pageLabel={pageLabel}
siteLabel={siteLabel} siteLabel={siteLabel}
titled={!!title} titled={!!title || nested}
/> />
))} ))}
</div> </div>
@ -156,6 +159,25 @@ function Block({ title, orgs, accent, pageLabel, siteLabel }) {
} }
/* Just the logos, in a row: an organizations block presented (095).
Picked ones in their order, else every one of the kind by name. */
export function OrgLogoRow({ kind, ids, accent = FALLBACK_COLOR }: { kind?: string | null; ids?: string[]; accent?: string }) {
const { organizations } = useOrganizations(kind, ids);
const sorted = ids?.length
? ids.flatMap((id) => organizations.filter((org) => org.id === id))
: [...organizations].sort(byName);
return (
<ul className="flex flex-wrap items-center gap-8">
{sorted.map((org) => (
<li key={org.id} title={org.name}>
<span className="sr-only">{org.name}</span>
<OrgLogo org={org} color={org.color || accent} size="h-24 w-44" fallbackSize="h-24 w-24 text-3xl" />
</li>
))}
</ul>
);
}
export default function OrgListCards({ export default function OrgListCards({
kind, kind,
ids, ids,
@ -167,14 +189,30 @@ export default function OrgListCards({
siteLabel = "Visit site", siteLabel = "Visit site",
sort = byName, sort = byName,
empty = "Nothing to show here yet.", empty = "Nothing to show here yet.",
nested = false,
}: {
kind?: string | null;
ids?: string[];
title?: string;
groups?: Array<{ key: string; title: string; pageLabel?: string; siteLabel?: string }>;
groupBy?: (org: any) => unknown;
accent?: string;
pageLabel?: string;
siteLabel?: string;
sort?: ((a: any, b: any) => number) | null;
empty?: string;
nested?: boolean;
}) { }) {
const { organizations, loading, error } = useOrganizations(kind, ids); const { organizations, loading, error } = useOrganizations(kind, ids);
const shell = children => ( const shell = children =>
<div className="mx-auto px-8 md:px-12" style={{ maxWidth: GRID_MAX }}> nested ? (
{children} <div>{children}</div>
</div> ) : (
); <div className="mx-auto px-8 md:px-12" style={{ maxWidth: GRID_MAX }}>
{children}
</div>
);
if (loading && organizations.length === 0) { if (loading && organizations.length === 0) {
return shell( return shell(
@ -214,6 +252,7 @@ export default function OrgListCards({
accent={accent} accent={accent}
pageLabel={pageLabel} pageLabel={pageLabel}
siteLabel={siteLabel} siteLabel={siteLabel}
nested={nested}
/> />
); );
} }