From df8052c75ec6f0995a18dbc07a7e1c18c8d46324 Mon Sep 17 00:00:00 2001 From: Zaldimmar Date: Mon, 9 Nov 2026 03:41:21 -0600 Subject: [PATCH] Present: the whole event page, in sections at its headings The presentation (now EventPresent) cuts the event's page into sections at its Heading blocks: a section's text on one slide, then its schedules' slides, a map block's map and each location lit up, and an events block's grid and each event. One Present button on the event page replaces the schedule's. Setup lists the sections, each schedule's days and entries under its own; the address keys are now skip and hide, numbered by schedule. Co-Authored-By: Claude Opus 5.5 --- docs/updating-data-in-code.md | 2 +- server/src/pageMeta.js | 2 +- src/App.tsx | 6 +- src/components/ContentBlocks.tsx | 29 +- src/components/MapBlock.tsx | 206 ++++-- src/components/ScheduleBlock.tsx | 24 +- src/pages/EventDetail.tsx | 20 +- .../{SchedulePresent.css => EventPresent.css} | 2 +- .../{SchedulePresent.tsx => EventPresent.tsx} | 604 +++++++++++++----- 9 files changed, 635 insertions(+), 260 deletions(-) rename src/pages/{SchedulePresent.css => EventPresent.css} (94%) rename src/pages/{SchedulePresent.tsx => EventPresent.tsx} (59%) diff --git a/docs/updating-data-in-code.md b/docs/updating-data-in-code.md index fbfbe4b..6a629b9 100644 --- a/docs/updating-data-in-code.md +++ b/docs/updating-data-in-code.md @@ -182,7 +182,7 @@ also in `server/src/admin-schema/` and a CHECK): | 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 | **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. 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 → 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`). | | Timeline → Kind (+ list filter) | milestone, event, organization, award, people | no | `KIND_NAMES` in `src/pages/sections/history/TimelineEntry.tsx` | | Timeline → Points at (+ list filter) | event, organization, award, person, team | no | `refHref` in `src/lib/hrefs.ts` | | Timeline → Precision (and on events/orgs) | year, month, day | no | the history page's grouping | diff --git a/server/src/pageMeta.js b/server/src/pageMeta.js index f6054e4..9540502 100644 --- a/server/src/pageMeta.js +++ b/server/src/pageMeta.js @@ -426,7 +426,7 @@ export function metaFor(db, rawPath, user = null) { }; } - // An event's schedule presentation (SchedulePresent.tsx): the + // An event page's presentation (EventPresent.tsx): the // event's own title and preview, kept out of search, pointing // search engines at the event page. const present = pathname.match(/^\/events\/([^/]+)\/present$/); diff --git a/src/App.tsx b/src/App.tsx index 4f6b860..c9c295e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -67,7 +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 SchedulePresent = lazyPage(() => import("./pages/SchedulePresent.tsx")) +const EventPresent = lazyPage(() => import("./pages/EventPresent.tsx")) /*Admin Pages*/ const AdminLayout = lazyPage(() => import("./pages/admin/AdminLayout.tsx")) @@ -110,12 +110,12 @@ export default function App() { {/* Every page of the site: Pages → Page management (PageAtPath). */} } /> - {/* A schedule as a slideshow for a screen: full screen, no Layout. */} + {/* An event page as a slideshow for a screen: full screen, no Layout. */} - + } /> diff --git a/src/components/ContentBlocks.tsx b/src/components/ContentBlocks.tsx index eb4f2a5..0b315da 100644 --- a/src/components/ContentBlocks.tsx +++ b/src/components/ContentBlocks.tsx @@ -52,7 +52,7 @@ import { mediaUrl } from '../lib/media.ts' import PeopleTiles from './PeopleTiles.tsx' -import type { ContentBlock, ContentBlockItem } from '../lib/useContent.ts' +import type { ContentBlock, ContentBlockItem, ItemEvent } from '../lib/useContent.ts' import { Anchor, Inline, Paragraphs, isExternalUrl } from './InlineText.tsx' import VideoPlayer from './VideoPlayer.tsx' import ScheduleBlock from './ScheduleBlock.tsx' @@ -72,7 +72,6 @@ export default function ContentBlocks({ blocks, accent = BRAND, className = '', - presentAt, anchorPrefix = '', }: { blocks?: ContentBlock[] | null @@ -80,9 +79,6 @@ 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=` naming which schedule (from 0). */ - presentAt?: string }) { if (!blocks?.length) return null // Headings get ids so a post's contents (PostContents) and a shared @@ -98,10 +94,6 @@ export default function ContentBlocks({ return level }) - let schedules = 0 - const presentHrefs = blocks.map((block) => - presentAt && block.type === 'schedule' ? `${presentAt}?block=${schedules++}` : undefined, - ) // The venues mapped here, for a schedule's places to link to. const maps = new Set(blocks.flatMap((block) => (block.type === 'map' && block.venue ? [block.venue.id] : []))) @@ -116,7 +108,6 @@ export default function ContentBlocks({ accent={accent} anchor={idAt.get(index)} level={levels[index]} - presentHref={presentHrefs[index]} /> ))} @@ -161,12 +152,19 @@ 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 }: { item: ContentBlockItem; accent: string }) { const event = item.event! const img = useSmallImage(mediaUrl(event.image)) const color = event.color || accent - 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 + const line = eventLine(event) return ( )} - {(kind || when) && ( + {line && ( - {[kind, when].filter(Boolean).join(' · ')} + {line} )} @@ -223,13 +221,11 @@ 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() @@ -439,7 +435,6 @@ function Block({ tags={block.tags} intro={block.text} accent={accent} - presentHref={presentHref} /> ) diff --git a/src/components/MapBlock.tsx b/src/components/MapBlock.tsx index 25728bd..bb704f3 100644 --- a/src/components/MapBlock.tsx +++ b/src/components/MapBlock.tsx @@ -13,6 +13,9 @@ the mark's own, so Layout's jump to the anchor scrolls it into view and focuses it. + 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. PageMaps holds the venues that have a map block among the blocks @@ -20,8 +23,8 @@ when there's a map on the page to go to. ═══════════════════════════════════════════════════════════════ */ -import { createContext, useState } from 'react' -import { Link, useLocation } from 'react-router-dom' +import { createContext, useState, type CSSProperties } from 'react' +import { Link, useLocation, type To } from 'react-router-dom' import { mediaUrl } from '../lib/media.ts' import type { Venue, VenueLocation } from '../lib/useContent.ts' @@ -33,15 +36,138 @@ export const PageMaps = createContext>(new Set()) export const mapAnchor = (venueId: string, key: string) => `map-${venueId}-${key}` 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 ( + + ) +} + +/* 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, +}: { + venue: Venue + accent: string + active: string | null + 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 ( +
+ {venue.map_alt + {venue.locations.filter(isMarked).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 = ( + <> + + {on && !big && ( + + )} + + ) + return link ? ( + + {inside} + + ) : ( + + ) + })} +
+ ) +} export default function MapBlock({ venue, accent }: { venue: Venue; accent: string }) { const { hash, search } = useLocation() const [hovered, setHovered] = useState(null) - const marked = venue.locations.filter((location) => location.x != null && location.y != null) const fromHash = venue.locations.find((location) => hash === `#${mapAnchor(venue.id, location.key)}`)?.key ?? null const active = hovered ?? fromHash - const image = useReadingMode() ? null : mediaUrl(venue.map_image) - const fill = accent.startsWith('#') ? accent : '#000000' + const picture = !useReadingMode() && Boolean(venue.map_image) const to = (key: string) => ({ search, hash: mapAnchor(venue.id, key) }) const light = (key: string) => ({ @@ -50,68 +176,12 @@ export default function MapBlock({ venue, accent }: { venue: Venue; accent: stri onFocus: () => setHovered(key), onBlur: () => setHovered(null), }) - const number = (location: VenueLocation) => venue.locations.indexOf(location) + 1 return (
- {image && ( -
- {venue.map_alt - {marked.map((location) => { - const on = active === location.key - const dim = active != null && !on - return ( - - - {on && ( - - )} - - ) - })} -
- )} + {picture && } -
+

{venue.name}

{venue.address &&

{venue.address}

}
    @@ -119,13 +189,7 @@ export default function MapBlock({ venue, accent }: { venue: Venue; accent: stri const on = active === location.key const row = ( <> - + {location.name} @@ -138,7 +202,7 @@ export default function MapBlock({ venue, accent }: { venue: Venue; accent: stri const rowStyle = on ? { background: withAlpha(accent, 12) } : undefined return (
  1. - {location.x != null && location.y != null ? ( + {isMarked(location) ? ( {row} diff --git a/src/components/ScheduleBlock.tsx b/src/components/ScheduleBlock.tsx index 7a65b96..bc7ee4d 100644 --- a/src/components/ScheduleBlock.tsx +++ b/src/components/ScheduleBlock.tsx @@ -38,8 +38,8 @@ that is an event (a workshop) has already taken what it left blank from it (shape.js). - On an event page a Present button opens the schedule as a - slideshow for a screen (SchedulePresent.tsx). + The event page's Present button shows it, with the rest of the + page, as a slideshow for a screen (EventPresent.tsx). Tabs follow the ARIA tab pattern: arrow keys move between them. @@ -48,7 +48,7 @@ it, no map frame (ReadingSchedule). ═══════════════════════════════════════════════════════════════ */ -import { CaretDown, MapPin, Presentation, Star } from '@phosphor-icons/react' +import { CaretDown, MapPin, Star } from '@phosphor-icons/react' import { Fragment, createContext, useContext, useId, useState, type KeyboardEvent, type ReactNode } from 'react' import { Link, useLocation } from 'react-router-dom' @@ -475,14 +475,11 @@ 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)) @@ -526,21 +523,6 @@ export default function ScheduleBlock({ )} - {presentHref && ( -
    - -
    - )} - {tabs.length > 1 && (
    {tabs.map((tab, index) => { diff --git a/src/pages/EventDetail.tsx b/src/pages/EventDetail.tsx index d237f7b..31c03a2 100644 --- a/src/pages/EventDetail.tsx +++ b/src/pages/EventDetail.tsx @@ -35,7 +35,8 @@ 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, BRAND } from '../lib/color.ts' +import { accentText, readableOn, withAlpha, BRAND } from '../lib/color.ts' +import { Presentation } from '@phosphor-icons/react' const BODY = 'var(--color-muted)' @@ -109,7 +110,22 @@ export default function EventDetail() { )}
    - + {/* The page as a slideshow for a screen (EventPresent.tsx). */} + {event.blocks.length > 0 && ( +
    + +
    + )} +
    {event.links.length > 0 && ( diff --git a/src/pages/SchedulePresent.css b/src/pages/EventPresent.css similarity index 94% rename from src/pages/SchedulePresent.css rename to src/pages/EventPresent.css index de31f90..98d7801 100644 --- a/src/pages/SchedulePresent.css +++ b/src/pages/EventPresent.css @@ -1,4 +1,4 @@ -/* The schedule presentation's motion (SchedulePresent.tsx). The +/* The event presentation's motion (EventPresent.tsx). The reduced motion rule in index.css stops all of it. */ .present-in { diff --git a/src/pages/SchedulePresent.tsx b/src/pages/EventPresent.tsx similarity index 59% rename from src/pages/SchedulePresent.tsx rename to src/pages/EventPresent.tsx index 29f9bde..b8a5d42 100644 --- a/src/pages/SchedulePresent.tsx +++ b/src/pages/EventPresent.tsx @@ -1,16 +1,23 @@ /* ═══════════════════════════════════════════════════════════════ - SCHEDULE PRESENTATION: /events/:id/present?block= + EVENT PRESENTATION: /events/:id/present - 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. + An event page's content blocks as an endless slideshow for a + screen (digital signage), opened from the page'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 page is cut into sections at its Heading blocks (the blocks + before the first are a section under the event's title). Each + section, in order, gives: + section its text blocks (everything but the kinds below) on + one slide under its heading, scrolling if long + schedule each schedule block's slides (below) + venue each map block (088): the map with its locations + place then the map once per marked location, it lit up + cards each events block (088): its events on one slide + event then each event alone: picture, title, card text + and its person host - The slides, for each day picked, in order: + A schedule's 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, @@ -21,10 +28,20 @@ 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=`) cuts every slide - to what one tag is on, eg. for a screen outside the youth room. + spotlight. "Only entries tagged" (`only=`) cuts every + schedule slide to what one tag is on, eg. for a screen outside the + youth room. + + First a setup screen: which sections, 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): `skip` the sections left out, by number; `hide` the days + (schedule.day), entries (schedule.day.entry) and sub-items + (schedule.day.entry.item) left out, a schedule numbered among the + page's schedules. 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. Keys while playing: arrows step, Space pauses, Escape leaves full screen (the browser's), S goes back to the setup. @@ -47,54 +64,99 @@ import { withTag, type Day, } from '../components/ScheduleBlock.tsx' +import ContentBlocks, { eventLine } from '../components/ContentBlocks.tsx' +import { LocationNumber, MapPicture, isMarked, locationNumber } from '../components/MapBlock.tsx' import { Paragraphs } from '../components/InlineText.tsx' -import { useEvent, type ContentBlockItem, type ScheduleTag } from '../lib/useContent.ts' +import { + useEvent, + type ContentBlock, + type ContentBlockItem, + type ScheduleTag, + type Venue, + type VenueLocation, +} 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' +import './EventPresent.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 }, + { key: 'section', label: 'Sections', help: "A section's text under its heading", seconds: 20 }, + { key: 'overview', label: 'Day overview', help: 'A schedule day on one slide', seconds: 20 }, + { key: 'spotlight', label: 'Entry spotlight', help: 'One schedule entry at a time, with its person', seconds: 12 }, + { key: 'block', label: 'Blocks', help: 'A schedule block and the things in it, before each gets a spotlight', seconds: 15 }, + { key: 'graphic', label: 'Graphics', help: "A schedule entry's graphic, full screen", seconds: 10 }, + { key: 'map', label: 'Map images', help: "A schedule entry's own map, full screen", seconds: 10 }, + { key: 'tag', label: 'Tag slides', help: "Each schedule tag and everything it's on, after the days", seconds: 15 }, + { key: 'venue', label: 'Maps', help: "A map block: the venue's map with its locations", seconds: 15 }, + { key: 'place', label: 'Map locations', help: 'The map again for each location, it lit up', seconds: 8 }, + { key: 'cards', label: 'Event lists', help: "An events block's events on one slide", seconds: 15 }, + { key: 'event', label: 'Event spotlight', help: 'Each event of an events block alone', seconds: 12 }, ] as const type Kind = (typeof KINDS)[number]['key'] +/* Blocks with slides of their own, not a section's text, as the + setup screen names them. */ +const OWN_SLIDES = new Map([ + ['schedule', 'Schedule'], + ['map', 'Map'], + ['events', 'Events'], +]) +/* Blocks that start a section. */ +const STARTS_SECTION = new Set(['heading', 'tab']) + /* 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 +/* A section's text is drawn at the page's size, zoomed to a screen + this many pixels wide or more. */ +const TEXT_WIDTH = 1000 -/* `parent` is a sub-item's block; a tag slide has its `tag` and the - `days` it gathers from. */ +/* `label` is the top bar's right side: the day, else the section. + The rest is what each kind draws. */ type Slide = { kind: Kind seconds: number - day: Day + label: string + day?: Day entry?: ContentBlockItem parent?: ContentBlockItem tag?: ScheduleTag days?: Day[] + tags?: ScheduleTag[] + blocks?: ContentBlock[] + venue?: Venue + location?: VenueLocation + items?: ContentBlockItem[] } -/* 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('.') +/* A part of the page: a heading and the blocks under it. */ +type Section = { title: string; blocks: ContentBlock[] } +/* A schedule block, numbered among the page's, with its days. */ +type Schedule = { n: number; days: Day[]; tags: ScheduleTag[] } + +function sectionsOf(blocks: ContentBlock[], title: string): Section[] { + const sections: Section[] = [{ title, blocks: [] }] + for (const block of blocks) { + if (STARTS_SECTION.has(block.type)) sections.push({ title: block.text || title, blocks: [] }) + else sections[sections.length - 1].blocks.push(block) + } + return sections.filter((section) => section.blocks.length) +} + +/* A day's, entry's or sub-item's key in the address: the schedule's + number, the day's, then the entry's and sub-item's, dotted. */ +const key = (...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')) ?? []) +function readSettings(params: URLSearchParams) { const seconds = Object.fromEntries( KINDS.map((kind) => { const value = Number(params.get(kind.key) ?? kind.seconds) @@ -103,51 +165,48 @@ function readSettings(params: URLSearchParams, days: Day[]) { ) as Record const screen = Number(params.get('screen') ?? PER_SCREEN) return { - pickedDays: new Set(pickedDays), - hidden, + skipped: new Set((list(params.get('skip')) ?? []).map(Number)), + hidden: new Set(list(params.get('hide')) ?? []), seconds, screen: Number.isFinite(screen) && screen > 0 ? screen : PER_SCREEN, only: params.get('only') || null, } } type Settings = ReturnType +type Picks = Pick -function buildSlides( - days: Day[], - tags: ScheduleTag[], - { pickedDays, hidden, seconds, only }: Pick, -): Slide[] { - const slides: Slide[] = [] +function scheduleSlides(slides: Slide[], { n, days, tags }: Schedule, { hidden, seconds, only }: Picks) { const kept: Day[] = [] days.forEach((all, d) => { - if (!pickedDays.has(d)) return + if (hidden.has(key(n, d))) return let entries = all.entries.flatMap((entry, e) => { - if (hidden.has(entryKey(d, e))) return [] + if (hidden.has(key(n, d, e))) return [] if (entry.kind !== 'block') return [entry] - return [{ ...entry, items: (entry.items ?? []).filter((_, i) => !hidden.has(entryKey(d, e, i))) }] + return [{ ...entry, items: (entry.items ?? []).filter((_, i) => !hidden.has(key(n, 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 at = { day, label: day.name, tags } + if (seconds.overview) slides.push({ kind: 'overview', seconds: seconds.overview, ...at }) 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 }) + if (seconds.graphic && entry.media) slides.push({ kind: 'graphic', seconds: seconds.graphic, ...at, entry, parent }) + if (seconds.map && entry.map_image) slides.push({ kind: 'map', seconds: seconds.map, ...at, 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 }) + if (seconds.block) slides.push({ kind: 'block', seconds: seconds.block, ...at, entry }) media(entry) for (const item of entry.items ?? []) { - if (seconds.spotlight) slides.push({ kind: 'spotlight', seconds: seconds.spotlight, day, entry: item, parent: entry }) + if (seconds.spotlight) slides.push({ kind: 'spotlight', seconds: seconds.spotlight, ...at, entry: item, parent: entry }) media(item, entry) } continue } - if (seconds.spotlight && entry.kind !== 'break') slides.push({ kind: 'spotlight', seconds: seconds.spotlight, day, entry }) + if (seconds.spotlight && entry.kind !== 'break') slides.push({ kind: 'spotlight', seconds: seconds.spotlight, ...at, entry }) media(entry) } }) @@ -156,24 +215,59 @@ function buildSlides( 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 }) + if (tagDays.length) slides.push({ kind: 'tag', seconds: seconds.tag, label: tag.name, tag, days: tagDays, tags }) } } +} + +function buildSlides(sections: Section[], schedules: Map, picks: Picks): Slide[] { + const { skipped, seconds } = picks + const slides: Slide[] = [] + sections.forEach((section, s) => { + if (skipped.has(s)) return + const label = section.title + const text = section.blocks.filter((block) => !OWN_SLIDES.has(block.type)) + if (seconds.section && text.length) slides.push({ kind: 'section', seconds: seconds.section, label, blocks: text }) + for (const block of section.blocks) { + const schedule = schedules.get(block) + if (schedule) scheduleSlides(slides, schedule, picks) + if (block.type === 'map' && block.venue) { + const venue = block.venue + if (seconds.venue) slides.push({ kind: 'venue', seconds: seconds.venue, label, venue }) + if (seconds.place && venue.map_image) { + for (const location of venue.locations.filter(isMarked)) { + slides.push({ kind: 'place', seconds: seconds.place, label, venue, location }) + } + } + } + if (block.type === 'events') { + const items = (block.items ?? []).filter((item) => item.event) + if (seconds.cards && items.length) slides.push({ kind: 'cards', seconds: seconds.cards, label, items }) + if (seconds.event) for (const entry of items) slides.push({ kind: 'event', seconds: seconds.event, label, entry }) + } + } + }) return slides } -export default function SchedulePresent() { +export default function EventPresent() { 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 ?? [] + const sections = useMemo(() => (event ? sectionsOf(event.blocks ?? [], event.title) : []), [event]) + const schedules = useMemo(() => { + const out = new Map() + for (const block of event?.blocks ?? []) { + if (block.type !== 'schedule') continue + const days = groupByDay(block.items ?? []) + if (days.length) out.set(block, { n: out.size, days, tags: block.tags ?? [] }) + } + return out + }, [event]) useEffect(() => { - if (event) document.title = documentTitle(`${event.title}: schedule`) + if (event) document.title = documentTitle(`${event.title}: present`) }, [event]) if (!event) { @@ -193,10 +287,10 @@ export default function SchedulePresent() { const accent = event.color || BRAND const back = `/events/${encodeURIComponent(event.id)}` - if (!schedule || days.length === 0) { + if (sections.length === 0) { return (
    -

    This event has no schedule to present.

    +

    This event has nothing on its page to present.

    Back to {event.title} @@ -204,22 +298,20 @@ export default function SchedulePresent() { ) } - const settings = readSettings(params, days) + const settings = readSettings(params) if (params.get('play') === '1') { return ( - - { - const next = new URLSearchParams(params) - next.delete('play') - setParams(next) - }} - /> - + { + const next = new URLSearchParams(params) + next.delete('play') + setParams(next) + }} + /> ) } return ( @@ -227,14 +319,14 @@ export default function SchedulePresent() { title={event.title} back={back} accent={accent} - days={days} - tags={tags} + sections={sections} + schedules={schedules} 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(',')) + const out = new URLSearchParams() + if (next.skipped.size) out.set('skip', [...next.skipped].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)) @@ -253,25 +345,26 @@ function Setup({ title, back, accent, - days, - tags, + sections, + schedules, settings, onPlay, }: { title: string back: string accent: string - days: Day[] - tags: ScheduleTag[] + sections: Section[] + schedules: Map settings: Settings onPlay: (settings: Settings) => void }) { - const [pickedDays, setPickedDays] = useState(settings.pickedDays) + const [skipped, setSkipped] = useState(settings.skipped) 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 count = buildSlides(sections, schedules, { skipped, hidden, seconds, only }).length + const tags = [...schedules.values()].flatMap((schedule) => schedule.tags) const toggle = (set: Set, value: T) => { const next = new Set(set) @@ -285,7 +378,7 @@ function Setup({
    -

    Present the schedule

    +

    Present the page

    {title}

    @@ -349,7 +442,9 @@ function Setup({ -
      - {day.entries.map((entry, e) => ( -
    • - setHidden(toggle(hidden, entryKey(d, e)))} - /> - {entry.kind === 'block' && entry.items?.length ? ( -
        - {entry.items.map((item, i) => ( -
      • - setHidden(toggle(hidden, entryKey(d, e, i)))} - /> -
      • - ))} -
      - ) : null} -
    • - ))} -
    - - ))} + {sections.map((section, s) => { + const on = !skipped.has(s) + const kinds = [...new Set(section.blocks.map((block) => (OWN_SLIDES.get(block.type) ?? 'Text')))] + return ( +
    + {section.title} + + {section.blocks.map((block, b) => { + const schedule = schedules.get(block) + if (!schedule) return null + const { n, days } = schedule + return ( +
    + {days.map((day, d) => ( +
    + setHidden(toggle(hidden, key(n, d)))} + /> +
      + {day.entries.map((entry, e) => ( +
    • + setHidden(toggle(hidden, key(n, d, e)))} + /> + {entry.kind === 'block' && entry.items?.length ? ( +
        + {entry.items.map((item, i) => ( +
      • + setHidden(toggle(hidden, key(n, d, e, i)))} + /> +
      • + ))} +
      + ) : null} +
    • + ))} +
    +
    + ))} +
    + ) + })} +
    + ) + })}
    @@ -412,7 +533,7 @@ function Setup({