Feature fixes: admin nav, hero event, schedule block, SEO, site settings, Google sign-in, QR tool #12

Merged
ngu-git-admin merged 14 commits from feature-fixes into main 2026-09-28 08:12:29 +01:00
10 changed files with 556 additions and 29 deletions
Showing only changes of commit 71a470b66f - Show all commits

View file

@ -175,7 +175,7 @@ also in `admin-schema.js` and a CHECK):
| Links → Kind (on organizations, events, people, teams) | action, social, website, email | no | `splitLinks` in `server/src/shape.js` |
| Links → Platform | instagram, facebook, discord, youtube, tiktok, x, substack, spotify, linkedin | **yes**, `PLATFORMS` | `PlatformIcon.tsx` draws the icon on the button. **No CHECK and no `enumeration`**: the column is plain text, so adding one is an entry in `PLATFORMS` (`src/lib/platforms.ts`) and its icon in `src/components/PlatformIcon.tsx`, no migration. |
| Content blocks → Shown in (slot) | card, body | **yes** | `paragraphs()` in `server/src/shape.js` (card), `ContentBlocks.tsx` (body) |
| Content blocks → Type | heading, subheading, paragraph, list, links, quote, image, divider, video, button, callout | **yes**, `BLOCK_TYPES` (with each type's description) | `ContentBlocks.tsx` (one renderer per type). Which fields each type shows is `when` on the fields in `blocksChild` (`src/lib/adminSchema.ts`). |
| Content blocks → Type | heading, subheading, paragraph, list, links, quote, image, divider, video, button, callout, schedule | **yes**, `BLOCK_TYPES` (with each type's description) | `ContentBlocks.tsx` (one renderer per type). Which fields each type shows is `when` on the fields in `blocksChild` (`src/lib/adminSchema.ts`). |
| Timeline → Kind (+ list filter) | milestone, event, organization, award, people | no | `KIND_NAMES` in `src/pages/sections/history/TimelineEntry.tsx` |
| Timeline → Points at (+ list filter) | event, organization, award, person, team | no | `refHref` in `src/lib/hrefs.ts` |
| Timeline → Precision (and on events/orgs) | year, month, day | no | the history page's grouping |

View file

@ -179,6 +179,7 @@ const blocksChild = (ownerKind) => ({
"video",
"button",
"callout",
"schedule",
],
{ required: true },
),
@ -198,6 +199,14 @@ const blocksChild = (ownerKind) => ({
text("text", { required: true }),
text("detail"),
text("url"),
// Schedule entries only (034_schedule_block.sql).
text("day"),
text("time"),
text("location"),
text("person_id"),
text("description"),
text("media"),
text("map"),
],
},
],

View file

@ -0,0 +1,99 @@
-- ═══════════════════════════════════════════════════════════════
-- 034 CONTENT BLOCKS: SCHEDULE
--
-- A 'schedule' block: the block's items are its entries, grouped
-- into one tab per day. Each entry says when, what and where, and
-- folds out for more. The block's own text is an optional intro.
--
-- content_block_items gains the entry's fields. A list or link-row
-- block leaves them empty:
--
-- day the tab it sits under, eg. 'Friday'. Tabs follow
-- the order entries are in; blank means one untitled
-- day, and a schedule of one day draws no tabs
-- time '7:00pm', '9:00 to 10:30am': shown as typed
-- location where it happens, eg. 'Main Hall'
-- person_id who hosts or speaks: a people row, drawn with its
-- photo and linked to its page. ON DELETE SET NULL,
-- and an unpublished person isn't shown
-- description the fold-out text, formatted like a paragraph
-- media a graphic in the fold-out: '/uploads/…' or a URL
-- map a place or address to show on a Google map in the
-- fold-out, eg. 'Camp Hebron, Halifax PA'
--
-- text is the entry's title, detail a line under it, url a link on
-- the title, as for list items.
--
-- The type list is a CHECK, so content_blocks is rebuilt the way
-- 031 and 032 did it (legacy_alter_table around the rename, then
-- the index and the owner trigger again). The item columns are
-- plain ADD COLUMNs.
--
-- PRAGMA user_version; -- reads 33 before this file
-- ═══════════════════════════════════════════════════════════════
CREATE TABLE content_blocks_new (
id INTEGER PRIMARY KEY AUTOINCREMENT,
owner_kind TEXT NOT NULL
CHECK (owner_kind IN ('organization', 'event', 'person', 'team', 'blog_post')),
owner_id TEXT NOT NULL,
slot TEXT NOT NULL DEFAULT 'body' CHECK (slot IN ('card', 'body')),
sort_order INTEGER NOT NULL DEFAULT 0,
type TEXT NOT NULL
CHECK (type IN ('heading', 'subheading', 'paragraph',
'list', 'links', 'quote', 'image', 'divider',
'video', 'button', 'callout', 'schedule')),
text TEXT,
media TEXT,
href TEXT,
alt TEXT,
cite TEXT
) STRICT;
INSERT INTO content_blocks_new
(id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite)
SELECT id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite
FROM content_blocks;
PRAGMA legacy_alter_table = ON;
DROP TABLE content_blocks;
ALTER TABLE content_blocks_new RENAME TO content_blocks;
PRAGMA legacy_alter_table = OFF;
CREATE INDEX content_blocks_owner_idx
ON content_blocks (owner_kind, owner_id, slot, sort_order);
ALTER TABLE content_block_items ADD COLUMN day TEXT;
ALTER TABLE content_block_items ADD COLUMN time TEXT;
ALTER TABLE content_block_items ADD COLUMN location TEXT;
ALTER TABLE content_block_items ADD COLUMN person_id TEXT
REFERENCES people (id) ON DELETE SET NULL;
ALTER TABLE content_block_items ADD COLUMN description TEXT;
ALTER TABLE content_block_items ADD COLUMN media TEXT;
ALTER TABLE content_block_items ADD COLUMN map TEXT;
-- ── Triggers last (see CLAUDE.md, Migrations) ──
CREATE TRIGGER content_blocks_owner_exists
BEFORE INSERT ON content_blocks
BEGIN
SELECT CASE
WHEN new.owner_kind = 'event'
AND NOT EXISTS (SELECT 1 FROM events WHERE id = new.owner_id)
THEN RAISE(ABORT, 'content_blocks: no such event')
WHEN new.owner_kind = 'organization'
AND NOT EXISTS (SELECT 1 FROM organizations WHERE id = new.owner_id)
THEN RAISE(ABORT, 'content_blocks: no such organization')
WHEN new.owner_kind = 'person'
AND NOT EXISTS (SELECT 1 FROM people WHERE id = new.owner_id)
THEN RAISE(ABORT, 'content_blocks: no such person')
WHEN new.owner_kind = 'team'
AND NOT EXISTS (SELECT 1 FROM teams WHERE id = new.owner_id)
THEN RAISE(ABORT, 'content_blocks: no such team')
WHEN new.owner_kind = 'blog_post'
AND NOT EXISTS (SELECT 1 FROM blog_posts WHERE id = new.owner_id)
THEN RAISE(ABORT, 'content_blocks: no such blog post')
END;
END;

View file

@ -16,7 +16,8 @@
/people/showcase-person person: bio, links, roles past and
current, events, awards, private data
/events/showcase-event upcoming retreat: hosts, billed
people, links, blocks, background
people, links, blocks, background,
a three-day schedule
/events/showcase-series weekly series with times
/events/showcase-past-event past event where the award was given
/blog/content-block-showcase every content block type
@ -81,6 +82,23 @@ const PAST = "showcase-past-event";
/* ── Content ───────────────────────────────────────────────── */
/* A schedule over three days, using every entry field: a plain
entry, one with a location and person, one folding out with a
description, graphic and map, one linked, and one with no day
(it lands in a tab of its own). */
const SCHEDULE = [
"schedule",
{ text: "The weekend at a glance. Tap an entry for more." },
[
{ day: "Friday", time: "4:00pm", text: "Arrivals and check-in", location: "Front desk" },
{ day: "Friday", time: "7:00 to 8:30pm", text: "Opening session", location: "Main Hall", person_id: "showcase-person", detail: "Welcome and worship", description: "The **opening session** sets the theme for the weekend.\n\nBring a notebook.", media: "/uploads/showcase.jpg", map: "Camp Hebron, Halifax PA" },
{ day: "Saturday", time: "9:00am", text: "Workshops", location: "Classrooms", person_id: "showcase-member-2", detail: "Pick one of three", url: "/blog/content-block-showcase" },
{ day: "Saturday", time: "7:00pm", text: "Talent night", location: "Main Hall", person_id: "showcase-member-3", description: "Sign up at the front desk by noon." },
{ day: "Sunday", time: "10:00am", text: "Closing service", location: "Chapel", map: "Main Street, Halifax PA" },
{ time: "Any time", text: "Quiet room open", location: "Library", detail: "An entry with no day" },
],
];
/* Every block type, for the blog showcase. [type, fields, items?] */
const ALL_BLOCKS = [
["paragraph", { text: "Every content block type, top to bottom, with each of its options. Use it to check the page after changing how blocks draw." }],
@ -109,6 +127,8 @@ const ALL_BLOCKS = [
["subheading", { text: "Images" }],
["image", { media: IMAGE, alt: "Describe the picture here", text: "An image with a caption and alt text" }],
["image", { media: IMAGE, alt: "The same picture, linked", href: "/history" }],
["subheading", { text: "Schedule" }],
SCHEDULE,
["subheading", { text: "Video" }],
["video", { href: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", text: "A YouTube video, with its own thumbnail" }],
["video", { href: "https://vimeo.com/76979871", media: IMAGE, text: "A Vimeo video with an uploaded still" }],
@ -354,7 +374,7 @@ tx(db, () => {
{ kind: "social", platform: "instagram", label: "@showcaseretreat", url: "https://instagram.com/showcaseretreat" },
]);
blocks("event", EVENT, "card", cardText("event"));
blocks("event", EVENT, "body", pageBody("event"));
blocks("event", EVENT, "body", [...pageBody("event"), ["heading", { text: "Schedule" }], SCHEDULE]);
insert("events", {
id: SERIES,

View file

@ -98,18 +98,39 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
const itemRows = db
.prepare(
`SELECT block_id, text, detail, url
FROM content_block_items
WHERE block_id IN (${placeholders(blockIds.length)})
ORDER BY block_id, sort_order`,
`SELECT i.block_id, i.text, i.detail, i.url,
i.day, i.time, i.location, i.description, i.media, i.map,
p.id AS person_id, p.display_name AS person_name,
p.photo AS person_photo, p.tagline AS person_tagline
FROM content_block_items i
LEFT JOIN people p ON p.id = i.person_id AND p.is_published = 1
WHERE i.block_id IN (${placeholders(blockIds.length)})
ORDER BY i.block_id, i.sort_order`,
)
.all(...blockIds);
// The schedule fields are null on a list or link-row item; they
// ride along anyway rather than branching on the block's type.
// An unpublished person comes back as no person.
for (const row of itemRows) {
byId.get(row.block_id)?.items.push({
text: row.text,
detail: row.detail,
url: row.url,
day: row.day,
time: row.time,
location: row.location,
description: row.description,
media: row.media,
map: row.map,
person: row.person_id
? {
id: row.person_id,
name: row.person_name,
photo: row.person_photo,
tagline: row.person_tagline,
}
: null,
});
}

View file

@ -19,6 +19,10 @@
image media, alt, text is the caption, href
video href is the video, media a still, text
the caption; click to play
schedule items as entries in day tabs (day, time,
text, detail, url, location, person, and
a fold-out of description, media, map);
text is an optional intro. ScheduleBlock
divider nothing
"Formatted" is InlineText.tsx: **bold**, *italic*, [text](url),
@ -33,6 +37,7 @@ import { blockMedia } from '../lib/media.ts'
import type { ContentBlock } from '../lib/useContent.ts'
import { Anchor, Inline, Paragraphs } from './InlineText.tsx'
import VideoPlayer from './VideoPlayer.tsx'
import ScheduleBlock from './ScheduleBlock.tsx'
const BODY = '#4a6b72'
@ -196,6 +201,10 @@ function Block({ block, accent }: { block: ContentBlock; accent: string }) {
</figure>
)
case 'schedule':
if (!block.items?.length) return null
return <ScheduleBlock items={block.items} intro={block.text} accent={accent} />
case 'divider':
return <hr className="border-0 h-px" style={{ background: accent, opacity: 0.3 }} />

View file

@ -0,0 +1,270 @@
/* ═══════════════════════════════════════════════════════════════
SCHEDULE BLOCK
The 'schedule' content block (034_schedule_block.sql): entries
in one tab per day, each a row of time, title, place and person,
folding out for the rest.
Tabs are the entries' `day` values in the order they first
appear, so the admin's order is the page's. An entry with no day
joins an untitled group; a schedule of one day draws no tabs. The
tab whose name starts with today's weekday opens first ("Friday",
"Fri", "Friday, June 6"), so on the day of an event the visitor
lands on today; otherwise the first tab.
A row folds out when it has anything more to show: a
description, a graphic, a map, or a person (their photo, tagline
and a link to their page). The map is Google's key-free embed of
the place typed in, with a link out to the full map.
Tabs follow the ARIA tab pattern: arrow keys move between them.
═══════════════════════════════════════════════════════════════ */
import { useId, useState, type KeyboardEvent } from 'react'
import { Link } from 'react-router-dom'
import { personHref } from '../lib/hrefs.ts'
import { blockMedia, initials, personPhoto } from '../lib/media.ts'
import type { ContentBlockItem } from '../lib/useContent.ts'
import { Anchor, Paragraphs } from './InlineText.tsx'
const BODY = '#4a6b72'
const WEEKDAYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
type Day = { name: string; entries: ContentBlockItem[] }
function groupByDay(items: ContentBlockItem[]): Day[] {
const days: Day[] = []
for (const item of items) {
const name = item.day?.trim() ?? ''
let day = days.find((d) => d.name === name)
if (!day) {
day = { name, entries: [] }
days.push(day)
}
day.entries.push(item)
}
return days
}
/* The tab to open with: today's weekday if a tab starts with it (or
its three-letter form), else the first. */
function todayIndex(days: Day[]): number {
const today = WEEKDAYS[new Date().getDay()]
const found = days.findIndex((day) => {
const name = day.name.toLowerCase()
return name.startsWith(today) || name.startsWith(today.slice(0, 3))
})
return found >= 0 ? found : 0
}
const mapEmbed = (place: string) =>
`https://maps.google.com/maps?q=${encodeURIComponent(place)}&output=embed`
const mapLink = (place: string) =>
`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(place)}`
function Avatar({ person, size }: { person: NonNullable<ContentBlockItem['person']>; size: string }) {
const [failed, setFailed] = useState(false)
const src = personPhoto(person.photo)
return src && !failed ? (
<img src={src} alt="" onError={() => setFailed(true)} className={`${size} shrink-0 rounded-full object-cover`} />
) : (
<span
aria-hidden="true"
className={`${size} flex shrink-0 items-center justify-center rounded-full bg-[#eef9fb] text-xs font-bold text-[#138ba0]`}
>
{initials(person.name)}
</span>
)
}
function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
const [open, setOpen] = useState(false)
const panelId = useId()
const graphic = blockMedia(entry.media)
const place = entry.map?.trim()
const more = Boolean(entry.description || graphic || place || entry.person)
const title = entry.url ? (
<Anchor href={entry.url} className="underline-offset-2 hover:underline" style={{ color: accent }}>
{entry.text}
</Anchor>
) : (
entry.text
)
return (
<li className="border-b border-[#138ba0]/10 last:border-b-0">
<div className="flex gap-4 py-4 sm:gap-6">
<p className="w-24 shrink-0 pt-0.5 text-sm font-semibold sm:w-32" style={{ color: accent }}>
{entry.time}
</p>
<div className="min-w-0 flex-1">
<p className="font-semibold text-[#26454c]">{title}</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>}
{entry.person && (
<span className="inline-flex items-center gap-2">
<Avatar person={entry.person} size="h-6 w-6" />
{entry.person.name}
</span>
)}
</p>
)}
{entry.detail && (
<p className="mt-1 text-sm" style={{ color: BODY }}>
{entry.detail}
</p>
)}
</div>
{more && (
<button
type="button"
onClick={() => setOpen((o) => !o)}
aria-expanded={open}
aria-controls={panelId}
aria-label={open ? `Less about ${entry.text}` : `More about ${entry.text}`}
className="h-8 w-8 shrink-0 rounded-full border text-sm transition-colors hover:bg-[#eef9fb]"
style={{ borderColor: `${accent}55`, color: accent }}
>
<span aria-hidden="true" className={`inline-block transition-transform ${open ? 'rotate-180' : ''}`}>
▾
</span>
</button>
)}
</div>
{more && open && (
<div id={panelId} className="mb-5 space-y-5 rounded-2xl bg-[#f6fbfc] p-5 sm:ml-38">
{entry.person && (
<div className="flex items-center gap-4">
<Avatar person={entry.person} size="h-16 w-16" />
<div>
<Link
to={personHref(entry.person.id)}
className="font-semibold hover:underline"
style={{ color: accent }}
>
{entry.person.name}
</Link>
{entry.person.tagline && (
<p className="text-sm" style={{ color: BODY }}>
{entry.person.tagline}
</p>
)}
</div>
</div>
)}
{entry.description && (
<div className="space-y-3 leading-relaxed" style={{ color: BODY }}>
<Paragraphs text={entry.description} accent={accent} />
</div>
)}
{graphic && <img src={graphic} alt="" loading="lazy" className="w-full rounded-lg" />}
{place && (
<div>
<iframe
src={mapEmbed(place)}
title={`Map: ${place}`}
loading="lazy"
referrerPolicy="no-referrer-when-downgrade"
className="aspect-video w-full rounded-lg border-0"
/>
<a
href={mapLink(place)}
target="_blank"
rel="noreferrer"
className="mt-2 inline-block text-sm underline"
style={{ color: accent }}
>
Open in Google Maps
</a>
</div>
)}
</div>
)}
</li>
)
}
export default function ScheduleBlock({
items,
intro,
accent,
}: {
items: ContentBlockItem[]
intro?: string | null
accent: string
}) {
const days = groupByDay(items)
const [active, setActive] = useState(() => todayIndex(days))
const baseId = useId()
if (days.length === 0) return null
const current = days[Math.min(active, days.length - 1)]
const onKey = (e: KeyboardEvent<HTMLButtonElement>) => {
const step = e.key === 'ArrowRight' ? 1 : e.key === 'ArrowLeft' ? -1 : 0
if (!step) return
e.preventDefault()
const next = (active + step + days.length) % days.length
setActive(next)
document.getElementById(`${baseId}-tab-${next}`)?.focus()
}
return (
<div className="space-y-4">
{intro && (
<div className="space-y-3 leading-relaxed" style={{ color: BODY }}>
<Paragraphs text={intro} accent={accent} />
</div>
)}
{days.length > 1 && (
<div role="tablist" aria-label="Days" className="flex flex-wrap gap-2">
{days.map((day, index) => {
const selected = day === current
return (
<button
key={day.name || index}
id={`${baseId}-tab-${index}`}
type="button"
role="tab"
aria-selected={selected}
aria-controls={`${baseId}-panel`}
tabIndex={selected ? 0 : -1}
onClick={() => setActive(index)}
onKeyDown={onKey}
className="rounded-full border px-5 py-2 text-sm font-semibold transition-colors"
style={
selected
? { background: accent, borderColor: accent, color: '#ffffff' }
: { borderColor: `${accent}55`, color: accent }
}
>
{day.name || 'Schedule'}
</button>
)
})}
</div>
)}
<ul
id={`${baseId}-panel`}
role={days.length > 1 ? 'tabpanel' : undefined}
aria-labelledby={days.length > 1 ? `${baseId}-tab-${days.indexOf(current)}` : undefined}
className="rounded-2xl border border-[#138ba0]/15 bg-white px-5"
>
{current.entries.map((entry, index) => (
<Entry key={`${current.name}-${index}`} entry={entry} accent={accent} />
))}
</ul>
</div>
)
}

View file

@ -32,12 +32,17 @@
can't keep a value for a choice it no longer makes: a featured
card switched from "record" to "link" drops its record.
`when: { scope: "parent", path, value }` looks at the row this
collection belongs to instead: a schedule entry shows its day and
time only while the block above it is a schedule.
A nested collection takes `when` the same way, and one that goes
hidden is emptied: a list block turned into a paragraph drops its
items.
`help` may be a function of the row, for help that depends on
another field (a content block's type says what its text is).
`help` and `label` may be functions of the row, for wording that
depends on another field (a content block's type says what its
text is).
`preview` on a collection names an entry in PREVIEWS below; each
open row then shows how it will look on the site, drawn by the
@ -78,7 +83,24 @@ import { ImageInput, LinkPreviewInput } from "./MediaLibrary.tsx";
/* Live previews a collection can name with `preview`. Each gets the
row as the form holds it, which is the API's shape. */
const PREVIEWS = {
contentBlock: (row) => <ContentBlocks blocks={[row]} />,
// 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 };
}),
},
]}
/>
),
};
const input =
@ -118,25 +140,33 @@ export function setPath(object, path, value) {
/* ── Conditional fields ──────────────────────────────────────── */
export function fieldShown(field, row) {
export function fieldShown(field, row, parent?) {
if (!field.when) return true;
const want = Array.isArray(field.when.value) ? field.when.value : [field.when.value];
return want.includes(row?.[field.when.path]);
const source = field.when.scope === "parent" ? parent : row;
return want.includes(source?.[field.when.path]);
}
/* A row after an edit, with any field the edit hid cleared. "" is
the engine's deliberate clear, so it saves as NULL. */
function withHiddenCleared(spec, row) {
function withHiddenCleared(spec, row, parent?) {
let next = row;
for (const field of spec.fields) {
const value = next[field.path];
if (!fieldShown(field, next) && value != null && value !== "") {
if (!fieldShown(field, next, parent) && value != null && value !== "") {
next = { ...next, [field.path]: "" };
}
}
for (const nested of spec.children ?? []) {
if (!fieldShown(nested, next) && next[nested.key]?.length) {
const rows = next[nested.key];
if (!rows?.length) continue;
if (!fieldShown(nested, next, parent)) {
next = { ...next, [nested.key]: [] };
} else {
// Its rows may have fields that follow this row (scope
// "parent"), which this edit may just have hidden.
const cleared = rows.map((child) => withHiddenCleared(nested, child, next));
if (cleared.some((child, i) => child !== rows[i])) next = { ...next, [nested.key]: cleared };
}
}
return next;
@ -197,7 +227,7 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
return (
<div className={field.full ? "sm:col-span-2" : ""}>
<label htmlFor={id} className="block text-sm font-medium text-[#26454c]">
{field.label}
{typeof field.label === "function" ? field.label(row) : field.label}
{field.required && !locked && <span className="ml-1 text-[#b3261e]">*</span>}
</label>
@ -357,6 +387,7 @@ export function Repeater({
errorPrefix,
onChange,
className = "mt-8",
parentRow = undefined,
}: any) {
const list = rows ?? [];
@ -382,7 +413,7 @@ export function Repeater({
const rowRefs = useRef<any[]>([]);
const update = (index, next) =>
onChange(list.map((row, i) => (i === index ? withHiddenCleared(spec, next) : row)));
onChange(list.map((row, i) => (i === index ? withHiddenCleared(spec, next, parentRow) : row)));
const move = (index, delta) => {
const target = index + delta;
@ -593,7 +624,7 @@ export function Repeater({
<>
<FieldGrid>
{spec.fields
.filter((field) => fieldShown(field, row))
.filter((field) => fieldShown(field, row, parentRow))
.map((field) => (
<Field
key={field.path}
@ -609,7 +640,7 @@ export function Repeater({
</FieldGrid>
{(spec.children ?? [])
.filter((nested) => fieldShown(nested, row))
.filter((nested) => fieldShown(nested, row, parentRow))
.map((nested) => (
<div key={nested.key} className="mt-4 border-t border-[#4a6b72]/15 pt-4">
<Repeater
@ -618,6 +649,7 @@ export function Repeater({
options={options}
errors={errors}
errorPrefix={`${errorPrefix}${index}.${nested.key}.`}
parentRow={row}
className=""
onChange={(value) => update(index, { ...row, [nested.key]: value })}
/>
@ -629,7 +661,7 @@ export function Repeater({
<p className="mb-3 text-xs font-semibold uppercase tracking-wider text-[#4a6b72]/70">
Preview
</p>
{PREVIEWS[spec.preview](row)}
{PREVIEWS[spec.preview](row, options)}
</div>
)}
</>

View file

@ -302,12 +302,16 @@ const BLOCK_TYPES = [
["button", "Button", "One filled call-to-action button, eg. Register, Donate."],
["image", "Image", "A picture, with alt text and an optional caption and link."],
["video", "Video", "A YouTube, Vimeo or Facebook video, or a video file, played in place."],
["schedule", "Schedule", "Entries in one tab per day, each folding out for more. The text is an optional intro."],
["divider", "Divider", "A thin line between parts."],
];
/* An item field that only a schedule's entries have. */
const SCHEDULE_ENTRY = { scope: "parent", path: "type", value: "schedule" };
const blockTypeLabel = (type) => BLOCK_TYPES.find(([value]) => value === type)?.[1] ?? type;
const TEXT_TYPES = ["paragraph", "heading", "subheading", "callout", "quote", "button", "image", "video"];
const TEXT_TYPES = ["paragraph", "heading", "subheading", "callout", "quote", "button", "image", "video", "schedule"];
const TEXT_HELP = {
paragraph: FORMATTING_HELP,
@ -316,9 +320,10 @@ const TEXT_HELP = {
button: "The button's label, eg. Register now",
image: "Caption shown under the image. Optional.",
video: "Caption shown under the video. Optional.",
schedule: "Optional intro above the tabs. " + FORMATTING_HELP,
};
const TEXT_LABEL = { button: "Label", image: "Caption", video: "Caption" };
const TEXT_LABEL = { button: "Label", image: "Caption", video: "Caption", schedule: "Intro" };
const HREF_HELP = {
paragraph: "Optional. Makes the whole paragraph one link. For a link inside the text, use [text](url).",
@ -357,7 +362,7 @@ const blocksChild = {
},
{
path: "text",
label: "Text",
label: (row) => TEXT_LABEL[row?.type] ?? "Text",
widget: "textarea",
full: true,
when: { path: "type", value: TEXT_TYPES },
@ -400,13 +405,59 @@ const blocksChild = {
key: "items",
label: "Items",
addLabel: "Add item",
when: { path: "type", value: ["list", "links"] },
title: (row) => row.text || "New item",
when: { path: "type", value: ["list", "links", "schedule"] },
title: (row) => [row.day, row.time, row.text].filter(Boolean).join(" · ") || "New item",
blank: { text: "" },
fields: [
{ path: "text", label: "Text", required: true },
{ path: "detail", label: "Detail", help: "Lists only: shown after the text" },
{ path: "url", label: "URL", help: "Blank for a plain list item. Link buttons need one." },
{
path: "day",
label: "Day",
help: "The tab it's under, eg. Friday. Entries with the same day share a tab, in this order.",
when: SCHEDULE_ENTRY,
},
{ path: "time", label: "Time", help: "eg. 7:00pm, or 9:00 to 10:30am", when: SCHEDULE_ENTRY },
{ path: "text", label: "Text", required: true, help: "Schedules: the entry's title" },
{
path: "location",
label: "Location",
help: "eg. Main Hall",
when: SCHEDULE_ENTRY,
},
{
path: "person_id",
label: "Person",
widget: "select",
optionsFrom: "people",
blankLabel: "Default: none",
help: "Who hosts or speaks: shown with their photo, linked to their page",
when: SCHEDULE_ENTRY,
},
{ path: "detail", label: "Detail", help: "A line under the text. Lists: shown after the text" },
{ path: "url", label: "URL", help: "Blank for plain text. Link buttons need one." },
{
path: "description",
label: "More",
widget: "textarea",
full: true,
help: "Shown when the entry is folded out. " + FORMATTING_HELP,
when: SCHEDULE_ENTRY,
},
{
path: "media",
label: "Graphic",
widget: "image",
resolve: blockMedia,
full: true,
help: "Optional, in the fold-out: a map of the site, a slide, a poster",
when: SCHEDULE_ENTRY,
},
{
path: "map",
label: "Map",
full: true,
help: "Optional, in the fold-out: a place or address for a Google map, eg. Camp Hebron, Halifax PA",
when: SCHEDULE_ENTRY,
},
],
},
],

View file

@ -34,6 +34,7 @@ export type ContentBlock = {
| 'video'
| 'button'
| 'callout'
| 'schedule'
text?: string | null
media?: string | null
href?: string | null
@ -41,7 +42,22 @@ export type ContentBlock = {
alt?: string | null
/** Who a quote is by. */
cite?: string | null
items?: Array<{ text: string; detail?: string | null; url?: string | null }>
items?: ContentBlockItem[]
}
/** A list, link-row or schedule entry. The schedule fields are
* empty on the other two (034_schedule_block.sql). */
export type ContentBlockItem = {
text: string
detail?: string | null
url?: string | null
day?: string | null
time?: string | null
location?: string | null
description?: string | null
media?: string | null
map?: string | null
person?: { id: string; name: string; photo?: string | null; tagline?: string | null } | null
}
export type Link = {