/* ═══════════════════════════════════════════════════════════════ 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. Tabs follow the ARIA tab pattern: arrow keys move between them. ═══════════════════════════════════════════════════════════════ */ import { CaretDown } from '@phosphor-icons/react' import { useId, useState, type KeyboardEvent } 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' const BODY = 'var(--color-muted)' const WEEKDAYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'] type Day = { name: string; entries: ContentBlockItem[] } 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 } 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)}` 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 more = Boolean(entry.description || graphic || place || 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 && (
    {showMap ? (