v1.14.2-present: event schedules, venues and map blocks, Present mode and its phone remote #33

Merged
ngu-git-admin merged 40 commits from event-schedule into main 2026-11-21 23:02:06 +00:00
6 changed files with 128 additions and 12 deletions
Showing only changes of commit 6a0271efd9 - Show all commits

View file

@ -1,4 +1,4 @@
import { text, real } from "./columns.js"; import { text, real, url } from "./columns.js";
/* ── Venues (088_venues.sql) ───────────────────────────────────── /* ── Venues (088_venues.sql) ─────────────────────────────────────
@ -38,6 +38,9 @@ export const venues = {
real("y"), real("y"),
real("w"), real("w"),
real("h"), real("h"),
// The place in Google and Apple Maps (091).
url("google_maps_url"),
url("apple_maps_url"),
], ],
}, },
], ],

View file

@ -0,0 +1,10 @@
-- ═══════════════════════════════════════════════════════════════
-- 091 A VENUE LOCATION'S MAP LINKS
--
-- Each location on a venue's map can link to the same place in
-- Google Maps and Apple Maps, shown as buttons beside it in a map
-- block's list. Null shows no button.
-- ═══════════════════════════════════════════════════════════════
ALTER TABLE venue_locations ADD COLUMN google_maps_url TEXT;
ALTER TABLE venue_locations ADD COLUMN apple_maps_url TEXT;

View file

@ -202,7 +202,7 @@ function attachVenues(db, blocks) {
); );
const locationRows = db const locationRows = db
.prepare( .prepare(
`SELECT venue_id, location_key AS key, name, detail, x, y, w, h `SELECT venue_id, location_key AS key, name, detail, x, y, w, h, google_maps_url, apple_maps_url
FROM venue_locations FROM venue_locations
WHERE venue_id IN (${placeholders(ids.length)}) WHERE venue_id IN (${placeholders(ids.length)})
ORDER BY venue_id, sort_order`, ORDER BY venue_id, sort_order`,

View file

@ -9,9 +9,14 @@
they stay on their places at any width. A location is lit up they stay on their places at any width. A location is lit up
(in the accent, the rest dimmed) while its row or mark is hovered (in the accent, the rest dimmed) while its row or mark is hovered
or focused, and when the address points at it: #map-<venue>-<key>, or focused, and when the address points at it: #map-<venue>-<key>,
the link a schedule entry's place makes (mapAnchor). That id is the link a schedule entry's place makes (mapAnchor). Those ids
the mark's own, so Layout's jump to the anchor scrolls it into sit at the block's top, so Layout's jump to the anchor brings the
view and focuses it. whole map into view, not the mark at the top of the screen.
The picture zooms (the buttons over it), scrolling inside its box
when it's bigger than it; the marks are in percent, so they keep
their places. A location's Google and Apple Maps links (091) are
buttons at the right of its row.
MapPicture is the picture and its marks alone; the event's MapPicture is the picture and its marks alone; the event's
presentation (EventPresent.tsx) draws it too, with no links. presentation (EventPresent.tsx) draws it too, with no links.
@ -23,7 +28,8 @@
when there's a map on the page to go to. when there's a map on the page to go to.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
import { createContext, useState, type CSSProperties } from 'react' import { createContext, useState, type CSSProperties, type ReactNode } from 'react'
import { AppleLogo, ArrowsIn, GoogleLogo, MagnifyingGlassMinus, MagnifyingGlassPlus } from '@phosphor-icons/react'
import { Link, useLocation, type To } from 'react-router-dom' import { Link, useLocation, type To } from 'react-router-dom'
import { mediaUrl } from '../lib/media.ts' import { mediaUrl } from '../lib/media.ts'
@ -35,6 +41,9 @@ export const PageMaps = createContext<Set<string>>(new Set())
export const mapAnchor = (venueId: string, key: string) => `map-${venueId}-${key}` export const mapAnchor = (venueId: string, key: string) => `map-${venueId}-${key}`
/* The picture's zoom steps, 1 the column's width. */
const ZOOMS = [1, 1.5, 2, 3, 4]
const isBox = (location: VenueLocation) => location.w != null && location.h != null const isBox = (location: VenueLocation) => location.w != null && location.h != null
export const isMarked = (location: VenueLocation) => location.x != null && location.y != null export const isMarked = (location: VenueLocation) => location.x != null && location.y != null
@ -143,7 +152,6 @@ export function MapPicture({
return link ? ( return link ? (
<Link <Link
key={location.key} key={location.key}
id={mapAnchor(venue.id, location.key)}
to={link(location.key)} to={link(location.key)}
aria-label={location.name} aria-label={location.name}
{...light?.(location.key)} {...light?.(location.key)}
@ -165,6 +173,7 @@ export function MapPicture({
export default function MapBlock({ venue, accent }: { venue: Venue; accent: string }) { export default function MapBlock({ venue, accent }: { venue: Venue; accent: string }) {
const { hash, search } = useLocation() const { hash, search } = useLocation()
const [hovered, setHovered] = useState<string | null>(null) const [hovered, setHovered] = useState<string | null>(null)
const [zoom, setZoom] = useState(0)
const fromHash = venue.locations.find((location) => hash === `#${mapAnchor(venue.id, location.key)}`)?.key ?? null const fromHash = venue.locations.find((location) => hash === `#${mapAnchor(venue.id, location.key)}`)?.key ?? null
const active = hovered ?? fromHash const active = hovered ?? fromHash
const picture = !useReadingMode() && Boolean(venue.map_image) const picture = !useReadingMode() && Boolean(venue.map_image)
@ -178,8 +187,34 @@ export default function MapBlock({ venue, accent }: { venue: Venue; accent: stri
}) })
return ( return (
<figure className="grid gap-6 md:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]"> <figure className="relative grid gap-6 md:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]">
{picture && <MapPicture venue={venue} accent={accent} active={active} link={to} light={light} className="self-start" />} {/* Where a link to a location lands: the map's top. */}
{venue.locations.map((location) => (
<span key={location.key} id={mapAnchor(venue.id, location.key)} className="absolute top-0 left-0" />
))}
{picture && (
<div className="relative self-start">
<div className="max-h-[80vh] overflow-auto border border-brand/15">
<div style={{ width: `${ZOOMS[zoom] * 100}%` }}>
<MapPicture venue={venue} accent={accent} active={active} link={to} light={light} />
</div>
</div>
<div className="absolute top-2 right-2 flex gap-1">
<ZoomButton label="Zoom in" disabled={zoom === ZOOMS.length - 1} onClick={() => setZoom(zoom + 1)}>
<MagnifyingGlassPlus weight="bold" className="h-5 w-5" />
</ZoomButton>
<ZoomButton label="Zoom out" disabled={zoom === 0} onClick={() => setZoom(zoom - 1)}>
<MagnifyingGlassMinus weight="bold" className="h-5 w-5" />
</ZoomButton>
{zoom > 0 && (
<ZoomButton label="Fit the map" onClick={() => setZoom(0)}>
<ArrowsIn weight="bold" className="h-5 w-5" />
</ZoomButton>
)}
</div>
</div>
)}
<figcaption className={picture ? '' : 'md:col-span-2'}> <figcaption className={picture ? '' : 'md:col-span-2'}>
<p className="font-display font-bold text-ink">{venue.name}</p> <p className="font-display font-bold text-ink">{venue.name}</p>
@ -201,14 +236,15 @@ export default function MapBlock({ venue, accent }: { venue: Venue; accent: stri
const rowClass = 'flex items-start gap-3 px-2 py-1.5 text-body' const rowClass = 'flex items-start gap-3 px-2 py-1.5 text-body'
const rowStyle = on ? { background: withAlpha(accent, 12) } : undefined const rowStyle = on ? { background: withAlpha(accent, 12) } : undefined
return ( return (
<li key={location.key}> <li key={location.key} className="flex items-start gap-2">
{isMarked(location) ? ( {isMarked(location) ? (
<Link to={to(location.key)} {...light(location.key)} className={rowClass} style={rowStyle}> <Link to={to(location.key)} {...light(location.key)} className={`${rowClass} flex-1`} style={rowStyle}>
{row} {row}
</Link> </Link>
) : ( ) : (
<div className={rowClass}>{row}</div> <div className={`${rowClass} flex-1`}>{row}</div>
)} )}
<MapLinks location={location} accent={accent} />
</li> </li>
) )
})} })}
@ -217,3 +253,57 @@ export default function MapBlock({ venue, accent }: { venue: Venue; accent: stri
</figure> </figure>
) )
} }
/* A zoom button over the map picture. */
function ZoomButton({
label,
disabled,
onClick,
children,
}: {
label: string
disabled?: boolean
onClick: () => void
children: ReactNode
}) {
return (
<button
type="button"
aria-label={label}
title={label}
disabled={disabled}
onClick={onClick}
className="btn flex h-9 w-9 items-center justify-center bg-raised text-ink shadow transition-colors hover:text-link disabled:opacity-40"
>
{children}
</button>
)
}
/* A location's Google and Apple Maps links (091), as buttons that
open them in a new tab. */
function MapLinks({ location, accent }: { location: VenueLocation; accent: string }) {
const links = [
{ href: location.google_maps_url, label: 'Google Maps', Icon: GoogleLogo },
{ href: location.apple_maps_url, label: 'Apple Maps', Icon: AppleLogo },
].filter((link) => link.href)
if (links.length === 0) return null
return (
<span className="flex shrink-0 gap-1 py-1.5">
{links.map(({ href, label, Icon }) => (
<a
key={label}
href={href!}
target="_blank"
rel="noreferrer"
aria-label={`${location.name} in ${label} (opens in a new tab)`}
title={label}
className="btn flex h-8 w-8 items-center justify-center border transition-colors hover:bg-tint"
style={{ borderColor: withAlpha(accent, 33), color: accentText(accent) }}
>
<Icon weight="bold" className="h-4 w-4" aria-hidden="true" />
</a>
))}
</span>
)
}

View file

@ -66,6 +66,16 @@ export const venues = {
full: true, full: true,
help: "Click the map for a pin, or drag out a box for an area. Default: listed, not marked.", help: "Click the map for a pin, or drag out a box for an area. Default: listed, not marked.",
}, },
{
path: "google_maps_url",
label: "Google Maps link",
help: "eg. https://maps.app.goo.gl/... Shown as a button beside it. Default: none",
},
{
path: "apple_maps_url",
label: "Apple Maps link",
help: "eg. https://maps.apple.com/?... Shown as a button beside it. Default: none",
},
], ],
}, },
], ],

View file

@ -82,6 +82,9 @@ export type VenueLocation = {
y?: number | null y?: number | null
w?: number | null w?: number | null
h?: number | null h?: number | null
/** The place in Google and Apple Maps (091). */
google_maps_url?: string | null
apple_maps_url?: string | null
} }
/** An event an item names (088): an events block's card, or the /** An event an item names (088): an events block's card, or the