diff --git a/server/src/admin-schema/venues.js b/server/src/admin-schema/venues.js index 2525229..932f433 100644 --- a/server/src/admin-schema/venues.js +++ b/server/src/admin-schema/venues.js @@ -1,4 +1,4 @@ -import { text, real } from "./columns.js"; +import { text, real, url } from "./columns.js"; /* ── Venues (088_venues.sql) ───────────────────────────────────── @@ -38,6 +38,9 @@ export const venues = { real("y"), real("w"), real("h"), + // The place in Google and Apple Maps (091). + url("google_maps_url"), + url("apple_maps_url"), ], }, ], diff --git a/server/src/migrations/091_location_map_links.sql b/server/src/migrations/091_location_map_links.sql new file mode 100644 index 0000000..ddeb57f --- /dev/null +++ b/server/src/migrations/091_location_map_links.sql @@ -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; diff --git a/server/src/shape.js b/server/src/shape.js index 0afbd86..2d31f80 100644 --- a/server/src/shape.js +++ b/server/src/shape.js @@ -202,7 +202,7 @@ function attachVenues(db, blocks) { ); const locationRows = db .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 WHERE venue_id IN (${placeholders(ids.length)}) ORDER BY venue_id, sort_order`, diff --git a/src/components/MapBlock.tsx b/src/components/MapBlock.tsx index bb704f3..036c168 100644 --- a/src/components/MapBlock.tsx +++ b/src/components/MapBlock.tsx @@ -9,9 +9,14 @@ 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 or focused, and when the address points at it: #map--, - the link a schedule entry's place makes (mapAnchor). That id is - the mark's own, so Layout's jump to the anchor scrolls it into - view and focuses it. + the link a schedule entry's place makes (mapAnchor). Those ids + sit at the block's top, so Layout's jump to the anchor brings the + 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 presentation (EventPresent.tsx) draws it too, with no links. @@ -23,7 +28,8 @@ 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 { mediaUrl } from '../lib/media.ts' @@ -35,6 +41,9 @@ export const PageMaps = createContext>(new Set()) 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 export const isMarked = (location: VenueLocation) => location.x != null && location.y != null @@ -143,7 +152,6 @@ export function MapPicture({ return link ? ( (null) + const [zoom, setZoom] = useState(0) const fromHash = venue.locations.find((location) => hash === `#${mapAnchor(venue.id, location.key)}`)?.key ?? null const active = hovered ?? fromHash const picture = !useReadingMode() && Boolean(venue.map_image) @@ -178,8 +187,34 @@ export default function MapBlock({ venue, accent }: { venue: Venue; accent: stri }) return ( -
- {picture && } +
+ {/* Where a link to a location lands: the map's top. */} + {venue.locations.map((location) => ( + + ))} + + {picture && ( +
+
+
+ +
+
+
+ setZoom(zoom + 1)}> + + + setZoom(zoom - 1)}> + + + {zoom > 0 && ( + setZoom(0)}> + + + )} +
+
+ )}

{venue.name}

@@ -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 rowStyle = on ? { background: withAlpha(accent, 12) } : undefined return ( -
  • +
  • {isMarked(location) ? ( - + {row} ) : ( -
    {row}
    +
    {row}
    )} +
  • ) })} @@ -217,3 +253,57 @@ export default function MapBlock({ venue, accent }: { venue: Venue; accent: stri
    ) } + +/* A zoom button over the map picture. */ +function ZoomButton({ + label, + disabled, + onClick, + children, +}: { + label: string + disabled?: boolean + onClick: () => void + children: ReactNode +}) { + return ( + + ) +} + +/* 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 ( + + {links.map(({ href, label, Icon }) => ( + + + ))} + + ) +} diff --git a/src/lib/adminSchema/venues.ts b/src/lib/adminSchema/venues.ts index 5b05189..f419c2e 100644 --- a/src/lib/adminSchema/venues.ts +++ b/src/lib/adminSchema/venues.ts @@ -66,6 +66,16 @@ export const venues = { full: true, 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", + }, ], }, ], diff --git a/src/lib/useContent.ts b/src/lib/useContent.ts index 4605ee0..be9c0e4 100644 --- a/src/lib/useContent.ts +++ b/src/lib/useContent.ts @@ -82,6 +82,9 @@ export type VenueLocation = { y?: number | null w?: 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