/* ═══════════════════════════════════════════════════════════════ 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. An entry's kind (086): a normal entry; a block, its sub-items listed under it, each a row of its own with its own fold-out; a break (a meal, free time), a quieter row with no fold-out; or a heading across the day. A featured entry stands out in the accent, with a star. Rows alternate a faint tint, for reading across. The time shown is `time`, which the API has already made from the picked times or the typed override. 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, Star } 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 ? ( ) : ( ) } /* A featured entry's star, read as a word by a screen reader. */ export function FeaturedStar({ className = 'h-4 w-4' }: { className?: string }) { return ( <>