Schedule tags: a block's own tags, tag tabs, chips, a tag filter and tag slides
A schedule block gets its own tags (content_block_tags, migration 087): a name, a color and whether it's a tab. Entries and sub-items pick them from a checklist. Each tag is a tab after the days, gathering what it's on from every day under the day's name; a tagged entry comes whole and an untagged block brings only its tagged sub-items. Rows show their tags as chips. The presentation can show only one tag's entries and adds a slide per tag after the days. Entries name a tag by a key the admin makes when the tag is added, so a rename keeps them, since the block's rows are rewritten on every save. For that the admin engine gets a function blank (fresh values for every new row and copy, with a `seeded` column that doesn't count as input), `lends` (a row's options for the collections nested in it) and a checklist widget. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7885d10249
commit
71d58318b6
12 changed files with 539 additions and 122 deletions
|
|
@ -18,21 +18,35 @@
|
|||
the spotlight, graphic and map slides an entry does
|
||||
graphic an entry's graphic, full screen
|
||||
map an entry's own map image (069), full screen
|
||||
tag after the days: each of the schedule's tags (087)
|
||||
and everything it's on, under each day's name
|
||||
A heading (086) is only a line on the overview; a break gets no
|
||||
spotlight.
|
||||
spotlight. "Only entries tagged" (`tag=<key>`) cuts every slide
|
||||
to what one tag is on, eg. for a screen outside the youth room.
|
||||
|
||||
Keys while playing: arrows step, Space pauses, Escape leaves full
|
||||
screen (the browser's), S goes back to the setup.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { ArrowsOut, CaretLeft, CaretRight, Gear, Pause, Play } from '@phosphor-icons/react'
|
||||
import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
|
||||
import { useContext, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
|
||||
import { useParams, useSearchParams } from 'react-router-dom'
|
||||
|
||||
import PageState from '../components/PageState.tsx'
|
||||
import { Avatar, FeaturedStar, featuredStyle, groupByDay, mapAlt, type Day } from '../components/ScheduleBlock.tsx'
|
||||
import {
|
||||
Avatar,
|
||||
FeaturedStar,
|
||||
ScheduleTags,
|
||||
TagChips,
|
||||
daysWithTag,
|
||||
featuredStyle,
|
||||
groupByDay,
|
||||
mapAlt,
|
||||
withTag,
|
||||
type Day,
|
||||
} from '../components/ScheduleBlock.tsx'
|
||||
import { Paragraphs } from '../components/InlineText.tsx'
|
||||
import { useEvent, type ContentBlockItem } from '../lib/useContent.ts'
|
||||
import { useEvent, type ContentBlockItem, type ScheduleTag } from '../lib/useContent.ts'
|
||||
import { mediaUrl } from '../lib/media.ts'
|
||||
import { BRAND, accentText, readableOn, withAlpha } from '../lib/color.ts'
|
||||
import { documentTitle } from '../lib/site.ts'
|
||||
|
|
@ -45,6 +59,7 @@ const KINDS = [
|
|||
{ key: 'block', label: 'Blocks', help: 'A block and the things in it, before each gets a spotlight', seconds: 15 },
|
||||
{ key: 'graphic', label: 'Graphics', help: "An entry's graphic, full screen", seconds: 10 },
|
||||
{ key: 'map', label: 'Map images', help: "An entry's own map, full screen", seconds: 10 },
|
||||
{ key: 'tag', label: 'Tag slides', help: "Each tag and everything it's on, after the days", seconds: 15 },
|
||||
] as const
|
||||
type Kind = (typeof KINDS)[number]['key']
|
||||
|
||||
|
|
@ -53,8 +68,17 @@ const ONE_COLUMN = 8
|
|||
/* How long the controls stay up after the pointer last moved (ms). */
|
||||
const CONTROLS_FOR = 2500
|
||||
|
||||
/* `parent` is a sub-item's block. */
|
||||
type Slide = { kind: Kind; seconds: number; day: Day; entry?: ContentBlockItem; parent?: ContentBlockItem }
|
||||
/* `parent` is a sub-item's block; a tag slide has its `tag` and the
|
||||
`days` it gathers from. */
|
||||
type Slide = {
|
||||
kind: Kind
|
||||
seconds: number
|
||||
day: Day
|
||||
entry?: ContentBlockItem
|
||||
parent?: ContentBlockItem
|
||||
tag?: ScheduleTag
|
||||
days?: Day[]
|
||||
}
|
||||
|
||||
/* An entry's key in the address: day index, a dot, entry index, and
|
||||
for a sub-item another dot and its index. */
|
||||
|
|
@ -73,20 +97,23 @@ function readSettings(params: URLSearchParams, days: Day[]) {
|
|||
return [kind.key, Number.isFinite(value) && value > 0 ? value : 0]
|
||||
}),
|
||||
) as Record<Kind, number>
|
||||
return { pickedDays: new Set(pickedDays), hidden, seconds }
|
||||
return { pickedDays: new Set(pickedDays), hidden, seconds, only: params.get('tag') || null }
|
||||
}
|
||||
type Settings = ReturnType<typeof readSettings>
|
||||
|
||||
function buildSlides(days: Day[], { pickedDays, hidden, seconds }: Settings): Slide[] {
|
||||
function buildSlides(days: Day[], tags: ScheduleTag[], { pickedDays, hidden, seconds, only }: Settings): Slide[] {
|
||||
const slides: Slide[] = []
|
||||
const kept: Day[] = []
|
||||
days.forEach((all, d) => {
|
||||
if (!pickedDays.has(d)) return
|
||||
const entries = all.entries.flatMap((entry, e) => {
|
||||
let entries = all.entries.flatMap((entry, e) => {
|
||||
if (hidden.has(entryKey(d, e))) return []
|
||||
if (entry.kind !== 'block') return [entry]
|
||||
return [{ ...entry, items: (entry.items ?? []).filter((_, i) => !hidden.has(entryKey(d, e, i))) }]
|
||||
})
|
||||
if (only) entries = withTag(entries, only)
|
||||
if (entries.length === 0) return
|
||||
kept.push({ name: all.name, entries })
|
||||
const day = { ...all, entries }
|
||||
if (seconds.overview) slides.push({ kind: 'overview', seconds: seconds.overview, day })
|
||||
|
||||
|
|
@ -109,6 +136,14 @@ function buildSlides(days: Day[], { pickedDays, hidden, seconds }: Settings): Sl
|
|||
media(entry)
|
||||
}
|
||||
})
|
||||
|
||||
if (seconds.tag) {
|
||||
for (const tag of tags) {
|
||||
if (only && tag.key !== only) continue
|
||||
const tagDays = daysWithTag(kept, tag.key)
|
||||
if (tagDays.length) slides.push({ kind: 'tag', seconds: seconds.tag, day: { name: '', entries: [] }, tag, days: tagDays })
|
||||
}
|
||||
}
|
||||
return slides
|
||||
}
|
||||
|
||||
|
|
@ -120,6 +155,7 @@ export default function SchedulePresent() {
|
|||
const blockIndex = Number(params.get('block') ?? 0)
|
||||
const schedule = event?.blocks?.filter((block) => block.type === 'schedule')[blockIndex]
|
||||
const days = useMemo(() => groupByDay(schedule?.items ?? []), [schedule])
|
||||
const tags = schedule?.tags ?? []
|
||||
|
||||
useEffect(() => {
|
||||
if (event) document.title = documentTitle(`${event.title}: schedule`)
|
||||
|
|
@ -156,16 +192,18 @@ export default function SchedulePresent() {
|
|||
const settings = readSettings(params, days)
|
||||
if (params.get('play') === '1') {
|
||||
return (
|
||||
<Player
|
||||
title={event.title}
|
||||
accent={accent}
|
||||
slides={buildSlides(days, settings)}
|
||||
onSetup={() => {
|
||||
const next = new URLSearchParams(params)
|
||||
next.delete('play')
|
||||
setParams(next)
|
||||
}}
|
||||
/>
|
||||
<ScheduleTags.Provider value={tags}>
|
||||
<Player
|
||||
title={event.title}
|
||||
accent={accent}
|
||||
slides={buildSlides(days, tags, settings)}
|
||||
onSetup={() => {
|
||||
const next = new URLSearchParams(params)
|
||||
next.delete('play')
|
||||
setParams(next)
|
||||
}}
|
||||
/>
|
||||
</ScheduleTags.Provider>
|
||||
)
|
||||
}
|
||||
return (
|
||||
|
|
@ -174,6 +212,7 @@ export default function SchedulePresent() {
|
|||
back={back}
|
||||
accent={accent}
|
||||
days={days}
|
||||
tags={tags}
|
||||
settings={settings}
|
||||
onPlay={(next) => {
|
||||
// Full screen needs the click itself, so it's asked for here.
|
||||
|
|
@ -182,6 +221,7 @@ export default function SchedulePresent() {
|
|||
if (next.pickedDays.size < days.length) out.set('days', [...next.pickedDays].sort((a, b) => a - b).join(','))
|
||||
if (next.hidden.size) out.set('hide', [...next.hidden].join(','))
|
||||
for (const kind of KINDS) out.set(kind.key, String(next.seconds[kind.key]))
|
||||
if (next.only) out.set('tag', next.only)
|
||||
out.set('play', '1')
|
||||
setParams(out)
|
||||
}}
|
||||
|
|
@ -196,6 +236,7 @@ function Setup({
|
|||
back,
|
||||
accent,
|
||||
days,
|
||||
tags,
|
||||
settings,
|
||||
onPlay,
|
||||
}: {
|
||||
|
|
@ -203,13 +244,15 @@ function Setup({
|
|||
back: string
|
||||
accent: string
|
||||
days: Day[]
|
||||
tags: ScheduleTag[]
|
||||
settings: Settings
|
||||
onPlay: (settings: Settings) => void
|
||||
}) {
|
||||
const [pickedDays, setPickedDays] = useState(settings.pickedDays)
|
||||
const [hidden, setHidden] = useState(settings.hidden)
|
||||
const [seconds, setSeconds] = useState(settings.seconds)
|
||||
const count = buildSlides(days, { pickedDays, hidden, seconds }).length
|
||||
const [only, setOnly] = useState(settings.only)
|
||||
const count = buildSlides(days, tags, { pickedDays, hidden, seconds, only }).length
|
||||
|
||||
const toggle = <T,>(set: Set<T>, value: T) => {
|
||||
const next = new Set(set)
|
||||
|
|
@ -260,6 +303,30 @@ function Setup({
|
|||
<p className="mt-2 text-sm text-muted">0 leaves that kind of slide out.</p>
|
||||
</section>
|
||||
|
||||
{tags.length > 0 && (
|
||||
<section>
|
||||
<h2 className="mb-4 text-2xl font-bold text-ink">Tags</h2>
|
||||
<label className="flex flex-wrap items-center gap-4 bg-raised p-4 shadow-sm">
|
||||
<span className="flex-1">
|
||||
<span className="block font-semibold text-ink">Only entries tagged</span>
|
||||
<span className="text-sm text-muted">Every slide shows only what this tag is on, eg. for one room's screen</span>
|
||||
</span>
|
||||
<select
|
||||
value={only ?? ''}
|
||||
onChange={(e) => setOnly(e.target.value || null)}
|
||||
className="border border-muted/25 bg-surface px-2 py-1"
|
||||
>
|
||||
<option value="">Default: every entry</option>
|
||||
{tags.map((tag) => (
|
||||
<option key={tag.key} value={tag.key}>
|
||||
{tag.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
</section>
|
||||
)}
|
||||
|
||||
<section>
|
||||
<h2 className="mb-4 text-2xl font-bold text-ink">Days and entries</h2>
|
||||
<div className="space-y-6">
|
||||
|
|
@ -305,7 +372,7 @@ function Setup({
|
|||
<button
|
||||
type="button"
|
||||
disabled={count === 0}
|
||||
onClick={() => onPlay({ pickedDays, hidden, seconds })}
|
||||
onClick={() => onPlay({ pickedDays, hidden, seconds, only })}
|
||||
className="btn inline-flex items-center gap-2 px-6 py-3 disabled:opacity-50"
|
||||
style={{ background: accent, color: readableOn(accent) }}
|
||||
>
|
||||
|
|
@ -516,10 +583,36 @@ function Rise({ order = 0, from = 'below', className = '', children }: {
|
|||
)
|
||||
}
|
||||
|
||||
/* An overview's rows: each entry, a block's sub-items under it.
|
||||
`start` is the first row's place in the slide's entrance. */
|
||||
function OverviewEntries({ entries, accent, start = 1 }: { entries: ContentBlockItem[]; accent: string; start?: number }) {
|
||||
return (
|
||||
<>
|
||||
{entries.map((entry, i) => (
|
||||
<li key={i} className="even:bg-tint-soft/60" style={entry.featured ? featuredStyle(accent) : undefined}>
|
||||
<Rise order={start + i} from="left">
|
||||
<OverviewLine entry={entry} accent={accent} />
|
||||
{entry.kind === 'block' && entry.items?.length ? (
|
||||
<ul className="ml-[14vw] pb-[1vh]">
|
||||
{entry.items.map((item, j) => (
|
||||
<li key={j} style={item.featured ? featuredStyle(accent) : undefined}>
|
||||
<OverviewLine entry={item} accent={accent} sub />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
</Rise>
|
||||
</li>
|
||||
))}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
/* One line of the day overview: an entry, or (`sub`) one of a
|
||||
block's sub-items under it. A heading is a label; a break is
|
||||
quieter. */
|
||||
function OverviewLine({ entry, accent, sub = false }: { entry: ContentBlockItem; accent: string; sub?: boolean }) {
|
||||
const tags = useContext(ScheduleTags)
|
||||
const color = accentText(accent)
|
||||
if (entry.kind === 'heading') {
|
||||
return (
|
||||
|
|
@ -553,10 +646,11 @@ function OverviewLine({ entry, accent, sub = false }: { entry: ContentBlockItem;
|
|||
)}
|
||||
{entry.text}
|
||||
</span>
|
||||
{(entry.location || entry.person) && (
|
||||
<span className="mt-1 flex flex-wrap items-center gap-x-[1.5vw] text-[clamp(0.9rem,1.4vw,1.8rem)] text-muted">
|
||||
{(entry.location || entry.person || entry.tags?.length) && (
|
||||
<span className="mt-1 flex flex-wrap items-center gap-x-[1.5vw] gap-y-1 text-[clamp(0.9rem,1.4vw,1.8rem)] text-muted">
|
||||
{entry.location && <span>{entry.location}</span>}
|
||||
{entry.person && <span>{entry.person.name}</span>}
|
||||
<TagChips keys={entry.tags} tags={tags} accent={accent} className="px-[0.6vw] py-[0.2vh] text-[0.8em]" />
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
|
|
@ -565,6 +659,7 @@ function OverviewLine({ entry, accent, sub = false }: { entry: ContentBlockItem;
|
|||
}
|
||||
|
||||
function SlideView({ slide, accent }: { slide: Slide; accent: string }) {
|
||||
const tags = useContext(ScheduleTags)
|
||||
const color = accentText(accent)
|
||||
|
||||
if (slide.kind === 'overview') {
|
||||
|
|
@ -578,22 +673,42 @@ function SlideView({ slide, accent }: { slide: Slide; accent: string }) {
|
|||
</h1>
|
||||
</Rise>
|
||||
<ul className={`grid min-h-0 flex-1 content-start gap-x-[4vw] ${two ? 'grid-cols-2' : 'grid-cols-1'}`}>
|
||||
{entries.map((entry, i) => (
|
||||
<li key={i} className="even:bg-tint-soft/60" style={entry.featured ? featuredStyle(accent) : undefined}>
|
||||
<Rise order={i + 1} from="left">
|
||||
<OverviewLine entry={entry} accent={accent} />
|
||||
{entry.kind === 'block' && entry.items?.length ? (
|
||||
<ul className="ml-[14vw] pb-[1vh]">
|
||||
{entry.items.map((item, j) => (
|
||||
<li key={j} style={item.featured ? featuredStyle(accent) : undefined}>
|
||||
<OverviewLine entry={item} accent={accent} sub />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
</Rise>
|
||||
</li>
|
||||
))}
|
||||
<OverviewEntries entries={entries} accent={accent} />
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (slide.kind === 'tag') {
|
||||
const tag = slide.tag!
|
||||
const tagDays = slide.days ?? []
|
||||
const tagColor = tag.color || accent
|
||||
const two = tagDays.reduce((n, day) => n + 1 + lineCount(day.entries), 0) > ONE_COLUMN
|
||||
let order = 1
|
||||
return (
|
||||
<div className="flex h-full flex-col">
|
||||
<Rise>
|
||||
<h1 className="mb-[3vh] text-[clamp(2rem,5vw,6rem)] font-bold leading-none" style={{ color: accentText(tagColor) }}>
|
||||
{tag.name}
|
||||
</h1>
|
||||
</Rise>
|
||||
<ul className={`grid min-h-0 flex-1 content-start gap-x-[4vw] ${two ? 'grid-cols-2' : 'grid-cols-1'}`}>
|
||||
{tagDays.map((day, d) => {
|
||||
const start = order
|
||||
order += day.entries.length + 1
|
||||
return (
|
||||
<li key={d}>
|
||||
{day.name && (
|
||||
<Rise order={start} from="left">
|
||||
<p className="pt-[1.5vh] pb-[0.5vh] text-[clamp(1rem,1.8vw,2.4rem)] font-bold text-ink">{day.name}</p>
|
||||
</Rise>
|
||||
)}
|
||||
<ul>
|
||||
<OverviewEntries entries={day.entries} accent={accent} start={start + 1} />
|
||||
</ul>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
|
|
@ -714,6 +829,13 @@ function SlideView({ slide, accent }: { slide: Slide; accent: string }) {
|
|||
{entry.text}
|
||||
</h1>
|
||||
</Rise>
|
||||
{entry.tags?.length ? (
|
||||
<Rise order={2} from="right">
|
||||
<p className="mt-[2vh]">
|
||||
<TagChips keys={entry.tags} tags={tags} accent={accent} className="px-[1vw] py-[0.4vh] text-[clamp(0.9rem,1.6vw,2rem)]" />
|
||||
</p>
|
||||
</Rise>
|
||||
) : null}
|
||||
{entry.location && (
|
||||
<Rise order={2} from="right">
|
||||
<p className="mt-[2vh] text-[clamp(1.2rem,2.4vw,3rem)] text-body">{entry.location}</p>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue