Present: the whole event page, in sections at its headings
The presentation (now EventPresent) cuts the event's page into sections at its Heading blocks: a section's text on one slide, then its schedules' slides, a map block's map and each location lit up, and an events block's grid and each event. One Present button on the event page replaces the schedule's. Setup lists the sections, each schedule's days and entries under its own; the address keys are now skip and hide, numbered by schedule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
818d648e91
commit
df8052c75e
9 changed files with 635 additions and 260 deletions
|
|
@ -13,6 +13,9 @@
|
|||
the mark's own, so Layout's jump to the anchor scrolls it into
|
||||
view and focuses it.
|
||||
|
||||
MapPicture is the picture and its marks alone; the event's
|
||||
presentation (EventPresent.tsx) draws it too, with no links.
|
||||
|
||||
Reading mode (readingMode.ts) gets the list alone, no picture.
|
||||
|
||||
PageMaps holds the venues that have a map block among the blocks
|
||||
|
|
@ -20,8 +23,8 @@
|
|||
when there's a map on the page to go to.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { createContext, useState } from 'react'
|
||||
import { Link, useLocation } from 'react-router-dom'
|
||||
import { createContext, useState, type CSSProperties } from 'react'
|
||||
import { Link, useLocation, type To } from 'react-router-dom'
|
||||
|
||||
import { mediaUrl } from '../lib/media.ts'
|
||||
import type { Venue, VenueLocation } from '../lib/useContent.ts'
|
||||
|
|
@ -33,15 +36,138 @@ export const PageMaps = createContext<Set<string>>(new Set())
|
|||
export const mapAnchor = (venueId: string, key: string) => `map-${venueId}-${key}`
|
||||
|
||||
const isBox = (location: VenueLocation) => location.w != null && location.h != null
|
||||
export const isMarked = (location: VenueLocation) => location.x != null && location.y != null
|
||||
|
||||
/* A location's number on the map and in the list: its place in the
|
||||
venue's order. */
|
||||
export const locationNumber = (venue: Venue, location: VenueLocation) => venue.locations.indexOf(location) + 1
|
||||
|
||||
/* A location's numbered dot, in the accent. */
|
||||
export function LocationNumber({
|
||||
n,
|
||||
accent,
|
||||
className = 'h-6 w-6 text-xs',
|
||||
style,
|
||||
}: {
|
||||
n: number
|
||||
accent: string
|
||||
className?: string
|
||||
style?: CSSProperties
|
||||
}) {
|
||||
return (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={`flex shrink-0 items-center justify-center rounded-full font-bold ${className}`}
|
||||
style={{ background: accent, color: readableOn(accent.startsWith('#') ? accent : '#000000'), ...style }}
|
||||
>
|
||||
{n}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
/* The venue's picture with its marks, `active` lit up. With `link`
|
||||
each mark is a link (and `light` its hover and focus); without,
|
||||
the marks are only drawn. `className` sizes the picture's box. */
|
||||
export function MapPicture({
|
||||
venue,
|
||||
accent,
|
||||
active,
|
||||
link,
|
||||
light,
|
||||
className = '',
|
||||
big = false,
|
||||
}: {
|
||||
venue: Venue
|
||||
accent: string
|
||||
active: string | null
|
||||
link?: (key: string) => To
|
||||
light?: (key: string) => object
|
||||
className?: string
|
||||
/** Bigger marks, for a screen across a room. */
|
||||
big?: boolean
|
||||
}) {
|
||||
const image = mediaUrl(venue.map_image)
|
||||
if (!image) return null
|
||||
return (
|
||||
<div className={`relative ${className}`}>
|
||||
<img src={image} alt={venue.map_alt || `Map of ${venue.name}`} className="block w-full" />
|
||||
{venue.locations.filter(isMarked).map((location) => {
|
||||
const on = active === location.key
|
||||
const dim = active != null && !on
|
||||
const style: CSSProperties = isBox(location)
|
||||
? {
|
||||
left: `${location.x}%`,
|
||||
top: `${location.y}%`,
|
||||
width: `${location.w}%`,
|
||||
height: `${location.h}%`,
|
||||
border: `${big ? 4 : 2}px solid ${accent}`,
|
||||
background: withAlpha(accent, on ? 35 : 12),
|
||||
opacity: dim ? 0.35 : 1,
|
||||
}
|
||||
: {
|
||||
left: `${location.x}%`,
|
||||
top: `${location.y}%`,
|
||||
transform: 'translate(-50%, -50%)',
|
||||
opacity: dim ? 0.35 : 1,
|
||||
zIndex: on ? 1 : undefined,
|
||||
}
|
||||
const dot = big
|
||||
? isBox(location)
|
||||
? 'absolute top-[0.5vw] left-[0.5vw] h-[2.6vw] w-[2.6vw] text-[1.3vw]'
|
||||
: on
|
||||
? 'h-[4vw] w-[4vw] text-[2vw]'
|
||||
: 'h-[2.8vw] w-[2.8vw] text-[1.4vw]'
|
||||
: isBox(location)
|
||||
? 'absolute top-1 left-1 h-6 w-6 text-xs'
|
||||
: on
|
||||
? 'h-9 w-9 text-xs'
|
||||
: 'h-7 w-7 text-xs'
|
||||
const inside = (
|
||||
<>
|
||||
<LocationNumber
|
||||
n={locationNumber(venue, location)}
|
||||
accent={accent}
|
||||
className={`shadow ${dot}`}
|
||||
style={on ? { outline: `${big ? 4 : 3}px solid white` } : undefined}
|
||||
/>
|
||||
{on && !big && (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className="absolute top-full left-1/2 mt-1 -translate-x-1/2 whitespace-nowrap bg-raised px-2 py-0.5 text-xs font-semibold text-ink shadow"
|
||||
>
|
||||
{location.name}
|
||||
</span>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
return link ? (
|
||||
<Link
|
||||
key={location.key}
|
||||
id={mapAnchor(venue.id, location.key)}
|
||||
to={link(location.key)}
|
||||
aria-label={location.name}
|
||||
{...light?.(location.key)}
|
||||
className="absolute transition-opacity"
|
||||
style={style}
|
||||
>
|
||||
{inside}
|
||||
</Link>
|
||||
) : (
|
||||
<span key={location.key} aria-hidden="true" className="absolute transition-opacity duration-500" style={style}>
|
||||
{inside}
|
||||
</span>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default function MapBlock({ venue, accent }: { venue: Venue; accent: string }) {
|
||||
const { hash, search } = useLocation()
|
||||
const [hovered, setHovered] = useState<string | null>(null)
|
||||
const marked = venue.locations.filter((location) => location.x != null && location.y != null)
|
||||
const fromHash = venue.locations.find((location) => hash === `#${mapAnchor(venue.id, location.key)}`)?.key ?? null
|
||||
const active = hovered ?? fromHash
|
||||
const image = useReadingMode() ? null : mediaUrl(venue.map_image)
|
||||
const fill = accent.startsWith('#') ? accent : '#000000'
|
||||
const picture = !useReadingMode() && Boolean(venue.map_image)
|
||||
|
||||
const to = (key: string) => ({ search, hash: mapAnchor(venue.id, key) })
|
||||
const light = (key: string) => ({
|
||||
|
|
@ -50,68 +176,12 @@ export default function MapBlock({ venue, accent }: { venue: Venue; accent: stri
|
|||
onFocus: () => setHovered(key),
|
||||
onBlur: () => setHovered(null),
|
||||
})
|
||||
const number = (location: VenueLocation) => venue.locations.indexOf(location) + 1
|
||||
|
||||
return (
|
||||
<figure className="grid gap-6 md:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]">
|
||||
{image && (
|
||||
<div className="relative self-start">
|
||||
<img src={image} alt={venue.map_alt || `Map of ${venue.name}`} className="block w-full" />
|
||||
{marked.map((location) => {
|
||||
const on = active === location.key
|
||||
const dim = active != null && !on
|
||||
return (
|
||||
<Link
|
||||
key={location.key}
|
||||
id={mapAnchor(venue.id, location.key)}
|
||||
to={to(location.key)}
|
||||
aria-label={location.name}
|
||||
{...light(location.key)}
|
||||
className="absolute transition-opacity"
|
||||
style={
|
||||
isBox(location)
|
||||
? {
|
||||
left: `${location.x}%`,
|
||||
top: `${location.y}%`,
|
||||
width: `${location.w}%`,
|
||||
height: `${location.h}%`,
|
||||
border: `2px solid ${accent}`,
|
||||
background: withAlpha(accent, on ? 35 : 12),
|
||||
opacity: dim ? 0.35 : 1,
|
||||
}
|
||||
: {
|
||||
left: `${location.x}%`,
|
||||
top: `${location.y}%`,
|
||||
transform: 'translate(-50%, -50%)',
|
||||
opacity: dim ? 0.35 : 1,
|
||||
zIndex: on ? 1 : undefined,
|
||||
}
|
||||
}
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={`flex items-center justify-center rounded-full text-xs font-bold shadow ${
|
||||
isBox(location) ? 'absolute top-1 left-1 h-6 w-6' : on ? 'h-9 w-9' : 'h-7 w-7'
|
||||
}`}
|
||||
style={{ background: accent, color: readableOn(fill), outline: on ? '3px solid white' : undefined }}
|
||||
>
|
||||
{number(location)}
|
||||
</span>
|
||||
{on && (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className="absolute top-full left-1/2 mt-1 -translate-x-1/2 whitespace-nowrap bg-raised px-2 py-0.5 text-xs font-semibold text-ink shadow"
|
||||
>
|
||||
{location.name}
|
||||
</span>
|
||||
)}
|
||||
</Link>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
{picture && <MapPicture venue={venue} accent={accent} active={active} link={to} light={light} className="self-start" />}
|
||||
|
||||
<figcaption className={image ? '' : 'md:col-span-2'}>
|
||||
<figcaption className={picture ? '' : 'md:col-span-2'}>
|
||||
<p className="font-display font-bold text-ink">{venue.name}</p>
|
||||
{venue.address && <p className="text-sm text-muted">{venue.address}</p>}
|
||||
<ol className="mt-3 space-y-1">
|
||||
|
|
@ -119,13 +189,7 @@ export default function MapBlock({ venue, accent }: { venue: Venue; accent: stri
|
|||
const on = active === location.key
|
||||
const row = (
|
||||
<>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className="flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-xs font-bold"
|
||||
style={{ background: accent, color: readableOn(fill) }}
|
||||
>
|
||||
{number(location)}
|
||||
</span>
|
||||
<LocationNumber n={locationNumber(venue, location)} accent={accent} />
|
||||
<span className="min-w-0">
|
||||
<span className="block font-semibold" style={on ? { color: accentText(accent) } : undefined}>
|
||||
{location.name}
|
||||
|
|
@ -138,7 +202,7 @@ export default function MapBlock({ venue, accent }: { venue: Venue; accent: stri
|
|||
const rowStyle = on ? { background: withAlpha(accent, 12) } : undefined
|
||||
return (
|
||||
<li key={location.key}>
|
||||
{location.x != null && location.y != null ? (
|
||||
{isMarked(location) ? (
|
||||
<Link to={to(location.key)} {...light(location.key)} className={rowClass} style={rowStyle}>
|
||||
{row}
|
||||
</Link>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue