diff --git a/docs/updating-data-in-code.md b/docs/updating-data-in-code.md index 9fa4888..27e2f17 100644 --- a/docs/updating-data-in-code.md +++ b/docs/updating-data-in-code.md @@ -184,6 +184,8 @@ also in `server/src/admin-schema/` and a CHECK): | 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 → 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) → Map → Location slides | (blank: each marked location), picked (the Locations with a slide), none | **yes**, migration 095 | `PRESENT_BLOCK_FIELDS` in `src/lib/adminSchema/shared.ts`; read by `mapSlides` in `src/pages/EventPresent.tsx` | +| Events → Presentation → Frame | (blank: the accent bar, title line and timer), border, none | **yes**, migration 095 | The `present_frame` field in `src/lib/adminSchema/events.ts`; drawn by `Player` in `src/pages/EventPresent.tsx` | | Content blocks → Organizations → List | (blank: only the picked ones), partner, region, group, ministry | **yes**, migration 093 | The `org_kind` field in `src/lib/adminSchema/shared.ts`; the `organizations` case in `ContentBlocks.tsx` passes it as the kind to `OrgListCards` (`nested`); items picked by `org_id` replace it | | Timeline → Kind (+ list filter) | milestone, event, organization, award, people | no | `KIND_NAMES` in `src/pages/sections/history/TimelineEntry.tsx` | | Timeline → Points at (+ list filter) | event, organization, award, person, team | no | `refHref` in `src/lib/hrefs.ts` | diff --git a/server/src/admin-schema/columns.js b/server/src/admin-schema/columns.js index cfbbdd7..e5831c0 100644 --- a/server/src/admin-schema/columns.js +++ b/server/src/admin-schema/columns.js @@ -181,6 +181,14 @@ export const blocksChild = (ownerKind) => ({ enumeration("list_style", ["plain"]), // Organizations blocks (093): the kind listed when none are picked. enumeration("org_kind", ["region", "group", "partner", "ministry"]), + // How it's presented (095): EventPresent.tsx. + bool("present_hide"), + 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: [ { diff --git a/server/src/admin-schema/events.js b/server/src/admin-schema/events.js index 3b5e791..581ef98 100644 --- a/server/src/admin-schema/events.js +++ b/server/src/admin-schema/events.js @@ -69,6 +69,14 @@ export const events = { 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"), // A repeating schedule. Columns rather than a side table: the // schedule is always exactly one per event, and the public view diff --git a/server/src/migrations/095_presentation.sql b/server/src/migrations/095_presentation.sql new file mode 100644 index 0000000..641896d --- /dev/null +++ b/server/src/migrations/095_presentation.sql @@ -0,0 +1,56 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 095 PRESENTATION SETTINGS +-- +-- How an event's page looks presented (EventPresent.tsx), set on +-- the event; nothing here changes the page itself. +-- +-- On events (v_events is SELECT e.*, so no rebuild): +-- present_background an image behind every slide +-- present_background_color the slides' background color; with an +-- image, laid over it at present_dim +-- present_dim percent of the color over the image, +-- 0 to 90; null 60 +-- present_frame null the accent bar, title line and +-- timer; 'border' an accent border around +-- the slide; 'none' the slide alone +-- present_accent in place of the event's color +-- present_text_color the slides' text; null the background +-- color's readable one, else the site's +-- present_logo in the slide's bottom-right corner +-- +-- On content blocks (any owner's; only an event's are presented): +-- present_hide left out of the presentation +-- present_text shown presented in place of its text, +-- eg. a shorter heading +-- present_map_split a map: a slide per map section (094) +-- present_map_no_list a map: no locations list beside it +-- present_map_no_details a map: no location detail lines +-- present_places a map: which locations get a slide of +-- their own; null every marked one, +-- 'picked' present_place_keys, 'none' +-- present_place_keys the venue's location_keys (088), +-- comma-separated +-- ═══════════════════════════════════════════════════════════════ + +ALTER TABLE events ADD COLUMN present_background TEXT; +ALTER TABLE events ADD COLUMN present_background_color TEXT; +ALTER TABLE events ADD COLUMN present_dim INTEGER + CHECK (present_dim BETWEEN 0 AND 90); +ALTER TABLE events ADD COLUMN present_frame TEXT + CHECK (present_frame IN ('border', 'none')); +ALTER TABLE events ADD COLUMN present_accent TEXT; +ALTER TABLE events ADD COLUMN present_text_color TEXT; +ALTER TABLE events ADD COLUMN present_logo TEXT; + +ALTER TABLE content_blocks ADD COLUMN present_hide INTEGER NOT NULL DEFAULT 0 + CHECK (present_hide IN (0, 1)); +ALTER TABLE content_blocks ADD COLUMN present_text TEXT; +ALTER TABLE content_blocks ADD COLUMN present_map_split INTEGER NOT NULL DEFAULT 0 + CHECK (present_map_split IN (0, 1)); +ALTER TABLE content_blocks ADD COLUMN present_map_no_list INTEGER NOT NULL DEFAULT 0 + CHECK (present_map_no_list IN (0, 1)); +ALTER TABLE content_blocks ADD COLUMN present_map_no_details INTEGER NOT NULL DEFAULT 0 + CHECK (present_map_no_details IN (0, 1)); +ALTER TABLE content_blocks ADD COLUMN present_places TEXT + CHECK (present_places IN ('picked', 'none')); +ALTER TABLE content_blocks ADD COLUMN present_place_keys TEXT; diff --git a/server/src/routes/content.js b/server/src/routes/content.js index 629192d..a8c7963 100644 --- a/server/src/routes/content.js +++ b/server/src/routes/content.js @@ -595,6 +595,16 @@ content.get("/events/:id", (c) => { ...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, + }, blocks: body, people, awards, diff --git a/server/src/shape.js b/server/src/shape.js index d3c7aa2..5870af4 100644 --- a/server/src/shape.js +++ b/server/src/shape.js @@ -64,6 +64,20 @@ 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 = { + hide: row.present_hide === 1, + text: row.present_text, + map_split: row.present_map_split === 1, + map_no_list: row.present_map_no_list === 1, + map_no_details: row.present_map_no_details === 1, + places: row.present_places, + place_keys: row.present_place_keys ? row.present_place_keys.split(",").filter(Boolean) : [], + }; + return Object.values(present).some((value) => (Array.isArray(value) ? value.length : value)) ? present : null; +} + export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) { const out = new Map(); if (ids.length === 0) return out; @@ -71,7 +85,9 @@ export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) { const blockRows = db .prepare( `SELECT id, owner_id, type, text, media, href, alt, cite, captions, team_id, venue_id, - word_motion, word_direction, word_seconds, list_style, org_kind + word_motion, word_direction, word_seconds, list_style, org_kind, + present_hide, present_text, present_map_split, present_map_no_list, + present_map_no_details, present_places, present_place_keys FROM content_blocks WHERE owner_kind = ? AND slot IN (?, 'both') AND owner_id IN (${placeholders(ids.length)}) ORDER BY owner_id, sort_order`, @@ -99,6 +115,8 @@ export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) { 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); diff --git a/src/components/ContentBlocks.tsx b/src/components/ContentBlocks.tsx index 27fa2a7..1e6e709 100644 --- a/src/components/ContentBlocks.tsx +++ b/src/components/ContentBlocks.tsx @@ -71,7 +71,8 @@ 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 from '../pages/sections/OrgList-Card.tsx' +import OrgListCards, { OrgLogoRow } from '../pages/sections/OrgList-Card.tsx' +import { usePresenting } from '../lib/presenting.ts' const BODY = 'var(--color-muted)' @@ -87,6 +88,14 @@ export default function ContentBlocks({ /** Put before each heading's id: a blog post's tab (contents.ts, splitTabs). */ anchorPrefix?: string }) { + const presenting = usePresenting() + // Presented, a block set to is left out and the rest take their + // Presentation text (095). + if (presenting && blocks) { + blocks = blocks + .filter((block) => !block.present?.hide) + .map((block) => (block.present?.text ? { ...block, text: block.present.text } : block)) + } if (!blocks?.length) return null // Headings get ids so a post's contents (PostContents) and a shared // link (#getting-there) can point at them. @@ -378,6 +387,9 @@ function Block({ }) { 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() switch (block.type) { // A blog post's tab marker (BlogPost.tsx splits the post at @@ -410,7 +422,7 @@ function Block({ - {item.url ? ( + {item.url && !presenting ? ( {item.text} @@ -607,6 +619,7 @@ function Block({ // 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 return ( - {block.team_id && } - {picked.length > 0 && } + {block.team_id && } + {picked.length > 0 && } ) } @@ -638,7 +651,7 @@ function Block({ case 'paragraph': default: if (!text) return null - return block.href ? ( + return block.href && !presenting ? (

{text} diff --git a/src/components/InlineText.tsx b/src/components/InlineText.tsx index 7528c3b..0c7f4f7 100644 --- a/src/components/InlineText.tsx +++ b/src/components/InlineText.tsx @@ -22,6 +22,7 @@ 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 @@ -77,7 +78,8 @@ export function Anchor({ ) } -function line(text: string, accent: string, key: string): ReactNode[] { +/* `plain`: a link's text alone, presented (095). */ +function line(text: string, accent: string, key: string, plain = false): ReactNode[] { const out: ReactNode[] = [] let last = 0 let n = 0 @@ -89,6 +91,7 @@ function line(text: string, accent: string, key: string): ReactNode[] { if (words != null) out.push( word.trim())} />) else if (bold != null) out.push({bold}) else if (italic != null) out.push({italic}) + else if (label != null && plain) out.push(label) else if (label != null && SAFE_URL.test(url)) { out.push( @@ -104,13 +107,14 @@ function line(text: string, accent: string, key: string): ReactNode[] { /** 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) => ( {i > 0 &&
} - {line(part, accent, `l${i}`)} + {line(part, accent, `l${i}`, plain)}
))} diff --git a/src/components/PeopleTiles.tsx b/src/components/PeopleTiles.tsx index d0371a7d..906acad 100644 --- a/src/components/PeopleTiles.tsx +++ b/src/components/PeopleTiles.tsx @@ -165,6 +165,8 @@ 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; /** How long a fetched team or person is reused, in ms. */ ttl?: number; emptyMessage?: string; @@ -195,8 +197,10 @@ export default function PeopleTiles({ ttl = 5 * 60_000, loadingMessage = "Loading…", errorMessage = "Couldn't load this list right now.", + row = false, ...view }: PeopleTilesProps) { + const View = row ? PeopleRow : PeopleTilesView; const specs = useMemo(() => normalizeTeams(teams), [teams]); const teamKey = specs.map((spec) => spec.id).join(","); @@ -278,14 +282,14 @@ export default function PeopleTiles({ if (specs.length) { if (failed) return

{errorMessage}

; if (!teamGroups) return

{loadingMessage}

; - return ; + return ; } if (slugKey) { if (failed) return

{errorMessage}

; if (!directory) return

{loadingMessage}

; return ( - ({ ...group, @@ -297,7 +301,7 @@ export default function PeopleTiles({ } return ( - group.people), ...(people ?? [])]; + return ( +
    + {everyone.map((person, i) => ( +
  • + + + + {person.name} +
  • + ))} +
+ ); +} + function Photo({ src, name }: { src?: string | null; name: string }) { const img = useSmallImage(src); diff --git a/src/components/admin/fields.tsx b/src/components/admin/fields.tsx index 0d35925..fd54d40 100644 --- a/src/components/admin/fields.tsx +++ b/src/components/admin/fields.tsx @@ -854,7 +854,9 @@ export function Repeater({ row={row} parentRow={parentRow} value={row[field.path]} - options={options} + // Its own lent options too: a map block's + // Locations with a slide (095). + options={spec.lends ? { ...options, ...spec.lends(row, options) } : options} error={errors?.[`${errorPrefix}${index}.${field.path}`]} onChange={(value) => update(index, { ...row, [field.path]: value })} onPatch={(patch) => update(index, { ...row, ...patch })} diff --git a/src/lib/adminSchema/events.ts b/src/lib/adminSchema/events.ts index a4babc0..b170549 100644 --- a/src/lib/adminSchema/events.ts +++ b/src/lib/adminSchema/events.ts @@ -1,5 +1,8 @@ import { mediaUrl } from "../media.ts"; -import { PLACE_FIELDS, PUBLISHED_FIELD, LISTED_FIELD, timelineGroup, timelineDetailGroup, linksChild, hostsChild, blocksChild, tagsChild } from "./shared.ts"; +import { PLACE_FIELDS, PUBLISHED_FIELD, LISTED_FIELD, timelineGroup, timelineDetailGroup, linksChild, hostsChild, blocksChild, tagsChild, PRESENT_BLOCK_FIELDS } from "./shared.ts"; + +/* An event's blocks also say how they're presented (095). */ +const eventBlocksChild = { ...blocksChild, fields: [...blocksChild.fields, ...PRESENT_BLOCK_FIELDS] }; /* ── Events ──────────────────────────────────────────────────── */ @@ -189,6 +192,58 @@ export const events = { }, ], }, + { + 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", + }, + { 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.", + }, + ], + }, timelineGroup("event"), timelineDetailGroup("event"), { legend: "Publishing", fields: [PUBLISHED_FIELD, LISTED_FIELD] }, @@ -231,6 +286,6 @@ export const events = { ], }, linksChild, - blocksChild, + eventBlocksChild, ], }; diff --git a/src/lib/adminSchema/shared.ts b/src/lib/adminSchema/shared.ts index 2eee278..1c225b5 100644 --- a/src/lib/adminSchema/shared.ts +++ b/src/lib/adminSchema/shared.ts @@ -494,6 +494,65 @@ const SUB_ITEM_FIELDS = [ TAGS_FIELD, ]; +/* An event's blocks' presentation fields (095), EventPresent.tsx. */ +export const PRESENT_BLOCK_FIELDS = [ + { + path: "present_hide", + label: "Leave out of the presentation", + widget: "checkbox", + help: "The page still shows it.", + }, + { + 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", diff --git a/src/lib/presenting.ts b/src/lib/presenting.ts new file mode 100644 index 0000000..db12d8e --- /dev/null +++ b/src/lib/presenting.ts @@ -0,0 +1,10 @@ +/* Whether the blocks are drawn for a presentation screen + (EventPresent.tsx, 095): ContentBlocks leaves out the blocks set to, + takes their Presentation text, and draws links as plain text, + people as a row of round photos and organizations as logos. */ + +import { createContext, useContext } from 'react' + +export const Presenting = createContext(false) + +export const usePresenting = () => useContext(Presenting) diff --git a/src/lib/useContent.ts b/src/lib/useContent.ts index f949890..c26abcc 100644 --- a/src/lib/useContent.ts +++ b/src/lib/useContent.ts @@ -70,6 +70,35 @@ export type ContentBlock = { /** 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 = { + hide: 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 } export type MapSection = { name: string; keys: string[] } @@ -246,6 +275,8 @@ export type EventRecord = { 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[] diff --git a/src/pages/EventPresent.tsx b/src/pages/EventPresent.tsx index 187fee2..b6b7917 100644 --- a/src/pages/EventPresent.tsx +++ b/src/pages/EventPresent.tsx @@ -43,11 +43,24 @@ half its seconds, scrolls to the end at "Scroll" seconds a screenful (`screen=`), then waits the other half. + A section with only a heading (and subheadings or dividers) before + its map, schedule or events gets no text slide: its heading titles + the slides that follow. The setup's Order list moves any slide + (`order`, slide ids, see buildSlides); a slide it doesn't name + stays after the one it follows by default. + + The event's Presentation settings (095) give the slides their + background, frame, colors and logo (lookTokens, Player); a block's + give its Presentation text, leave it out, and say how a map is + shown. The blocks themselves are drawn for a screen (Presenting): + links as their text, people as round photos and names, + organizations as their logos. + 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 { ArrowDown, ArrowUp, ArrowsOut, CaretLeft, CaretRight, DotsSixVertical, 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' @@ -67,10 +80,13 @@ import { import ContentBlocks, { eventLine } from '../components/ContentBlocks.tsx' import { LocationNumber, MapPicture, isMarked, locationNumber } from '../components/MapBlock.tsx' import { Paragraphs } from '../components/InlineText.tsx' +import Logo from '../components/Logo.tsx' +import { Presenting } from '../lib/presenting.ts' import { useEvent, type ContentBlock, type ContentBlockItem, + type EventPresentLook, type ScheduleTag, type Venue, type VenueLocation, @@ -105,6 +121,11 @@ const OWN_SLIDES = new Map([ ]) /* Blocks that start a section. */ const STARTS_SECTION = new Set(['heading', 'tab']) +/* Text that alone makes no section slide: the heading titles what + follows instead. */ +const FILLER = new Set(['subheading', 'divider']) +/* Percent of the background color over the background image, unset. */ +const DIM = 60 /* Seconds a long slide takes to scroll one screenful, when unset. */ const PER_SCREEN = 8 @@ -119,7 +140,11 @@ const TEXT_WIDTH = 1000 /* `label` is the top bar's right side: the day, else the section. The rest is what each kind draws. */ type Slide = { + /* Where it comes from, for the Order list (buildSlides). */ + id: string kind: Kind + /* A map's or event list's title, when not the label. */ + title?: string seconds: number label: string day?: Day @@ -132,18 +157,28 @@ type Slide = { venue?: Venue location?: VenueLocation items?: ContentBlockItem[] + /* A map: the locations shown, by key (all when unset), and its + block's Map only and No location details (095). */ + only?: string[] + noList?: boolean + noDetails?: boolean } -/* A part of the page: a heading and the blocks under it. */ -type Section = { title: string; blocks: ContentBlock[] } +/* A part of the page: a heading (`headed`, else the event's title) + and the blocks under it. */ +type Section = { title: string; headed: boolean; blocks: ContentBlock[] } /* A schedule block, numbered among the page's, with its days. */ type Schedule = { n: number; days: Day[]; tags: ScheduleTag[] } +/* Blocks left out of the presentation (095) are dropped; a left out + heading still starts its section, under the event's title. */ function sectionsOf(blocks: ContentBlock[], title: string): Section[] { - const sections: Section[] = [{ title, blocks: [] }] + const sections: Section[] = [{ title, headed: false, 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) + if (STARTS_SECTION.has(block.type)) { + const heading = block.present?.hide ? '' : block.present?.text || block.text + sections.push({ title: heading || title, headed: Boolean(heading), blocks: [] }) + } else if (!block.present?.hide) sections[sections.length - 1].blocks.push(block) } return sections.filter((section) => section.blocks.length) } @@ -170,43 +205,58 @@ function readSettings(params: URLSearchParams) { seconds, screen: Number.isFinite(screen) && screen > 0 ? screen : PER_SCREEN, only: params.get('only') || null, + order: list(params.get('order')), } } type Settings = ReturnType type Picks = Pick +/* An entry or sub-item with its key (key()), carried through the + picks and the tag filter, which copy blocks. */ +type Keyed = ContentBlockItem & { slideKey: string } +const keyOf = (entry: ContentBlockItem) => (entry as Keyed).slideKey + function scheduleSlides(slides: Slide[], { n, days, tags }: Schedule, { hidden, seconds, only }: Picks) { const kept: Day[] = [] days.forEach((all, d) => { if (hidden.has(key(n, d))) return - let entries = all.entries.flatMap((entry, e) => { + let entries: ContentBlockItem[] = all.entries.flatMap((entry, e) => { if (hidden.has(key(n, d, e))) return [] - if (entry.kind !== 'block') return [entry] - return [{ ...entry, items: (entry.items ?? []).filter((_, i) => !hidden.has(key(n, d, e, i))) }] + const slideKey = key(n, d, e) + if (entry.kind !== 'block') return [{ ...entry, slideKey }] + const items = (entry.items ?? []).flatMap((item, i) => + hidden.has(key(n, d, e, i)) ? [] : [{ ...item, slideKey: key(n, d, e, i) }], + ) + return [{ ...entry, slideKey, items }] }) if (only) entries = withTag(entries, only) if (entries.length === 0) return kept.push({ name: all.name, entries }) const day = { ...all, entries } const at = { day, label: day.name, tags } - if (seconds.overview) slides.push({ kind: 'overview', seconds: seconds.overview, ...at }) + if (seconds.overview) slides.push({ id: `o${key(n, d)}`, kind: 'overview', seconds: seconds.overview, ...at }) const media = (entry: ContentBlockItem, parent?: ContentBlockItem) => { - 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 }) + const k = keyOf(entry) + if (seconds.graphic && entry.media) slides.push({ id: `g${k}`, kind: 'graphic', seconds: seconds.graphic, ...at, entry, parent }) + if (seconds.map && entry.map_image) slides.push({ id: `m${k}`, 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, ...at, entry }) + if (seconds.block) slides.push({ id: `k${keyOf(entry)}`, 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, ...at, entry: item, parent: entry }) + if (seconds.spotlight) { + slides.push({ id: `s${keyOf(item)}`, 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, ...at, entry }) + if (seconds.spotlight && entry.kind !== 'break') { + slides.push({ id: `s${keyOf(entry)}`, kind: 'spotlight', seconds: seconds.spotlight, ...at, entry }) + } media(entry) } }) @@ -215,11 +265,41 @@ function scheduleSlides(slides: Slide[], { n, days, tags }: Schedule, { hidden, 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, label: tag.name, tag, days: tagDays, tags }) + if (tagDays.length) slides.push({ id: `x${n}.${tag.key}`, kind: 'tag', seconds: seconds.tag, label: tag.name, tag, days: tagDays, tags }) } } } +/* A map block's slides: the map (once per section with A slide per + section), then each location picked for a slide of its own (095). + `title` is the heading folded in, if any. */ +function mapSlides(slides: Slide[], block: ContentBlock, at: string, label: string, title: string | null, seconds: Picks['seconds']) { + const venue = block.venue! + const present = block.present + const shown = { noList: present?.map_no_list, noDetails: present?.map_no_details } + if (seconds.venue) { + const parts = present?.map_split ? (block.map_sections ?? []) : [] + if (parts.length) { + parts.forEach((part, i) => { + slides.push({ id: `v${at}.${i}`, kind: 'venue', seconds: seconds.venue, label, venue, title: part.name, only: part.keys, ...shown }) + }) + } else { + slides.push({ id: `v${at}`, kind: 'venue', seconds: seconds.venue, label, venue, title: title ?? venue.name, ...shown }) + } + } + if (!seconds.place || !venue.map_image || present?.places === 'none') return + const picked = present?.places === 'picked' ? new Set(present.place_keys) : null + for (const location of venue.locations.filter(isMarked)) { + if (picked && !picked.has(location.key)) continue + slides.push({ id: `p${at}.${location.key}`, kind: 'place', seconds: seconds.place, label, venue, location, ...shown }) + } +} + +/* Each slide's id says where it comes from, so a saved order still + finds it: t
a section's text; v and p a map and its + locations, c and e an events list and its events, by +
.; o, k, s, g and m a schedule's overview, block, + spotlight, graphic and map image, and x its tag slides, by key(). */ function buildSlides(sections: Section[], schedules: Map, picks: Picks): Slide[] { const { skipped, seconds } = picks const slides: Slide[] = [] @@ -227,29 +307,66 @@ function buildSlides(sections: Section[], schedules: Map 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) { + // Nothing but a heading: it titles the slides that follow. + const own = text.some((block) => !FILLER.has(block.type)) + if (seconds.section && own) slides.push({ id: `t${s}`, kind: 'section', seconds: seconds.section, label, blocks: text }) + const title = section.headed && !own ? label : null + section.blocks.forEach((block, b) => { + const at = `${s}.${b}` 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 === 'map' && block.venue) mapSlides(slides, block, at, label, title, seconds) 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 }) + if (seconds.cards && items.length) slides.push({ id: `c${at}`, kind: 'cards', seconds: seconds.cards, label, items }) + if (seconds.event) { + items.forEach((entry, i) => slides.push({ id: `e${at}.${i}`, kind: 'event', seconds: seconds.event, label, entry })) + } } - } + }) }) return slides } +/* The slides in the Order list's order: one it doesn't name stays + right after the slide it follows by default. */ +function ordered(slides: Slide[], order: string[] | null): Slide[] { + if (!order?.length) return slides + const rank = new Map(order.map((id, i) => [id, i])) + let last = -1 + return slides + .map((slide, i) => { + const at = rank.get(slide.id) + if (at != null) last = at + return { slide, i, at: at ?? last + 0.5 } + }) + .sort((a, b) => a.at - b.at || a.i - b.i) + .map(({ slide }) => slide) +} + +/* A slide's line in the Order list. */ +function slideName(slide: Slide): string { + const entry = slide.entry + switch (slide.kind) { + case 'section': + case 'cards': + return slide.label + case 'overview': + return slide.day?.name || 'Schedule' + case 'tag': + return slide.tag!.name + case 'venue': + return slide.title ?? slide.venue!.name + case 'place': + return slide.location!.name + case 'event': + return entry!.text || entry!.event!.title + default: + return [slide.day?.name, entry!.time, entry!.text].filter(Boolean).join(' · ') + } +} +const KIND_LABEL = new Map(KINDS.map((kind) => [kind.key, kind.label])) + export default function EventPresent() { const { id } = useParams() const [params, setParams] = useSearchParams() @@ -284,7 +401,8 @@ export default function EventPresent() { ) } - const accent = event.color || BRAND + const look = event.present + const accent = look?.accent || event.color || BRAND const back = `/events/${encodeURIComponent(event.id)}` if (sections.length === 0) { @@ -304,7 +422,8 @@ export default function EventPresent() { { const next = new URLSearchParams(params) @@ -332,6 +451,7 @@ export default function EventPresent() { out.set('screen', String(next.screen)) // Not 'tag': that's the tag slides' seconds. if (next.only) out.set('only', next.only) + if (next.order?.length) out.set('order', next.order.join(',')) out.set('play', '1') setParams(out) }} @@ -363,7 +483,18 @@ function Setup({ const [seconds, setSeconds] = useState(settings.seconds) const [only, setOnly] = useState(settings.only) const [screen, setScreen] = useState(settings.screen) - const count = buildSlides(sections, schedules, { skipped, hidden, seconds, only }).length + const [order, setOrder] = useState(settings.order) + const [dragging, setDragging] = useState(null) + const slides = ordered(buildSlides(sections, schedules, { skipped, hidden, seconds, only }), order) + const count = slides.length + // Moves a slide in the list, which then names every slide shown. + const move = (from: number, to: number) => { + if (to < 0 || to >= slides.length || from === to) return + const ids = slides.map((slide) => slide.id) + const [id] = ids.splice(from, 1) + ids.splice(to, 0, id) + setOrder(ids) + } const tags = [...schedules.values()].flatMap((schedule) => schedule.tags) const toggle = (set: Set, value: T) => { @@ -529,11 +660,67 @@ function Setup({
+ {slides.length > 1 && ( +
+
+

Order

+ {order && ( + + )} +
+

+ Drag a slide, or move it with its arrows. A slide picked again later goes back after the one it follows on + the page. +

+
    + {slides.map((slide, i) => ( +
  1. setDragging(i)} + onDragOver={(e) => e.preventDefault()} + onDrop={() => { + if (dragging != null) move(dragging, i) + setDragging(null) + }} + onDragEnd={() => setDragging(null)} + className={`flex cursor-grab items-center gap-3 bg-raised px-3 py-2 shadow-sm ${dragging === i ? 'opacity-50' : ''}`} + > +
  2. + ))} +
+
+ )} +