/* ═══════════════════════════════════════════════════════════════ SCHEDULE BLOCK The 'schedule' content block (034_schedule_block.sql): entries in one tab per day, each a row of time, title, place and person, folding out for the rest. Tabs are the entries' `day` values in the order they first appear, so the admin's order is the page's. An entry with no day joins an untitled group; a schedule of one day draws no tabs. The tab whose name starts with today's weekday opens first ("Friday", "Fri", "Friday, June 6"), so on the day of an event the visitor lands on today; otherwise the first tab. A row folds out when it has anything more to show: a description, a graphic, a map, or a person (their photo, tagline and a link to their page). The map is Google's key-free embed of the place typed in, with a link out to the full map; an entry's own map image (069) shows instead, the link out kept. On an event page a Present button opens the schedule as a slideshow for a screen (SchedulePresent.tsx). Tabs follow the ARIA tab pattern: arrow keys move between them. Reading mode (readingMode.ts) gets every day as a heading, each entry a line (time, title, place, person) with its fold-out after it, no map frame (ReadingSchedule). ═══════════════════════════════════════════════════════════════ */ import { CaretDown, Presentation } from '@phosphor-icons/react' import { Fragment, useId, useState, type KeyboardEvent, type ReactNode } from 'react' import { Link } from 'react-router-dom' import { personHref } from '../lib/hrefs.ts' import { mediaUrl, initials } from '../lib/media.ts' import type { ContentBlockItem } from '../lib/useContent.ts' import { Anchor, Paragraphs } from './InlineText.tsx' import { withAlpha, accentText, readableOn } from '../lib/color.ts' import { useSmallImage } from '../lib/useSmallImage.ts' import { focusOnMount } from '../lib/focus.ts' import { useReadingMode } from '../lib/readingMode.ts' const BODY = 'var(--color-muted)' const WEEKDAYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'] export type Day = { name: string; entries: ContentBlockItem[] } export function groupByDay(items: ContentBlockItem[]): Day[] { const days: Day[] = [] for (const item of items) { const name = item.day?.trim() ?? '' let day = days.find((d) => d.name === name) if (!day) { day = { name, entries: [] } days.push(day) } day.entries.push(item) } return days } /* The tab to open with: today's weekday if a tab starts with it (or its three-letter form), else the first. */ function todayIndex(days: Day[]): number { const today = WEEKDAYS[new Date().getDay()] const found = days.findIndex((day) => { const name = day.name.toLowerCase() return name.startsWith(today) || name.startsWith(today.slice(0, 3)) }) return found >= 0 ? found : 0 } /* An entry's own map image says what it maps. */ export const mapAlt = (entry: ContentBlockItem) => `Map: ${entry.map?.trim() || entry.location || entry.text}` const mapEmbed = (place: string) => `https://maps.google.com/maps?q=${encodeURIComponent(place)}&output=embed&maptype=satellite` const mapLink = (place: string) => `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(place)}` export function Avatar({ person, size }: { person: NonNullable; size: string }) { const img = useSmallImage(mediaUrl(person.photo)) return !img.failed ? ( ) : ( ) } function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) { const [open, setOpen] = useState(false) // Google's map loads only when asked for (Privacy page). const [showMap, setShowMap] = useState(false) const panelId = useId() const graphic = mediaUrl(entry.media) const place = entry.map?.trim() const mapImage = mediaUrl(entry.map_image) const more = Boolean(entry.description || graphic || place || mapImage || entry.person) const title = entry.url ? ( {entry.text} ) : ( entry.text ) return (
  • {/* On a phone the time sits on its own line above the entry, leaving the title the full width. */}

    {entry.time}

    {title}

    {(entry.location || entry.person) && (

    {entry.location && {entry.location}} {entry.person && ( {entry.person.name} )}

    )} {entry.detail && (

    {entry.detail}

    )}
    {more && ( )}
    {more && open && (
    {entry.person && (
    {entry.person.name} {entry.person.tagline && (

    {entry.person.tagline}

    )}
    )} {entry.description && (
    )} {graphic && {entry.media_alt} {(place || mapImage) && (
    {mapImage ? ( {mapAlt(entry)} ) : showMap && place ? (