Venues, map blocks and event blocks; schedule entries link to them
Data → Venues: a map picture with its locations marked as pins or boxes (088). A Map block draws a venue with its locations listed; a schedule names a venue and its entries pick a location, linking to the map on the page with it lit up. Entries and sub-items can name an event (a workshop) and take what they leave blank from it, and an Events block shows event cards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3d087da005
commit
818d648e91
18 changed files with 964 additions and 35 deletions
|
|
@ -30,6 +30,12 @@
|
|||
people team_id's members as people tiles, then
|
||||
items as more tiles: person, text their
|
||||
title (an unpublished person is left out)
|
||||
map venue: its map, locations marked and
|
||||
listed (MapBlock); a schedule's places
|
||||
link to it
|
||||
events items as event cards: event (from
|
||||
event_id), text the title shown, detail
|
||||
in place of the event's card text
|
||||
divider nothing
|
||||
|
||||
"Formatted" is InlineText.tsx: **bold**, *italic*, [text](url),
|
||||
|
|
@ -50,6 +56,9 @@ import type { ContentBlock, ContentBlockItem } from '../lib/useContent.ts'
|
|||
import { Anchor, Inline, Paragraphs, isExternalUrl } from './InlineText.tsx'
|
||||
import VideoPlayer from './VideoPlayer.tsx'
|
||||
import ScheduleBlock from './ScheduleBlock.tsx'
|
||||
import MapBlock, { PageMaps } from './MapBlock.tsx'
|
||||
import { eventHref } from '../lib/hrefs.ts'
|
||||
import { occurrenceLabel } from '../lib/eventSeries.ts'
|
||||
import { accentText, BRAND } from '../lib/color.ts'
|
||||
import { headingAnchors } from '../lib/contents.ts'
|
||||
import { SITE_NAME } from '../lib/site.ts'
|
||||
|
|
@ -94,7 +103,11 @@ export default function ContentBlocks({
|
|||
presentAt && block.type === 'schedule' ? `${presentAt}?block=${schedules++}` : undefined,
|
||||
)
|
||||
|
||||
// The venues mapped here, for a schedule's places to link to.
|
||||
const maps = new Set(blocks.flatMap((block) => (block.type === 'map' && block.venue ? [block.venue.id] : [])))
|
||||
|
||||
return (
|
||||
<PageMaps.Provider value={maps}>
|
||||
<div className={`space-y-6 ${className}`}>
|
||||
{blocks.map((block, index) => (
|
||||
<WordMotion key={block.id ?? index} settings={block.words}>
|
||||
|
|
@ -108,6 +121,7 @@ export default function ContentBlocks({
|
|||
</WordMotion>
|
||||
))}
|
||||
</div>
|
||||
</PageMaps.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -144,6 +158,40 @@ function LinkCard({ item }: { item: ContentBlockItem }) {
|
|||
)
|
||||
}
|
||||
|
||||
/* One event card (088): the event's picture, its type and date,
|
||||
its title (or the item's text) and card text (or the item's
|
||||
detail); the whole card links to the event. */
|
||||
function EventCard({ item, accent }: { item: ContentBlockItem; accent: string }) {
|
||||
const event = item.event!
|
||||
const img = useSmallImage(mediaUrl(event.image))
|
||||
const color = event.color || accent
|
||||
const when = event.date_label || (event.starts_on ? occurrenceLabel(event.starts_on) : null)
|
||||
const kind = event.event_type && event.event_type !== 'other' ? event.event_type : null
|
||||
return (
|
||||
<Anchor
|
||||
href={eventHref(event.id)}
|
||||
className="group flex h-full flex-col overflow-hidden border border-brand/15 bg-raised shadow-sm transition-shadow hover:shadow-lg"
|
||||
>
|
||||
{!img.failed && (
|
||||
<img src={img.src} alt="" loading="lazy" onError={img.onError} className="aspect-video w-full object-cover" />
|
||||
)}
|
||||
<span className="flex flex-1 flex-col gap-1 p-4">
|
||||
{(kind || when) && (
|
||||
<span className="text-xs font-semibold capitalize" style={{ color: accentText(color) }}>
|
||||
{[kind, when].filter(Boolean).join(' · ')}
|
||||
</span>
|
||||
)}
|
||||
<span className="font-display text-base font-bold leading-snug text-ink group-hover:text-link">
|
||||
{item.text || event.title}
|
||||
</span>
|
||||
{(item.detail || event.blurb) && (
|
||||
<span className="line-clamp-3 text-sm leading-snug text-body">{item.detail || event.blurb}</span>
|
||||
)}
|
||||
</span>
|
||||
</Anchor>
|
||||
)
|
||||
}
|
||||
|
||||
/* A table block's text as rows of cells: one row per line, cells
|
||||
split by "|" (a literal bar is "\|"), blank lines skipped. A
|
||||
leading and trailing bar, as in Markdown, is allowed. */
|
||||
|
|
@ -395,6 +443,24 @@ function Block({
|
|||
/>
|
||||
)
|
||||
|
||||
case 'map':
|
||||
if (!block.venue) return null
|
||||
return <MapBlock venue={block.venue} accent={accent} />
|
||||
|
||||
case 'events': {
|
||||
const events = (block.items ?? []).filter((item) => item.event)
|
||||
if (events.length === 0) return null
|
||||
return (
|
||||
<ul className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{events.map((item, i) => (
|
||||
<li key={i}>
|
||||
<EventCard item={item} accent={accent} />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
|
||||
case 'people': {
|
||||
const picked = (block.items ?? [])
|
||||
.filter((item) => item.person)
|
||||
|
|
|
|||
155
src/components/MapBlock.tsx
Normal file
155
src/components/MapBlock.tsx
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
MAP BLOCK
|
||||
|
||||
The 'map' content block (088): a venue's map picture with its
|
||||
locations marked on it, each a numbered pin or a box, and the
|
||||
locations listed beside it (under it on a phone).
|
||||
|
||||
One picture, the marks drawn over it in percent of its size, so
|
||||
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-<venue>-<key>,
|
||||
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.
|
||||
|
||||
Reading mode (readingMode.ts) gets the list alone, no picture.
|
||||
|
||||
PageMaps holds the venues that have a map block among the blocks
|
||||
drawn together (ContentBlocks), so a schedule's places link only
|
||||
when there's a map on the page to go to.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { createContext, useState } from 'react'
|
||||
import { Link, useLocation } from 'react-router-dom'
|
||||
|
||||
import { mediaUrl } from '../lib/media.ts'
|
||||
import type { Venue, VenueLocation } from '../lib/useContent.ts'
|
||||
import { accentText, readableOn, withAlpha } from '../lib/color.ts'
|
||||
import { useReadingMode } from '../lib/readingMode.ts'
|
||||
|
||||
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 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 to = (key: string) => ({ search, hash: mapAnchor(venue.id, key) })
|
||||
const light = (key: string) => ({
|
||||
onMouseEnter: () => setHovered(key),
|
||||
onMouseLeave: () => setHovered(null),
|
||||
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>
|
||||
)}
|
||||
|
||||
<figcaption className={image ? '' : '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">
|
||||
{venue.locations.map((location) => {
|
||||
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>
|
||||
<span className="min-w-0">
|
||||
<span className="block font-semibold" style={on ? { color: accentText(accent) } : undefined}>
|
||||
{location.name}
|
||||
</span>
|
||||
{location.detail && <span className="block text-sm text-muted">{location.detail}</span>}
|
||||
</span>
|
||||
</>
|
||||
)
|
||||
const rowClass = 'flex items-start gap-3 px-2 py-1.5 text-body'
|
||||
const rowStyle = on ? { background: withAlpha(accent, 12) } : undefined
|
||||
return (
|
||||
<li key={location.key}>
|
||||
{location.x != null && location.y != null ? (
|
||||
<Link to={to(location.key)} {...light(location.key)} className={rowClass} style={rowStyle}>
|
||||
{row}
|
||||
</Link>
|
||||
) : (
|
||||
<div className={rowClass}>{row}</div>
|
||||
)}
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ol>
|
||||
</figcaption>
|
||||
</figure>
|
||||
)
|
||||
}
|
||||
|
|
@ -32,6 +32,12 @@
|
|||
day's name. A tagged entry comes whole; an untagged block comes
|
||||
with only its tagged sub-items. A tag on nothing draws no tab.
|
||||
|
||||
An entry's place on the block's venue (088) links to the map
|
||||
block on the same page, the location lit up there (MapBlock);
|
||||
with no map of that venue on the page it's plain text. An entry
|
||||
that is an event (a workshop) has already taken what it left
|
||||
blank from it (shape.js).
|
||||
|
||||
On an event page a Present button opens the schedule as a
|
||||
slideshow for a screen (SchedulePresent.tsx).
|
||||
|
||||
|
|
@ -42,9 +48,9 @@
|
|||
it, no map frame (ReadingSchedule).
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { CaretDown, Presentation, Star } from '@phosphor-icons/react'
|
||||
import { CaretDown, MapPin, Presentation, Star } from '@phosphor-icons/react'
|
||||
import { Fragment, createContext, useContext, useId, useState, type KeyboardEvent, type ReactNode } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { Link, useLocation } from 'react-router-dom'
|
||||
|
||||
import { personHref } from '../lib/hrefs.ts'
|
||||
import { mediaUrl, initials } from '../lib/media.ts'
|
||||
|
|
@ -54,6 +60,7 @@ import { withAlpha, accentText, readableOn } from '../lib/color.ts'
|
|||
import { useSmallImage } from '../lib/useSmallImage.ts'
|
||||
import { focusOnMount } from '../lib/focus.ts'
|
||||
import { useReadingMode } from '../lib/readingMode.ts'
|
||||
import { PageMaps, mapAnchor } from './MapBlock.tsx'
|
||||
|
||||
const BODY = 'var(--color-muted)'
|
||||
const WEEKDAYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
|
||||
|
|
@ -136,6 +143,26 @@ function todayIndex(days: Day[]): number {
|
|||
return found >= 0 ? found : 0
|
||||
}
|
||||
|
||||
/* An entry's location, linked to its place on a map block on the
|
||||
page when there is one (088). */
|
||||
function Place({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
|
||||
const maps = useContext(PageMaps)
|
||||
const { search } = useLocation()
|
||||
if (!entry.location) return null
|
||||
if (!entry.place || !maps.has(entry.place.venue_id)) return <span>{entry.location}</span>
|
||||
return (
|
||||
<Link
|
||||
to={{ search, hash: mapAnchor(entry.place.venue_id, entry.place.key) }}
|
||||
className="inline-flex items-center gap-1 underline-offset-2 hover:underline"
|
||||
style={{ color: accentText(accent) }}
|
||||
>
|
||||
<MapPin aria-hidden="true" weight="bold" className="h-4 w-4 shrink-0" />
|
||||
{entry.location}
|
||||
<span className="sr-only">, on the map</span>
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
||||
/* An entry's own map image says what it maps. */
|
||||
export const mapAlt = (entry: ContentBlockItem) => `Map: ${entry.map?.trim() || entry.location || entry.text}`
|
||||
|
||||
|
|
@ -240,7 +267,7 @@ function Entry({ entry, accent, sub = false }: { entry: ContentBlockItem; accent
|
|||
</p>
|
||||
{(entry.location || entry.person) && (
|
||||
<p className="mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-sm" style={{ color: BODY }}>
|
||||
{entry.location && <span>{entry.location}</span>}
|
||||
<Place entry={entry} accent={accent} />
|
||||
{entry.person && (
|
||||
<span className="inline-flex items-center gap-2">
|
||||
<Avatar person={entry.person} size="h-6 w-6" />
|
||||
|
|
|
|||
130
src/components/admin/MapMarkerInput.tsx
Normal file
130
src/components/admin/MapMarkerInput.tsx
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
/* A venue location's mark on the venue's map (088), for the
|
||||
`mapMarker` widget (fields.tsx): click the picture for a pin, drag
|
||||
for a box. Saved as x, y (and w, h for a box) in percent of the
|
||||
picture from its top left, one decimal, through onPatch. The
|
||||
numbers under it set the same thing by keyboard. */
|
||||
|
||||
import { useRef, useState, type PointerEvent } from "react";
|
||||
|
||||
type Mark = { x: number | null; y: number | null; w: number | null; h: number | null };
|
||||
|
||||
const round = (n: number) => Math.round(Math.min(100, Math.max(0, n)) * 10) / 10;
|
||||
// Moved less than this (percent) between press and release: a click.
|
||||
const CLICK = 1.5;
|
||||
|
||||
export default function MapMarkerInput({ image, row, locked, onPatch }: any) {
|
||||
const box = useRef<HTMLDivElement>(null);
|
||||
const [drag, setDrag] = useState<{ x0: number; y0: number; x1: number; y1: number } | null>(null);
|
||||
const mark: Mark = { x: row.x ?? null, y: row.y ?? null, w: row.w ?? null, h: row.h ?? null };
|
||||
|
||||
const at = (e: PointerEvent) => {
|
||||
const r = box.current!.getBoundingClientRect();
|
||||
return { x: round(((e.clientX - r.left) / r.width) * 100), y: round(((e.clientY - r.top) / r.height) * 100) };
|
||||
};
|
||||
|
||||
const up = (e: PointerEvent) => {
|
||||
if (!drag) return;
|
||||
const { x, y } = at(e);
|
||||
setDrag(null);
|
||||
if (Math.abs(x - drag.x0) < CLICK && Math.abs(y - drag.y0) < CLICK) {
|
||||
onPatch({ x: drag.x0, y: drag.y0, w: null, h: null });
|
||||
} else {
|
||||
onPatch({
|
||||
x: Math.min(x, drag.x0),
|
||||
y: Math.min(y, drag.y0),
|
||||
w: round(Math.abs(x - drag.x0)),
|
||||
h: round(Math.abs(y - drag.y0)),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const shown = drag
|
||||
? {
|
||||
x: Math.min(drag.x0, drag.x1),
|
||||
y: Math.min(drag.y0, drag.y1),
|
||||
w: Math.abs(drag.x1 - drag.x0),
|
||||
h: Math.abs(drag.y1 - drag.y0),
|
||||
}
|
||||
: mark;
|
||||
|
||||
const number = (key: keyof Mark, label: string) => (
|
||||
<label className="flex items-center gap-1">
|
||||
{label}
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
max={100}
|
||||
step={0.1}
|
||||
value={mark[key] ?? ""}
|
||||
disabled={locked}
|
||||
onChange={(e) => onPatch({ [key]: e.target.value === "" ? null : round(Number(e.target.value)) })}
|
||||
className="w-20 border border-muted/25 bg-surface px-2 py-1 text-body"
|
||||
/>
|
||||
</label>
|
||||
);
|
||||
|
||||
return (
|
||||
<div>
|
||||
{image ? (
|
||||
<div
|
||||
ref={box}
|
||||
className={`relative select-none ${locked ? "" : "cursor-crosshair"}`}
|
||||
onPointerDown={(e) => {
|
||||
if (locked) return;
|
||||
e.currentTarget.setPointerCapture(e.pointerId);
|
||||
const { x, y } = at(e);
|
||||
setDrag({ x0: x, y0: y, x1: x, y1: y });
|
||||
}}
|
||||
onPointerMove={(e) => drag && setDrag({ ...drag, x1: at(e).x, y1: at(e).y })}
|
||||
onPointerUp={up}
|
||||
>
|
||||
<img src={image} alt="" draggable={false} className="block w-full" />
|
||||
{shown.x != null && shown.y != null && (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className="pointer-events-none absolute"
|
||||
style={
|
||||
shown.w && shown.h
|
||||
? {
|
||||
left: `${shown.x}%`,
|
||||
top: `${shown.y}%`,
|
||||
width: `${shown.w}%`,
|
||||
height: `${shown.h}%`,
|
||||
border: "2px solid var(--color-action)",
|
||||
background: "color-mix(in srgb, var(--color-action) 20%, transparent)",
|
||||
}
|
||||
: {
|
||||
left: `${shown.x}%`,
|
||||
top: `${shown.y}%`,
|
||||
width: 16,
|
||||
height: 16,
|
||||
transform: "translate(-50%, -50%)",
|
||||
borderRadius: "50%",
|
||||
background: "var(--color-action)",
|
||||
outline: "2px solid white",
|
||||
}
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<p className="notice p-3 text-sm text-muted">Add the venue's map above, then mark this location on it.</p>
|
||||
)}
|
||||
<div className="mt-2 flex flex-wrap items-center gap-3 text-xs text-muted">
|
||||
{number("x", "Left %")}
|
||||
{number("y", "Top %")}
|
||||
{number("w", "Width %")}
|
||||
{number("h", "Height %")}
|
||||
{mark.x != null && !locked && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onPatch({ x: null, y: null, w: null, h: null })}
|
||||
className="text-link hover:underline"
|
||||
>
|
||||
Clear mark
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -77,6 +77,15 @@
|
|||
Data → Links/redirects (the `redirects` options) that fills the
|
||||
field with the short link's full address, <site>/go/<URL ID>.
|
||||
|
||||
`fills: "text"` on a select fills that field of the row, while
|
||||
it's empty, with the picked option's label.
|
||||
|
||||
`widget: "mapMarker"` (on `x`) marks a venue's location on the
|
||||
map picture its parent row holds in `imageFrom`: a click is a
|
||||
pin (x, y), a drag a box (x, y, w, h), in percent (MapMarkerInput
|
||||
below). `lends` gets the form's options too, so a block can lend
|
||||
its venue's locations from the venues list.
|
||||
|
||||
`widget: "testNotice"` is a text box of email addresses with a
|
||||
"Send a test notice" button (TestNoticeInput below), for Site
|
||||
settings → Notices.
|
||||
|
|
@ -114,6 +123,9 @@ import ContentBlocks from "../ContentBlocks.tsx";
|
|||
import { FILTER_FROM, OptionFilter, narrow } from "../OptionFilter.tsx";
|
||||
import { ImageInput, LinkPreviewInput } from "./MediaLibrary.tsx";
|
||||
import { ChooseFileButton } from "./DriveFiles.tsx";
|
||||
import MapMarkerInput from "./MapMarkerInput.tsx";
|
||||
import { venueFromOption } from "../../lib/adminSchema/shared.ts";
|
||||
import { mediaUrl } from "../../lib/media.ts";
|
||||
import { siteUrl } from "../../lib/site.ts";
|
||||
|
||||
/* Live previews a collection can name with `preview`. Each gets the
|
||||
|
|
@ -122,21 +134,25 @@ const PREVIEWS = {
|
|||
// The form holds an entry's person as person_id; the renderer wants
|
||||
// the person, so it's looked up in the select options (a name, no
|
||||
// photo: the options carry no more).
|
||||
contentBlock: (row, options) => (
|
||||
<ContentBlocks
|
||||
blocks={[
|
||||
{
|
||||
...row,
|
||||
items: (row.items ?? []).map((item) => {
|
||||
const person = item.person_id
|
||||
? options?.people?.find((p) => p.id === item.person_id)
|
||||
: null;
|
||||
return { ...item, person: person ? { id: person.id, name: person.label } : null };
|
||||
}),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
),
|
||||
// A venue and an item's event and map location come from the
|
||||
// options the same way (088): an event as its title only.
|
||||
contentBlock: (row, options) => {
|
||||
const venue = venueFromOption(options?.venues?.find((v) => v.id === row.venue_id));
|
||||
const shape = (item) => {
|
||||
const person = item.person_id ? options?.people?.find((p) => p.id === item.person_id) : null;
|
||||
const event = item.event_id ? options?.events?.find((e) => e.id === item.event_id) : null;
|
||||
const location = venue?.locations.find((l) => l.key === item.location_key);
|
||||
return {
|
||||
...item,
|
||||
person: person ? { id: person.id, name: person.label } : null,
|
||||
event: event ? { id: event.id, title: event.label } : null,
|
||||
place: location ? { venue_id: venue!.id, key: location.key, name: location.name } : null,
|
||||
location: item.location || location?.name,
|
||||
items: (item.items ?? []).map(shape),
|
||||
};
|
||||
};
|
||||
return <ContentBlocks blocks={[{ ...row, venue, items: (row.items ?? []).map(shape) }]} />;
|
||||
},
|
||||
};
|
||||
|
||||
const input =
|
||||
|
|
@ -282,7 +298,7 @@ function Checklist({ id, options, value, disabled, empty, onChange }: {
|
|||
|
||||
/* ── Field ───────────────────────────────────────────────────── */
|
||||
|
||||
export function Field({ field, value, row, options, error, onChange, onPatch }: any) {
|
||||
export function Field({ field, value, row, parentRow, options, error, onChange, onPatch }: any) {
|
||||
const id = `f-${field.path.replace(/\./g, "-")}`;
|
||||
const widget = field.widget ?? "text";
|
||||
// readOnly may be a test of the row (a core page's address).
|
||||
|
|
@ -397,6 +413,14 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
|
|||
)}
|
||||
<select
|
||||
{...common}
|
||||
onChange={(e) => {
|
||||
// `fills`: a pick also fills that empty field of the
|
||||
// row with the option's label (a workshop's title).
|
||||
const picked = e.target.value;
|
||||
const label = list?.find(([optionId]) => String(optionId) === picked)?.[1];
|
||||
if (field.fills && picked && !row?.[field.fills] && onPatch) onPatch({ [field.path]: picked, [field.fills]: label });
|
||||
else onChange(picked);
|
||||
}}
|
||||
disabled={locked}
|
||||
className={`${locked ? inputLocked : common.className} ${
|
||||
orphaned && !locked ? inputError : ""
|
||||
|
|
@ -440,6 +464,13 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
|
|||
onChange={onChange}
|
||||
onPatch={onPatch}
|
||||
/>
|
||||
) : widget === "mapMarker" ? (
|
||||
<MapMarkerInput
|
||||
image={field.imageFrom ? mediaUrl(parentRow?.[field.imageFrom]) : null}
|
||||
row={row}
|
||||
locked={locked}
|
||||
onPatch={onPatch}
|
||||
/>
|
||||
) : widget === "testNotice" ? (
|
||||
<TestNoticeInput
|
||||
id={id}
|
||||
|
|
@ -805,6 +836,7 @@ export function Repeater({
|
|||
key={field.path}
|
||||
field={field}
|
||||
row={row}
|
||||
parentRow={parentRow}
|
||||
value={row[field.path]}
|
||||
options={options}
|
||||
error={errors?.[`${errorPrefix}${index}.${field.path}`]}
|
||||
|
|
@ -821,7 +853,7 @@ export function Repeater({
|
|||
<Repeater
|
||||
spec={nested}
|
||||
rows={row[nested.key]}
|
||||
options={spec.lends ? { ...options, ...spec.lends(row) } : options}
|
||||
options={spec.lends ? { ...options, ...spec.lends(row, options) } : options}
|
||||
errors={errors}
|
||||
errorPrefix={`${errorPrefix}${index}.${nested.key}.`}
|
||||
parentRow={row}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import { tags } from "./adminSchema/tags.ts";
|
|||
import { contactTypes } from "./adminSchema/contactTypes.ts";
|
||||
import { redirects } from "./adminSchema/redirects.ts";
|
||||
import { pages } from "./adminSchema/sitePages.ts";
|
||||
import { venues } from "./adminSchema/venues.ts";
|
||||
|
||||
export const ADMIN_ENTITIES: Record<string, any> = {
|
||||
organizations,
|
||||
|
|
@ -42,6 +43,7 @@ export const ADMIN_ENTITIES: Record<string, any> = {
|
|||
tags,
|
||||
contact_types: contactTypes,
|
||||
redirects,
|
||||
venues,
|
||||
teams,
|
||||
awards,
|
||||
timeline,
|
||||
|
|
|
|||
|
|
@ -309,6 +309,8 @@ export const BLOCK_TYPES = [
|
|||
["table", "Table", "A grid of text, eg. a comparison chart: one row per line, cells split by |, the first row the header."],
|
||||
["cards", "Link cards", "Cards with a picture, title and description, each a link to a page or a file, like a link shared in a chat; up to three in a row. Paste a link and press Fetch preview, or Choose a file."],
|
||||
["people", "People", "People tiles: a team's members, or people picked one by one as items (each with their title), or both."],
|
||||
["map", "Map", "A venue's map with its locations marked and listed beside it (Data → Venues). A schedule on the same page with the same venue links its locations here."],
|
||||
["events", "Events", "Event cards, eg. the workshops on offer: picture, type, date, title and card text, each linking to the event's page."],
|
||||
["divider", "Divider", "A thin line between parts."],
|
||||
];
|
||||
|
||||
|
|
@ -336,6 +338,42 @@ export const CARD_ITEM = { scope: "parent", path: "type", value: "cards" };
|
|||
export const NOT_CARD_ITEM = { scope: "parent", path: "type", value: ["list", "links", "schedule"] };
|
||||
/* An item that's a person on a people block. */
|
||||
export const PEOPLE_ITEM = { scope: "parent", path: "type", value: "people" };
|
||||
/* An item that's an event card on an events block (088). */
|
||||
export const EVENT_ITEM = { scope: "parent", path: "type", value: "events" };
|
||||
|
||||
/* A venues option (the /admin/options query) as a Venue: its
|
||||
locations arrive as JSON. */
|
||||
export const venueFromOption = (option) =>
|
||||
option
|
||||
? {
|
||||
id: option.id,
|
||||
name: option.label,
|
||||
map_image: option.map_image,
|
||||
map_alt: option.map_alt,
|
||||
locations: JSON.parse(option.locations || "[]"),
|
||||
}
|
||||
: null;
|
||||
|
||||
/* A schedule entry's or sub-item's workshop and place (088). */
|
||||
const eventField = (when?: any) => ({
|
||||
path: "event_id",
|
||||
label: "Event",
|
||||
widget: "select",
|
||||
optionsFrom: "events",
|
||||
fills: "text",
|
||||
blankLabel: "Default: none",
|
||||
help: "Optional: a workshop or other event this is. Its title fills an empty Title; its card text, photo, person host and page fill what's left blank here.",
|
||||
when,
|
||||
});
|
||||
const placeField = (when?: any) => ({
|
||||
path: "location_key",
|
||||
label: "Map location",
|
||||
widget: "select",
|
||||
optionsFrom: "mapLocations",
|
||||
blankLabel: "Default: none",
|
||||
help: "One of the block's venue's locations (the block's Venue, Data → Venues). Links to the map on the page and fills an empty Location.",
|
||||
when,
|
||||
});
|
||||
|
||||
export const blockTypeLabel = (type) => BLOCK_TYPES.find(([value]) => value === type)?.[1] ?? type;
|
||||
|
||||
|
|
@ -417,8 +455,10 @@ const TAGS_FIELD = {
|
|||
block's day. */
|
||||
const SUB_ITEM_FIELDS = [
|
||||
...scheduleTimeFields(),
|
||||
eventField(),
|
||||
{ path: "text", label: "Title", required: true },
|
||||
{ path: "location", label: "Location", help: "eg. Room B" },
|
||||
placeField(),
|
||||
{ path: "location", label: "Location", help: "eg. Room B. Default: the map location's name" },
|
||||
{
|
||||
path: "person_id",
|
||||
label: "Person",
|
||||
|
|
@ -546,13 +586,29 @@ export const blocksChild = {
|
|||
help: "Shows the team's members as tiles, its leads first. People added as items show after it.",
|
||||
when: { path: "type", value: "people" },
|
||||
},
|
||||
{
|
||||
path: "venue_id",
|
||||
label: "Venue",
|
||||
widget: "select",
|
||||
optionsFrom: "venues",
|
||||
blankLabel: "Default: none",
|
||||
help: (row) =>
|
||||
row?.type === "map"
|
||||
? "Whose map to show (Data → Venues). Without one the block shows nothing."
|
||||
: "Optional: the venue whose locations entries pick from (Data → Venues). With a Map block of it on the page, they link to it.",
|
||||
when: { path: "type", value: ["map", "schedule"] },
|
||||
},
|
||||
...wordFields("", "", { path: "type", value: ["heading", "subheading", "paragraph", "callout", "quote"] }),
|
||||
],
|
||||
// A schedule's tags, for its entries' and sub-items' Tags (087).
|
||||
lends: (row) => ({
|
||||
lends: (row, options) => ({
|
||||
scheduleTags: (row.tags ?? [])
|
||||
.filter((tag) => tag.name?.trim())
|
||||
.map((tag) => ({ id: tag.tag_key, label: tag.name })),
|
||||
// Its venue's locations, for entries' Map location (088).
|
||||
mapLocations: (venueFromOption(options?.venues?.find((v) => v.id === row.venue_id))?.locations ?? []).map(
|
||||
(location) => ({ id: location.key, label: location.name }),
|
||||
),
|
||||
}),
|
||||
children: [
|
||||
{
|
||||
|
|
@ -573,7 +629,7 @@ export const blocksChild = {
|
|||
key: "items",
|
||||
label: "Items",
|
||||
addLabel: "Add item",
|
||||
when: { path: "type", value: ["list", "links", "schedule", "cards", "people"] },
|
||||
when: { path: "type", value: ["list", "links", "schedule", "cards", "people", "events"] },
|
||||
title: (row) => [row.day, row.time || row.start_time, row.text].filter(Boolean).join(" · ") || "New item",
|
||||
blank: { text: "" },
|
||||
fields: [
|
||||
|
|
@ -613,11 +669,28 @@ export const blocksChild = {
|
|||
help: "Shown as a tile with their photo, linked to their page",
|
||||
when: PEOPLE_ITEM,
|
||||
},
|
||||
{ path: "text", label: "Text", required: true, help: "Schedules: the entry's title. Cards: the card's title. People: their title on the tile, eg. Speaker" },
|
||||
{
|
||||
path: "event_id",
|
||||
label: "Event",
|
||||
widget: "select",
|
||||
optionsFrom: "events",
|
||||
fills: "text",
|
||||
required: true,
|
||||
help: "The event the card shows and links to. An unpublished one is left out.",
|
||||
when: EVENT_ITEM,
|
||||
},
|
||||
eventField(SCHEDULE_ENTRY),
|
||||
{
|
||||
path: "text",
|
||||
label: "Text",
|
||||
required: true,
|
||||
help: "Schedules: the entry's title. Cards: the card's title. Events: the title shown, filled from the event. People: their title on the tile, eg. Speaker",
|
||||
},
|
||||
placeField(SCHEDULE_ENTRY),
|
||||
{
|
||||
path: "location",
|
||||
label: "Location",
|
||||
help: "eg. Main Hall",
|
||||
help: "eg. Main Hall. Default: the map location's name",
|
||||
when: SCHEDULE_ENTRY,
|
||||
},
|
||||
{
|
||||
|
|
@ -631,6 +704,7 @@ export const blocksChild = {
|
|||
},
|
||||
{ path: "detail", label: "Detail", help: "A line under the text. Lists: shown after the text", when: NOT_CARD_ITEM },
|
||||
{ path: "detail", label: "Description", widget: "textarea", full: true, when: CARD_ITEM },
|
||||
{ path: "detail", label: "Card text", widget: "textarea", full: true, help: "Default: the event's card text", when: EVENT_ITEM },
|
||||
{ path: "url", label: "URL", help: "Blank for plain text. Link buttons need one.", files: true, when: NOT_CARD_ITEM },
|
||||
{
|
||||
path: "media",
|
||||
|
|
|
|||
72
src/lib/adminSchema/venues.ts
Normal file
72
src/lib/adminSchema/venues.ts
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/* ── Venues (088_venues.sql) ─────────────────────────────────────
|
||||
Data → Venues: a place we gather, with one map picture and the
|
||||
locations marked on it (a pin or a box each). A Map content block
|
||||
draws it; a schedule block names it, and its entries pick one of
|
||||
its locations, linking to the map. Server side:
|
||||
server/src/admin-schema/venues.js. */
|
||||
|
||||
import { mediaUrl } from "../media.ts";
|
||||
|
||||
export const venues = {
|
||||
key: "venues",
|
||||
label: "Venues",
|
||||
singular: "venue",
|
||||
idLabel: "URL ID",
|
||||
slugFrom: "name",
|
||||
|
||||
list: {
|
||||
columns: [
|
||||
{ key: "name", label: "Name", primary: true },
|
||||
{ key: "address", label: "Address" },
|
||||
],
|
||||
filters: [],
|
||||
},
|
||||
|
||||
groups: [
|
||||
{
|
||||
legend: "Venue",
|
||||
fields: [
|
||||
{ path: "name", label: "Name", required: true, help: "eg. Camp Hebron" },
|
||||
{ path: "address", label: "Address", help: "Shown over the list of locations. Optional." },
|
||||
{
|
||||
path: "map_image",
|
||||
label: "Map",
|
||||
widget: "image",
|
||||
crop: "free",
|
||||
resolve: mediaUrl,
|
||||
full: true,
|
||||
help: "One picture of the whole place, eg. the camp's site plan. Locations are marked on it below.",
|
||||
},
|
||||
{
|
||||
path: "map_alt",
|
||||
label: "Map description",
|
||||
full: true,
|
||||
help: "For screen readers. Default: Map of <name>.",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
children: [
|
||||
{
|
||||
key: "locations",
|
||||
label: "Locations",
|
||||
addLabel: "Add location",
|
||||
note: "The places on the map, in the order they're listed. Schedule entries pick one of these.",
|
||||
title: (row) => row.name || "New location",
|
||||
blank: () => ({ location_key: crypto.randomUUID().slice(0, 8) }),
|
||||
fields: [
|
||||
{ path: "name", label: "Name", required: true, help: "eg. Main Hall" },
|
||||
{ path: "detail", label: "Detail", help: "A line under the name, eg. Upstairs, by the dining hall" },
|
||||
{
|
||||
path: "x",
|
||||
label: "On the map",
|
||||
widget: "mapMarker",
|
||||
imageFrom: "map_image",
|
||||
full: true,
|
||||
help: "Click the map for a pin, or drag out a box for an area. Default: listed, not marked.",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
|
@ -43,6 +43,8 @@ export type ContentBlock = {
|
|||
| 'tab'
|
||||
| 'cards'
|
||||
| 'people'
|
||||
| 'map'
|
||||
| 'events'
|
||||
text?: string | null
|
||||
media?: string | null
|
||||
href?: string | null
|
||||
|
|
@ -57,6 +59,43 @@ export type ContentBlock = {
|
|||
items?: ContentBlockItem[]
|
||||
/** A schedule's own tags (087). */
|
||||
tags?: ScheduleTag[]
|
||||
/** A map or schedule block's venue (088). */
|
||||
venue_id?: string | null
|
||||
venue?: Venue | null
|
||||
}
|
||||
|
||||
/** 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. */
|
||||
export type Venue = {
|
||||
id: string
|
||||
name: string
|
||||
address?: string | null
|
||||
map_image?: string | null
|
||||
map_alt?: string | null
|
||||
locations: VenueLocation[]
|
||||
}
|
||||
export type VenueLocation = {
|
||||
key: string
|
||||
name: string
|
||||
detail?: string | null
|
||||
x?: number | null
|
||||
y?: number | null
|
||||
w?: number | null
|
||||
h?: number | null
|
||||
}
|
||||
|
||||
/** An event an item names (088): an events block's card, or the
|
||||
* workshop a schedule entry is. */
|
||||
export type ItemEvent = {
|
||||
id: string
|
||||
title: string
|
||||
event_type?: string | null
|
||||
starts_on?: string | null
|
||||
ends_on?: string | null
|
||||
date_label?: string | null
|
||||
color?: string | null
|
||||
image?: string | null
|
||||
blurb?: string | null
|
||||
}
|
||||
|
||||
/** A schedule's tag (087). `tab` is whether it gets a tab of its own. */
|
||||
|
|
@ -89,6 +128,11 @@ export type ContentBlockItem = {
|
|||
items?: ContentBlockItem[]
|
||||
/** Its block's tags it has, by key (087). */
|
||||
tags?: string[]
|
||||
/** The event it is, and its place on the block's venue (088). */
|
||||
event_id?: string | null
|
||||
event?: ItemEvent | null
|
||||
location_key?: string | null
|
||||
place?: { venue_id: string; key: string; name: string } | null
|
||||
}
|
||||
|
||||
export type Link = {
|
||||
|
|
|
|||
|
|
@ -587,6 +587,7 @@ export default function EntityEdit() {
|
|||
options={options}
|
||||
errors={errors}
|
||||
errorPrefix={`${child.key}.`}
|
||||
parentRow={form}
|
||||
className=""
|
||||
onChange={(rows) => setForm((prev) => ({ ...prev, [child.key]: rows }))}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -90,6 +90,11 @@ export const DATA_NAV = {
|
|||
label: "Tags",
|
||||
blurb: "Descriptors for organizations and events, eg. Online, In-Person. Who carries a tag is edited on the record.",
|
||||
},
|
||||
{
|
||||
to: "/admin/venues",
|
||||
label: "Venues",
|
||||
blurb: "Places we gather, each with a map and its locations marked, for map blocks and schedules.",
|
||||
},
|
||||
{
|
||||
to: "/admin/redirects",
|
||||
label: "Links/redirects",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue