v1.14.2-present: event schedules, venues and map blocks, Present mode and its phone remote #33
8 changed files with 200 additions and 43 deletions
|
|
@ -264,6 +264,15 @@ export const blocksChild = (ownerKind) => ({
|
||||||
bool("no_tab"),
|
bool("no_tab"),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
// A map block's own sections of its venue's locations (094).
|
||||||
|
key: "map_sections",
|
||||||
|
table: "content_block_map_sections",
|
||||||
|
owner: { column: "block_id" },
|
||||||
|
order: "sort_order",
|
||||||
|
when: { column: "type", value: "map" },
|
||||||
|
columns: [text("name", { required: true }), text("location_keys")],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
27
server/src/migrations/094_map_sections.sql
Normal file
27
server/src/migrations/094_map_sections.sql
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
-- 094 A MAP BLOCK'S SECTIONS
|
||||||
|
--
|
||||||
|
-- A map content block can group its venue's locations into
|
||||||
|
-- sections of its own, eg. Main spaces, Small group spaces: the
|
||||||
|
-- block's list shows them under those names, and a visitor can pick
|
||||||
|
-- one to see only its locations on the map. They're the block's,
|
||||||
|
-- not the venue's, so each event groups the same venue its own way.
|
||||||
|
--
|
||||||
|
-- With sections, the block shows only the locations they name (in
|
||||||
|
-- the sections' order); without, every location, as before.
|
||||||
|
--
|
||||||
|
-- location_keys the venue's location_keys (088) it holds,
|
||||||
|
-- comma-separated, as schedule tags are (087). A
|
||||||
|
-- key the venue no longer has is skipped.
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
|
CREATE TABLE content_block_map_sections (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
block_id INTEGER NOT NULL REFERENCES content_blocks (id) ON DELETE CASCADE,
|
||||||
|
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||||
|
name TEXT NOT NULL,
|
||||||
|
location_keys TEXT
|
||||||
|
) STRICT;
|
||||||
|
|
||||||
|
CREATE INDEX content_block_map_sections_block_idx
|
||||||
|
ON content_block_map_sections (block_id, sort_order);
|
||||||
|
|
@ -187,6 +187,32 @@ export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) {
|
||||||
attachVenues(db, [...byId.values()]);
|
attachVenues(db, [...byId.values()]);
|
||||||
attachEvents(db, [...byId.values()], depth);
|
attachEvents(db, [...byId.values()], depth);
|
||||||
|
|
||||||
|
// A map block's sections (094): each names some of its venue's
|
||||||
|
// locations. With any, the block's venue is cut to the locations
|
||||||
|
// they name, in their order, so the page, its schedule's links
|
||||||
|
// and the presentation all see the same places, numbered alike.
|
||||||
|
const sectionRows = db
|
||||||
|
.prepare(
|
||||||
|
`SELECT block_id, name, location_keys
|
||||||
|
FROM content_block_map_sections
|
||||||
|
WHERE block_id IN (${placeholders(blockIds.length)})
|
||||||
|
ORDER BY block_id, sort_order`,
|
||||||
|
)
|
||||||
|
.all(...blockIds);
|
||||||
|
for (const row of sectionRows) {
|
||||||
|
const block = byId.get(row.block_id);
|
||||||
|
if (!block?.venue) continue;
|
||||||
|
const known = new Set(block.venue.locations.map((location) => location.key));
|
||||||
|
const keys = (row.location_keys ?? "").split(",").filter((key) => known.has(key));
|
||||||
|
if (keys.length) (block.map_sections ??= []).push({ name: row.name, keys });
|
||||||
|
}
|
||||||
|
for (const block of byId.values()) {
|
||||||
|
if (!block.map_sections) continue;
|
||||||
|
const byKey = new Map(block.venue.locations.map((location) => [location.key, location]));
|
||||||
|
const shown = [...new Set(block.map_sections.flatMap((section) => section.keys))];
|
||||||
|
block.venue = { ...block.venue, locations: shown.map((key) => byKey.get(key)) };
|
||||||
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ import type { ContentBlock, ContentBlockItem, ItemEvent } from '../lib/useConten
|
||||||
import { Anchor, Inline, Paragraphs, isExternalUrl } from './InlineText.tsx'
|
import { Anchor, Inline, Paragraphs, isExternalUrl } from './InlineText.tsx'
|
||||||
import VideoPlayer from './VideoPlayer.tsx'
|
import VideoPlayer from './VideoPlayer.tsx'
|
||||||
import ScheduleBlock, { Avatar } from './ScheduleBlock.tsx'
|
import ScheduleBlock, { Avatar } from './ScheduleBlock.tsx'
|
||||||
import MapBlock, { PageMaps } from './MapBlock.tsx'
|
import MapBlock, { PageMaps, mapAnchor } from './MapBlock.tsx'
|
||||||
import { eventHref, personHref } from '../lib/hrefs.ts'
|
import { eventHref, personHref } from '../lib/hrefs.ts'
|
||||||
import { occurrenceLabel } from '../lib/eventSeries.ts'
|
import { occurrenceLabel } from '../lib/eventSeries.ts'
|
||||||
import { accentText, BRAND } from '../lib/color.ts'
|
import { accentText, BRAND } from '../lib/color.ts'
|
||||||
|
|
@ -102,8 +102,15 @@ export default function ContentBlocks({
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
// The venues mapped here, for a schedule's places to link to.
|
// The places mapped here, for a schedule's places to link to: a
|
||||||
const maps = new Set(blocks.flatMap((block) => (block.type === 'map' && block.venue ? [block.venue.id] : [])))
|
// map block's venue's locations (only those its sections show).
|
||||||
|
const maps = new Set(
|
||||||
|
blocks.flatMap((block) =>
|
||||||
|
block.type === 'map' && block.venue
|
||||||
|
? block.venue.locations.map((location) => mapAnchor(block.venue!.id, location.key))
|
||||||
|
: [],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageMaps.Provider value={maps}>
|
<PageMaps.Provider value={maps}>
|
||||||
|
|
@ -588,7 +595,7 @@ function Block({
|
||||||
|
|
||||||
case 'map':
|
case 'map':
|
||||||
if (!block.venue) return null
|
if (!block.venue) return null
|
||||||
return <MapBlock venue={block.venue} accent={accent} />
|
return <MapBlock venue={block.venue} sections={block.map_sections} accent={accent} />
|
||||||
|
|
||||||
case 'events': {
|
case 'events': {
|
||||||
const events = (block.items ?? []).filter((item) => item.event)
|
const events = (block.items ?? []).filter((item) => item.event)
|
||||||
|
|
|
||||||
|
|
@ -23,17 +23,24 @@
|
||||||
|
|
||||||
Reading mode (readingMode.ts) gets the list alone, no picture.
|
Reading mode (readingMode.ts) gets the list alone, no picture.
|
||||||
|
|
||||||
PageMaps holds the venues that have a map block among the blocks
|
A block's own sections (094), eg. Main spaces, group the list
|
||||||
drawn together (ContentBlocks), so a schedule's places link only
|
under their names; the API has already cut the venue to the
|
||||||
when there's a map on the page to go to.
|
locations they hold. Buttons over the list (All, then one per
|
||||||
|
section) show one section alone, its marks on the map and its
|
||||||
|
rows in the list. A link to a location outside the section in
|
||||||
|
view goes back to All.
|
||||||
|
|
||||||
|
PageMaps holds the locations mapped by the blocks drawn together
|
||||||
|
(their anchors, ContentBlocks), so a schedule's places link only
|
||||||
|
when there's a map on the page showing them.
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
import { createContext, useState, type CSSProperties, type ReactNode } from 'react'
|
import { createContext, useEffect, useState, type CSSProperties, type ReactNode } from 'react'
|
||||||
import { AppleLogo, ArrowsIn, GoogleLogo, MagnifyingGlassMinus, MagnifyingGlassPlus } from '@phosphor-icons/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'
|
||||||
import type { Venue, VenueLocation } from '../lib/useContent.ts'
|
import type { MapSection, Venue, VenueLocation } from '../lib/useContent.ts'
|
||||||
import { accentText, readableOn, withAlpha } from '../lib/color.ts'
|
import { accentText, readableOn, withAlpha } from '../lib/color.ts'
|
||||||
import { useReadingMode } from '../lib/readingMode.ts'
|
import { useReadingMode } from '../lib/readingMode.ts'
|
||||||
|
|
||||||
|
|
@ -85,10 +92,13 @@ export function MapPicture({
|
||||||
light,
|
light,
|
||||||
className = '',
|
className = '',
|
||||||
big = false,
|
big = false,
|
||||||
|
only,
|
||||||
}: {
|
}: {
|
||||||
venue: Venue
|
venue: Venue
|
||||||
accent: string
|
accent: string
|
||||||
active: string | null
|
active: string | null
|
||||||
|
/** Marks only these locations' keys; all when unset. */
|
||||||
|
only?: Set<string>
|
||||||
link?: (key: string) => To
|
link?: (key: string) => To
|
||||||
light?: (key: string) => object
|
light?: (key: string) => object
|
||||||
className?: string
|
className?: string
|
||||||
|
|
@ -100,7 +110,7 @@ export function MapPicture({
|
||||||
return (
|
return (
|
||||||
<div className={`relative ${className}`}>
|
<div className={`relative ${className}`}>
|
||||||
<img src={image} alt={venue.map_alt || `Map of ${venue.name}`} className="block w-full" />
|
<img src={image} alt={venue.map_alt || `Map of ${venue.name}`} className="block w-full" />
|
||||||
{venue.locations.filter(isMarked).map((location) => {
|
{venue.locations.filter((location) => isMarked(location) && (!only || only.has(location.key))).map((location) => {
|
||||||
const on = active === location.key
|
const on = active === location.key
|
||||||
const dim = active != null && !on
|
const dim = active != null && !on
|
||||||
const style: CSSProperties = isBox(location)
|
const style: CSSProperties = isBox(location)
|
||||||
|
|
@ -170,11 +180,36 @@ export function MapPicture({
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function MapBlock({ venue, accent }: { venue: Venue; accent: string }) {
|
export default function MapBlock({
|
||||||
|
venue,
|
||||||
|
sections = [],
|
||||||
|
accent,
|
||||||
|
}: {
|
||||||
|
venue: Venue
|
||||||
|
sections?: MapSection[]
|
||||||
|
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 [zoom, setZoom] = useState(0)
|
||||||
|
// The section in view, by index; null is All.
|
||||||
|
const [view, setView] = useState<number | null>(null)
|
||||||
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 viewed = view != null ? sections[view] : undefined
|
||||||
|
|
||||||
|
// A link to a place outside the section in view shows All again.
|
||||||
|
useEffect(() => {
|
||||||
|
if (fromHash && viewed && !viewed.keys.includes(fromHash)) setView(null)
|
||||||
|
}, [fromHash, viewed])
|
||||||
|
|
||||||
|
const byKey = new Map(venue.locations.map((location) => [location.key, location]))
|
||||||
|
const groups: { name?: string; locations: VenueLocation[] }[] = sections.length
|
||||||
|
? (viewed ? [viewed] : sections).map((section) => ({
|
||||||
|
name: section.name,
|
||||||
|
locations: section.keys.flatMap((key) => byKey.get(key) ?? []),
|
||||||
|
}))
|
||||||
|
: [{ locations: venue.locations }]
|
||||||
|
const only = viewed ? new Set(viewed.keys) : undefined
|
||||||
const active = hovered ?? fromHash
|
const active = hovered ?? fromHash
|
||||||
const picture = !useReadingMode() && Boolean(venue.map_image)
|
const picture = !useReadingMode() && Boolean(venue.map_image)
|
||||||
|
|
||||||
|
|
@ -197,7 +232,7 @@ export default function MapBlock({ venue, accent }: { venue: Venue; accent: stri
|
||||||
<div className="relative self-start">
|
<div className="relative self-start">
|
||||||
<div className="max-h-[80vh] overflow-auto border border-brand/15">
|
<div className="max-h-[80vh] overflow-auto border border-brand/15">
|
||||||
<div style={{ width: `${ZOOMS[zoom] * 100}%` }}>
|
<div style={{ width: `${ZOOMS[zoom] * 100}%` }}>
|
||||||
<MapPicture venue={venue} accent={accent} active={active} link={to} light={light} />
|
<MapPicture venue={venue} accent={accent} active={active} link={to} light={light} only={only} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="absolute top-2 right-2 flex gap-1">
|
<div className="absolute top-2 right-2 flex gap-1">
|
||||||
|
|
@ -219,8 +254,34 @@ export default function MapBlock({ venue, accent }: { venue: Venue; accent: stri
|
||||||
<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>
|
||||||
{venue.address && <p className="text-sm text-muted">{venue.address}</p>}
|
{venue.address && <p className="text-sm text-muted">{venue.address}</p>}
|
||||||
<ol className="mt-3 space-y-1">
|
{sections.length > 1 && (
|
||||||
{venue.locations.map((location) => {
|
<div role="group" aria-label="Show" className="mt-3 flex flex-wrap gap-2">
|
||||||
|
{[null, ...sections.map((_, i) => i)].map((i) => {
|
||||||
|
const selected = view === i
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
key={i ?? 'all'}
|
||||||
|
type="button"
|
||||||
|
aria-pressed={selected}
|
||||||
|
onClick={() => setView(i)}
|
||||||
|
className="btn border px-3 py-1 text-xs transition-colors"
|
||||||
|
style={
|
||||||
|
selected
|
||||||
|
? { background: accent, borderColor: accent, color: readableOn(accent) }
|
||||||
|
: { borderColor: withAlpha(accent, 33), color: accentText(accent) }
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{i == null ? 'All' : sections[i].name}
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{groups.map((group, g) => (
|
||||||
|
<div key={group.name ?? g} className="mt-3">
|
||||||
|
{group.name && <p className="px-2 text-sm font-bold text-ink">{group.name}</p>}
|
||||||
|
<ol className="mt-1 space-y-1">
|
||||||
|
{group.locations.map((location) => {
|
||||||
const on = active === location.key
|
const on = active === location.key
|
||||||
const row = (
|
const row = (
|
||||||
<>
|
<>
|
||||||
|
|
@ -249,6 +310,8 @@ export default function MapBlock({ venue, accent }: { venue: Venue; accent: stri
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</ol>
|
</ol>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
</figcaption>
|
</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ function Place({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
|
||||||
const maps = useContext(PageMaps)
|
const maps = useContext(PageMaps)
|
||||||
const { search } = useLocation()
|
const { search } = useLocation()
|
||||||
if (!entry.location) return null
|
if (!entry.location) return null
|
||||||
if (!entry.place || !maps.has(entry.place.venue_id)) return <span>{entry.location}</span>
|
if (!entry.place || !maps.has(mapAnchor(entry.place.venue_id, entry.place.key))) return <span>{entry.location}</span>
|
||||||
return (
|
return (
|
||||||
<Link
|
<Link
|
||||||
to={{ search, hash: mapAnchor(entry.place.venue_id, entry.place.key) }}
|
to={{ search, hash: mapAnchor(entry.place.venue_id, entry.place.key) }}
|
||||||
|
|
|
||||||
|
|
@ -650,6 +650,26 @@ export const blocksChild = {
|
||||||
{ path: "no_tab", label: "No tab", widget: "checkbox", help: "Leave it out of the tabs (it still shows on entries)" },
|
{ path: "no_tab", label: "No tab", widget: "checkbox", help: "Leave it out of the tabs (it still shows on entries)" },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: "map_sections",
|
||||||
|
label: "Sections",
|
||||||
|
addLabel: "Add section",
|
||||||
|
note: "Optional: group the venue's locations for this page, eg. Main spaces, Small group spaces. Visitors can pick one to see only its places on the map. With sections, only the locations they hold are shown. The venue itself is unchanged.",
|
||||||
|
when: { path: "type", value: "map" },
|
||||||
|
title: (row) => row.name || "New section",
|
||||||
|
blank: { name: "" },
|
||||||
|
fields: [
|
||||||
|
{ path: "name", label: "Name", required: true, help: "eg. Main spaces" },
|
||||||
|
{
|
||||||
|
path: "location_keys",
|
||||||
|
label: "Locations",
|
||||||
|
widget: "checklist",
|
||||||
|
optionsFrom: "mapLocations",
|
||||||
|
full: true,
|
||||||
|
emptyNote: "No locations yet: pick the block's Venue, and give it locations under Data → Venues.",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: "items",
|
key: "items",
|
||||||
label: "Items",
|
label: "Items",
|
||||||
|
|
|
||||||
|
|
@ -67,8 +67,13 @@ export type ContentBlock = {
|
||||||
/** A map or schedule block's venue (088). */
|
/** A map or schedule block's venue (088). */
|
||||||
venue_id?: string | null
|
venue_id?: string | null
|
||||||
venue?: Venue | null
|
venue?: Venue | null
|
||||||
|
/** A map block's own sections of its venue's locations, by key
|
||||||
|
* (094). With any, `venue` holds only the locations they name. */
|
||||||
|
map_sections?: MapSection[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type MapSection = { name: string; keys: string[] }
|
||||||
|
|
||||||
/** A venue (088): its map picture and the locations marked on it,
|
/** A venue (088): its map picture and the locations marked on it,
|
||||||
* each a pin (x, y) or a box (x, y, w, h), in percent. */
|
* each a pin (x, y) or a box (x, y, w, h), in percent. */
|
||||||
export type Venue = {
|
export type Venue = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue