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
2 changed files with 94 additions and 33 deletions
Showing only changes of commit 3d087da005 - Show all commits

View file

@ -39,19 +39,18 @@
} }
} }
/* A slide part taller than its room (Scroll): holds at the top, /* A slide part taller than its room (Scroll): moves up by
moves up by --present-scroll, holds at the end. With reduced --present-scroll at a steady pace; its wait at the top is the
motion it stays at the top. */ inline animation-delay, and it stays at the end after. With
reduced motion it stays at the top. */
.present-scroll { .present-scroll {
animation: present-scroll ease-in-out both; animation: present-scroll linear both;
} }
@keyframes present-scroll { @keyframes present-scroll {
0%, from {
15% {
transform: none; transform: none;
} }
85%, to {
100% {
transform: translateY(var(--present-scroll)); transform: translateY(var(--present-scroll));
} }
} }

View file

@ -21,8 +21,9 @@
tag after the days: each of the schedule's tags (087) tag after the days: each of the schedule's tags (087)
and everything it's on, under each day's name and everything it's on, under each day's name
A heading (086) is only a line on the overview; a break gets no A heading (086) is only a line on the overview; a break gets no
spotlight. A slide with more than the screen holds scrolls through spotlight. A slide with more than the screen holds waits half its
it over its seconds. "Only entries tagged" (`only=<key>`) cuts every slide 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. to what one tag is on, eg. for a screen outside the youth room.
Keys while playing: arrows step, Space pauses, Escape leaves full Keys while playing: arrows step, Space pauses, Escape leaves full
@ -30,7 +31,7 @@
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
import { ArrowsOut, CaretLeft, CaretRight, Gear, Pause, Play } from '@phosphor-icons/react' import { ArrowsOut, CaretLeft, CaretRight, Gear, Pause, Play } from '@phosphor-icons/react'
import { useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type ReactNode } from 'react' import { createContext, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type ReactNode } from 'react'
import { useParams, useSearchParams } from 'react-router-dom' import { useParams, useSearchParams } from 'react-router-dom'
import PageState from '../components/PageState.tsx' import PageState from '../components/PageState.tsx'
@ -64,6 +65,8 @@ const KINDS = [
] as const ] as const
type Kind = (typeof KINDS)[number]['key'] 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. */ /* An overview with more entries than this goes to two columns. */
const ONE_COLUMN = 8 const ONE_COLUMN = 8
/* How long the controls stay up after the pointer last moved (ms). */ /* How long the controls stay up after the pointer last moved (ms). */
@ -98,11 +101,22 @@ function readSettings(params: URLSearchParams, days: Day[]) {
return [kind.key, Number.isFinite(value) && value > 0 ? value : 0] return [kind.key, Number.isFinite(value) && value > 0 ? value : 0]
}), }),
) as Record<Kind, number> ) as Record<Kind, number>
return { pickedDays: new Set(pickedDays), hidden, seconds, only: params.get('only') || null } 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> type Settings = ReturnType<typeof readSettings>
function buildSlides(days: Day[], tags: ScheduleTag[], { pickedDays, hidden, seconds, only }: Settings): Slide[] { function buildSlides(
days: Day[],
tags: ScheduleTag[],
{ pickedDays, hidden, seconds, only }: Pick<Settings, 'pickedDays' | 'hidden' | 'seconds' | 'only'>,
): Slide[] {
const slides: Slide[] = [] const slides: Slide[] = []
const kept: Day[] = [] const kept: Day[] = []
days.forEach((all, d) => { days.forEach((all, d) => {
@ -198,6 +212,7 @@ export default function SchedulePresent() {
title={event.title} title={event.title}
accent={accent} accent={accent}
slides={buildSlides(days, tags, settings)} slides={buildSlides(days, tags, settings)}
screen={settings.screen}
onSetup={() => { onSetup={() => {
const next = new URLSearchParams(params) const next = new URLSearchParams(params)
next.delete('play') next.delete('play')
@ -222,6 +237,7 @@ export default function SchedulePresent() {
if (next.pickedDays.size < days.length) out.set('days', [...next.pickedDays].sort((a, b) => a - b).join(',')) 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(',')) if (next.hidden.size) out.set('hide', [...next.hidden].join(','))
for (const kind of KINDS) out.set(kind.key, String(next.seconds[kind.key])) 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. // Not 'tag': that's the tag slides' seconds.
if (next.only) out.set('only', next.only) if (next.only) out.set('only', next.only)
out.set('play', '1') out.set('play', '1')
@ -254,6 +270,7 @@ function Setup({
const [hidden, setHidden] = useState(settings.hidden) const [hidden, setHidden] = useState(settings.hidden)
const [seconds, setSeconds] = useState(settings.seconds) const [seconds, setSeconds] = useState(settings.seconds)
const [only, setOnly] = useState(settings.only) 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(days, tags, { pickedDays, hidden, seconds, only }).length
const toggle = <T,>(set: Set<T>, value: T) => { const toggle = <T,>(set: Set<T>, value: T) => {
@ -301,6 +318,27 @@ function Setup({
</span> </span>
</label> </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> </div>
<p className="mt-2 text-sm text-muted">0 leaves that kind of slide out.</p> <p className="mt-2 text-sm text-muted">0 leaves that kind of slide out.</p>
</section> </section>
@ -374,7 +412,7 @@ function Setup({
<button <button
type="button" type="button"
disabled={count === 0} disabled={count === 0}
onClick={() => onPlay({ pickedDays, hidden, seconds, only })} onClick={() => onPlay({ pickedDays, hidden, seconds, screen, only })}
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) }}
> >
@ -431,26 +469,31 @@ function Player({
title, title,
accent, accent,
slides, slides,
screen,
onSetup, onSetup,
}: { }: {
title: string title: string
accent: string accent: string
slides: Slide[] slides: Slide[]
screen: number
onSetup: () => void onSetup: () => void
}) { }) {
const [index, setIndex] = useState(0) 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 [paused, setPaused] = useState(false)
const [controls, setControls] = useState(true) const [controls, setControls] = useState(true)
const hideTimer = useRef(0) const hideTimer = useRef(0)
const slide = slides[index % Math.max(slides.length, 1)] const slide = slides[index % Math.max(slides.length, 1)]
const step = (by: number) => setIndex((i) => (i + by + slides.length) % slides.length) 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. // The next slide when this one's time is up.
useEffect(() => { useEffect(() => {
if (paused || !slide) return if (paused || !slide) return
const timer = window.setTimeout(() => step(1), slide.seconds * 1000) const timer = window.setTimeout(() => step(1), seconds * 1000)
return () => window.clearTimeout(timer) return () => window.clearTimeout(timer)
}, [index, paused, slide?.seconds, slides.length]) }, [index, paused, seconds, slides.length])
useEffect(() => { useEffect(() => {
const onKey = (e: KeyboardEvent) => { const onKey = (e: KeyboardEvent) => {
@ -519,7 +562,11 @@ function Player({
{/* Keyed by index, so every slide's entrance animation plays. */} {/* Keyed by index, so every slide's entrance animation plays. */}
<div key={index} className="min-h-0 flex-1 px-[4vw] py-[3vh]"> <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} /> <SlideView slide={slide} accent={accent} />
</SlideTime.Provider>
</div> </div>
{/* How long this slide has left. */} {/* How long this slide has left. */}
@ -527,7 +574,7 @@ function Player({
<div <div
key={`${index}-${paused}`} key={`${index}-${paused}`}
className={paused ? 'h-full w-0' : 'present-timer h-full'} className={paused ? 'h-full w-0' : 'present-timer h-full'}
style={{ background: accent, animationDuration: `${slide.seconds}s` }} style={{ background: accent, animationDuration: `${seconds}s` }}
/> />
</div> </div>
@ -585,29 +632,44 @@ function Rise({ order = 0, from = 'below', className = '', children }: {
) )
} }
/* 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 /* A slide's part that may not fit: when its content is taller than
the room it has, it holds, scrolls to the end over the slide's the room it has, it waits, scrolls to the end at the Player's
`seconds`, then holds again. `center` puts short content in the seconds a screenful (making the slide that much longer), then waits
middle (and still starts long content at the top). */ again. `center` puts short content in the middle (and still starts
function Scroll({ seconds, center = false, className = '', children }: { long content at the top). */
seconds: number function Scroll({ center = false, className = '', children }: {
center?: boolean center?: boolean
className?: string className?: string
children: ReactNode children: ReactNode
}) { }) {
const { wait, screen, paused, scrolls } = useContext(SlideTime)
const box = useRef<HTMLDivElement>(null) const box = useRef<HTMLDivElement>(null)
const [by, setBy] = useState(0) const [scrollFor, setScrollFor] = useState({ by: 0, seconds: 0 })
useLayoutEffect(() => { useLayoutEffect(() => {
const outer = box.current const outer = box.current
const inner = outer?.firstElementChild as HTMLElement | null const inner = outer?.firstElementChild as HTMLElement | null
if (outer && inner) setBy(Math.max(0, inner.offsetHeight - outer.clientHeight)) 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 ( return (
<div ref={box} className={`min-h-0 flex-1 overflow-hidden ${center ? 'flex flex-col' : ''} ${className}`}> <div ref={box} className={`min-h-0 flex-1 overflow-hidden ${center ? 'flex flex-col' : ''} ${className}`}>
<div <div className={`${center ? 'my-auto' : ''} ${by ? 'present-scroll' : ''}`} style={by ? style : undefined}>
className={`${center ? 'my-auto' : ''} ${by ? 'present-scroll' : ''}`}
style={by ? ({ '--present-scroll': `-${by}px`, animationDuration: `${seconds}s` } as CSSProperties) : undefined}
>
{children} {children}
</div> </div>
</div> </div>
@ -703,7 +765,7 @@ function SlideView({ slide, accent }: { slide: Slide; accent: string }) {
{slide.day.name || 'Schedule'} {slide.day.name || 'Schedule'}
</h1> </h1>
</Rise> </Rise>
<Scroll seconds={slide.seconds}> <Scroll>
<ul className={`grid content-start gap-x-[4vw] ${two ? 'grid-cols-2' : 'grid-cols-1'}`}> <ul className={`grid content-start gap-x-[4vw] ${two ? 'grid-cols-2' : 'grid-cols-1'}`}>
<OverviewEntries entries={entries} accent={accent} /> <OverviewEntries entries={entries} accent={accent} />
</ul> </ul>
@ -725,7 +787,7 @@ function SlideView({ slide, accent }: { slide: Slide; accent: string }) {
{tag.name} {tag.name}
</h1> </h1>
</Rise> </Rise>
<Scroll seconds={slide.seconds}> <Scroll>
<ul className={`grid content-start gap-x-[4vw] ${two ? 'grid-cols-2' : 'grid-cols-1'}`}> <ul className={`grid content-start gap-x-[4vw] ${two ? 'grid-cols-2' : 'grid-cols-1'}`}>
{tagDays.map((day, d) => { {tagDays.map((day, d) => {
const start = order const start = order
@ -779,7 +841,7 @@ function SlideView({ slide, accent }: { slide: Slide; accent: string }) {
</p> </p>
</Rise> </Rise>
)} )}
<Scroll seconds={slide.seconds} className="mt-[4vh]"> <Scroll className="mt-[4vh]">
<ul style={{ borderLeft: `0.4vw solid ${withAlpha(accent, 40)}` }}> <ul style={{ borderLeft: `0.4vw solid ${withAlpha(accent, 40)}` }}>
{items.map((item, i) => ( {items.map((item, i) => (
<li key={i} className="even:bg-tint-soft/60" style={item.featured ? featuredStyle(accent) : undefined}> <li key={i} className="even:bg-tint-soft/60" style={item.featured ? featuredStyle(accent) : undefined}>
@ -850,7 +912,7 @@ function SlideView({ slide, accent }: { slide: Slide; accent: string }) {
)} )}
</Rise> </Rise>
)} )}
<Scroll seconds={slide.seconds} center className="min-w-0 self-stretch"> <Scroll center className="min-w-0 self-stretch">
<Rise from="right"> <Rise from="right">
<p className="text-[clamp(1.2rem,2.4vw,3rem)] font-semibold" style={{ color }}> <p className="text-[clamp(1.2rem,2.4vw,3rem)] font-semibold" style={{ color }}>
{[slide.day.name, slide.parent?.text, entry.time].filter(Boolean).join(' · ')} {[slide.day.name, slide.parent?.text, entry.time].filter(Boolean).join(' · ')}