Events block: a card opens the event in full, its own blocks too

An events block's events bring their own page's blocks (one level
deep, so events listing each other stop there), photo and place. A
card opens the event under the cards: photo, type and date, title,
place, person host, its blocks (else its card text) and a link to its
page. Reading mode shows them all in full, and the presentation's
event spotlight shows its blocks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-11-09 04:31:34 -06:00
parent df8052c75e
commit 375c364861
4 changed files with 174 additions and 33 deletions

View file

@ -64,7 +64,7 @@ export function loadLinks(db, ownerKind, ids) {
rather than no key, so the renderer never has to check.
───────────────────────────────────────────────────────────── */
export function loadBlocks(db, ownerKind, ids, slot = "body") {
export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) {
const out = new Map();
if (ids.length === 0) return out;
@ -175,7 +175,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
}
attachVenues(db, [...byId.values()]);
attachEvents(db, [...byId.values()]);
attachEvents(db, [...byId.values()], depth);
return out;
}
@ -220,8 +220,13 @@ function attachVenues(db, blocks) {
schedule entry or sub-item that is a workshop, which takes what
it leaves blank from its event: the link, the description (its
card text), the graphic (its photo) and the person (a person
host). An unpublished event is no event. */
function attachEvents(db, blocks) {
host). An unpublished event is no event.
An events block's event also brings its own page's blocks
(`blocks`), drawn when its card is opened. Only at the top
(`depth` 0): a workshop's blocks don't bring theirs, so two
events listing each other can't go round forever. */
function attachEvents(db, blocks, depth = 0) {
const entries = [];
const walk = (entry) => {
entries.push(entry);
@ -234,7 +239,8 @@ function attachEvents(db, blocks) {
const rows = db
.prepare(
`SELECT e.id, e.title, e.tagline, e.event_type, e.starts_on, e.ends_on, e.date_label,
e.effective_color AS color, COALESCE(e.card_image, e.photo) AS image, e.photo_alt,
e.effective_color AS color, COALESCE(e.card_image, e.photo) AS image, e.photo, e.photo_alt,
e.location_label,
p.id AS person_id, p.display_name AS person_name, p.photo AS person_photo,
p.tagline AS person_tagline
FROM v_events e
@ -244,6 +250,9 @@ function attachEvents(db, blocks) {
.all(...ids);
const cards = loadBlocks(db, "event", rows.map((row) => row.id), "card");
const events = new Map(rows.map((row) => [row.id, row]));
const shown = blocks.filter((block) => block.type === "events").flatMap((block) => block.items);
const shownIds = [...new Set(shown.map((item) => item.event_id).filter((id) => events.has(id)))];
const bodies = depth === 0 && shownIds.length ? loadBlocks(db, "event", shownIds, "body", depth + 1) : new Map();
for (const entry of entries) {
const row = events.get(entry.event_id);
@ -261,8 +270,12 @@ function attachEvents(db, blocks) {
date_label: row.date_label,
color: row.color,
image: row.image,
photo: row.photo,
photo_alt: row.photo_alt,
location_label: row.location_label,
blurb,
};
if (shown.includes(entry)) entry.event.blocks = bodies.get(row.id) ?? [];
entry.url ||= `/events/${row.id}`;
entry.description ||= blurb;
if (!entry.media && row.image) {

View file

@ -35,7 +35,9 @@
link to it
events items as event cards: event (from
event_id), text the title shown, detail
in place of the event's card text
in place of the event's card text; a card
opens the event in full under them, its
own page's blocks too (EventsBlock)
divider nothing
"Formatted" is InlineText.tsx: **bold**, *italic*, [text](url),
@ -50,14 +52,18 @@
visible even if the renderer hasn't caught up with it.
═══════════════════════════════════════════════════════════════ */
import { CaretDown } from '@phosphor-icons/react'
import { useEffect, useId, useRef, useState } from 'react'
import { Link } from 'react-router-dom'
import { mediaUrl } from '../lib/media.ts'
import PeopleTiles from './PeopleTiles.tsx'
import type { ContentBlock, ContentBlockItem, ItemEvent } from '../lib/useContent.ts'
import { Anchor, Inline, Paragraphs, isExternalUrl } from './InlineText.tsx'
import VideoPlayer from './VideoPlayer.tsx'
import ScheduleBlock from './ScheduleBlock.tsx'
import ScheduleBlock, { Avatar } from './ScheduleBlock.tsx'
import MapBlock, { PageMaps } from './MapBlock.tsx'
import { eventHref } from '../lib/hrefs.ts'
import { eventHref, personHref } from '../lib/hrefs.ts'
import { occurrenceLabel } from '../lib/eventSeries.ts'
import { accentText, BRAND } from '../lib/color.ts'
import { headingAnchors } from '../lib/contents.ts'
@ -160,15 +166,34 @@ export function eventLine(event: ItemEvent): string | null {
return [kind, when].filter(Boolean).join(' · ') || null
}
function EventCard({ item, accent }: { item: ContentBlockItem; accent: string }) {
function EventCard({
item,
accent,
open,
panelId,
onToggle,
}: {
item: ContentBlockItem
accent: string
open: boolean
panelId: string
onToggle: () => void
}) {
const event = item.event!
const img = useSmallImage(mediaUrl(event.image))
const color = event.color || accent
const line = eventLine(event)
return (
<Anchor
href={eventHref(event.id)}
className="group flex h-full flex-col overflow-hidden border border-brand/15 bg-raised shadow-sm transition-shadow hover:shadow-lg"
<button
type="button"
onClick={onToggle}
aria-expanded={open}
aria-controls={panelId}
className="group flex h-full w-full flex-col overflow-hidden border bg-raised text-left shadow-sm transition-shadow hover:shadow-lg"
style={{
borderColor: open ? accent : 'color-mix(in srgb, var(--color-brand) 15%, transparent)',
boxShadow: open ? `inset 0 -4px 0 ${accent}` : undefined,
}}
>
{!img.failed && (
<img src={img.src} alt="" loading="lazy" onError={img.onError} className="aspect-video w-full object-cover" />
@ -185,8 +210,101 @@ function EventCard({ item, accent }: { item: ContentBlockItem; accent: string })
{(item.detail || event.blurb) && (
<span className="line-clamp-3 text-sm leading-snug text-body">{item.detail || event.blurb}</span>
)}
<span className="mt-auto inline-flex items-center gap-1 pt-2 text-sm font-semibold" style={{ color: accentText(color) }}>
{open ? 'Close' : 'More'}
<CaretDown aria-hidden="true" weight="bold" className={`h-4 w-4 transition-transform ${open ? 'rotate-180' : ''}`} />
</span>
</span>
</button>
)
}
/* An event in full (088): its photo, type and date, title, place and
person host, then its own page's blocks (else its card text), and
a link to its page. */
function EventInFull({ item, accent, level }: { item: ContentBlockItem; accent: string; level: 3 | 4 | 5 }) {
const event = item.event!
const color = event.color || accent
const photo = mediaUrl(event.photo || event.image)
const line = eventLine(event)
const Title = `h${level}` as 'h3'
const blurb = item.detail || event.blurb
return (
<section aria-label={item.text || event.title} className="space-y-6 bg-raised p-6 shadow-md">
{photo && <img src={photo} alt={event.photo_alt ?? ''} loading="lazy" className="aspect-video w-full object-cover" />}
<div>
{line && (
<p className="text-sm font-semibold capitalize" style={{ color: accentText(color) }}>
{line}
</p>
)}
<Title className="text-2xl font-bold text-ink">{item.text || event.title}</Title>
{(event.location_label || item.person) && (
<p className="mt-2 flex flex-wrap items-center gap-x-4 gap-y-2 text-sm text-muted">
{event.location_label && <span>{event.location_label}</span>}
{item.person && (
<Link to={personHref(item.person.id)} className="inline-flex items-center gap-2 hover:underline">
<Avatar person={item.person} size="h-8 w-8" />
{item.person.name}
</Link>
)}
</p>
)}
</div>
{event.blocks?.length ? (
<ContentBlocks blocks={event.blocks} accent={color} anchorPrefix={`${event.id}-`} />
) : blurb ? (
<div className="space-y-3 leading-relaxed" style={{ color: BODY }}>
<Paragraphs text={blurb} accent={color} />
</div>
) : null}
<Anchor href={eventHref(event.id)} className="inline-block text-sm font-semibold underline" style={{ color: accentText(color) }}>
{event.title}: the event's page
</Anchor>
</section>
)
}
/* An events block (088): its events as cards; one opened shows in
full under them, scrolled into view. Reading mode has them all in
full. */
function EventsBlock({ items, accent, level }: { items: ContentBlockItem[]; accent: string; level: 3 | 4 | 5 }) {
const [open, setOpen] = useState<number | null>(null)
const panelId = useId()
const panel = useRef<HTMLDivElement>(null)
const reading = useReadingMode()
useEffect(() => {
if (open != null) panel.current?.scrollIntoView({ behavior: 'smooth', block: 'nearest' })
}, [open])
if (reading) {
return (
<div className="space-y-6">
{items.map((item, i) => (
<EventInFull key={i} item={item} accent={accent} level={level} />
))}
</div>
)
}
return (
<div className="space-y-6">
<ul className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
{items.map((item, i) => (
<li key={i}>
<EventCard
item={item}
accent={accent}
open={open === i}
panelId={panelId}
onToggle={() => setOpen(open === i ? null : i)}
/>
</li>
))}
</ul>
<div ref={panel} id={panelId}>
{open != null && items[open] && <EventInFull item={items[open]} accent={accent} level={level} />}
</div>
</div>
)
}
@ -445,15 +563,7 @@ function Block({
case 'events': {
const events = (block.items ?? []).filter((item) => item.event)
if (events.length === 0) return null
return (
<ul className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
{events.map((item, i) => (
<li key={i}>
<EventCard item={item} accent={accent} />
</li>
))}
</ul>
)
return <EventsBlock items={events} accent={accent} level={level} />
}
case 'people': {

View file

@ -95,7 +95,13 @@ export type ItemEvent = {
date_label?: string | null
color?: string | null
image?: string | null
/** Its own 16:9 photo, and where it is, for showing it in full. */
photo?: string | null
photo_alt?: string | null
location_label?: string | null
blurb?: string | null
/** Its own page's blocks: an events block's events only. */
blocks?: ContentBlock[]
}
/** A schedule's tag (087). `tab` is whether it gets a tab of its own. */

View file

@ -14,8 +14,8 @@
venue each map block (088): the map with its locations
place then the map once per marked location, it lit up
cards each events block (088): its events on one slide
event then each event alone: picture, title, card text
and its person host
event then each event alone: picture, title, its person
host and its own page's blocks (else its card text)
A schedule's slides, for each day picked, in order:
overview the day's picked entries on one slide
@ -1040,6 +1040,10 @@ function SlideView({ slide, accent }: { slide: Slide; accent: string }) {
const event = entry.event!
const image = mediaUrl(event.image)
const blurb = entry.detail || event.blurb
// Its own page's blocks, when it has some, in place of its card
// text, zoomed for the column they're in.
const blocks = event.blocks?.length ? event.blocks : null
const zoom = Math.max(1, (window.innerWidth * 0.75) / TEXT_WIDTH)
return (
<div className="flex h-full items-center gap-[5vw]">
{image && (
@ -1047,7 +1051,7 @@ function SlideView({ slide, accent }: { slide: Slide; accent: string }) {
<img src={image} alt="" className="aspect-video w-full object-cover shadow-lg" />
</Rise>
)}
<Scroll center className="min-w-0 self-stretch">
<Scroll center={!blocks} className="min-w-0 self-stretch">
{eventLine(event) && (
<Rise from="right">
<p className="text-[clamp(1.2rem,2.4vw,3rem)] font-semibold capitalize" style={{ color }}>
@ -1060,15 +1064,8 @@ function SlideView({ slide, accent }: { slide: Slide; accent: string }) {
{entry.text || event.title}
</h1>
</Rise>
{blurb && (
<Rise order={2} from="right">
<div className="mt-[3vh] space-y-3 text-[clamp(1rem,1.8vw,2.2rem)] leading-snug text-muted">
<Paragraphs text={blurb} accent={accent} />
</div>
</Rise>
)}
{entry.person && (
<Rise order={3} from="right" className="mt-[3vh] flex items-center gap-[1.5vw]">
<Rise order={2} from="right" className="mt-[3vh] flex items-center gap-[1.5vw]">
<Avatar person={entry.person} size="h-[6vw] w-[6vw] text-[1.6vw]" />
<span>
<span className="block text-[clamp(1.1rem,2vw,2.6rem)] font-bold text-ink">{entry.person.name}</span>
@ -1078,6 +1075,21 @@ function SlideView({ slide, accent }: { slide: Slide; accent: string }) {
</span>
</Rise>
)}
{blocks ? (
<Rise order={3} from="right" className="mt-[3vh]">
<div style={{ zoom }}>
<ContentBlocks blocks={blocks} accent={event.color || accent} anchorPrefix={`${event.id}-`} />
</div>
</Rise>
) : (
blurb && (
<Rise order={3} from="right">
<div className="mt-[3vh] space-y-3 text-[clamp(1rem,1.8vw,2.2rem)] leading-snug text-muted">
<Paragraphs text={blurb} accent={accent} />
</div>
</Rise>
)
)}
</Scroll>
</div>
)