v1.14.2-present: event schedules, venues and map blocks, Present mode and its phone remote #33

Merged
ngu-git-admin merged 40 commits from event-schedule into main 2026-11-21 23:02:06 +00:00
Showing only changes of commit a59702b7f3 - Show all commits

View file

@ -30,6 +30,9 @@
i<section>.<block>) and ticks its items on and off (`hide`, i<section>.<block>) and ticks its items on and off (`hide`,
l<section>.<block>.<item>). A people block shows each one's role l<section>.<block>.<item>). A people block shows each one's role
or title when the setup ticks it (`titles`, <section>.<block>). or title when the setup ticks it (`titles`, <section>.<block>).
A section with pictures (image blocks) and other text can have the
setup put its pictures in a column left or right of the rest
(`pictures`, <section>:left|right), the slide shrunk to fit.
callout a callout block the setup picks for a slide of its callout a callout block the setup picks for a slide of its
own (`lists`, q<section>.<block>): its text centered own (`lists`, q<section>.<block>): its text centered
under its heading (the subheading above it in the under its heading (the subheading above it in the
@ -174,6 +177,11 @@ const ownSlides = (block: ContentBlock, lists: Set<string>, s: number, b: number
(block.type === 'list' && (lists.has(overviewKey(s, b)) || lists.has(itemsKey(s, b))) ? 'List' : null) ?? (block.type === 'list' && (lists.has(overviewKey(s, b)) || lists.has(itemsKey(s, b))) ? 'List' : null) ??
(block.type === 'callout' && lists.has(calloutKey(s, b)) ? 'Callout' : null) (block.type === 'callout' && lists.has(calloutKey(s, b)) ? 'Callout' : null)
/* Where a section's pictures can go beside its text. */
const SIDES = ['left', 'right'] as const
type Side = (typeof SIDES)[number]
const isPicture = (block: ContentBlock) => block.type === 'image'
/* Blocks that start a section. */ /* Blocks that start a section. */
const STARTS_SECTION = new Set(['heading', 'tab']) const STARTS_SECTION = new Set(['heading', 'tab'])
/* Text that alone makes no section slide: the heading titles what /* Text that alone makes no section slide: the heading titles what
@ -219,6 +227,8 @@ type Slide = {
days?: Day[] days?: Day[]
tags?: ScheduleTag[] tags?: ScheduleTag[]
blocks?: ContentBlock[] blocks?: ContentBlock[]
/* A section's pictures in a column beside its text (the setup). */
pictures?: Side
venue?: Venue venue?: Venue
location?: VenueLocation location?: VenueLocation
items?: ContentBlockItem[] items?: ContentBlockItem[]
@ -275,11 +285,17 @@ function readSettings(params: URLSearchParams) {
order: list(params.get('order')), order: list(params.get('order')),
lists: new Set(list(params.get('lists')) ?? []), lists: new Set(list(params.get('lists')) ?? []),
titles: new Set(list(params.get('titles')) ?? []), titles: new Set(list(params.get('titles')) ?? []),
pictures: new Map(
(list(params.get('pictures')) ?? []).flatMap((pick) => {
const [at, side] = pick.split(':')
return SIDES.includes(side as Side) ? [[Number(at), side as Side] as const] : []
}),
),
theme: THEMES.find((theme) => theme === params.get('theme')) ?? null, theme: THEMES.find((theme) => theme === params.get('theme')) ?? null,
} }
} }
type Settings = ReturnType<typeof readSettings> type Settings = ReturnType<typeof readSettings>
type Picks = Pick<Settings, 'skipped' | 'hidden' | 'seconds' | 'only' | 'lists' | 'titles'> type Picks = Pick<Settings, 'skipped' | 'hidden' | 'seconds' | 'only' | 'lists' | 'titles' | 'pictures'>
/* An entry or sub-item with its key (key()), carried through the /* An entry or sub-item with its key (key()), carried through the
picks and the tag filter, which copy blocks. */ picks and the tag filter, which copy blocks. */
@ -372,7 +388,7 @@ function mapSlides(slides: Slide[], block: ContentBlock, at: string, label: stri
o, k, s, g and m a schedule's overview, block, spotlight, graphic o, k, s, g and m a schedule's overview, block, spotlight, graphic
and map image, and x its tag slides, by key(). */ and map image, and x its tag slides, by key(). */
function buildSlides(sections: Section[], schedules: Map<ContentBlock, Schedule>, picks: Picks): Slide[] { function buildSlides(sections: Section[], schedules: Map<ContentBlock, Schedule>, picks: Picks): Slide[] {
const { skipped, seconds, hidden, lists, titles } = picks const { skipped, seconds, hidden, lists, titles, pictures } = picks
const slides: Slide[] = [] const slides: Slide[] = []
sections.forEach((section, s) => { sections.forEach((section, s) => {
if (skipped.has(s)) return if (skipped.has(s)) return
@ -385,7 +401,11 @@ function buildSlides(sections: Section[], schedules: Map<ContentBlock, Schedule>
}) })
// Nothing but a heading: it titles the slides that follow. // Nothing but a heading: it titles the slides that follow.
const own = text.some((block) => !FILLER.has(block.type)) 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 }) if (seconds.section && own) {
// Pictures beside the text, when picked and there are both.
const side = text.some(isPicture) && text.some((block) => !isPicture(block)) ? pictures.get(s) : undefined
slides.push({ id: `t${s}`, kind: 'section', seconds: seconds.section, label, blocks: text, pictures: side })
}
const title = section.headed && !own ? label : null const title = section.headed && !own ? label : null
section.blocks.forEach((block, b) => { section.blocks.forEach((block, b) => {
const at = `${s}.${b}` const at = `${s}.${b}`
@ -568,6 +588,7 @@ export default function EventPresent() {
if (next.theme) out.set('theme', next.theme) if (next.theme) out.set('theme', next.theme)
if (next.lists.size) out.set('lists', [...next.lists].join(',')) if (next.lists.size) out.set('lists', [...next.lists].join(','))
if (next.titles.size) out.set('titles', [...next.titles].join(',')) if (next.titles.size) out.set('titles', [...next.titles].join(','))
if (next.pictures.size) out.set('pictures', [...next.pictures].map(([at, side]) => `${at}:${side}`).join(','))
out.set('play', '1') out.set('play', '1')
setParams(out) setParams(out)
}} }}
@ -603,8 +624,9 @@ function Setup({
const [theme, setTheme] = useState(settings.theme) const [theme, setTheme] = useState(settings.theme)
const [lists, setLists] = useState(settings.lists) const [lists, setLists] = useState(settings.lists)
const [titles, setTitles] = useState(settings.titles) const [titles, setTitles] = useState(settings.titles)
const [pictures, setPictures] = useState(settings.pictures)
const [dragging, setDragging] = useState<number | null>(null) const [dragging, setDragging] = useState<number | null>(null)
const slides = ordered(buildSlides(sections, schedules, { skipped, hidden, seconds, only, lists, titles }), order) const slides = ordered(buildSlides(sections, schedules, { skipped, hidden, seconds, only, lists, titles, pictures }), order)
const count = slides.length const count = slides.length
// Moves a slide in the list, which then names every slide shown. // Moves a slide in the list, which then names every slide shown.
const move = (from: number, to: number) => { const move = (from: number, to: number) => {
@ -750,6 +772,29 @@ function Setup({
<span className="font-bold text-ink">{section.title}</span> <span className="font-bold text-ink">{section.title}</span>
<span className="text-xs text-muted">{kinds.join(', ')}</span> <span className="text-xs text-muted">{kinds.join(', ')}</span>
</label> </label>
{/* Pictures and other text: where the pictures go. */}
{section.blocks.some(isPicture) &&
section.blocks.some((block, b) => !isPicture(block) && !ownSlides(block, lists, s, b)) && (
<label className={`mt-3 flex flex-wrap items-center gap-3 pl-7 ${on ? '' : 'opacity-50'}`}>
<span className="text-sm">Pictures</span>
<select
disabled={!on}
value={pictures.get(s) ?? ''}
onChange={(e) => {
const next = new Map(pictures)
const side = SIDES.find((one) => one === e.target.value)
if (side) next.set(s, side)
else next.delete(s)
setPictures(next)
}}
className="border border-muted/25 bg-surface px-2 py-1 text-sm"
>
<option value="">Default: in the text, as on the page</option>
<option value="left">Left of the text</option>
<option value="right">Right of the text</option>
</select>
</label>
)}
{section.blocks.map((block, b) => { {section.blocks.map((block, b) => {
// A list: its own slides if picked, then its items. // A list: its own slides if picked, then its items.
if (block.type === 'list' && block.items?.length) { if (block.type === 'list' && block.items?.length) {
@ -1001,7 +1046,7 @@ function Setup({
<button <button
type="button" type="button"
disabled={count === 0} disabled={count === 0}
onClick={() => onPlay({ skipped, hidden, seconds, screen, only, order, theme, lists, titles })} onClick={() => onPlay({ skipped, hidden, seconds, screen, only, order, theme, lists, titles, pictures })}
className="btn inline-flex items-center gap-2 px-6 py-3 disabled:opacity-50" className="btn inline-flex items-center gap-2 px-6 py-3 disabled:opacity-50"
style={{ background: accent, color: readableOn(accent) }} style={{ background: accent, color: readableOn(accent) }}
> >
@ -1387,7 +1432,8 @@ function Scroll({ center = false, className = '', children }: {
/* A slide's part shrunk to fit the room it has, never scrolled: /* A slide's part shrunk to fit the room it has, never scrolled:
zoomed down until its content is no taller than its box (a few zoomed down until its content is no taller than its box (a few
passes, since text narrower in zoom wraps less). */ passes, since text narrower in zoom wraps less). Again whenever
its size changes, eg. a picture loading. */
function Fit({ className = '', children }: { className?: string; children: ReactNode }) { function Fit({ className = '', children }: { className?: string; children: ReactNode }) {
const box = useRef<HTMLDivElement>(null) const box = useRef<HTMLDivElement>(null)
const inner = useRef<HTMLDivElement>(null) const inner = useRef<HTMLDivElement>(null)
@ -1395,14 +1441,20 @@ function Fit({ className = '', children }: { className?: string; children: React
const outer = box.current const outer = box.current
const content = inner.current const content = inner.current
if (!outer || !content) return if (!outer || !content) return
let zoom = 1 const fit = () => {
content.style.zoom = '1' let zoom = 1
for (let pass = 0; pass < 4; pass++) { content.style.zoom = '1'
const tall = content.getBoundingClientRect().height for (let pass = 0; pass < 4; pass++) {
if (tall <= outer.clientHeight + 1) break const tall = content.getBoundingClientRect().height
zoom *= outer.clientHeight / tall if (tall <= outer.clientHeight + 1) break
content.style.zoom = String(zoom) zoom *= outer.clientHeight / tall
content.style.zoom = String(zoom)
}
} }
fit()
const watch = new ResizeObserver(fit)
watch.observe(content)
return () => watch.disconnect()
}, []) }, [])
return ( return (
<div ref={box} className={`min-h-0 flex-1 overflow-hidden ${className}`}> <div ref={box} className={`min-h-0 flex-1 overflow-hidden ${className}`}>
@ -1551,6 +1603,36 @@ function SlideView({ slide, accent }: { slide: Slide; accent: string }) {
</div> </div>
) )
} }
// Pictures in a column beside the text, shrunk to fit the slide.
if (slide.pictures) {
const pics = (
<div className="min-w-0">
<ContentBlocks blocks={slide.blocks!.filter(isPicture)} accent={accent} />
</div>
)
const rest = (
<div className="min-w-0">
<ContentBlocks blocks={slide.blocks!.filter((block) => !isPicture(block))} accent={accent} />
</div>
)
const left = slide.pictures === 'left'
return (
<div className="flex h-full flex-col">
<SlideTitle color={color}>{slide.label}</SlideTitle>
<Rise order={1} className="flex min-h-0 flex-1 flex-col">
<Fit>
<div
className={`grid items-center gap-[3vw] ${left ? 'grid-cols-[2fr_3fr]' : 'grid-cols-[3fr_2fr]'}`}
style={{ zoom }}
>
{left ? pics : rest}
{left ? rest : pics}
</div>
</Fit>
</Rise>
</div>
)
}
return ( return (
<div className="flex h-full flex-col"> <div className="flex h-full flex-col">
<SlideTitle color={color}>{slide.label}</SlideTitle> <SlideTitle color={color}>{slide.label}</SlideTitle>