Compare commits
No commits in common. "main" and "v1.14.1-schedule" have entirely different histories.
main
...
v1.14.1-sc
55 changed files with 1119 additions and 5235 deletions
|
|
@ -35,7 +35,6 @@ 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`.
|
||||
- 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`.
|
||||
- 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/`.
|
||||
- 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`.
|
||||
|
|
|
|||
12
docs/seo.md
12
docs/seo.md
|
|
@ -111,18 +111,6 @@ with it off it blocks everything.
|
|||
client_max_body_size 26m;
|
||||
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
|
||||
|
|
|
|||
|
|
@ -181,14 +181,8 @@ 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 → Platform | instagram, facebook, discord, youtube, tiktok, x, substack, spotify, linkedin | **yes**, `PLATFORMS` | `PlatformIcon.tsx` draws the icon on the button. **No CHECK and no `enumeration`**: the column is plain text, so adding one is an entry in `PLATFORMS` (`src/lib/platforms.ts`) and its icon in `src/components/PlatformIcon.tsx`, no migration. |
|
||||
| Content blocks → Shown in (slot) | card, body | **yes** | `paragraphs()` in `server/src/shape.js` (card), `ContentBlocks.tsx` (body) |
|
||||
| Content blocks → Type | heading, subheading, paragraph, list, links, quote, image, divider, video, button, callout, 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 `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 |
|
||||
| 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 → 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. |
|
||||
| Timeline → Kind (+ list filter) | milestone, event, organization, award, people | no | `KIND_NAMES` in `src/pages/sections/history/TimelineEntry.tsx` |
|
||||
| Timeline → Points at (+ list filter) | event, organization, award, person, team | no | `refHref` in `src/lib/hrefs.ts` |
|
||||
| Timeline → Precision (and on events/orgs) | year, month, day | no | the history page's grouping |
|
||||
|
|
@ -278,7 +272,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. |
|
||||
| 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 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. |
|
||||
| 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. |
|
||||
| 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 and person role labels (public site) | `ROLE_LABEL` in `src/pages/EventDetail.tsx` and `src/pages/PersonDetail.tsx` | |
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@ import { tags } from "./admin-schema/tags.js";
|
|||
import { contactTypes } from "./admin-schema/contactTypes.js";
|
||||
import { redirects } from "./admin-schema/redirects.js";
|
||||
import { pages } from "./admin-schema/sitePages.js";
|
||||
import { venues } from "./admin-schema/venues.js";
|
||||
|
||||
export const ENTITIES = {
|
||||
organizations,
|
||||
|
|
@ -74,7 +73,6 @@ export const ENTITIES = {
|
|||
tags,
|
||||
contact_types: contactTypes,
|
||||
redirects,
|
||||
venues,
|
||||
teams,
|
||||
awards,
|
||||
timeline,
|
||||
|
|
@ -100,10 +98,6 @@ export const OPTION_QUERIES = {
|
|||
// What an organization cards section can hand-pick (067).
|
||||
card_orgs:
|
||||
"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",
|
||||
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",
|
||||
|
|
@ -112,15 +106,6 @@ export const OPTION_QUERIES = {
|
|||
contact_types: "SELECT id, name AS label FROM contact_types ORDER BY sort_order, name",
|
||||
// Link fields with `redirects: true` pick from these (068).
|
||||
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",
|
||||
// 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",
|
||||
|
|
|
|||
|
|
@ -154,18 +154,11 @@ export const blocksChild = (ownerKind) => ({
|
|||
"people",
|
||||
// A blog post's tab (079): its text is the tab's title.
|
||||
"tab",
|
||||
// A venue's map, and event cards (088).
|
||||
"map",
|
||||
"events",
|
||||
// Organization cards (093).
|
||||
"organizations",
|
||||
],
|
||||
{ required: true },
|
||||
),
|
||||
text("text"),
|
||||
text("media"),
|
||||
// Image blocks (102): shown in place of media in the dark theme.
|
||||
text("media_dark"),
|
||||
url("href"),
|
||||
text("alt"),
|
||||
text("cite"),
|
||||
|
|
@ -177,23 +170,6 @@ export const blocksChild = (ownerKind) => ({
|
|||
int("word_seconds"),
|
||||
// People blocks only (054): whose team's tiles to show.
|
||||
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: [
|
||||
{
|
||||
|
|
@ -222,15 +198,6 @@ export const blocksChild = (ownerKind) => ({
|
|||
bool("featured"),
|
||||
// The block's tags it has, by key, comma-separated (087).
|
||||
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: [
|
||||
{
|
||||
|
|
@ -256,8 +223,6 @@ export const blocksChild = (ownerKind) => ({
|
|||
text("map_image"),
|
||||
bool("featured"),
|
||||
text("tags"),
|
||||
text("event_id"),
|
||||
text("location_key"),
|
||||
],
|
||||
},
|
||||
],
|
||||
|
|
@ -277,15 +242,6 @@ export const blocksChild = (ownerKind) => ({
|
|||
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")],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { text, int, real, bool, date, time, enumeration, placeColumns, timelineExtension, linksChild, blocksChild, hostsChild } from "./columns.js";
|
||||
import { text, int, bool, date, time, enumeration, placeColumns, timelineExtension, linksChild, blocksChild, hostsChild } from "./columns.js";
|
||||
import { tagsChild } from "./tags.js";
|
||||
|
||||
/* ── Events ──────────────────────────────────────────────────── */
|
||||
|
|
@ -67,28 +67,6 @@ export const events = {
|
|||
bool("is_published"),
|
||||
bool("is_listed"),
|
||||
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
|
||||
// schedule is always exactly one per event, and the public view
|
||||
|
|
|
|||
|
|
@ -214,11 +214,11 @@ const sectionsChild = {
|
|||
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
|
||||
records' own pages, the account pages and the remote. */
|
||||
records' own pages and the account pages. */
|
||||
const RESERVED = [
|
||||
"admin", "api", "uploads", "assets", "pa", "go",
|
||||
"events", "regions", "groups", "partners", "organizations", "teams", "awards", "people", "blog", "directory",
|
||||
"sign-in", "account", "remote", "sitemap.xml", "robots.txt",
|
||||
"sign-in", "account", "sitemap.xml", "robots.txt",
|
||||
];
|
||||
|
||||
/* After a save: the address is one a page may have. */
|
||||
|
|
|
|||
|
|
@ -1,47 +0,0 @@
|
|||
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"),
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
|
@ -43,7 +43,6 @@ import imports from "./routes/import.js";
|
|||
import files from "./routes/files.js";
|
||||
import countdown from "./routes/countdown.js";
|
||||
import redirects from "./routes/redirects.js";
|
||||
import present from "./routes/present.js";
|
||||
import { CLIPS_DIR, startClipWorker } from "./clips.js";
|
||||
import { UPLOADS_DIR, writeMissingThumbs } from "./media.js";
|
||||
import { logSafe, requireStaff, startSessionSweeper } from "./auth.js";
|
||||
|
|
@ -138,7 +137,7 @@ app.use(
|
|||
so each is capped well above its longest real body (a 5000
|
||||
character message) and far below nginx's limit. */
|
||||
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", "/api/present/*"]) 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"]) app.use(path, smallBody);
|
||||
|
||||
/* What the policy above would have blocked. Browsers post these on
|
||||
their own; a short line per report is plenty to go on. */
|
||||
|
|
@ -203,11 +202,6 @@ app.use("/api/countdown/*", rateLimit({ windowMs: 60_000, max: 600 }));
|
|||
app.route("/api", countdown);
|
||||
|
||||
// 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.route("/api/feedback", feedback);
|
||||
// Requests carry files: fewer again.
|
||||
|
|
|
|||
|
|
@ -1,125 +0,0 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 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;
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 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;
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 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;
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 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;
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 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'));
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 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;
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 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);
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 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;
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 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;
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 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);
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 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));
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 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;
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 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;
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 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'));
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 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;
|
||||
|
|
@ -413,9 +413,6 @@ export function metaFor(db, rawPath, user = null) {
|
|||
// in particular, so never indexed or in the sitemap.
|
||||
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
|
||||
// viewer; disabled stays out of search.
|
||||
const page = pageAt(db, pathname);
|
||||
|
|
@ -429,7 +426,7 @@ export function metaFor(db, rawPath, user = null) {
|
|||
};
|
||||
}
|
||||
|
||||
// An event page's presentation (EventPresent.tsx): the
|
||||
// An event's schedule presentation (SchedulePresent.tsx): the
|
||||
// event's own title and preview, kept out of search, pointing
|
||||
// search engines at the event page.
|
||||
const present = pathname.match(/^\/events\/([^/]+)\/present$/);
|
||||
|
|
|
|||
|
|
@ -591,42 +591,7 @@ content.get("/events/:id", (c) => {
|
|||
citation: r.citation,
|
||||
}));
|
||||
|
||||
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,
|
||||
};
|
||||
const event = { ...shapeEvent(row, links, cards, hosts), blocks: body, people, awards };
|
||||
attachTags(db, "event", [event]);
|
||||
|
||||
return json(c, { event });
|
||||
|
|
|
|||
|
|
@ -1,151 +0,0 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
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;
|
||||
|
|
@ -79,7 +79,6 @@ const MEMBERS = ["showcase-member-1", "showcase-member-2", "showcase-member-3"];
|
|||
const EVENT = "showcase-event";
|
||||
const SERIES = "showcase-series";
|
||||
const PAST = "showcase-past-event";
|
||||
const VENUE = "showcase-venue";
|
||||
|
||||
/* ── Content ───────────────────────────────────────────────── */
|
||||
|
||||
|
|
@ -88,24 +87,21 @@ const VENUE = "showcase-venue";
|
|||
a description, graphic and map, one linked, a heading, a featured
|
||||
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
|
||||
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. */
|
||||
with no day (it lands in a tab of its own). */
|
||||
const SCHEDULE = [
|
||||
"schedule",
|
||||
{ text: "The weekend at a glance. Tap an entry for more.", venue_id: VENUE },
|
||||
{ text: "The weekend at a glance. Tap an entry for more." },
|
||||
[
|
||||
{ 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", 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: "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: "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: [
|
||||
{ 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: "Leading worship", location: "Room A", person_id: "showcase-member-2", url: "/blog/content-block-showcase" },
|
||||
{ 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" },
|
||||
] },
|
||||
{ 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: "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: "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" },
|
||||
],
|
||||
|
|
@ -145,13 +141,6 @@ const ALL_BLOCKS = [
|
|||
["image", { media: IMAGE, alt: "The same picture, linked", href: "/history" }],
|
||||
["subheading", { text: "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" }],
|
||||
["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" }],
|
||||
|
|
@ -266,7 +255,6 @@ tx(db, () => {
|
|||
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 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 organizations WHERE id = ?`).run(GROUP);
|
||||
db.prepare(`DELETE FROM organizations WHERE id LIKE 'showcase-%'`).run();
|
||||
|
|
@ -424,6 +412,7 @@ tx(db, () => {
|
|||
{ kind: "social", platform: "instagram", label: "@showcaseretreat", url: "https://instagram.com/showcaseretreat" },
|
||||
]);
|
||||
blocks("event", EVENT, "both", cardText("event"));
|
||||
blocks("event", EVENT, "body", [...pageBody("event"), ["heading", { text: "Schedule" }], SCHEDULE]);
|
||||
|
||||
insert("events", {
|
||||
id: SERIES,
|
||||
|
|
@ -469,23 +458,6 @@ tx(db, () => {
|
|||
insert("event_people", { event_id: PAST, person_id: PERSON, role: "host", is_public: 1, sort_order: 0 });
|
||||
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 ── */
|
||||
insert("awards", {
|
||||
id: AWARD,
|
||||
|
|
|
|||
|
|
@ -64,32 +64,14 @@ export function loadLinks(db, ownerKind, ids) {
|
|||
rather than no key, so the renderer never has to check.
|
||||
───────────────────────────────────────────────────────────── */
|
||||
|
||||
/* 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) {
|
||||
export function loadBlocks(db, ownerKind, ids, slot = "body") {
|
||||
const out = new Map();
|
||||
if (ids.length === 0) return out;
|
||||
|
||||
const blockRows = db
|
||||
.prepare(
|
||||
`SELECT id, owner_id, type, text, media, media_dark, href, alt, cite, captions, team_id, venue_id,
|
||||
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
|
||||
`SELECT id, owner_id, type, text, media, href, alt, cite, captions, team_id,
|
||||
word_motion, word_direction, word_seconds
|
||||
FROM content_blocks
|
||||
WHERE owner_kind = ? AND slot IN (?, 'both') AND owner_id IN (${placeholders(ids.length)})
|
||||
ORDER BY owner_id, sort_order`,
|
||||
|
|
@ -105,22 +87,15 @@ export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) {
|
|||
type: row.type,
|
||||
text: row.text,
|
||||
media: row.media,
|
||||
media_dark: row.media_dark,
|
||||
href: row.href,
|
||||
alt: row.alt,
|
||||
cite: row.cite,
|
||||
captions: row.captions,
|
||||
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.
|
||||
words: row.word_motion || row.word_direction || row.word_seconds
|
||||
? { motion: row.word_motion, direction: row.word_direction, seconds: row.word_seconds }
|
||||
: null,
|
||||
// How it's presented (095), when anything is set.
|
||||
present: presentOf(row),
|
||||
items: [],
|
||||
};
|
||||
byId.set(row.id, block);
|
||||
|
|
@ -134,13 +109,12 @@ export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) {
|
|||
|
||||
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.event_id, i.location_key,
|
||||
p.id AS person_id, p.display_name AS person_name,
|
||||
p.photo AS person_photo, p.tagline AS person_tagline`;
|
||||
|
||||
const itemRows = db
|
||||
.prepare(
|
||||
`SELECT i.id, i.block_id, i.day, i.kind, i.heading, i.subheading, i.org_id, ${ENTRY_FIELDS}
|
||||
`SELECT i.id, i.block_id, i.day, i.kind, ${ENTRY_FIELDS}
|
||||
FROM content_block_items i
|
||||
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)})
|
||||
|
|
@ -152,15 +126,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) {
|
|||
// ride along anyway rather than branching on the block's type.
|
||||
const itemsById = new Map();
|
||||
for (const row of itemRows) {
|
||||
const item = {
|
||||
...scheduleEntry(row),
|
||||
day: row.day,
|
||||
kind: row.kind ?? "entry",
|
||||
heading: row.heading,
|
||||
subheading: row.subheading,
|
||||
org_id: row.org_id,
|
||||
items: [],
|
||||
};
|
||||
const item = { ...scheduleEntry(row), day: row.day, kind: row.kind ?? "entry", items: [] };
|
||||
itemsById.set(row.id, item);
|
||||
byId.get(row.block_id)?.items.push(item);
|
||||
}
|
||||
|
|
@ -206,146 +172,9 @@ export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) {
|
|||
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;
|
||||
}
|
||||
|
||||
/* 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
|
||||
to show: the typed override, else the picked times (086). An
|
||||
unpublished person comes back as no person. */
|
||||
|
|
@ -365,8 +194,6 @@ function scheduleEntry(row) {
|
|||
map_image: row.map_image,
|
||||
featured: row.featured === 1,
|
||||
tags: row.tags ? row.tags.split(",").filter(Boolean) : [],
|
||||
event_id: row.event_id,
|
||||
location_key: row.location_key,
|
||||
person: row.person_id
|
||||
? {
|
||||
id: row.person_id,
|
||||
|
|
|
|||
16
src/App.tsx
16
src/App.tsx
|
|
@ -67,8 +67,7 @@ const AwardDetail = lazyPage(() => import("./pages/AwardDetail.tsx"))
|
|||
const PersonDetail = lazyPage(() => import("./pages/PersonDetail.tsx"))
|
||||
const BlogPost = lazyPage(() => import("./pages/BlogPost.tsx"))
|
||||
const DirectoryPage = lazyPage(() => import("./pages/DirectoryPage.tsx"))
|
||||
const EventPresent = lazyPage(() => import("./pages/EventPresent.tsx"))
|
||||
const PresentRemote = lazyPage(() => import("./pages/PresentRemote.tsx"))
|
||||
const SchedulePresent = lazyPage(() => import("./pages/SchedulePresent.tsx"))
|
||||
|
||||
/*Admin Pages*/
|
||||
const AdminLayout = lazyPage(() => import("./pages/admin/AdminLayout.tsx"))
|
||||
|
|
@ -111,21 +110,12 @@ export default function App() {
|
|||
{/* Every page of the site: Pages → Page management (PageAtPath). */}
|
||||
<Route path="*" element={<PageAtPath />} />
|
||||
</Route>
|
||||
{/* An event page as a slideshow for a screen: full screen, no Layout. */}
|
||||
{/* A schedule as a slideshow for a screen: full screen, no Layout. */}
|
||||
<Route
|
||||
path="/events/:id/present"
|
||||
element={
|
||||
<Suspense fallback={null}>
|
||||
<EventPresent />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
{/* A phone driving a presenting screen, by its code. */}
|
||||
<Route
|
||||
path="/remote/:code?"
|
||||
element={
|
||||
<Suspense fallback={null}>
|
||||
<PresentRemote />
|
||||
<SchedulePresent />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -30,14 +30,6 @@
|
|||
people team_id's members as people tiles, then
|
||||
items as more tiles: person, text their
|
||||
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
|
||||
|
||||
"Formatted" is InlineText.tsx: **bold**, *italic*, [text](url),
|
||||
|
|
@ -52,38 +44,26 @@
|
|||
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 PeopleTiles from './PeopleTiles.tsx'
|
||||
import type { ContentBlock, ContentBlockItem, ItemEvent } from '../lib/useContent.ts'
|
||||
import type { ContentBlock, ContentBlockItem } from '../lib/useContent.ts'
|
||||
import { Anchor, Inline, Paragraphs, isExternalUrl } from './InlineText.tsx'
|
||||
import VideoPlayer from './VideoPlayer.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 ScheduleBlock from './ScheduleBlock.tsx'
|
||||
import { accentText, BRAND } from '../lib/color.ts'
|
||||
import { headingAnchors } from '../lib/contents.ts'
|
||||
import { SITE_NAME } from '../lib/site.ts'
|
||||
import { useSmallImage } from '../lib/useSmallImage.ts'
|
||||
import { useReadingMode } from '../lib/readingMode.ts'
|
||||
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)'
|
||||
|
||||
/* 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({
|
||||
blocks,
|
||||
accent = BRAND,
|
||||
className = '',
|
||||
presentAt,
|
||||
anchorPrefix = '',
|
||||
}: {
|
||||
blocks?: ContentBlock[] | null
|
||||
|
|
@ -91,19 +71,10 @@ export default function ContentBlocks({
|
|||
className?: string
|
||||
/** Put before each heading's id: a blog post's tab (contents.ts, splitTabs). */
|
||||
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
|
||||
// Headings get ids so a post's contents (PostContents) and a shared
|
||||
// link (#getting-there) can point at them.
|
||||
|
|
@ -118,19 +89,12 @@ export default function ContentBlocks({
|
|||
return level
|
||||
})
|
||||
|
||||
|
||||
// The places mapped here, for a schedule's places to link to: a
|
||||
// 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))
|
||||
: [],
|
||||
),
|
||||
let schedules = 0
|
||||
const presentHrefs = blocks.map((block) =>
|
||||
presentAt && block.type === 'schedule' ? `${presentAt}?block=${schedules++}` : undefined,
|
||||
)
|
||||
|
||||
return (
|
||||
<PageMaps.Provider value={maps}>
|
||||
<div className={`space-y-6 ${className}`}>
|
||||
{blocks.map((block, index) => (
|
||||
<WordMotion key={block.id ?? index} settings={block.words}>
|
||||
|
|
@ -139,11 +103,11 @@ export default function ContentBlocks({
|
|||
accent={accent}
|
||||
anchor={idAt.get(index)}
|
||||
level={levels[index]}
|
||||
presentHref={presentHrefs[index]}
|
||||
/>
|
||||
</WordMotion>
|
||||
))}
|
||||
</div>
|
||||
</PageMaps.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -180,182 +144,6 @@ 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
|
||||
split by "|" (a literal bar is "\|"), blank lines skipped. A
|
||||
leading and trailing bar, as in Markdown, is allowed. */
|
||||
|
|
@ -387,19 +175,16 @@ function Block({
|
|||
accent,
|
||||
anchor,
|
||||
level,
|
||||
presentHref,
|
||||
}: {
|
||||
block: ContentBlock
|
||||
accent: string
|
||||
anchor?: string
|
||||
level: 3 | 4 | 5
|
||||
presentHref?: string
|
||||
}) {
|
||||
const text = block.text ?? ''
|
||||
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) {
|
||||
// A blog post's tab marker (BlogPost.tsx splits the post at
|
||||
|
|
@ -419,10 +204,7 @@ function Block({
|
|||
</h4>
|
||||
)
|
||||
|
||||
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'
|
||||
case 'list':
|
||||
return (
|
||||
<ul className="space-y-2">
|
||||
{(block.items ?? []).map((item, index) => (
|
||||
|
|
@ -430,23 +212,20 @@ function Block({
|
|||
<span aria-hidden="true" style={{ color: accentText(accent) }}>
|
||||
•
|
||||
</span>
|
||||
<span style={{ color: plain ? BODY : 'var(--color-body)' }}>
|
||||
<span className={plain ? undefined : 'font-bold'}>
|
||||
{item.url && !presenting ? (
|
||||
<span style={{ color: BODY }}>
|
||||
{item.url ? (
|
||||
<Anchor href={item.url} className="underline" style={{ color: accentText(accent) }}>
|
||||
{item.text}
|
||||
</Anchor>
|
||||
) : (
|
||||
<Inline text={item.text} accent={accent} />
|
||||
)}
|
||||
</span>
|
||||
{item.detail && <span className={plain ? 'opacity-70' : undefined}>: {item.detail}</span>}
|
||||
{item.detail && <span className="opacity-70">: {item.detail}</span>}
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
|
||||
case 'links':
|
||||
return (
|
||||
|
|
@ -564,7 +343,7 @@ function Block({
|
|||
)
|
||||
|
||||
case 'image': {
|
||||
const src = mediaUrl((dark && block.media_dark) || block.media)
|
||||
const src = mediaUrl(block.media)
|
||||
if (!src) return null
|
||||
// The reader leaves out a picture with no alt, and its link with it.
|
||||
if (reading && block.href && !block.alt) {
|
||||
|
|
@ -586,7 +365,7 @@ function Block({
|
|||
/>
|
||||
)
|
||||
return (
|
||||
<figure className={block.image_size ? `mx-auto ${IMAGE_SIZE[block.image_size]}` : undefined}>
|
||||
<figure>
|
||||
{block.href ? <Anchor href={block.href}>{img}</Anchor> : img}
|
||||
<Caption text={text} />
|
||||
</figure>
|
||||
|
|
@ -612,36 +391,10 @@ function Block({
|
|||
tags={block.tags}
|
||||
intro={block.text}
|
||||
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': {
|
||||
const picked = (block.items ?? [])
|
||||
.filter((item) => item.person)
|
||||
|
|
@ -649,8 +402,8 @@ function Block({
|
|||
if (!block.team_id && picked.length === 0) return null
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{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} row={presenting} titles={block.present?.titles} />}
|
||||
{block.team_id && <PeopleTiles size="lg" teams={block.team_id} accent={accent} headingLevel={level} />}
|
||||
{picked.length > 0 && <PeopleTiles size="lg" people={picked} accent={accent} headingLevel={level} />}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
@ -661,7 +414,7 @@ function Block({
|
|||
case 'paragraph':
|
||||
default:
|
||||
if (!text) return null
|
||||
return block.href && !presenting ? (
|
||||
return block.href ? (
|
||||
<p className="leading-relaxed" style={{ color: BODY }}>
|
||||
<Anchor href={block.href} className="underline" style={{ color: accentText(accent) }}>
|
||||
{text}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import { Fragment, type CSSProperties, type ReactNode } from 'react'
|
|||
import { Link } from 'react-router-dom'
|
||||
import { accentText } from '../lib/color.ts'
|
||||
import { RotatingWords } from './RotatingWords.tsx'
|
||||
import { usePresenting } from '../lib/presenting.ts'
|
||||
|
||||
const TOKEN = /\*\*(.+?)\*\*|\*(.+?)\*|\[([^\]]+)\]\(([^)\s]+)\)|\{([^{}|\n]+(?:\|[^{}|\n]+)+)\}/g
|
||||
const SAFE_URL = /^(\/(?!\/)|#|https?:\/\/|mailto:|tel:)/i
|
||||
|
|
@ -78,8 +77,7 @@ export function Anchor({
|
|||
)
|
||||
}
|
||||
|
||||
/* `plain`: a link's text alone, presented (095). */
|
||||
function line(text: string, accent: string, key: string, plain = false): ReactNode[] {
|
||||
function line(text: string, accent: string, key: string): ReactNode[] {
|
||||
const out: ReactNode[] = []
|
||||
let last = 0
|
||||
let n = 0
|
||||
|
|
@ -91,7 +89,6 @@ function line(text: string, accent: string, key: string, plain = false): ReactNo
|
|||
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 (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)) {
|
||||
out.push(
|
||||
<Anchor key={k} href={url} className="underline underline-offset-2" style={{ color: accentText(accent) }}>
|
||||
|
|
@ -107,14 +104,13 @@ function line(text: string, accent: string, key: string, plain = false): ReactNo
|
|||
|
||||
/** Text inside another element: formatting and line breaks. */
|
||||
export function Inline({ text, accent }: { text?: string | null; accent: string }) {
|
||||
const plain = usePresenting()
|
||||
const lines = (text ?? '').split('\n')
|
||||
return (
|
||||
<>
|
||||
{lines.map((part, i) => (
|
||||
<Fragment key={i}>
|
||||
{i > 0 && <br />}
|
||||
{line(part, accent, `l${i}`, plain)}
|
||||
{line(part, accent, `l${i}`)}
|
||||
</Fragment>
|
||||
))}
|
||||
</>
|
||||
|
|
|
|||
|
|
@ -1,372 +0,0 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
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>
|
||||
)
|
||||
}
|
||||
|
|
@ -165,10 +165,6 @@ export interface PeopleTilesProps
|
|||
/** 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. */
|
||||
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. */
|
||||
ttl?: number;
|
||||
emptyMessage?: string;
|
||||
|
|
@ -199,14 +195,8 @@ export default function PeopleTiles({
|
|||
ttl = 5 * 60_000,
|
||||
loadingMessage = "Loading…",
|
||||
errorMessage = "Couldn't load this list right now.",
|
||||
row = false,
|
||||
titles = false,
|
||||
...view
|
||||
}: PeopleTilesProps) {
|
||||
const View = useMemo(
|
||||
() => (row ? (props) => <PeopleRow {...props} titles={titles} /> : PeopleTilesView),
|
||||
[row, titles],
|
||||
);
|
||||
const specs = useMemo(() => normalizeTeams(teams), [teams]);
|
||||
const teamKey = specs.map((spec) => spec.id).join(",");
|
||||
|
||||
|
|
@ -288,14 +278,14 @@ export default function PeopleTiles({
|
|||
if (specs.length) {
|
||||
if (failed) return <p className="pl__empty">{errorMessage}</p>;
|
||||
if (!teamGroups) return <p className="pl__empty">{loadingMessage}</p>;
|
||||
return <View {...view} groups={teamGroups} />;
|
||||
return <PeopleTilesView {...view} groups={teamGroups} />;
|
||||
}
|
||||
|
||||
if (slugKey) {
|
||||
if (failed) return <p className="pl__empty">{errorMessage}</p>;
|
||||
if (!directory) return <p className="pl__empty">{loadingMessage}</p>;
|
||||
return (
|
||||
<View
|
||||
<PeopleTilesView
|
||||
{...view}
|
||||
groups={groups?.map((group) => ({
|
||||
...group,
|
||||
|
|
@ -307,7 +297,7 @@ export default function PeopleTiles({
|
|||
}
|
||||
|
||||
return (
|
||||
<View
|
||||
<PeopleTilesView
|
||||
{...view}
|
||||
groups={groups as PeopleGroup[] | undefined}
|
||||
people={people as Person[] | undefined}
|
||||
|
|
@ -778,25 +768,6 @@ 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 }) {
|
||||
const img = useSmallImage(src);
|
||||
|
||||
|
|
|
|||
|
|
@ -28,18 +28,12 @@
|
|||
|
||||
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
|
||||
in a row of its own under the days, with a note saying what it
|
||||
does, gathering what it's on from every day under the day's name. A tagged entry comes whole; an untagged block comes
|
||||
after the days, 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.
|
||||
|
||||
An entry's place on the block's venue (088) links to the map
|
||||
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).
|
||||
On an event page a Present button opens the schedule as a
|
||||
slideshow for a screen (SchedulePresent.tsx).
|
||||
|
||||
Tabs follow the ARIA tab pattern: arrow keys move between them.
|
||||
|
||||
|
|
@ -48,9 +42,9 @@
|
|||
it, no map frame (ReadingSchedule).
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { CaretDown, MapPin, Star, Tag as TagIcon } from '@phosphor-icons/react'
|
||||
import { CaretDown, Presentation, Star } from '@phosphor-icons/react'
|
||||
import { Fragment, createContext, useContext, useId, useState, type KeyboardEvent, type ReactNode } from 'react'
|
||||
import { Link, useLocation } from 'react-router-dom'
|
||||
import { Link } from 'react-router-dom'
|
||||
|
||||
import { personHref } from '../lib/hrefs.ts'
|
||||
import { mediaUrl, initials } from '../lib/media.ts'
|
||||
|
|
@ -60,7 +54,6 @@ import { withAlpha, accentText, readableOn } from '../lib/color.ts'
|
|||
import { useSmallImage } from '../lib/useSmallImage.ts'
|
||||
import { focusOnMount } from '../lib/focus.ts'
|
||||
import { useReadingMode } from '../lib/readingMode.ts'
|
||||
import { PageMaps, mapAnchor } from './MapBlock.tsx'
|
||||
|
||||
const BODY = 'var(--color-muted)'
|
||||
const WEEKDAYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
|
||||
|
|
@ -143,26 +136,6 @@ function todayIndex(days: Day[]): number {
|
|||
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. */
|
||||
export const mapAlt = (entry: ContentBlockItem) => `Map: ${entry.map?.trim() || entry.location || entry.text}`
|
||||
|
||||
|
|
@ -267,7 +240,7 @@ function Entry({ entry, accent, sub = false }: { entry: ContentBlockItem; accent
|
|||
</p>
|
||||
{(entry.location || entry.person) && (
|
||||
<p className="mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-sm" style={{ color: BODY }}>
|
||||
<Place entry={entry} accent={accent} />
|
||||
{entry.location && <span>{entry.location}</span>}
|
||||
{entry.person && (
|
||||
<span className="inline-flex items-center gap-2">
|
||||
<Avatar person={entry.person} size="h-6 w-6" />
|
||||
|
|
@ -475,11 +448,14 @@ export default function ScheduleBlock({
|
|||
tags = [],
|
||||
intro,
|
||||
accent,
|
||||
presentHref,
|
||||
}: {
|
||||
items: ContentBlockItem[]
|
||||
tags?: ScheduleTag[]
|
||||
intro?: string | null
|
||||
accent: string
|
||||
/** Where the Present button goes; no button without it. */
|
||||
presentHref?: string
|
||||
}) {
|
||||
const days = groupByDay(items)
|
||||
const [active, setActive] = useState(() => todayIndex(days))
|
||||
|
|
@ -496,41 +472,9 @@ export default function ScheduleBlock({
|
|||
.map((tag) => ({ label: tag.name, days: daysWithTag(days, tag.key), color: tag.color, tag: true }))
|
||||
.filter((tab) => tab.days.length),
|
||||
]
|
||||
const dayCount = days.length
|
||||
const at = Math.min(active, tabs.length - 1)
|
||||
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.
|
||||
const onKey = (e: KeyboardEvent<HTMLButtonElement>) => {
|
||||
const last = tabs.length - 1
|
||||
|
|
@ -555,29 +499,48 @@ export default function ScheduleBlock({
|
|||
</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 && (
|
||||
<div className="space-y-3">
|
||||
{/* Days, then the tags in a row of their own: one tablist,
|
||||
so the arrow keys still walk every tab. */}
|
||||
<div role="tablist" aria-label="Days and tags" className="space-y-3">
|
||||
<div role="presentation" className="flex flex-wrap gap-2">
|
||||
{tabs.slice(0, dayCount).map((tab, index) => tabButton(tab, index))}
|
||||
</div>
|
||||
{tabs.length > dayCount && (
|
||||
<div role="presentation" className="flex flex-wrap items-center gap-2 border-t border-brand/15 pt-3">
|
||||
<span aria-hidden="true" className="mr-1 inline-flex items-center gap-1.5 text-sm font-semibold text-ink">
|
||||
<TagIcon weight="bold" className="h-4 w-4" />
|
||||
By tag
|
||||
</span>
|
||||
{tabs.slice(dayCount).map((tab, i) => tabButton(tab, dayCount + i))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{tabs.length > dayCount && (
|
||||
<p className="text-sm text-muted">
|
||||
Pick a tag to see everything it's on, from every day.
|
||||
</p>
|
||||
)}
|
||||
<div role="tablist" aria-label="Days and tags" className="flex flex-wrap gap-2">
|
||||
{tabs.map((tab, index) => {
|
||||
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 border px-5 py-2 text-sm transition-colors"
|
||||
style={
|
||||
selected
|
||||
? { background: color, borderColor: color, color: readableOn(color) }
|
||||
: { borderColor: `${withAlpha(color, 33)}`, color: accentText(color) }
|
||||
}
|
||||
>
|
||||
{tab.label}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,130 +0,0 @@
|
|||
/* 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>
|
||||
);
|
||||
}
|
||||
|
|
@ -77,15 +77,6 @@
|
|||
Data → Links/redirects (the `redirects` options) that fills the
|
||||
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
|
||||
"Send a test notice" button (TestNoticeInput below), for Site
|
||||
settings → Notices.
|
||||
|
|
@ -123,9 +114,6 @@ import ContentBlocks from "../ContentBlocks.tsx";
|
|||
import { FILTER_FROM, OptionFilter, narrow } from "../OptionFilter.tsx";
|
||||
import { ImageInput, LinkPreviewInput } from "./MediaLibrary.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";
|
||||
|
||||
/* Live previews a collection can name with `preview`. Each gets the
|
||||
|
|
@ -134,41 +122,21 @@ const PREVIEWS = {
|
|||
// 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
|
||||
// photo: the options carry no more).
|
||||
// A venue and an item's event and map location come from the
|
||||
// options the same way (088): an event as its title only. A map
|
||||
// block's sections (094) are made as the API makes them (shape.js):
|
||||
// their keys the venue still has, the venue cut to those.
|
||||
contentBlock: (row, options) => {
|
||||
const venue = venueFromOption(options?.venues?.find((v) => v.id === row.venue_id));
|
||||
const known = new Map((venue?.locations ?? []).map((l) => [l.key, l]));
|
||||
const sections = (row.map_sections ?? [])
|
||||
.map((section) => ({
|
||||
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 (
|
||||
contentBlock: (row, options) => (
|
||||
<ContentBlocks
|
||||
blocks={[{ ...row, venue: mapped, map_sections: sections, items: (row.items ?? []).map(shape) }]}
|
||||
/>
|
||||
);
|
||||
blocks={[
|
||||
{
|
||||
...row,
|
||||
items: (row.items ?? []).map((item) => {
|
||||
const person = item.person_id
|
||||
? options?.people?.find((p) => p.id === item.person_id)
|
||||
: null;
|
||||
return { ...item, person: person ? { id: person.id, name: person.label } : null };
|
||||
}),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
),
|
||||
};
|
||||
|
||||
const input =
|
||||
|
|
@ -314,7 +282,7 @@ function Checklist({ id, options, value, disabled, empty, onChange }: {
|
|||
|
||||
/* ── Field ───────────────────────────────────────────────────── */
|
||||
|
||||
export function Field({ field, value, row, parentRow, options, error, onChange, onPatch }: any) {
|
||||
export function Field({ field, value, row, options, error, onChange, onPatch }: any) {
|
||||
const id = `f-${field.path.replace(/\./g, "-")}`;
|
||||
const widget = field.widget ?? "text";
|
||||
// readOnly may be a test of the row (a core page's address).
|
||||
|
|
@ -429,14 +397,6 @@ export function Field({ field, value, row, parentRow, options, error, onChange,
|
|||
)}
|
||||
<select
|
||||
{...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}
|
||||
className={`${locked ? inputLocked : common.className} ${
|
||||
orphaned && !locked ? inputError : ""
|
||||
|
|
@ -480,13 +440,6 @@ export function Field({ field, value, row, parentRow, options, error, onChange,
|
|||
onChange={onChange}
|
||||
onPatch={onPatch}
|
||||
/>
|
||||
) : widget === "mapMarker" ? (
|
||||
<MapMarkerInput
|
||||
image={field.imageFrom ? mediaUrl(parentRow?.[field.imageFrom]) : null}
|
||||
row={row}
|
||||
locked={locked}
|
||||
onPatch={onPatch}
|
||||
/>
|
||||
) : widget === "testNotice" ? (
|
||||
<TestNoticeInput
|
||||
id={id}
|
||||
|
|
@ -852,11 +805,8 @@ export function Repeater({
|
|||
key={field.path}
|
||||
field={field}
|
||||
row={row}
|
||||
parentRow={parentRow}
|
||||
value={row[field.path]}
|
||||
// Its own lent options too: a map block's
|
||||
// Locations with a slide (095).
|
||||
options={spec.lends ? { ...options, ...spec.lends(row, options) } : options}
|
||||
options={options}
|
||||
error={errors?.[`${errorPrefix}${index}.${field.path}`]}
|
||||
onChange={(value) => update(index, { ...row, [field.path]: value })}
|
||||
onPatch={(patch) => update(index, { ...row, ...patch })}
|
||||
|
|
@ -871,7 +821,7 @@ export function Repeater({
|
|||
<Repeater
|
||||
spec={nested}
|
||||
rows={row[nested.key]}
|
||||
options={spec.lends ? { ...options, ...spec.lends(row, options) } : options}
|
||||
options={spec.lends ? { ...options, ...spec.lends(row) } : options}
|
||||
errors={errors}
|
||||
errorPrefix={`${errorPrefix}${index}.${nested.key}.`}
|
||||
parentRow={row}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ import { tags } from "./adminSchema/tags.ts";
|
|||
import { contactTypes } from "./adminSchema/contactTypes.ts";
|
||||
import { redirects } from "./adminSchema/redirects.ts";
|
||||
import { pages } from "./adminSchema/sitePages.ts";
|
||||
import { venues } from "./adminSchema/venues.ts";
|
||||
|
||||
export const ADMIN_ENTITIES: Record<string, any> = {
|
||||
organizations,
|
||||
|
|
@ -43,7 +42,6 @@ export const ADMIN_ENTITIES: Record<string, any> = {
|
|||
tags,
|
||||
contact_types: contactTypes,
|
||||
redirects,
|
||||
venues,
|
||||
teams,
|
||||
awards,
|
||||
timeline,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
import { mediaUrl } from "../media.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] };
|
||||
import { PLACE_FIELDS, PUBLISHED_FIELD, LISTED_FIELD, timelineGroup, timelineDetailGroup, linksChild, hostsChild, blocksChild, tagsChild } from "./shared.ts";
|
||||
|
||||
/* ── Events ──────────────────────────────────────────────────── */
|
||||
|
||||
|
|
@ -176,113 +173,6 @@ 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"),
|
||||
timelineDetailGroup("event"),
|
||||
{ legend: "Publishing", fields: [PUBLISHED_FIELD, LISTED_FIELD] },
|
||||
|
|
@ -325,6 +215,6 @@ export const events = {
|
|||
],
|
||||
},
|
||||
linksChild,
|
||||
eventBlocksChild,
|
||||
blocksChild,
|
||||
],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -309,9 +309,6 @@ 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."],
|
||||
["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."],
|
||||
["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."],
|
||||
];
|
||||
|
||||
|
|
@ -339,44 +336,6 @@ export const CARD_ITEM = { scope: "parent", path: "type", value: "cards" };
|
|||
export const NOT_CARD_ITEM = { scope: "parent", path: "type", value: ["list", "links", "schedule"] };
|
||||
/* An item that's a person on a people block. */
|
||||
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;
|
||||
|
||||
|
|
@ -458,10 +417,8 @@ const TAGS_FIELD = {
|
|||
block's day. */
|
||||
const SUB_ITEM_FIELDS = [
|
||||
...scheduleTimeFields(),
|
||||
eventField(),
|
||||
{ path: "text", label: "Title", required: true },
|
||||
placeField(),
|
||||
{ path: "location", label: "Location", help: "eg. Room B. Default: the map location's name" },
|
||||
{ path: "location", label: "Location", help: "eg. Room B" },
|
||||
{
|
||||
path: "person_id",
|
||||
label: "Person",
|
||||
|
|
@ -494,70 +451,6 @@ const SUB_ITEM_FIELDS = [
|
|||
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 = {
|
||||
key: "content_blocks",
|
||||
label: "Content blocks",
|
||||
|
|
@ -596,28 +489,6 @@ export const blocksChild = {
|
|||
when: { path: "type", value: TEXT_TYPES },
|
||||
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",
|
||||
label: "Attribution",
|
||||
|
|
@ -659,29 +530,6 @@ export const blocksChild = {
|
|||
when: { path: "type", value: "video" },
|
||||
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",
|
||||
label: "Alt text",
|
||||
|
|
@ -698,29 +546,13 @@ export const blocksChild = {
|
|||
help: "Shows the team's members as tiles, its leads first. People added as items show after it.",
|
||||
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"] }),
|
||||
],
|
||||
// A schedule's tags, for its entries' and sub-items' Tags (087).
|
||||
lends: (row, options) => ({
|
||||
lends: (row) => ({
|
||||
scheduleTags: (row.tags ?? [])
|
||||
.filter((tag) => tag.name?.trim())
|
||||
.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: [
|
||||
{
|
||||
|
|
@ -737,31 +569,11 @@ export const blocksChild = {
|
|||
{ 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",
|
||||
label: "Items",
|
||||
addLabel: "Add item",
|
||||
when: { path: "type", value: ["list", "links", "schedule", "cards", "people", "events", "organizations"] },
|
||||
when: { path: "type", value: ["list", "links", "schedule", "cards", "people"] },
|
||||
title: (row) => [row.day, row.time || row.start_time, row.text].filter(Boolean).join(" · ") || "New item",
|
||||
blank: { text: "" },
|
||||
fields: [
|
||||
|
|
@ -801,38 +613,11 @@ export const blocksChild = {
|
|||
help: "Shown as a tile with their photo, linked to their page",
|
||||
when: PEOPLE_ITEM,
|
||||
},
|
||||
{
|
||||
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: "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: "location",
|
||||
label: "Location",
|
||||
help: "eg. Main Hall. Default: the map location's name",
|
||||
help: "eg. Main Hall",
|
||||
when: SCHEDULE_ENTRY,
|
||||
},
|
||||
{
|
||||
|
|
@ -846,7 +631,6 @@ 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: "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: "media",
|
||||
|
|
@ -902,15 +686,6 @@ export const blocksChild = {
|
|||
},
|
||||
{ path: "featured", label: "Featured", widget: "checkbox", help: "Makes the row stand out", 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: [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,82 +0,0 @@
|
|||
/* ── 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",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
import { visionColor } from "./color.ts";
|
||||
|
||||
export const BASE = import.meta.env?.VITE_API_BASE ?? "/api";
|
||||
const BASE = import.meta.env?.VITE_API_BASE ?? "/api";
|
||||
const DEFAULT_TTL = 60_000;
|
||||
|
||||
/* A draft's preview (server/src/drafts.js): a tab opened from the
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
/* 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)
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
/* 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)
|
||||
|
|
@ -43,9 +43,6 @@ export type ContentBlock = {
|
|||
| 'tab'
|
||||
| 'cards'
|
||||
| 'people'
|
||||
| 'map'
|
||||
| 'events'
|
||||
| 'organizations'
|
||||
text?: string | null
|
||||
media?: string | null
|
||||
href?: string | null
|
||||
|
|
@ -55,110 +52,11 @@ export type ContentBlock = {
|
|||
team_id?: string | null
|
||||
/** Who a quote is by. */
|
||||
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). */
|
||||
captions?: string | null
|
||||
items?: ContentBlockItem[]
|
||||
/** A schedule's own tags (087). */
|
||||
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. */
|
||||
|
|
@ -187,20 +85,10 @@ export type ContentBlockItem = {
|
|||
start_time?: string | null
|
||||
end_time?: string | null
|
||||
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. */
|
||||
items?: ContentBlockItem[]
|
||||
/** Its block's tags it has, by key (087). */
|
||||
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 = {
|
||||
|
|
@ -286,12 +174,6 @@ export type EventRecord = {
|
|||
links: Link[]
|
||||
/** The instagram link's label, the handle. See splitLinks in shape.js. */
|
||||
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[]
|
||||
people: EventPerson[]
|
||||
awards: EventAward[]
|
||||
|
|
|
|||
|
|
@ -1,88 +0,0 @@
|
|||
/* 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 }
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
A version with no words after its number has no name.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
export const SITE_VERSION = "NGU-Web.v1.14.2-present";
|
||||
export const SITE_VERSION = "NGU-Web.v1.14.1-schedule";
|
||||
|
||||
/** The number, eg. v1.13.2. */
|
||||
export const VERSION_NUMBER: string = SITE_VERSION.match(/v\d+(?:\.\d+)*/)?.[0] ?? SITE_VERSION
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ import PageShell, { type ShellSection } from '../components/PageShell.tsx'
|
|||
import PageState from '../components/PageState.tsx'
|
||||
import PlatformIcon from '../components/PlatformIcon.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 PeopleTiles, { type PeopleGroupInput } from '../components/PeopleTiles.tsx'
|
||||
import {
|
||||
|
|
@ -37,8 +35,7 @@ import { mediaUrl } from '../lib/media.ts'
|
|||
import { eventTypeLabel } from '../lib/eventTypes.ts'
|
||||
import { occurrenceLabel, seriesLabel, seriesTimes, upcomingOccurrences } from '../lib/eventSeries.ts'
|
||||
import { capitalize } from '../lib/text.ts'
|
||||
import { accentText, readableOn, withAlpha, BRAND } from '../lib/color.ts'
|
||||
import { Presentation } from '@phosphor-icons/react'
|
||||
import { accentText, readableOn, BRAND } from '../lib/color.ts'
|
||||
|
||||
const BODY = 'var(--color-muted)'
|
||||
|
||||
|
|
@ -91,12 +88,6 @@ export default function EventDetail() {
|
|||
|
||||
const accent = event.color || BRAND
|
||||
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[] = [
|
||||
{
|
||||
|
|
@ -113,41 +104,15 @@ export default function EventDetail() {
|
|||
<img
|
||||
src={mediaUrl(event.photo) ?? ''}
|
||||
alt={event.photo_alt ?? ''}
|
||||
className="aspect-video w-full object-cover"
|
||||
className="aspect-video w-full max-w-3xl object-cover"
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* The blocks take the column's whole width, beside the
|
||||
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 className="max-w-3xl">
|
||||
<ContentBlocks blocks={event.blocks} accent={accent} presentAt={`/events/${encodeURIComponent(event.id)}/present`} />
|
||||
</div>
|
||||
|
||||
{event.links.length > 0 && (
|
||||
<div className="space-y-4">
|
||||
{event.links_heading && (
|
||||
<h3 className="text-2xl font-bold" style={{ color: accentText(accent) }}>
|
||||
{event.links_heading}
|
||||
</h3>
|
||||
)}
|
||||
<div className="flex flex-wrap gap-3">
|
||||
{event.links.map((link) => (
|
||||
<a
|
||||
|
|
@ -163,7 +128,6 @@ export default function EventDetail() {
|
|||
</a>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
),
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,250 +0,0 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
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>
|
||||
)
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
/* The event presentation's motion (EventPresent.tsx). The
|
||||
/* The schedule presentation's motion (SchedulePresent.tsx). The
|
||||
reduced motion rule in index.css stops all of it. */
|
||||
|
||||
.present-in {
|
||||
958
src/pages/SchedulePresent.tsx
Normal file
958
src/pages/SchedulePresent.tsx
Normal file
|
|
@ -0,0 +1,958 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
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>
|
||||
)
|
||||
}
|
||||
|
|
@ -587,7 +587,6 @@ export default function EntityEdit() {
|
|||
options={options}
|
||||
errors={errors}
|
||||
errorPrefix={`${child.key}.`}
|
||||
parentRow={form}
|
||||
className=""
|
||||
onChange={(rows) => setForm((prev) => ({ ...prev, [child.key]: rows }))}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -90,11 +90,6 @@ export const DATA_NAV = {
|
|||
label: "Tags",
|
||||
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",
|
||||
label: "Links/redirects",
|
||||
|
|
|
|||
|
|
@ -19,9 +19,6 @@ import { useReadingMode } from '../../lib/readingMode.ts'
|
|||
|
||||
<OrgListCards kind="partner" pageLabel="Partner page" />
|
||||
<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
|
||||
card carries as much as fits at a glance and the organization's
|
||||
|
|
@ -126,11 +123,11 @@ function OrgCard({ org, accent, pageLabel, siteLabel, titled }) {
|
|||
);
|
||||
}
|
||||
|
||||
function Block({ title, orgs, accent, pageLabel, siteLabel, nested = false }) {
|
||||
function Block({ title, orgs, accent, pageLabel, siteLabel }) {
|
||||
if (orgs.length === 0) return null;
|
||||
|
||||
return (
|
||||
<section className={nested ? undefined : "mb-12"}>
|
||||
<section className="mb-12">
|
||||
{title && (
|
||||
<h3 className="text-xl font-bold mb-5" style={{ color: FALLBACK_COLOR }}>
|
||||
{title}
|
||||
|
|
@ -150,7 +147,7 @@ function Block({ title, orgs, accent, pageLabel, siteLabel, nested = false }) {
|
|||
accent={accent}
|
||||
pageLabel={pageLabel}
|
||||
siteLabel={siteLabel}
|
||||
titled={!!title || nested}
|
||||
titled={!!title}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
|
@ -159,25 +156,6 @@ function Block({ title, orgs, accent, pageLabel, siteLabel, nested = false }) {
|
|||
}
|
||||
|
||||
|
||||
/* 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({
|
||||
kind,
|
||||
ids,
|
||||
|
|
@ -189,26 +167,10 @@ export default function OrgListCards({
|
|||
siteLabel = "Visit site",
|
||||
sort = byName,
|
||||
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 shell = children =>
|
||||
nested ? (
|
||||
<div>{children}</div>
|
||||
) : (
|
||||
const shell = children => (
|
||||
<div className="mx-auto px-8 md:px-12" style={{ maxWidth: GRID_MAX }}>
|
||||
{children}
|
||||
</div>
|
||||
|
|
@ -252,7 +214,6 @@ export default function OrgListCards({
|
|||
accent={accent}
|
||||
pageLabel={pageLabel}
|
||||
siteLabel={siteLabel}
|
||||
nested={nested}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue