Schedule presentation and map images for schedule entries (migration 069)
A schedule block on an event page has a Present button, opening /events/<id>/present in a new tab: a setup screen (days, entries, seconds for each kind of slide) and then an endless full screen slideshow of day overviews, entry spotlights with their person, graphics and map images, its settings kept in the address so a signage screen can bookmark it. Schedule entries take a Map image (069), shown in the fold-out in place of the Google map and as a slide in the presentation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
96b96c3e6c
commit
07c15ce96d
13 changed files with 710 additions and 22 deletions
|
|
@ -15,7 +15,11 @@
|
|||
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.
|
||||
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.
|
||||
|
||||
|
|
@ -24,7 +28,7 @@
|
|||
it, no map frame (ReadingSchedule).
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { CaretDown } from '@phosphor-icons/react'
|
||||
import { CaretDown, Presentation } from '@phosphor-icons/react'
|
||||
import { Fragment, useId, useState, type KeyboardEvent, type ReactNode } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
|
||||
|
|
@ -40,9 +44,9 @@ import { useReadingMode } from '../lib/readingMode.ts'
|
|||
const BODY = 'var(--color-muted)'
|
||||
const WEEKDAYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
|
||||
|
||||
type Day = { name: string; entries: ContentBlockItem[] }
|
||||
export type Day = { name: string; entries: ContentBlockItem[] }
|
||||
|
||||
function groupByDay(items: ContentBlockItem[]): Day[] {
|
||||
export function groupByDay(items: ContentBlockItem[]): Day[] {
|
||||
const days: Day[] = []
|
||||
for (const item of items) {
|
||||
const name = item.day?.trim() ?? ''
|
||||
|
|
@ -67,12 +71,15 @@ function todayIndex(days: Day[]): number {
|
|||
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)}`
|
||||
|
||||
function Avatar({ person, size }: { person: NonNullable<ContentBlockItem['person']>; size: string }) {
|
||||
export function Avatar({ person, size }: { person: NonNullable<ContentBlockItem['person']>; size: string }) {
|
||||
const img = useSmallImage(mediaUrl(person.photo))
|
||||
return !img.failed ? (
|
||||
<img src={img.src} alt="" onError={img.onError} className={`${size} shrink-0 object-cover`} />
|
||||
|
|
@ -93,7 +100,8 @@ function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
|
|||
const panelId = useId()
|
||||
const graphic = mediaUrl(entry.media)
|
||||
const place = entry.map?.trim()
|
||||
const more = Boolean(entry.description || graphic || place || entry.person)
|
||||
const mapImage = mediaUrl(entry.map_image)
|
||||
const more = Boolean(entry.description || graphic || place || mapImage || entry.person)
|
||||
|
||||
const title = entry.url ? (
|
||||
<Anchor href={entry.url} className="underline-offset-2 hover:underline" style={{ color: accentText(accent) }}>
|
||||
|
|
@ -181,9 +189,11 @@ function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
|
|||
|
||||
{graphic && <img src={graphic} alt={entry.media_alt ?? ""} loading="lazy" className="w-full" />}
|
||||
|
||||
{place && (
|
||||
{(place || mapImage) && (
|
||||
<div>
|
||||
{showMap ? (
|
||||
{mapImage ? (
|
||||
<img src={mapImage} alt={mapAlt(entry)} loading="lazy" className="w-full" />
|
||||
) : showMap && place ? (
|
||||
<iframe
|
||||
ref={focusOnMount}
|
||||
src={mapEmbed(place)}
|
||||
|
|
@ -203,15 +213,17 @@ function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
|
|||
<span className="text-xs">{place}, from Google Maps</span>
|
||||
</button>
|
||||
)}
|
||||
<a
|
||||
href={mapLink(place)}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="mt-2 inline-block text-sm underline"
|
||||
style={{ color: accentText(accent) }}
|
||||
>
|
||||
Open in Google Maps
|
||||
</a>
|
||||
{place && (
|
||||
<a
|
||||
href={mapLink(place)}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="mt-2 inline-block text-sm underline"
|
||||
style={{ color: accentText(accent) }}
|
||||
>
|
||||
Open in Google Maps
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
|
@ -233,6 +245,7 @@ function ReadingSchedule({ days, intro, accent }: { days: Day[]; intro?: string
|
|||
{day.entries.map((entry, i) => {
|
||||
const graphic = mediaUrl(entry.media)
|
||||
const place = entry.map?.trim()
|
||||
const mapImage = mediaUrl(entry.map_image)
|
||||
const parts: ReactNode[] = [
|
||||
entry.time,
|
||||
entry.url ? <Anchor href={entry.url}>{entry.text}</Anchor> : entry.text,
|
||||
|
|
@ -253,6 +266,7 @@ function ReadingSchedule({ days, intro, accent }: { days: Day[]; intro?: string
|
|||
{entry.person?.tagline && <p>{entry.person.tagline}</p>}
|
||||
{entry.description && <Paragraphs text={entry.description} accent={accent} />}
|
||||
{graphic && <img src={graphic} alt={entry.media_alt ?? ''} />}
|
||||
{mapImage && <img src={mapImage} alt={mapAlt(entry)} />}
|
||||
{place && (
|
||||
<p>
|
||||
<a href={mapLink(place)}>Open {place} in Google Maps</a>
|
||||
|
|
@ -272,10 +286,13 @@ export default function ScheduleBlock({
|
|||
items,
|
||||
intro,
|
||||
accent,
|
||||
presentHref,
|
||||
}: {
|
||||
items: ContentBlockItem[]
|
||||
intro?: string | null
|
||||
accent: string
|
||||
/** Where the Present button goes; no button without it. */
|
||||
presentHref?: string
|
||||
}) {
|
||||
const days = groupByDay(items)
|
||||
const [active, setActive] = useState(() => todayIndex(days))
|
||||
|
|
@ -309,6 +326,21 @@ export default function ScheduleBlock({
|
|||
</div>
|
||||
)}
|
||||
|
||||
{presentHref && (
|
||||
<div className="flex justify-end">
|
||||
<Link
|
||||
to={presentHref}
|
||||
target="_blank"
|
||||
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) }}
|
||||
>
|
||||
<Presentation aria-hidden="true" weight="bold" className="h-4 w-4" />
|
||||
Present
|
||||
<span className="sr-only">(opens in a new tab)</span>
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{days.length > 1 && (
|
||||
<div role="tablist" aria-label="Days" className="flex flex-wrap gap-2">
|
||||
{days.map((day, index) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue