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
12 changed files with 539 additions and 122 deletions
Showing only changes of commit 71d58318b6 - Show all commits

View file

@ -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. | | 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 → 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 | **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 → Type | heading, subheading, paragraph, list, links, quote, image, divider, video, button, callout, schedule, table | **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`. | | 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. |
| Timeline → Kind (+ list filter) | milestone, event, organization, award, people | no | `KIND_NAMES` in `src/pages/sections/history/TimelineEntry.tsx` | | 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 → 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 | | Timeline → Precision (and on events/orgs) | year, month, day | no | the history page's grouping |

View file

@ -494,6 +494,8 @@ function isBlankChildRow(child, raw) {
if (!raw || typeof raw !== "object") return true; if (!raw || typeof raw !== "object") return true;
for (const column of child.columns) { for (const column of child.columns) {
// A value the admin seeds every new row with (`seeded`), not input.
if (column.seeded) continue;
const value = raw[column.name]; const value = raw[column.name];
if (value === undefined || value === null || value === "") continue; if (value === undefined || value === null || value === "") continue;
// An unchecked box is the default state of a new row, not input. // An unchecked box is the default state of a new row, not input.

View file

@ -196,6 +196,8 @@ export const blocksChild = (ownerKind) => ({
time("start_time"), time("start_time"),
time("end_time"), time("end_time"),
bool("featured"), bool("featured"),
// The block's tags it has, by key, comma-separated (087).
text("tags"),
], ],
children: [ children: [
{ {
@ -220,10 +222,26 @@ export const blocksChild = (ownerKind) => ({
text("map"), text("map"),
text("map_image"), text("map_image"),
bool("featured"), bool("featured"),
text("tags"),
], ],
}, },
], ],
}, },
{
// A schedule's own tags (087).
key: "tags",
table: "content_block_tags",
owner: { column: "block_id" },
order: "sort_order",
when: { column: "type", value: "schedule" },
columns: [
// Made by the admin as the row is added, so it isn't input.
text("tag_key", { required: true, seeded: true }),
text("name", { required: true }),
text("color"),
bool("no_tab"),
],
},
], ],
}); });

View file

@ -0,0 +1,28 @@
-- ═══════════════════════════════════════════════════════════════
-- 087 SCHEDULE TAGS
--
-- A schedule block's own tags, eg. Youth or Worship: entries and
-- sub-items are tagged with them, a tag can be a tab of its own
-- gathering every entry it's on (across the days), and the schedule
-- presentation can show only one tag's entries and a slide per tag.
--
-- These are the block's, not Data → Tags (070). The block's rows are
-- rewritten on every save, so entries name a tag by `tag_key` (made
-- in the admin when the tag is added, kept when it's renamed), not
-- by its row id. An entry's `tags` is its keys, comma-separated; a
-- key no tag has any more is skipped.
-- ═══════════════════════════════════════════════════════════════
CREATE TABLE content_block_tags (
id INTEGER PRIMARY KEY AUTOINCREMENT,
block_id INTEGER NOT NULL REFERENCES content_blocks (id) ON DELETE CASCADE,
sort_order INTEGER NOT NULL DEFAULT 0,
tag_key TEXT NOT NULL,
name TEXT NOT NULL,
color TEXT, -- null: the event's accent
no_tab INTEGER NOT NULL DEFAULT 0 CHECK (no_tab IN (0, 1)),
UNIQUE (block_id, tag_key)
) STRICT;
ALTER TABLE content_block_items ADD COLUMN tags TEXT;
ALTER TABLE content_block_subitems ADD COLUMN tags TEXT;

View file

@ -86,24 +86,29 @@ const PAST = "showcase-past-event";
plain entry, one with a location and person, one folding out with plain entry, one with a location and person, one folding out with
a description, graphic and map, one linked, a heading, a featured a description, graphic and map, one linked, a heading, a featured
entry, a block with sub-items, a break, typed and picked times, entry, a block with sub-items, a break, typed and picked times,
and one with no day (it lands in a tab of its own). */ tags (one a tab of its own in its color, one with No tab), and one
with no day (it lands in a tab of its own). */
const SCHEDULE = [ const SCHEDULE = [
"schedule", "schedule",
{ text: "The weekend at a glance. Tap an entry for more." }, { text: "The weekend at a glance. Tap an entry for more." },
[ [
{ day: "Friday", start_time: "16:00", text: "Arrivals and check-in", location: "Front desk" }, { day: "Friday", start_time: "16:00", text: "Arrivals and check-in", location: "Front desk", tags: "showcase-youth,showcase-all" },
{ day: "Friday", kind: "heading", text: "Evening", detail: "A heading across the day" }, { day: "Friday", kind: "heading", text: "Evening", detail: "A heading across the day" },
{ day: "Friday", time: "7:00 to 8:30pm", text: "Opening session", location: "Main Hall", person_id: "showcase-person", detail: "Welcome and worship", description: "The **opening session** sets the theme for the weekend.\n\nBring a notebook.", media: "/uploads/showcase.jpg", map: "Camp Hebron, Halifax PA", map_image: "/uploads/showcase.jpg" }, { day: "Friday", time: "7:00 to 8:30pm", text: "Opening session", location: "Main Hall", person_id: "showcase-person", detail: "Welcome and worship", description: "The **opening session** sets the theme for the weekend.\n\nBring a notebook.", media: "/uploads/showcase.jpg", map: "Camp Hebron, Halifax PA", map_image: "/uploads/showcase.jpg" },
{ day: "Saturday", start_time: "08:00", end_time: "09:00", kind: "break", text: "Breakfast", location: "Dining hall" }, { day: "Saturday", start_time: "08:00", end_time: "09:00", kind: "break", text: "Breakfast", location: "Dining hall" },
{ day: "Saturday", start_time: "09:00", end_time: "10:30", kind: "block", text: "Workshops", location: "Classrooms", detail: "Pick one of three", items: [ { day: "Saturday", start_time: "09:00", end_time: "10:30", kind: "block", text: "Workshops", location: "Classrooms", detail: "Pick one of three", items: [
{ start_time: "09:00", end_time: "09:45", text: "Leading worship", location: "Room A", person_id: "showcase-member-2", url: "/blog/content-block-showcase" }, { start_time: "09:00", end_time: "09:45", text: "Leading worship", location: "Room A", person_id: "showcase-member-2", url: "/blog/content-block-showcase" },
{ start_time: "09:00", end_time: "09:45", text: "Speaking with confidence", location: "Room B", featured: 1, description: "A featured sub-item that folds out." }, { start_time: "09:00", end_time: "09:45", text: "Speaking with confidence", location: "Room B", featured: 1, tags: "showcase-youth", description: "A featured sub-item that folds out." },
{ time: "After the first round", text: "Open questions", location: "Room C" }, { time: "After the first round", text: "Open questions", location: "Room C" },
] }, ] },
{ day: "Saturday", start_time: "19:00", featured: 1, text: "Talent night", location: "Main Hall", person_id: "showcase-member-3", description: "Sign up at the front desk by noon." }, { day: "Saturday", start_time: "19:00", featured: 1, tags: "showcase-youth", text: "Talent night", location: "Main Hall", person_id: "showcase-member-3", description: "Sign up at the front desk by noon." },
{ day: "Sunday", time: "10:00am", text: "Closing service", location: "Chapel", map: "Main Street, Halifax PA" }, { day: "Sunday", time: "10:00am", text: "Closing service", location: "Chapel", map: "Main Street, Halifax PA" },
{ time: "Any time", text: "Quiet room open", location: "Library", detail: "An entry with no day" }, { time: "Any time", text: "Quiet room open", location: "Library", detail: "An entry with no day" },
], ],
[
{ tag_key: "showcase-youth", name: "Youth", color: "#00748a" },
{ tag_key: "showcase-all", name: "Everyone", no_tab: 1 },
],
]; ];
/* Every block type, for the blog showcase. [type, fields, items?] */ /* Every block type, for the blog showcase. [type, fields, items?] */
@ -208,7 +213,7 @@ function insert(table, row) {
} }
function blocks(ownerKind, ownerId, slot, list) { function blocks(ownerKind, ownerId, slot, list) {
list.forEach(([type, f, items = []], order) => { list.forEach(([type, f, items = [], tags = []], order) => {
const { lastInsertRowid } = insert("content_blocks", { const { lastInsertRowid } = insert("content_blocks", {
owner_kind: ownerKind, owner_kind: ownerKind,
owner_id: ownerId, owner_id: ownerId,
@ -221,6 +226,7 @@ function blocks(ownerKind, ownerId, slot, list) {
const entry = insert("content_block_items", { block_id: lastInsertRowid, sort_order: i, ...item }); const entry = insert("content_block_items", { block_id: lastInsertRowid, sort_order: i, ...item });
subitems.forEach((sub, j) => insert("content_block_subitems", { item_id: entry.lastInsertRowid, sort_order: j, ...sub })); subitems.forEach((sub, j) => insert("content_block_subitems", { item_id: entry.lastInsertRowid, sort_order: j, ...sub }));
}); });
tags.forEach((tag, i) => insert("content_block_tags", { block_id: lastInsertRowid, sort_order: i, ...tag }));
}); });
} }

View file

@ -108,7 +108,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
const blockIds = [...byId.keys()]; const blockIds = [...byId.keys()];
const ENTRY_FIELDS = `i.text, i.detail, i.url, i.start_time, i.end_time, i.time, i.location, const ENTRY_FIELDS = `i.text, i.detail, i.url, i.start_time, i.end_time, i.time, i.location,
i.description, i.media, i.media_alt, i.map, i.map_image, i.featured, i.description, i.media, i.media_alt, i.map, i.map_image, i.featured, i.tags,
p.id AS person_id, p.display_name AS person_name, p.id AS person_id, p.display_name AS person_name,
p.photo AS person_photo, p.tagline AS person_tagline`; p.photo AS person_photo, p.tagline AS person_tagline`;
@ -146,6 +146,32 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
for (const row of subRows) itemsById.get(row.item_id)?.items.push(scheduleEntry(row)); for (const row of subRows) itemsById.get(row.item_id)?.items.push(scheduleEntry(row));
} }
// A schedule's own tags (087), and each entry's cut to the ones
// the block still has.
const tagRows = db
.prepare(
`SELECT block_id, tag_key, name, color, no_tab
FROM content_block_tags
WHERE block_id IN (${placeholders(blockIds.length)})
ORDER BY block_id, sort_order`,
)
.all(...blockIds);
for (const row of tagRows) {
const block = byId.get(row.block_id);
if (!block) continue;
block.tags ??= [];
block.tags.push({ key: row.tag_key, name: row.name, color: row.color, tab: row.no_tab === 0 });
}
for (const block of byId.values()) {
if (block.type !== "schedule") continue;
const known = new Set((block.tags ??= []).map((tag) => tag.key));
const cut = (entry) => {
entry.tags = entry.tags.filter((key) => known.has(key));
entry.items?.forEach(cut);
};
block.items.forEach(cut);
}
return out; return out;
} }
@ -167,6 +193,7 @@ function scheduleEntry(row) {
map: row.map, map: row.map,
map_image: row.map_image, map_image: row.map_image,
featured: row.featured === 1, featured: row.featured === 1,
tags: row.tags ? row.tags.split(",").filter(Boolean) : [],
person: row.person_id person: row.person_id
? { ? {
id: row.person_id, id: row.person_id,

View file

@ -385,7 +385,15 @@ function Block({
case 'schedule': case 'schedule':
if (!block.items?.length) return null if (!block.items?.length) return null
return <ScheduleBlock items={block.items} intro={block.text} accent={accent} presentHref={presentHref} /> return (
<ScheduleBlock
items={block.items}
tags={block.tags}
intro={block.text}
accent={accent}
presentHref={presentHref}
/>
)
case 'people': { case 'people': {
const picked = (block.items ?? []) const picked = (block.items ?? [])

View file

@ -26,6 +26,12 @@
across. The time shown is `time`, which the API has already made across. The time shown is `time`, which the API has already made
from the picked times or the typed override. from the picked times or the typed override.
Tags (087) are the block's own: an entry or sub-item shows its
tags as chips, and each tag (unless it's set No tab) is a tab
after the days, gathering what it's on from every day under the
day's name. A tagged entry comes whole; an untagged block comes
with only its tagged sub-items. A tag on nothing draws no tab.
On an event page a Present button opens the schedule as a On an event page a Present button opens the schedule as a
slideshow for a screen (SchedulePresent.tsx). slideshow for a screen (SchedulePresent.tsx).
@ -37,12 +43,12 @@
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
import { CaretDown, Presentation, Star } from '@phosphor-icons/react' import { CaretDown, Presentation, Star } from '@phosphor-icons/react'
import { Fragment, useId, useState, type KeyboardEvent, type ReactNode } from 'react' import { Fragment, createContext, useContext, useId, useState, type KeyboardEvent, type ReactNode } from 'react'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import { personHref } from '../lib/hrefs.ts' import { personHref } from '../lib/hrefs.ts'
import { mediaUrl, initials } from '../lib/media.ts' import { mediaUrl, initials } from '../lib/media.ts'
import type { ContentBlockItem } from '../lib/useContent.ts' import type { ContentBlockItem, ScheduleTag } from '../lib/useContent.ts'
import { Anchor, Paragraphs } from './InlineText.tsx' import { Anchor, Paragraphs } from './InlineText.tsx'
import { withAlpha, accentText, readableOn } from '../lib/color.ts' import { withAlpha, accentText, readableOn } from '../lib/color.ts'
import { useSmallImage } from '../lib/useSmallImage.ts' import { useSmallImage } from '../lib/useSmallImage.ts'
@ -68,6 +74,57 @@ export function groupByDay(items: ContentBlockItem[]): Day[] {
return days return days
} }
/* What a tag is on (087): a tagged entry whole, and an untagged
block with only its tagged sub-items. */
export function withTag(entries: ContentBlockItem[], key: string): ContentBlockItem[] {
return entries.flatMap((entry) => {
if (entry.tags?.includes(key)) return [entry]
if (entry.kind !== 'block') return []
const items = (entry.items ?? []).filter((item) => item.tags?.includes(key))
return items.length ? [{ ...entry, items }] : []
})
}
/* The days, each cut to what a tag is on, empty ones dropped. */
export const daysWithTag = (days: Day[], key: string): Day[] =>
days.map((day) => ({ name: day.name, entries: withTag(day.entries, key) })).filter((day) => day.entries.length)
/* The schedule's tags, for its rows' chips. */
export const ScheduleTags = createContext<ScheduleTag[]>([])
/* An entry's tags as chips, each in its tag's color (else the
accent). `className` sizes them. */
export function TagChips({
keys,
tags,
accent,
className = 'px-2 py-0.5 text-xs',
}: {
keys?: string[]
tags: ScheduleTag[]
accent: string
className?: string
}) {
const shown = tags.filter((tag) => keys?.includes(tag.key))
if (shown.length === 0) return null
return (
<span className="inline-flex flex-wrap gap-1.5">
{shown.map((tag) => {
const color = tag.color || accent
return (
<span
key={tag.key}
className={`font-semibold ${className}`}
style={{ background: withAlpha(color, 14), color: accentText(color) }}
>
{tag.name}
</span>
)
})}
</span>
)
}
/* The tab to open with: today's weekday if a tab starts with it (or /* The tab to open with: today's weekday if a tab starts with it (or
its three-letter form), else the first. */ its three-letter form), else the first. */
function todayIndex(days: Day[]): number { function todayIndex(days: Day[]): number {
@ -119,6 +176,7 @@ export const featuredStyle = (accent: string) => ({
}) })
function Entry({ entry, accent, sub = false }: { entry: ContentBlockItem; accent: string; sub?: boolean }) { function Entry({ entry, accent, sub = false }: { entry: ContentBlockItem; accent: string; sub?: boolean }) {
const tags = useContext(ScheduleTags)
const [open, setOpen] = useState(false) const [open, setOpen] = useState(false)
// Google's map loads only when asked for (Privacy page). // Google's map loads only when asked for (Privacy page).
const [showMap, setShowMap] = useState(false) const [showMap, setShowMap] = useState(false)
@ -196,6 +254,11 @@ function Entry({ entry, accent, sub = false }: { entry: ContentBlockItem; accent
{entry.detail} {entry.detail}
</p> </p>
)} )}
{entry.tags?.length ? (
<div className="mt-2">
<TagChips keys={entry.tags} tags={tags} accent={accent} />
</div>
) : null}
</div> </div>
{more && ( {more && (
@ -300,7 +363,7 @@ function Entry({ entry, accent, sub = false }: { entry: ContentBlockItem; accent
} }
/* One entry in reading mode, a block's sub-items in a list under it. */ /* One entry in reading mode, a block's sub-items in a list under it. */
function readingEntry(entry: ContentBlockItem, accent: string, key: number): ReactNode { function readingEntry(entry: ContentBlockItem, accent: string, key: number, tags: ScheduleTag[]): ReactNode {
if (entry.kind === 'heading') { if (entry.kind === 'heading') {
return ( return (
<li key={key}> <li key={key}>
@ -332,6 +395,9 @@ function readingEntry(entry: ContentBlockItem, accent: string, key: number): Rea
))} ))}
</p> </p>
{entry.detail && <p>{entry.detail}</p>} {entry.detail && <p>{entry.detail}</p>}
{entry.tags?.length ? (
<p>Tags: {tags.filter((tag) => entry.tags!.includes(tag.key)).map((tag) => tag.name).join(', ')}</p>
) : null}
{entry.person?.tagline && <p>{entry.person.tagline}</p>} {entry.person?.tagline && <p>{entry.person.tagline}</p>}
{entry.description && <Paragraphs text={entry.description} accent={accent} />} {entry.description && <Paragraphs text={entry.description} accent={accent} />}
{graphic && <img src={graphic} alt={entry.media_alt ?? ''} />} {graphic && <img src={graphic} alt={entry.media_alt ?? ''} />}
@ -342,7 +408,7 @@ function readingEntry(entry: ContentBlockItem, accent: string, key: number): Rea
</p> </p>
)} )}
{entry.kind === 'block' && entry.items?.length ? ( {entry.kind === 'block' && entry.items?.length ? (
<ul>{entry.items.map((item, i) => readingEntry(item, accent, i))}</ul> <ul>{entry.items.map((item, i) => readingEntry(item, accent, i, tags))}</ul>
) : null} ) : null}
</li> </li>
) )
@ -350,27 +416,42 @@ function readingEntry(entry: ContentBlockItem, accent: string, key: number): Rea
/* Reading mode: every day, every entry and its fold-out, as text. A /* Reading mode: every day, every entry and its fold-out, as text. A
day is an h4, under the page's h3 block headings (ContentBlocks). */ day is an h4, under the page's h3 block headings (ContentBlocks). */
function ReadingSchedule({ days, intro, accent }: { days: Day[]; intro?: string | null; accent: string }) { function ReadingSchedule({
days,
tags,
intro,
accent,
}: {
days: Day[]
tags: ScheduleTag[]
intro?: string | null
accent: string
}) {
return ( return (
<div> <div>
{intro && <Paragraphs text={intro} accent={accent} />} {intro && <Paragraphs text={intro} accent={accent} />}
{days.map((day, index) => ( {days.map((day, index) => (
<div key={day.name || index}> <div key={day.name || index}>
{days.length > 1 && <h4>{day.name || 'Schedule'}</h4>} {days.length > 1 && <h4>{day.name || 'Schedule'}</h4>}
<ul>{day.entries.map((entry, i) => readingEntry(entry, accent, i))}</ul> <ul>{day.entries.map((entry, i) => readingEntry(entry, accent, i, tags))}</ul>
</div> </div>
))} ))}
</div> </div>
) )
} }
/* A tab: a day, or a tag's entries from every day (087). */
type Tab = { label: string; days: Day[]; color?: string | null; tag?: boolean }
export default function ScheduleBlock({ export default function ScheduleBlock({
items, items,
tags = [],
intro, intro,
accent, accent,
presentHref, presentHref,
}: { }: {
items: ContentBlockItem[] items: ContentBlockItem[]
tags?: ScheduleTag[]
intro?: string | null intro?: string | null
accent: string accent: string
/** Where the Present button goes; no button without it. */ /** Where the Present button goes; no button without it. */
@ -382,15 +463,24 @@ export default function ScheduleBlock({
const reading = useReadingMode() const reading = useReadingMode()
if (days.length === 0) return null if (days.length === 0) return null
if (reading) return <ReadingSchedule days={days} intro={intro} accent={accent} /> if (reading) return <ReadingSchedule days={days} tags={tags} intro={intro} accent={accent} />
const current = days[Math.min(active, days.length - 1)]
const tabs: Tab[] = [
...days.map((day) => ({ label: day.name || 'Schedule', days: [day] })),
...tags
.filter((tag) => tag.tab)
.map((tag) => ({ label: tag.name, days: daysWithTag(days, tag.key), color: tag.color, tag: true }))
.filter((tab) => tab.days.length),
]
const at = Math.min(active, tabs.length - 1)
const current = tabs[at]
// Arrows move one tab and wrap; Home and End jump to the ends. // Arrows move one tab and wrap; Home and End jump to the ends.
const onKey = (e: KeyboardEvent<HTMLButtonElement>) => { const onKey = (e: KeyboardEvent<HTMLButtonElement>) => {
const last = days.length - 1 const last = tabs.length - 1
const next = const next =
e.key === 'ArrowRight' ? (active + 1) % days.length e.key === 'ArrowRight' ? (at + 1) % tabs.length
: e.key === 'ArrowLeft' ? (active + last) % days.length : e.key === 'ArrowLeft' ? (at + last) % tabs.length
: e.key === 'Home' ? 0 : e.key === 'Home' ? 0
: e.key === 'End' ? last : e.key === 'End' ? last
: null : null
@ -401,67 +491,82 @@ export default function ScheduleBlock({
} }
return ( return (
<div className="space-y-4"> <ScheduleTags.Provider value={tags}>
{intro && ( <div className="space-y-4">
<div className="space-y-3 leading-relaxed" style={{ color: BODY }}> {intro && (
<Paragraphs text={intro} accent={accent} /> <div className="space-y-3 leading-relaxed" style={{ color: BODY }}>
</div> <Paragraphs text={intro} accent={accent} />
)} </div>
)}
{presentHref && ( {presentHref && (
<div className="flex justify-end"> <div className="flex justify-end">
<Link <Link
to={presentHref} to={presentHref}
target="_blank" target="_blank"
className="btn inline-flex items-center gap-2 border px-4 py-2 text-sm transition-colors hover:bg-tint" className="btn inline-flex items-center gap-2 border px-4 py-2 text-sm transition-colors hover:bg-tint"
style={{ borderColor: `${withAlpha(accent, 33)}`, color: accentText(accent) }} style={{ borderColor: `${withAlpha(accent, 33)}`, color: accentText(accent) }}
> >
<Presentation aria-hidden="true" weight="bold" className="h-4 w-4" /> <Presentation aria-hidden="true" weight="bold" className="h-4 w-4" />
Present Present
<span className="sr-only">(opens in a new tab)</span> <span className="sr-only">(opens in a new tab)</span>
</Link> </Link>
</div> </div>
)} )}
{days.length > 1 && ( {tabs.length > 1 && (
<div role="tablist" aria-label="Days" className="flex flex-wrap gap-2"> <div role="tablist" aria-label="Days and tags" className="flex flex-wrap gap-2">
{days.map((day, index) => { {tabs.map((tab, index) => {
const selected = day === current const selected = index === at
return ( const color = tab.color || accent
<button return (
key={day.name || index} <button
id={`${baseId}-tab-${index}`} key={index}
type="button" id={`${baseId}-tab-${index}`}
role="tab" type="button"
aria-selected={selected} role="tab"
aria-controls={`${baseId}-panel`} aria-selected={selected}
tabIndex={selected ? 0 : -1} aria-controls={`${baseId}-panel`}
onClick={() => setActive(index)} tabIndex={selected ? 0 : -1}
onKeyDown={onKey} onClick={() => setActive(index)}
className="btn border px-5 py-2 text-sm transition-colors" onKeyDown={onKey}
style={ className="btn border px-5 py-2 text-sm transition-colors"
selected style={
? { background: accent, borderColor: accent, color: readableOn(accent) } selected
: { borderColor: `${withAlpha(accent, 33)}`, color: accentText(accent) } ? { background: color, borderColor: color, color: readableOn(color) }
} : { borderColor: `${withAlpha(color, 33)}`, color: accentText(color) }
> }
{day.name || 'Schedule'} >
</button> {tab.label}
) </button>
})} )
</div> })}
)} </div>
)}
<ul <div
id={`${baseId}-panel`} id={`${baseId}-panel`}
role={days.length > 1 ? 'tabpanel' : undefined} role={tabs.length > 1 ? 'tabpanel' : undefined}
aria-labelledby={days.length > 1 ? `${baseId}-tab-${days.indexOf(current)}` : undefined} aria-labelledby={tabs.length > 1 ? `${baseId}-tab-${at}` : undefined}
className="border border-brand/15 bg-surface" className="border border-brand/15 bg-surface"
> >
{current.entries.map((entry, index) => ( {current.days.map((day, d) => (
<Entry key={`${current.name}-${index}`} entry={entry} accent={accent} /> <Fragment key={`${at}-${d}`}>
))} {/* A tag's tab names each day it gathers from. */}
</ul> {current.tag && current.days.length > 1 && (
</div> <p className="border-b border-brand/15 bg-tint px-5 py-2 text-sm font-bold text-ink">
{day.name || 'Schedule'}
</p>
)}
<ul>
{day.entries.map((entry, index) => (
<Entry key={`${at}-${d}-${index}`} entry={entry} accent={accent} />
))}
</ul>
</Fragment>
))}
</div>
</div>
</ScheduleTags.Provider>
) )
} }

View file

@ -24,7 +24,18 @@
server doesn't also declare as a column default. If you give a server doesn't also declare as a column default. If you give a
blank row a starting value here, add the matching default: to blank row a starting value here, add the matching default: to
that column in the server's admin-schema.js or the row will be that column in the server's admin-schema.js or the row will be
saved as real input. saved as real input. `blank` can be a function instead, for a
value made fresh for every new row and every copy (a schedule
tag's key); mark that column `seeded` on the server so a row with
only that in it still counts as blank.
`lends: (row) => ({ name: [{ id, label }] })` on a collection gives
the collections nested in each row (at any depth) more options,
made from that row: a schedule block lends its tags to its
entries and their sub-items.
`widget: "checklist"` is a checkbox per option of `optionsFrom`,
saved as the picked ids, comma-separated, in the options' order.
In a repeater row, `when: { path, value }` shows a field only In a repeater row, `when: { path, value }` shows a field only
while another field of the row holds that value (or one of them, while another field of the row holds that value (or one of them,
@ -226,8 +237,49 @@ function withoutIds(value) {
return copy; return copy;
} }
/* A new row, and the fresh values a function `blank` gives every
new row (a copy keeps the rest of what it copies). */
const newRow = (spec) => (typeof spec.blank === "function" ? spec.blank() : { ...spec.blank });
const seeded = (spec) => (typeof spec.blank === "function" ? spec.blank() : {});
const helpText = (field, row) => (typeof field.help === "function" ? field.help(row) : field.help); const helpText = (field, row) => (typeof field.help === "function" ? field.help(row) : field.help);
/* `widget: "checklist"`: the picked ids, comma-separated. An id no
option has any more is dropped at the next change. */
function Checklist({ id, options, value, disabled, empty, onChange }: {
id: string
options: { id: string; label: string }[]
value?: string | null
disabled?: boolean
empty?: string
onChange: (value: string) => void
}) {
const picked = new Set((value ?? "").split(",").filter(Boolean));
if (options.length === 0) return <p id={id} className="text-sm text-muted">{empty ?? "Nothing to pick yet."}</p>;
const toggle = (key: string) => {
const next = new Set(picked);
if (next.has(key)) next.delete(key);
else next.add(key);
onChange(options.filter((o) => next.has(o.id)).map((o) => o.id).join(","));
};
return (
<div id={id} role="group" className="flex flex-wrap gap-x-4 gap-y-1.5">
{options.map((o) => (
<label key={o.id} className="flex items-center gap-2 text-sm text-body">
<input
type="checkbox"
checked={picked.has(o.id)}
disabled={disabled}
onChange={() => toggle(o.id)}
className="h-4 w-4 border-muted/40 text-link focus:ring-brand/40 disabled:opacity-50"
/>
{o.label}
</label>
))}
</div>
);
}
/* ── Field ───────────────────────────────────────────────────── */ /* ── Field ───────────────────────────────────────────────────── */
export function Field({ field, value, row, options, error, onChange, onPatch }: any) { export function Field({ field, value, row, options, error, onChange, onPatch }: any) {
@ -315,6 +367,15 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
/> />
{helpText(field, row) ?? "Yes"} {helpText(field, row) ?? "Yes"}
</label> </label>
) : widget === "checklist" ? (
<Checklist
id={id}
options={options?.[field.optionsFrom] ?? []}
value={value}
disabled={locked}
empty={field.emptyNote}
onChange={onChange}
/>
) : widget === "textarea" ? ( ) : widget === "textarea" ? (
<textarea <textarea
{...common} {...common}
@ -558,7 +619,7 @@ export function Repeater({
const add = () => { const add = () => {
setOpen((prev) => new Set(prev).add(list.length)); setOpen((prev) => new Set(prev).add(list.length));
onChange([...list, { ...spec.blank }]); onChange([...list, newRow(spec)]);
}; };
/* A row placed at `at`, pushing everything from there down one, /* A row placed at `at`, pushing everything from there down one,
@ -714,13 +775,13 @@ export function Repeater({
</IconButton> </IconButton>
<IconButton <IconButton
label="Insert a new one below" label="Insert a new one below"
onClick={() => insertAt(index + 1, { ...spec.blank })} onClick={() => insertAt(index + 1, newRow(spec))}
> >
<Plus size={14} weight="bold" aria-hidden="true" /> <Plus size={14} weight="bold" aria-hidden="true" />
</IconButton> </IconButton>
<IconButton <IconButton
label="Duplicate" label="Duplicate"
onClick={() => insertAt(index + 1, withoutIds(row))} onClick={() => insertAt(index + 1, { ...withoutIds(row), ...seeded(spec) })}
> >
<Copy size={14} weight="bold" aria-hidden="true" /> <Copy size={14} weight="bold" aria-hidden="true" />
</IconButton> </IconButton>
@ -760,7 +821,7 @@ export function Repeater({
<Repeater <Repeater
spec={nested} spec={nested}
rows={row[nested.key]} rows={row[nested.key]}
options={options} options={spec.lends ? { ...options, ...spec.lends(row) } : options}
errors={errors} errors={errors}
errorPrefix={`${errorPrefix}${index}.${nested.key}.`} errorPrefix={`${errorPrefix}${index}.${nested.key}.`}
parentRow={row} parentRow={row}

View file

@ -402,6 +402,17 @@ export const wordFields = (prefix: string, label: string, when?: any) => [
{ path: `${prefix}word_seconds`, label: label ? `${label}seconds per word` : "Seconds per word", widget: "number", help: "1 to 20. Default: the site's", when }, { path: `${prefix}word_seconds`, label: label ? `${label}seconds per word` : "Seconds per word", widget: "number", help: "1 to 20. Default: the site's", when },
]; ];
/* An entry's or sub-item's tags (087): the block's, lent by
blocksChild. */
const TAGS_FIELD = {
path: "tags",
label: "Tags",
widget: "checklist",
optionsFrom: "scheduleTags",
full: true,
emptyNote: "No tags yet: add them under the block's Tags.",
};
/* A block entry's sub-item (086): an entry's fields, under its /* A block entry's sub-item (086): an entry's fields, under its
block's day. */ block's day. */
const SUB_ITEM_FIELDS = [ const SUB_ITEM_FIELDS = [
@ -437,6 +448,7 @@ const SUB_ITEM_FIELDS = [
help: "Optional: your own map, shown in place of the Google map and as a slide when presented", help: "Optional: your own map, shown in place of the Google map and as a slide when presented",
}, },
{ path: "featured", label: "Featured", widget: "checkbox", help: "Makes it stand out" }, { path: "featured", label: "Featured", widget: "checkbox", help: "Makes it stand out" },
TAGS_FIELD,
]; ];
export const blocksChild = { export const blocksChild = {
@ -536,7 +548,27 @@ export const blocksChild = {
}, },
...wordFields("", "", { path: "type", value: ["heading", "subheading", "paragraph", "callout", "quote"] }), ...wordFields("", "", { path: "type", value: ["heading", "subheading", "paragraph", "callout", "quote"] }),
], ],
// A schedule's tags, for its entries' and sub-items' Tags (087).
lends: (row) => ({
scheduleTags: (row.tags ?? [])
.filter((tag) => tag.name?.trim())
.map((tag) => ({ id: tag.tag_key, label: tag.name })),
}),
children: [ children: [
{
key: "tags",
label: "Tags",
addLabel: "Add tag",
note: "Tag entries with these, eg. Youth or Worship. Each tag is a tab of its own gathering the entries it's on, and can be shown alone or as a slide when the schedule is presented.",
when: { path: "type", value: "schedule" },
title: (row) => row.name || "New tag",
blank: () => ({ tag_key: crypto.randomUUID().slice(0, 8) }),
fields: [
{ path: "name", label: "Name", required: true, help: "eg. Youth" },
{ path: "color", label: "Color", widget: "color", help: "Default: the event's color" },
{ path: "no_tab", label: "No tab", widget: "checkbox", help: "Leave it out of the tabs (it still shows on entries)" },
],
},
{ {
key: "items", key: "items",
label: "Items", label: "Items",
@ -653,6 +685,7 @@ export const blocksChild = {
when: SCHEDULE_ENTRY, when: SCHEDULE_ENTRY,
}, },
{ path: "featured", label: "Featured", widget: "checkbox", help: "Makes the row stand out", when: SCHEDULE_ENTRY }, { path: "featured", label: "Featured", widget: "checkbox", help: "Makes the row stand out", when: SCHEDULE_ENTRY },
{ ...TAGS_FIELD, when: SCHEDULE_ENTRY },
], ],
children: [ children: [
{ {

View file

@ -55,8 +55,13 @@ export type ContentBlock = {
/** A video block's WebVTT file, for an uploaded video (066). */ /** A video block's WebVTT file, for an uploaded video (066). */
captions?: string | null captions?: string | null
items?: ContentBlockItem[] items?: ContentBlockItem[]
/** A schedule's own tags (087). */
tags?: ScheduleTag[]
} }
/** A schedule's tag (087). `tab` is whether it gets a tab of its own. */
export type ScheduleTag = { key: string; name: string; color?: string | null; tab: boolean }
/** A list, link-row or schedule entry. The schedule fields are /** A list, link-row or schedule entry. The schedule fields are
* empty on the other two (034_schedule_block.sql). */ * empty on the other two (034_schedule_block.sql). */
export type ContentBlockItem = { export type ContentBlockItem = {
@ -82,6 +87,8 @@ export type ContentBlockItem = {
featured?: boolean featured?: boolean
/** A block entry's sub-items. */ /** A block entry's sub-items. */
items?: ContentBlockItem[] items?: ContentBlockItem[]
/** Its block's tags it has, by key (087). */
tags?: string[]
} }
export type Link = { export type Link = {

View file

@ -18,21 +18,35 @@
the spotlight, graphic and map slides an entry does the spotlight, graphic and map slides an entry does
graphic an entry's graphic, full screen graphic an entry's graphic, full screen
map an entry's own map image (069), 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 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 Keys while playing: arrows step, Space pauses, Escape leaves full
screen (the browser's), S goes back to the setup. screen (the browser's), S goes back to the setup.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
import { ArrowsOut, CaretLeft, CaretRight, Gear, Pause, Play } from '@phosphor-icons/react' 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 { useParams, useSearchParams } from 'react-router-dom'
import PageState from '../components/PageState.tsx' 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 { 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 { mediaUrl } from '../lib/media.ts'
import { BRAND, accentText, readableOn, withAlpha } from '../lib/color.ts' import { BRAND, accentText, readableOn, withAlpha } from '../lib/color.ts'
import { documentTitle } from '../lib/site.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: '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: '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: '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 ] as const
type Kind = (typeof KINDS)[number]['key'] 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). */ /* How long the controls stay up after the pointer last moved (ms). */
const CONTROLS_FOR = 2500 const CONTROLS_FOR = 2500
/* `parent` is a sub-item's block. */ /* `parent` is a sub-item's block; a tag slide has its `tag` and the
type Slide = { kind: Kind; seconds: number; day: Day; entry?: ContentBlockItem; parent?: ContentBlockItem } `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 /* An entry's key in the address: day index, a dot, entry index, and
for a sub-item another dot and its index. */ 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] 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 } return { pickedDays: new Set(pickedDays), hidden, seconds, only: params.get('tag') || null }
} }
type Settings = ReturnType<typeof readSettings> 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 slides: Slide[] = []
const kept: Day[] = []
days.forEach((all, d) => { days.forEach((all, d) => {
if (!pickedDays.has(d)) return 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 (hidden.has(entryKey(d, e))) return []
if (entry.kind !== 'block') return [entry] 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(entryKey(d, e, i))) }]
}) })
if (only) entries = withTag(entries, only)
if (entries.length === 0) return if (entries.length === 0) return
kept.push({ name: all.name, entries })
const day = { ...all, entries } const day = { ...all, entries }
if (seconds.overview) slides.push({ kind: 'overview', seconds: seconds.overview, day }) 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) 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 return slides
} }
@ -120,6 +155,7 @@ export default function SchedulePresent() {
const blockIndex = Number(params.get('block') ?? 0) const blockIndex = Number(params.get('block') ?? 0)
const schedule = event?.blocks?.filter((block) => block.type === 'schedule')[blockIndex] const schedule = event?.blocks?.filter((block) => block.type === 'schedule')[blockIndex]
const days = useMemo(() => groupByDay(schedule?.items ?? []), [schedule]) const days = useMemo(() => groupByDay(schedule?.items ?? []), [schedule])
const tags = schedule?.tags ?? []
useEffect(() => { useEffect(() => {
if (event) document.title = documentTitle(`${event.title}: schedule`) if (event) document.title = documentTitle(`${event.title}: schedule`)
@ -156,16 +192,18 @@ export default function SchedulePresent() {
const settings = readSettings(params, days) const settings = readSettings(params, days)
if (params.get('play') === '1') { if (params.get('play') === '1') {
return ( return (
<Player <ScheduleTags.Provider value={tags}>
title={event.title} <Player
accent={accent} title={event.title}
slides={buildSlides(days, settings)} accent={accent}
onSetup={() => { slides={buildSlides(days, tags, settings)}
const next = new URLSearchParams(params) onSetup={() => {
next.delete('play') const next = new URLSearchParams(params)
setParams(next) next.delete('play')
}} setParams(next)
/> }}
/>
</ScheduleTags.Provider>
) )
} }
return ( return (
@ -174,6 +212,7 @@ export default function SchedulePresent() {
back={back} back={back}
accent={accent} accent={accent}
days={days} days={days}
tags={tags}
settings={settings} settings={settings}
onPlay={(next) => { onPlay={(next) => {
// Full screen needs the click itself, so it's asked for here. // 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.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]))
if (next.only) out.set('tag', next.only)
out.set('play', '1') out.set('play', '1')
setParams(out) setParams(out)
}} }}
@ -196,6 +236,7 @@ function Setup({
back, back,
accent, accent,
days, days,
tags,
settings, settings,
onPlay, onPlay,
}: { }: {
@ -203,13 +244,15 @@ function Setup({
back: string back: string
accent: string accent: string
days: Day[] days: Day[]
tags: ScheduleTag[]
settings: Settings settings: Settings
onPlay: (settings: Settings) => void onPlay: (settings: Settings) => void
}) { }) {
const [pickedDays, setPickedDays] = useState(settings.pickedDays) const [pickedDays, setPickedDays] = useState(settings.pickedDays)
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 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 toggle = <T,>(set: Set<T>, value: T) => {
const next = new Set(set) 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> <p className="mt-2 text-sm text-muted">0 leaves that kind of slide out.</p>
</section> </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> <section>
<h2 className="mb-4 text-2xl font-bold text-ink">Days and entries</h2> <h2 className="mb-4 text-2xl font-bold text-ink">Days and entries</h2>
<div className="space-y-6"> <div className="space-y-6">
@ -305,7 +372,7 @@ function Setup({
<button <button
type="button" type="button"
disabled={count === 0} 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" 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) }}
> >
@ -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 /* 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 block's sub-items under it. A heading is a label; a break is
quieter. */ quieter. */
function OverviewLine({ entry, accent, sub = false }: { entry: ContentBlockItem; accent: string; sub?: boolean }) { function OverviewLine({ entry, accent, sub = false }: { entry: ContentBlockItem; accent: string; sub?: boolean }) {
const tags = useContext(ScheduleTags)
const color = accentText(accent) const color = accentText(accent)
if (entry.kind === 'heading') { if (entry.kind === 'heading') {
return ( return (
@ -553,10 +646,11 @@ function OverviewLine({ entry, accent, sub = false }: { entry: ContentBlockItem;
)} )}
{entry.text} {entry.text}
</span> </span>
{(entry.location || entry.person) && ( {(entry.location || entry.person || entry.tags?.length) && (
<span className="mt-1 flex flex-wrap items-center gap-x-[1.5vw] text-[clamp(0.9rem,1.4vw,1.8rem)] text-muted"> <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.location && <span>{entry.location}</span>}
{entry.person && <span>{entry.person.name}</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>
)} )}
</span> </span>
@ -565,6 +659,7 @@ function OverviewLine({ entry, accent, sub = false }: { entry: ContentBlockItem;
} }
function SlideView({ slide, accent }: { slide: Slide; accent: string }) { function SlideView({ slide, accent }: { slide: Slide; accent: string }) {
const tags = useContext(ScheduleTags)
const color = accentText(accent) const color = accentText(accent)
if (slide.kind === 'overview') { if (slide.kind === 'overview') {
@ -578,22 +673,42 @@ function SlideView({ slide, accent }: { slide: Slide; accent: string }) {
</h1> </h1>
</Rise> </Rise>
<ul className={`grid min-h-0 flex-1 content-start gap-x-[4vw] ${two ? 'grid-cols-2' : 'grid-cols-1'}`}> <ul className={`grid min-h-0 flex-1 content-start gap-x-[4vw] ${two ? 'grid-cols-2' : 'grid-cols-1'}`}>
{entries.map((entry, i) => ( <OverviewEntries entries={entries} accent={accent} />
<li key={i} className="even:bg-tint-soft/60" style={entry.featured ? featuredStyle(accent) : undefined}> </ul>
<Rise order={i + 1} from="left"> </div>
<OverviewLine entry={entry} accent={accent} /> )
{entry.kind === 'block' && entry.items?.length ? ( }
<ul className="ml-[14vw] pb-[1vh]">
{entry.items.map((item, j) => ( if (slide.kind === 'tag') {
<li key={j} style={item.featured ? featuredStyle(accent) : undefined}> const tag = slide.tag!
<OverviewLine entry={item} accent={accent} sub /> const tagDays = slide.days ?? []
</li> const tagColor = tag.color || accent
))} const two = tagDays.reduce((n, day) => n + 1 + lineCount(day.entries), 0) > ONE_COLUMN
</ul> let order = 1
) : null} return (
</Rise> <div className="flex h-full flex-col">
</li> <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> </ul>
</div> </div>
) )
@ -714,6 +829,13 @@ function SlideView({ slide, accent }: { slide: Slide; accent: string }) {
{entry.text} {entry.text}
</h1> </h1>
</Rise> </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 && ( {entry.location && (
<Rise order={2} from="right"> <Rise order={2} from="right">
<p className="mt-[2vh] text-[clamp(1.2rem,2.4vw,3rem)] text-body">{entry.location}</p> <p className="mt-[2vh] text-[clamp(1.2rem,2.4vw,3rem)] text-body">{entry.location}</p>