Compare commits

..

No commits in common. "1edc82fcf7f246d152470e6491b0a0b4c10e4101" and "970730de2029ee57c9132333379c41a1974e0c03" have entirely different histories.

45 changed files with 289 additions and 1610 deletions

View file

@ -15,14 +15,6 @@ in the `media` table (`server/src/migrations/028_media.sql`).
- **Keep original** stores the file exactly as uploaded (up to 10 MB), - **Keep original** stores the file exactly as uploaded (up to 10 MB),
metadata and all. metadata and all.
- SVGs are always kept as they are. - SVGs are always kept as they are.
- A photo field with a shape (people, event photos and card
backgrounds, blog covers, hero photos, link card pictures, block
images and schedule graphics; not logos) opens **Frame the photo**
before uploading a JPEG, PNG or WebP: drag and zoom it inside the
field's shape, or pick another (As uploaded keeps the photo's own).
The framed part is what's uploaded; nothing about the framing is
saved, so framing again means uploading again. Upload as is skips
it. A field's shape is its `crop` option (`src/components/admin/fields.tsx`).
- Accepted types: JPEG, PNG, GIF, WebP, SVG, and WebVTT captions - Accepted types: JPEG, PNG, GIF, WebP, SVG, and WebVTT captions
(`.vtt`, kept as they are, always in `captions/`). The type is read (`.vtt`, kept as they are, always in `captions/`). The type is read
from the file's contents, not its name: a captions file has to start from the file's contents, not its name: a captions file has to start

View file

@ -29,7 +29,6 @@ what a dropdown in the admin editor says.
| ------------------------------------------------------------ | ---------------- | ------------------------------------ | | ------------------------------------------------------------ | ---------------- | ------------------------------------ |
| A record: an event, organization, person, team, award, timeline entry | the database | editing it in the admin | | A record: an event, organization, person, team, award, timeline entry | the database | editing it in the admin |
| People tags (directories, eg. Musicians, at `/directory/<tag>`) and contact types (Minister, General info), and organizations' contacts | the database | Admin → Data → People tags, Contact types; who carries a tag is set on the person, contacts on the organization | | People tags (directories, eg. Musicians, at `/directory/<tag>`) and contact types (Minister, General info), and organizations' contacts | the database | Admin → Data → People tags, Contact types; who carries a tag is set on the person, contacts on the organization |
| Tags for organizations and events (Online, In-Person; URL ID `online` marks an event online for the calendar filter) | the database | Admin → Data → Tags; who carries a tag is set on the organization or event |
| The front page's words, photos, bands, stats and paths | the database | Admin → Pages → Front page | | The front page's words, photos, bands, stats and paths | the database | Admin → Pages → Front page |
| Blog posts, and the Community page's blog settings (headings, pins, feeds) | the database | Admin → Data → Blog posts, and Admin → Pages → Community | | Blog posts, and the Community page's blog settings (headings, pins, feeds) | the database | Admin → Data → Blog posts, and Admin → Pages → Community |
| The sections of Retreats, Community, Resources, Organization and History: titles, blurbs, accents, their content blocks and presets (the blog, groups map, regions, partners, events, timeline, a people directory) | the database | Admin → Pages → the page. A section title is 30 characters at most (it's listed in the side nav); a front page heading fits about 60. Preset names: `PRESETS` in `src/lib/adminSchema/sitePages.ts`, what each draws: `PRESETS` in `src/pages/SitePage.tsx` | | The sections of Retreats, Community, Resources, Organization and History: titles, blurbs, accents, their content blocks and presets (the blog, groups map, regions, partners, events, timeline, a people directory) | the database | Admin → Pages → the page. A section title is 30 characters at most (it's listed in the side nav); a front page heading fits about 60. Preset names: `PRESETS` in `src/lib/adminSchema/sitePages.ts`, what each draws: `PRESETS` in `src/pages/SitePage.tsx` |
@ -205,7 +204,6 @@ code):
| Group → Region | `regions` | organizations of kind region | | Group → Region | `regions` | organizations of kind region |
| Group → Ministry | `ministries` | organizations of kind ministry | | Group → Ministry | `ministries` | organizations of kind ministry |
| People → Directories → Tag; Pages → Sections → Directory: tag | `person_tag_types` | Data → People tags | | People → Directories → Tag; Pages → Sections → Directory: tag | `person_tag_types` | Data → People tags |
| Organizations and Events → Tags → Tag | `tags` | Data → Tags |
| Organizations → Contacts → Type | `contact_types` | Data → Contact types | | Organizations → Contacts → Type | `contact_types` | Data → Contact types |
| Event → Scope (+ list filter); Front page → Countdown → Only this scope | `event_scopes` | the `event_scopes` table (migration only) | | Event → Scope (+ list filter); Front page → Countdown → Only this scope | `event_scopes` | the `event_scopes` table (migration only) |
| Event hosts → Organization; affiliations; team and award "Organization" / "Awarded by"; person → Home organization | `organizations` | organizations, labeled by name, except ministries (they have no page to link to) | | Event hosts → Organization; affiliations; team and award "Organization" / "Awarded by"; person → Home organization | `organizations` | organizations, labeled by name, except ministries (they have no page to link to) |

View file

@ -55,7 +55,6 @@ import { blogPosts } from "./admin-schema/blog.js";
import { siteSettings } from "./admin-schema/siteSettings.js"; import { siteSettings } from "./admin-schema/siteSettings.js";
import { newsletters } from "./admin-schema/newsletters.js"; import { newsletters } from "./admin-schema/newsletters.js";
import { personTagTypes } from "./admin-schema/personTags.js"; import { personTagTypes } from "./admin-schema/personTags.js";
import { tags } from "./admin-schema/tags.js";
import { contactTypes } from "./admin-schema/contactTypes.js"; import { contactTypes } from "./admin-schema/contactTypes.js";
import { redirects } from "./admin-schema/redirects.js"; import { redirects } from "./admin-schema/redirects.js";
import { import {
@ -71,7 +70,6 @@ export const ENTITIES = {
events, events,
people, people,
person_tag_types: personTagTypes, person_tag_types: personTagTypes,
tags,
contact_types: contactTypes, contact_types: contactTypes,
redirects, redirects,
teams, teams,
@ -107,7 +105,6 @@ export const OPTION_QUERIES = {
events: "SELECT id, title AS label FROM events ORDER BY starts_on DESC, title", events: "SELECT id, title AS label FROM events ORDER BY starts_on DESC, title",
people: "SELECT id, display_name AS label FROM people ORDER BY sort_name, display_name", people: "SELECT id, display_name AS label FROM people ORDER BY sort_name, display_name",
person_tag_types: "SELECT id, name AS label FROM person_tag_types ORDER BY sort_order, name", person_tag_types: "SELECT id, name AS label FROM person_tag_types ORDER BY sort_order, name",
tags: "SELECT id, name AS label FROM tags ORDER BY sort_order, name",
contact_types: "SELECT id, name AS label FROM contact_types ORDER BY sort_order, name", contact_types: "SELECT id, name AS label FROM contact_types ORDER BY sort_order, name",
// Link fields with `redirects: true` pick from these (068). // Link fields with `redirects: true` pick from these (068).
redirects: "SELECT id, id || ' (' || target_url || ')' AS label FROM redirects ORDER BY id", redirects: "SELECT id, id || ' (' || target_url || ')' AS label FROM redirects ORDER BY id",

View file

@ -28,6 +28,7 @@ export const placeColumns = [
text("location_label"), text("location_label"),
real("latitude"), real("latitude"),
real("longitude"), real("longitude"),
bool("is_online"),
]; ];
/* The affiliation's own fields, minus whichever end owns the row. /* The affiliation's own fields, minus whichever end owns the row.
@ -131,7 +132,7 @@ export const blocksChild = (ownerKind) => ({
owner: { column: "owner_id", kindColumn: "owner_kind", kindValue: ownerKind }, owner: { column: "owner_id", kindColumn: "owner_kind", kindValue: ownerKind },
order: "sort_order", order: "sort_order",
columns: [ columns: [
enumeration("slot", ["card", "body", "both"], { required: true }), enumeration("slot", ["card", "body"], { required: true }),
enumeration( enumeration(
"type", "type",
[ [
@ -182,7 +183,6 @@ export const blocksChild = (ownerKind) => ({
text("media"), text("media"),
text("media_alt"), text("media_alt"),
text("map"), text("map"),
text("map_image"),
], ],
}, },
], ],

View file

@ -1,5 +1,4 @@
import { text, int, bool, date, time, enumeration, placeColumns, timelineExtension, linksChild, blocksChild, hostsChild } from "./columns.js"; import { text, int, bool, date, time, enumeration, placeColumns, timelineExtension, linksChild, blocksChild, hostsChild } from "./columns.js";
import { tagsChild } from "./tags.js";
/* ── Events ──────────────────────────────────────────────────── */ /* ── Events ──────────────────────────────────────────────────── */
@ -86,7 +85,6 @@ export const events = {
children: [ children: [
hostsChild, hostsChild,
tagsChild("event_tags", "event_id"),
linksChild("event"), linksChild("event"),
blocksChild("event"), blocksChild("event"),
{ {

View file

@ -1,5 +1,4 @@
import { text, int, real, bool, enumeration, placeColumns, timelineExtension, linksChild, blocksChild } from "./columns.js"; import { text, int, real, bool, enumeration, placeColumns, timelineExtension, linksChild, blocksChild } from "./columns.js";
import { tagsChild } from "./tags.js";
/* ── Organizations ───────────────────────────────────────────── */ /* ── Organizations ───────────────────────────────────────────── */
@ -68,7 +67,6 @@ export const organizations = {
], ],
children: [ children: [
tagsChild("organization_tags", "org_id"),
linksChild("organization"), linksChild("organization"),
blocksChild("organization"), blocksChild("organization"),
// Who to write to there, by role (064_org_contacts.sql): private, // Who to write to there, by role (064_org_contacts.sql): private,

View file

@ -1,35 +0,0 @@
import { text, int } from "./columns.js";
/* ── Tags (070_tags.sql) ─────────────────────────────────────────
Descriptor tags for organizations and events (Online, In-Person).
Its own entity, not a repeater, because organization_tags and
event_tags point at it: deleting a tag takes it off every record
(cascade). Which records carry a tag is edited on the record. The
URL ID "online" is what v_events reads as an online event. */
export const tags = {
key: "tags",
table: "tags",
idColumn: "id",
idKind: "slug",
list: {
columns: ["id", "name", "sort_order"],
filters: [],
search: ["name", "id"],
order: "sort_order, name",
},
columns: [text("name", { required: true }), int("sort_order")],
};
/* The Tags repeater on an organization or event: owner is the
record's id column in that tag table. */
export const tagsChild = (table, owner) => ({
key: "tags",
table,
owner: { column: owner },
order: "sort_order",
columns: [text("tag_id", { required: true })],
});

View file

@ -1,10 +0,0 @@
-- ═══════════════════════════════════════════════════════════════
-- 069 SCHEDULE MAP IMAGE
--
-- A schedule entry's own map picture (an upload), eg. a drawn map of
-- the camp with the room marked. Shown in the entry's fold-out in
-- place of the Google map, and as a slide in the schedule
-- presentation (/events/<id>/present).
-- ═══════════════════════════════════════════════════════════════
ALTER TABLE content_block_items ADD COLUMN map_image TEXT;

View file

@ -1,84 +0,0 @@
-- ═══════════════════════════════════════════════════════════════
-- 070 TAGS
--
-- Descriptor tags for organizations and events (Data → Tags), in
-- place of the Online checkbox: Online and In-Person to start, more
-- as they're needed. A record's tags show on its page and, for
-- groups, on the Community map's list and grid.
--
-- The tag with URL ID "online" still means online to the site:
-- v_events turns it back into is_online, which the calendar's
-- online filter, the "Online" place line and an event's search data
-- read. Records ticked Online get the tag; nothing gets In-Person
-- automatically.
-- ═══════════════════════════════════════════════════════════════
CREATE TABLE tags (
id TEXT PRIMARY KEY
CONSTRAINT "A tag's URL ID can use only lowercase letters, numbers and hyphens, eg. in-person."
CHECK (id <> '' AND id NOT GLOB '*[^a-z0-9-]*'),
name TEXT NOT NULL, -- 'In-Person', as shown
sort_order INTEGER NOT NULL DEFAULT 0
) STRICT;
INSERT INTO tags (id, name, sort_order) VALUES
('online', 'Online', 0),
('in-person', 'In-Person', 1);
CREATE TABLE organization_tags (
org_id TEXT NOT NULL REFERENCES organizations (id) ON DELETE CASCADE,
tag_id TEXT NOT NULL REFERENCES tags (id) ON DELETE CASCADE,
sort_order INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (org_id, tag_id)
) STRICT;
CREATE INDEX organization_tags_tag_idx ON organization_tags (tag_id);
CREATE TABLE event_tags (
event_id TEXT NOT NULL REFERENCES events (id) ON DELETE CASCADE,
tag_id TEXT NOT NULL REFERENCES tags (id) ON DELETE CASCADE,
sort_order INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (event_id, tag_id)
) STRICT;
CREATE INDEX event_tags_tag_idx ON event_tags (tag_id);
INSERT INTO organization_tags (org_id, tag_id) SELECT id, 'online' FROM organizations WHERE is_online = 1;
INSERT INTO event_tags (event_id, tag_id) SELECT id, 'online' FROM events WHERE is_online = 1;
-- v_events reads e.*, so it goes while the column does and comes
-- back with is_online from the tag.
DROP VIEW v_events;
ALTER TABLE organizations DROP COLUMN is_online;
ALTER TABLE events DROP COLUMN is_online;
CREATE VIEW v_events AS
SELECT
e.*,
EXISTS (SELECT 1 FROM event_tags et WHERE et.event_id = e.id AND et.tag_id = 'online')
AS is_online,
CASE WHEN eh.id IS NULL THEN NULL
WHEN eh.person_id IS NULL THEN 'organization' ELSE 'person' END
AS host_kind,
COALESCE(eh.org_id, eh.person_id) AS host_id,
COALESCE(o.name, p.display_name) AS host_name,
o.kind AS host_org_kind,
COALESCE(e.org_logo, o.logo) AS effective_org_logo,
COALESCE(e.color, o.color) AS effective_color,
COALESCE(
e.status,
CASE WHEN e.ends_on IS NOT NULL AND e.ends_on < date('now')
THEN 'past' ELSE 'upcoming' END
) AS effective_status
FROM events e
LEFT JOIN event_hosts eh
ON eh.id = (
SELECT x.id
FROM event_hosts x
LEFT JOIN organizations xo ON xo.id = x.org_id
LEFT JOIN people xp ON xp.id = x.person_id
WHERE x.event_id = e.id
AND COALESCE(xo.is_published, xp.is_published) = 1
ORDER BY x.sort_order, x.id
LIMIT 1
)
LEFT JOIN organizations o ON o.id = eh.org_id
LEFT JOIN people p ON p.id = eh.person_id;

View file

@ -1,82 +0,0 @@
-- ═══════════════════════════════════════════════════════════════
-- 071 BLOCK SLOT: BOTH
--
-- A content block's "Shown in" gets a third choice. Until now a card
-- block showed on the card and on the record's page as well (the
-- pages printed the card's paragraphs above the body), which the
-- editor didn't say. Now:
--
-- body the page only
-- card the card only
-- both the card and the page (the card takes paragraphs only)
--
-- Every existing card block becomes both, so nothing on the site
-- moves. The CHECK can't change in place, so the table is rebuilt.
-- ═══════════════════════════════════════════════════════════════
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', 'page_section',
'newsletter')),
owner_id TEXT NOT NULL,
slot TEXT NOT NULL DEFAULT 'body' CHECK (slot IN ('card', 'body', 'both')),
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', 'table', 'cards',
'people')),
text TEXT,
media TEXT,
href TEXT,
alt TEXT,
cite TEXT,
team_id TEXT REFERENCES teams (id) ON DELETE SET NULL,
captions TEXT
) STRICT;
INSERT INTO content_blocks_new
(id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite, team_id, captions)
SELECT id, owner_kind, owner_id, CASE slot WHEN 'card' THEN 'both' ELSE slot END,
sort_order, type, text, media, href, alt, cite, team_id, captions
FROM content_blocks;
-- The cleanup triggers on other tables name content_blocks; legacy
-- mode leaves them alone through the rename.
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);
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')
WHEN new.owner_kind = 'page_section'
AND NOT EXISTS (SELECT 1 FROM page_sections WHERE CAST(id AS TEXT) = new.owner_id)
THEN RAISE(ABORT, 'content_blocks: no such page section')
WHEN new.owner_kind = 'newsletter'
AND NOT EXISTS (SELECT 1 FROM newsletters WHERE CAST(id AS TEXT) = new.owner_id)
THEN RAISE(ABORT, 'content_blocks: no such newsletter')
END;
END;

View file

@ -400,21 +400,6 @@ export function metaFor(db, rawPath) {
return { ...meta, title: titled(site, page.title), description: plainText(page.description) ?? meta.description }; return { ...meta, title: titled(site, page.title), description: plainText(page.description) ?? meta.description };
} }
// An event's schedule presentation (SchedulePresent.tsx): the
// event's own title and preview, kept out of search, pointing
// search engines at the event page.
const present = pathname.match(/^\/events\/([^/]+)\/present$/);
if (present) {
let id;
try {
id = decodeURIComponent(present[1]);
} catch {
return notFound(meta);
}
const event = eventMeta(site, db, id, { ...meta, canonical: `${origin(site)}/events/${present[1]}` });
return event.status === 200 ? { ...event, noindex: true, jsonLd: null } : event;
}
const match = pathname.match(/^\/(events|regions|groups|partners|organizations|teams|awards|people|blog|directory)\/([^/]+)$/); const match = pathname.match(/^\/(events|regions|groups|partners|organizations|teams|awards|people|blog|directory)\/([^/]+)$/);
if (!match) return notFound(meta); if (!match) return notFound(meta);

View file

@ -75,7 +75,7 @@ function firstParagraphs(db, rows) {
`SELECT owner_id, text FROM ( `SELECT owner_id, text FROM (
SELECT owner_id, text, ROW_NUMBER() OVER (PARTITION BY owner_id ORDER BY sort_order) AS n SELECT owner_id, text, ROW_NUMBER() OVER (PARTITION BY owner_id ORDER BY sort_order) AS n
FROM content_blocks FROM content_blocks
WHERE owner_kind = 'blog_post' AND slot IN ('body', 'both') AND type = 'paragraph' WHERE owner_kind = 'blog_post' AND slot = 'body' AND type = 'paragraph'
AND text IS NOT NULL AND text <> '' AND text IS NOT NULL AND text <> ''
AND owner_id IN (${marks(ids.length)}) AND owner_id IN (${marks(ids.length)})
) WHERE n = 1`, ) WHERE n = 1`,

View file

@ -62,7 +62,6 @@ import {
paragraphs, paragraphs,
shapeSeries, shapeSeries,
splitLinks, splitLinks,
attachTags,
} from "../shape.js"; } from "../shape.js";
const content = new Hono(); const content = new Hono();
@ -167,7 +166,7 @@ function shapeEvent(row, links, cardBlocks, hosts = []) {
/* The common card surface every organization has, whatever kind it /* The common card surface every organization has, whatever kind it
is. Kind-specific fields go in `details`, attached by the caller. */ is. Kind-specific fields go in `details`, attached by the caller. */
function shapeOrganization(row, links, cardBlocks, bodyBlocks) { function shapeOrganization(row, links, cardBlocks, bodyBlocks) {
const { actions, socials, websites, emails, website, email, instagram } = splitLinks(links); const { actions, socials, website, email, instagram } = splitLinks(links);
return { return {
id: row.id, id: row.id,
@ -184,18 +183,16 @@ function shapeOrganization(row, links, cardBlocks, bodyBlocks) {
state_code: row.state_code, state_code: row.state_code,
country: row.country, country: row.country,
location_label: row.location_label, location_label: row.location_label,
is_online: asBool(row.is_online),
sort_order: row.sort_order, sort_order: row.sort_order,
description: paragraphs(cardBlocks), description: paragraphs(cardBlocks),
blocks: bodyBlocks, blocks: bodyBlocks,
links: actions, links: actions,
socials, socials,
websites,
emails,
website, website,
email, email,
instagram, instagram,
tags: [],
details: {}, details: {},
leadership: [], leadership: [],
@ -586,10 +583,14 @@ content.get("/events/:id", (c) => {
citation: r.citation, citation: r.citation,
})); }));
const event = { ...shapeEvent(row, links, cards, hosts), blocks: body, people, awards }; return json(c, {
attachTags(db, "event", [event]); event: {
...shapeEvent(row, links, cards, hosts),
return json(c, { event }); blocks: body,
people,
awards,
},
});
}); });
/* ── Organizations ───────────────────────────────────────────── /* ── Organizations ─────────────────────────────────────────────
@ -646,7 +647,6 @@ content.get("/organizations", (c) => {
attachRegionDetails(db, organizations); attachRegionDetails(db, organizations);
attachGroupDetails(db, organizations); attachGroupDetails(db, organizations);
attachTags(db, "organization", organizations);
return json(c, { organizations }); return json(c, { organizations });
}); });
@ -669,7 +669,6 @@ content.get("/organizations/:id", (c) => {
attachRegionDetails(db, one); attachRegionDetails(db, one);
attachGroupDetails(db, one); attachGroupDetails(db, one);
attachTags(db, "organization", one);
attachLeadership(db, one); attachLeadership(db, one);
attachTeams(db, one); attachTeams(db, one);
attachAwards(db, one); attachAwards(db, one);

View file

@ -91,7 +91,7 @@ const SCHEDULE = [
{ text: "The weekend at a glance. Tap an entry for more." }, { 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: "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", map_image: "/uploads/showcase.jpg" }, { 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: "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: "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" }, { day: "Sunday", time: "10:00am", text: "Closing service", location: "Chapel", map: "Main Street, Halifax PA" },
@ -165,10 +165,7 @@ const pageBody = (what) => [
["button", { text: "Get involved", href: "/feedback" }], ["button", { text: "Get involved", href: "/feedback" }],
]; ];
/* Card text: paragraphs only, shown on cards and list rows. Most /* The card slot: paragraphs only, shown on cards and list rows. */
records put it in "both" (the card and the page); the series and
the past event keep it to the card, to check that it stays off
their pages. */
const cardText = (what) => [ const cardText = (what) => [
["paragraph", { text: `Showcase ${what}: the short description that appears on its card.` }], ["paragraph", { text: `Showcase ${what}: the short description that appears on its card.` }],
["paragraph", { text: "A second card paragraph, to check how two read." }], ["paragraph", { text: "A second card paragraph, to check how two read." }],
@ -182,10 +179,6 @@ const standardLinks = (name) => [
{ kind: "social", platform: "youtube", label: "YouTube", url: "https://youtube.com/@showcase" }, { kind: "social", platform: "youtube", label: "YouTube", url: "https://youtube.com/@showcase" },
{ kind: "website", label: "Website", url: "https://example.org" }, { kind: "website", label: "Website", url: "https://example.org" },
{ kind: "email", label: "showcase@example.org", url: "mailto:showcase@example.org" }, { kind: "email", label: "showcase@example.org", url: "mailto:showcase@example.org" },
// A second of each, labeled unlike its address: both listed, each
// going to its own URL.
{ kind: "website", label: "Our blog", url: "https://example.org/blog" },
{ kind: "email", label: "Prayer requests", url: "prayer@example.org" },
]; ];
/* ── Writing ───────────────────────────────────────────────── */ /* ── Writing ───────────────────────────────────────────────── */
@ -253,6 +246,7 @@ tx(db, () => {
color: "#7a5ea8", color: "#7a5ea8",
logo: IMAGE, logo: IMAGE,
...place, ...place,
is_online: 0,
is_published: 1, is_published: 1,
is_listed: LISTED, is_listed: LISTED,
sort_order: 99, sort_order: 99,
@ -262,7 +256,7 @@ tx(db, () => {
insert("region_areas", { region_id: REGION, area_code: "PA", share: 0.5, edge: "top", note: "western half" }); insert("region_areas", { region_id: REGION, area_code: "PA", share: 0.5, edge: "top", note: "western half" });
insert("region_areas", { region_id: REGION, area_code: "OH", share: 1 }); insert("region_areas", { region_id: REGION, area_code: "OH", share: 1 });
links("organization", REGION, standardLinks("Showcase Region")); links("organization", REGION, standardLinks("Showcase Region"));
blocks("organization", REGION, "both", cardText("region")); blocks("organization", REGION, "card", cardText("region"));
blocks("organization", REGION, "body", pageBody("region")); blocks("organization", REGION, "body", pageBody("region"));
insert("organizations", { insert("organizations", {
@ -275,14 +269,14 @@ tx(db, () => {
logo: IMAGE, logo: IMAGE,
...place, ...place,
venue: "Showcase Community Hall", venue: "Showcase Community Hall",
is_online: 1,
is_published: 1, is_published: 1,
is_listed: LISTED, is_listed: LISTED,
sort_order: 99, sort_order: 99,
}); });
insert("groups", { id: GROUP, region_id: REGION, meets: "2nd Sundays, 6:00pm", started: "Since 2021" }); insert("groups", { id: GROUP, region_id: REGION, meets: "2nd Sundays, 6:00pm", started: "Since 2021" });
["in-person", "online"].forEach((tag_id, i) => insert("organization_tags", { org_id: GROUP, tag_id, sort_order: i }));
links("organization", GROUP, standardLinks("Showcase Group")); links("organization", GROUP, standardLinks("Showcase Group"));
blocks("organization", GROUP, "both", cardText("group")); blocks("organization", GROUP, "card", cardText("group"));
blocks("organization", GROUP, "body", pageBody("group")); blocks("organization", GROUP, "body", pageBody("group"));
/* ── People ── */ /* ── People ── */
@ -318,7 +312,7 @@ tx(db, () => {
{ kind: "website", label: "Website", url: "https://example.org/person" }, { kind: "website", label: "Website", url: "https://example.org/person" },
{ kind: "action", label: "Book a call", url: "https://example.org/call" }, { kind: "action", label: "Book a call", url: "https://example.org/call" },
]); ]);
blocks("person", PERSON, "both", cardText("person")); blocks("person", PERSON, "card", cardText("person"));
blocks("person", PERSON, "body", pageBody("person")); blocks("person", PERSON, "body", pageBody("person"));
MEMBERS.forEach((id, i) => MEMBERS.forEach((id, i) =>
@ -349,7 +343,7 @@ tx(db, () => {
sort_order: 99, sort_order: 99,
}); });
links("team", TEAM, [{ kind: "action", label: "Join the team", url: "https://example.org/join" }]); links("team", TEAM, [{ kind: "action", label: "Join the team", url: "https://example.org/join" }]);
blocks("team", TEAM, "both", cardText("team")); blocks("team", TEAM, "card", cardText("team"));
blocks("team", TEAM, "body", pageBody("team")); blocks("team", TEAM, "body", pageBody("team"));
insert("affiliations", { person_id: PERSON, org_id: REGION, team_id: TEAM, title: "Showcase Team Lead", role: "lead", is_owner: 1, started_on: "2023-01-01", is_public: 1, sort_order: 0 }); insert("affiliations", { person_id: PERSON, org_id: REGION, team_id: TEAM, title: "Showcase Team Lead", role: "lead", is_owner: 1, started_on: "2023-01-01", is_public: 1, sort_order: 0 });
@ -370,6 +364,7 @@ tx(db, () => {
ends_on: db.prepare(`SELECT date('now', '+47 days') AS d`).get().d, ends_on: db.prepare(`SELECT date('now', '+47 days') AS d`).get().d,
date_label: "Three days, six weeks from now", date_label: "Three days, six weeks from now",
...place, ...place,
is_online: 0,
org_logo: IMAGE, org_logo: IMAGE,
event_logo: IMAGE, event_logo: IMAGE,
color: "#d62976", color: "#d62976",
@ -395,7 +390,7 @@ tx(db, () => {
{ kind: "action", platform: "discord", label: "Event Discord", url: "https://discord.com/invite/example" }, { kind: "action", platform: "discord", label: "Event Discord", url: "https://discord.com/invite/example" },
{ kind: "social", platform: "instagram", label: "@showcaseretreat", url: "https://instagram.com/showcaseretreat" }, { kind: "social", platform: "instagram", label: "@showcaseretreat", url: "https://instagram.com/showcaseretreat" },
]); ]);
blocks("event", EVENT, "both", cardText("event")); blocks("event", EVENT, "card", cardText("event"));
blocks("event", EVENT, "body", [...pageBody("event"), ["heading", { text: "Schedule" }], SCHEDULE]); blocks("event", EVENT, "body", [...pageBody("event"), ["heading", { text: "Schedule" }], SCHEDULE]);
insert("events", { insert("events", {
@ -407,6 +402,7 @@ tx(db, () => {
starts_on: db.prepare(`SELECT date('now', '-14 days') AS d`).get().d, starts_on: db.prepare(`SELECT date('now', '-14 days') AS d`).get().d,
ends_on: db.prepare(`SELECT date('now', '+90 days') AS d`).get().d, ends_on: db.prepare(`SELECT date('now', '+90 days') AS d`).get().d,
location_label: "Online", location_label: "Online",
is_online: 1,
color: "#138ba0", color: "#138ba0",
is_series: 1, is_series: 1,
series_frequency: "weekly", series_frequency: "weekly",
@ -420,7 +416,6 @@ tx(db, () => {
is_listed: LISTED, is_listed: LISTED,
}); });
insert("event_hosts", { event_id: SERIES, org_id: GROUP, sort_order: 0 }); insert("event_hosts", { event_id: SERIES, org_id: GROUP, sort_order: 0 });
insert("event_tags", { event_id: SERIES, tag_id: "online" });
links("event", SERIES, [{ kind: "action", label: "Join on Zoom", url: "https://example.org/zoom" }]); links("event", SERIES, [{ kind: "action", label: "Join on Zoom", url: "https://example.org/zoom" }]);
blocks("event", SERIES, "card", cardText("series")); blocks("event", SERIES, "card", cardText("series"));

View file

@ -53,8 +53,7 @@ export function loadLinks(db, ownerKind, ids) {
} }
/* ── Blocks ──────────────────────────────────────────────────── /* ── Blocks ────────────────────────────────────────────────────
Map of owner_id → blocks for one slot, items attached. A Map of owner_id → blocks for one slot, items attached.
"both" block (071) is in the card's and the body's.
Two queries: the blocks, then every item belonging to them. Two queries: the blocks, then every item belonging to them.
Blocks with no children come back with an empty items array Blocks with no children come back with an empty items array
@ -69,7 +68,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
.prepare( .prepare(
`SELECT id, owner_id, type, text, media, href, alt, cite, captions, team_id `SELECT id, owner_id, type, text, media, href, alt, cite, captions, team_id
FROM content_blocks FROM content_blocks
WHERE owner_kind = ? AND slot IN (?, 'both') AND owner_id IN (${placeholders(ids.length)}) WHERE owner_kind = ? AND slot = ? AND owner_id IN (${placeholders(ids.length)})
ORDER BY owner_id, sort_order`, ORDER BY owner_id, sort_order`,
) )
.all(ownerKind, slot, ...ids); .all(ownerKind, slot, ...ids);
@ -102,7 +101,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
const itemRows = db const itemRows = db
.prepare( .prepare(
`SELECT i.block_id, i.text, i.detail, i.url, `SELECT i.block_id, i.text, i.detail, i.url,
i.day, i.time, i.location, i.description, i.media, i.media_alt, i.map, i.map_image, i.day, i.time, i.location, i.description, i.media, i.media_alt, i.map,
p.id AS person_id, p.display_name AS person_name, p.id AS person_id, p.display_name AS person_name,
p.photo AS person_photo, p.tagline AS person_tagline p.photo AS person_photo, p.tagline AS person_tagline
FROM content_block_items i FROM content_block_items i
@ -127,7 +126,6 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
media: row.media, media: row.media,
media_alt: row.media_alt, media_alt: row.media_alt,
map: row.map, map: row.map,
map_image: row.map_image,
person: row.person_id person: row.person_id
? { ? {
id: row.person_id, id: row.person_id,
@ -146,8 +144,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
The card slot is paragraphs by convention, so it collapses to The card slot is paragraphs by convention, so it collapses to
an array of strings, desc_a and desc_b become description[0] an array of strings, desc_a and desc_b become description[0]
and description[1]. A non-paragraph block in the card slot is and description[1]. A non-paragraph block in the card slot is
ignored here. Only cards show it: a record's page draws its ignored here; put it in the body slot instead.
body blocks, "both" ones among them.
───────────────────────────────────────────────────────────── */ ───────────────────────────────────────────────────────────── */
export function paragraphs(blocks = []) { export function paragraphs(blocks = []) {
@ -162,42 +159,12 @@ export function paragraphs(blocks = []) {
underlying rows are the same table. underlying rows are the same table.
───────────────────────────────────────────────────────────── */ ───────────────────────────────────────────────────────────── */
/* ── Tags (070_tags.sql) ───────────────────────────────────────
Sets `tags` ([{ id, name }], in the record's order) on each of
these shaped organizations or events, in one query. */
const TAG_TABLES = { organization: ["organization_tags", "org_id"], event: ["event_tags", "event_id"] };
export function attachTags(db, kind, records) {
if (records.length === 0) return;
const [table, owner] = TAG_TABLES[kind];
const rows = db
.prepare(
`SELECT x.${owner} AS owner_id, t.id, t.name
FROM ${table} x
JOIN tags t ON t.id = x.tag_id
WHERE x.${owner} IN (${placeholders(records.length)})
ORDER BY x.sort_order, t.sort_order, t.name`,
)
.all(...records.map((record) => record.id));
for (const record of records) {
record.tags = rows.filter((row) => row.owner_id === record.id).map(({ id, name }) => ({ id, name }));
}
}
export function splitLinks(links = []) { export function splitLinks(links = []) {
const websites = links.filter((link) => link.kind === "website");
// An email row's URL is the address, with or without mailto:.
const emails = links
.filter((link) => link.kind === "email")
.map((link) => ({ ...link, url: link.url.replace(/^mailto:/i, "") }));
return { return {
actions: links.filter((link) => link.kind === "action"), actions: links.filter((link) => link.kind === "action"),
socials: links.filter((link) => link.kind === "social"), socials: links.filter((link) => link.kind === "social"),
// Every one, for a record's own page; the first, for cards. website: links.find((link) => link.kind === "website")?.url ?? null,
websites, email: links.find((link) => link.kind === "email")?.label ?? null,
emails,
website: websites[0]?.url ?? null,
email: emails[0]?.url ?? null,
instagram: instagram:
links.find((link) => link.platform === "instagram")?.label ?? null, links.find((link) => link.platform === "instagram")?.label ?? null,
}; };

View file

@ -70,7 +70,6 @@ const AwardDetail = lazyPage(() => import("./pages/AwardDetail.tsx"))
const PersonDetail = lazyPage(() => import("./pages/PersonDetail.tsx")) const PersonDetail = lazyPage(() => import("./pages/PersonDetail.tsx"))
const BlogPost = lazyPage(() => import("./pages/BlogPost.tsx")) const BlogPost = lazyPage(() => import("./pages/BlogPost.tsx"))
const DirectoryPage = lazyPage(() => import("./pages/DirectoryPage.tsx")) const DirectoryPage = lazyPage(() => import("./pages/DirectoryPage.tsx"))
const SchedulePresent = lazyPage(() => import("./pages/SchedulePresent.tsx"))
/*Admin Pages*/ /*Admin Pages*/
const AdminLayout = lazyPage(() => import("./pages/admin/AdminLayout.tsx")) const AdminLayout = lazyPage(() => import("./pages/admin/AdminLayout.tsx"))
@ -114,15 +113,6 @@ export default function App() {
<Route path="terms" element={<Terms />} /> <Route path="terms" element={<Terms />} />
<Route path="*" element={<NotFound />} /> <Route path="*" element={<NotFound />} />
</Route> </Route>
{/* A schedule as a slideshow for a screen: full screen, no Layout. */}
<Route
path="/events/:id/present"
element={
<Suspense fallback={null}>
<SchedulePresent />
</Suspense>
}
/>
<Route <Route
element={ element={
<AuthProvider> <AuthProvider>

View file

@ -62,14 +62,10 @@ export default function ContentBlocks({
blocks, blocks,
accent = BRAND, accent = BRAND,
className = '', className = '',
presentAt,
}: { }: {
blocks?: ContentBlock[] | null blocks?: ContentBlock[] | null
accent?: string accent?: string
className?: string className?: string
/** An event page's presentation route: each schedule gets a Present
* button to it, `?block=<n>` naming which schedule (from 0). */
presentAt?: string
}) { }) {
if (!blocks?.length) return null if (!blocks?.length) return null
// Headings get ids so a post's contents (PostContents) and a shared // Headings get ids so a post's contents (PostContents) and a shared
@ -85,22 +81,10 @@ export default function ContentBlocks({
return level return level
}) })
let schedules = 0
const presentHrefs = blocks.map((block) =>
presentAt && block.type === 'schedule' ? `${presentAt}?block=${schedules++}` : undefined,
)
return ( return (
<div className={`space-y-6 ${className}`}> <div className={`space-y-6 ${className}`}>
{blocks.map((block, index) => ( {blocks.map((block, index) => (
<Block <Block key={block.id ?? index} block={block} accent={accent} anchor={idAt.get(index)} level={levels[index]} />
key={block.id ?? index}
block={block}
accent={accent}
anchor={idAt.get(index)}
level={levels[index]}
presentHref={presentHrefs[index]}
/>
))} ))}
</div> </div>
) )
@ -170,13 +154,11 @@ function Block({
accent, accent,
anchor, anchor,
level, level,
presentHref,
}: { }: {
block: ContentBlock block: ContentBlock
accent: string accent: string
anchor?: string anchor?: string
level: 3 | 4 | 5 level: 3 | 4 | 5
presentHref?: string
}) { }) {
const text = block.text ?? '' const text = block.text ?? ''
const reading = useReadingMode() const reading = useReadingMode()
@ -377,7 +359,7 @@ function Block({
case 'schedule': case 'schedule':
if (!block.items?.length) return null if (!block.items?.length) return null
return <ScheduleBlock items={block.items} intro={block.text} accent={accent} presentHref={presentHref} /> return <ScheduleBlock items={block.items} intro={block.text} accent={accent} />
case 'people': { case 'people': {
const picked = (block.items ?? []) const picked = (block.items ?? [])

View file

@ -22,7 +22,7 @@ function PlatformName({ platform, label }: { platform?: string | null; label?: s
export default function OrgContact({ org, accent }: { org: OrganizationRecord; accent: string }) { export default function OrgContact({ org, accent }: { org: OrganizationRecord; accent: string }) {
const hasAny = const hasAny =
org.links.length > 0 || org.socials.length > 0 || org.websites.length > 0 || org.emails.length > 0 org.links.length > 0 || org.socials.length > 0 || org.website || org.email
if (!hasAny) return null if (!hasAny) return null
@ -43,27 +43,28 @@ export default function OrgContact({ org, accent }: { org: OrganizationRecord; a
</a> </a>
))} ))}
{/* Every website and email row, each its own button with its {/* website and email arrive as bare strings (splitLinks in
own label; an email's url is the bare address (splitLinks shape.js); socials are whole link rows. */}
in shape.js). */}
{[ {[
...org.websites, org.website ? { url: org.website, label: 'Website', platform: null } : null,
...org.emails.map((link) => ({ ...link, url: `mailto:${link.url}` })), org.email ? { url: `mailto:${org.email}`, label: org.email, platform: null } : null,
...org.socials, ...org.socials,
].map((link) => ( ]
<a .filter((link): link is NonNullable<typeof link> => Boolean(link))
key={link.url} .map((link) => (
href={link.url} <a
target="_blank" key={link.url}
rel="noreferrer" href={link.url}
className="inline-flex items-center gap-2 btn border px-4 py-1.5 text-sm transition-colors hover:bg-tint" target="_blank"
style={{ borderColor: accent, color: accentText(accent) }} rel="noreferrer"
> className="inline-flex items-center gap-2 btn border px-4 py-1.5 text-sm transition-colors hover:bg-tint"
<PlatformIcon platform={link.platform} /> style={{ borderColor: accent, color: accentText(accent) }}
<PlatformName platform={link.platform} label={link.label} /> >
{link.label} <PlatformIcon platform={link.platform} />
</a> <PlatformName platform={link.platform} label={link.label} />
))} {link.label}
</a>
))}
</div> </div>
) )
} }

View file

@ -16,13 +16,10 @@ export default function OrgLogo({
org, org,
color, color,
size = 'h-14 w-14', size = 'h-14 w-14',
fallbackSize = size,
}: { }: {
org: { logo?: string | null; name: string } org: { logo?: string | null; name: string }
color: string color: string
size?: string size?: string
/** The initials square's size, when the logo's box isn't square. */
fallbackSize?: string
}) { }) {
return ( return (
<Logo <Logo
@ -30,7 +27,7 @@ export default function OrgLogo({
className={`${size} object-contain shrink-0`} className={`${size} object-contain shrink-0`}
fallback={ fallback={
<span <span
className={`${fallbackSize} shrink-0 flex items-center justify-center font-display font-bold`} className={`${size} shrink-0 flex items-center justify-center font-display font-bold`}
style={{ border: `1px solid ${color}`, color: accentText(color) }} style={{ border: `1px solid ${color}`, color: accentText(color) }}
aria-hidden="true" aria-hidden="true"
> >

View file

@ -107,17 +107,16 @@ export function Section({ section }: { section: ShellSection }) {
const circleSize = (box: { width: number; height: number }) => const circleSize = (box: { width: number; height: number }) =>
Math.min(Math.max(box.width * 1.5, box.height * 1.1), 22 * 16); Math.min(Math.max(box.width * 1.5, box.height * 1.1), 22 * 16);
/* The height a pill `width` wide (rounded-full: straight sides, round /* The height an ellipse `width` wide needs to take in a box reaching
ends of radius r = width / 2) needs to take in a box reaching
`across` and `down` from its center (or a corner it's centered on): `across` and `down` from its center (or a corner it's centered on):
the corner must sit inside an end's circle, so the straight part (across / a)^2 + (down / b)^2 <= 1. Equal to the width when a circle
reaches down - sqrt(r^2 - across^2). Equal to the width when a that wide would do; taller when the list is too tall for one. A
circle that wide would do; taller when the list is too tall for box as wide as the ellipse can't be taken in, so it stops at 95%
one. A box as wide as the pill can't be taken in, so it stops at 95%. */ (about three times the box's height). */
const coverHeight = (width: number, across: number, down: number) => { const coverHeight = (width: number, across: number, down: number) => {
const r = width / 2; const a = width / 2;
const ratio = Math.min(across / r, 0.95); const ratio = Math.min(across / a, 0.95);
return Math.max(width, 2 * (down - r * Math.sqrt(1 - ratio * ratio) + r)); return Math.max(width, (2 * down) / Math.sqrt(1 - ratio * ratio));
}; };
/* How far the list sits in from the column's top and left: the /* How far the list sits in from the column's top and left: the
@ -185,7 +184,7 @@ export default function PageShell({ title, intro, sections, sideNav = false }: P
// The shape at rest: a circle centered on the list (a little left, // The shape at rest: a circle centered on the list (a little left,
// never left of the heading's center), CIRCLE_EDGE clear of the // never left of the heading's center), CIRCLE_EDGE clear of the
// section's edge, made a pill as tall as it takes when the list // section's edge, made an ellipse as tall as it takes when the list
// is too tall for the circle (10 sections of two-line titles). // is too tall for the circle (10 sections of two-line titles).
// The shape at a given width: its center as near the list's as the // The shape at a given width: its center as near the list's as the
// section's edge allows (it may run off the screen's left edge), and // section's edge allows (it may run off the screen's left edge), and
@ -245,7 +244,7 @@ export default function PageShell({ title, intro, sections, sideNav = false }: P
// far corner. Never wider than the column (it'd show a cut edge at // far corner. Never wider than the column (it'd show a cut edge at
// the content): held narrower by the window, it stays centered on // the content): held narrower by the window, it stays centered on
// the header's edge (so below it, it only ever curves inward) and // the header's edge (so below it, it only ever curves inward) and
// becomes a pill, as tall as it takes to take the list in. // becomes an ellipse, as tall as it takes to take the list in.
const circleBox = (() => { const circleBox = (() => {
if (!listBox || !rest) return null; if (!listBox || !rest) return null;
if (stuck) { if (stuck) {

View file

@ -15,11 +15,7 @@
A row folds out when it has anything more to show: a A row folds out when it has anything more to show: a
description, a graphic, a map, or a person (their photo, tagline 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 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; an entry's the place typed in, with a link out to the full map.
own map image (069) shows instead, the link out kept.
On an event page a Present button opens the schedule as a
slideshow for a screen (SchedulePresent.tsx).
Tabs follow the ARIA tab pattern: arrow keys move between them. Tabs follow the ARIA tab pattern: arrow keys move between them.
@ -28,7 +24,7 @@
it, no map frame (ReadingSchedule). it, no map frame (ReadingSchedule).
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
import { CaretDown, Presentation } from '@phosphor-icons/react' import { CaretDown } from '@phosphor-icons/react'
import { Fragment, useId, useState, type KeyboardEvent, type ReactNode } from 'react' import { Fragment, useId, useState, type KeyboardEvent, type ReactNode } from 'react'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
@ -44,9 +40,9 @@ import { useReadingMode } from '../lib/readingMode.ts'
const BODY = 'var(--color-muted)' const BODY = 'var(--color-muted)'
const WEEKDAYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'] const WEEKDAYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
export type Day = { name: string; entries: ContentBlockItem[] } type Day = { name: string; entries: ContentBlockItem[] }
export function groupByDay(items: ContentBlockItem[]): Day[] { function groupByDay(items: ContentBlockItem[]): Day[] {
const days: Day[] = [] const days: Day[] = []
for (const item of items) { for (const item of items) {
const name = item.day?.trim() ?? '' const name = item.day?.trim() ?? ''
@ -71,15 +67,12 @@ function todayIndex(days: Day[]): number {
return found >= 0 ? found : 0 return found >= 0 ? found : 0
} }
/* An entry's own map image says what it maps. */
export const mapAlt = (entry: ContentBlockItem) => `Map: ${entry.map?.trim() || entry.location || entry.text}`
const mapEmbed = (place: string) => const mapEmbed = (place: string) =>
`https://maps.google.com/maps?q=${encodeURIComponent(place)}&output=embed&maptype=satellite` `https://maps.google.com/maps?q=${encodeURIComponent(place)}&output=embed&maptype=satellite`
const mapLink = (place: string) => const mapLink = (place: string) =>
`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(place)}` `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(place)}`
export function Avatar({ person, size }: { person: NonNullable<ContentBlockItem['person']>; size: string }) { function Avatar({ person, size }: { person: NonNullable<ContentBlockItem['person']>; size: string }) {
const img = useSmallImage(mediaUrl(person.photo)) const img = useSmallImage(mediaUrl(person.photo))
return !img.failed ? ( return !img.failed ? (
<img src={img.src} alt="" onError={img.onError} className={`${size} shrink-0 object-cover`} /> <img src={img.src} alt="" onError={img.onError} className={`${size} shrink-0 object-cover`} />
@ -100,8 +93,7 @@ function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
const panelId = useId() const panelId = useId()
const graphic = mediaUrl(entry.media) const graphic = mediaUrl(entry.media)
const place = entry.map?.trim() const place = entry.map?.trim()
const mapImage = mediaUrl(entry.map_image) const more = Boolean(entry.description || graphic || place || entry.person)
const more = Boolean(entry.description || graphic || place || mapImage || entry.person)
const title = entry.url ? ( const title = entry.url ? (
<Anchor href={entry.url} className="underline-offset-2 hover:underline" style={{ color: accentText(accent) }}> <Anchor href={entry.url} className="underline-offset-2 hover:underline" style={{ color: accentText(accent) }}>
@ -189,11 +181,9 @@ function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
{graphic && <img src={graphic} alt={entry.media_alt ?? ""} loading="lazy" className="w-full" />} {graphic && <img src={graphic} alt={entry.media_alt ?? ""} loading="lazy" className="w-full" />}
{(place || mapImage) && ( {place && (
<div> <div>
{mapImage ? ( {showMap ? (
<img src={mapImage} alt={mapAlt(entry)} loading="lazy" className="w-full" />
) : showMap && place ? (
<iframe <iframe
ref={focusOnMount} ref={focusOnMount}
src={mapEmbed(place)} src={mapEmbed(place)}
@ -213,17 +203,15 @@ function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
<span className="text-xs">{place}, from Google Maps</span> <span className="text-xs">{place}, from Google Maps</span>
</button> </button>
)} )}
{place && ( <a
<a href={mapLink(place)}
href={mapLink(place)} target="_blank"
target="_blank" rel="noreferrer"
rel="noreferrer" className="mt-2 inline-block text-sm underline"
className="mt-2 inline-block text-sm underline" style={{ color: accentText(accent) }}
style={{ color: accentText(accent) }} >
> Open in Google Maps
Open in Google Maps </a>
</a>
)}
</div> </div>
)} )}
</div> </div>
@ -245,7 +233,6 @@ function ReadingSchedule({ days, intro, accent }: { days: Day[]; intro?: string
{day.entries.map((entry, i) => { {day.entries.map((entry, i) => {
const graphic = mediaUrl(entry.media) const graphic = mediaUrl(entry.media)
const place = entry.map?.trim() const place = entry.map?.trim()
const mapImage = mediaUrl(entry.map_image)
const parts: ReactNode[] = [ const parts: ReactNode[] = [
entry.time, entry.time,
entry.url ? <Anchor href={entry.url}>{entry.text}</Anchor> : entry.text, entry.url ? <Anchor href={entry.url}>{entry.text}</Anchor> : entry.text,
@ -266,7 +253,6 @@ function ReadingSchedule({ days, intro, accent }: { days: Day[]; intro?: string
{entry.person?.tagline && <p>{entry.person.tagline}</p>} {entry.person?.tagline && <p>{entry.person.tagline}</p>}
{entry.description && <Paragraphs text={entry.description} accent={accent} />} {entry.description && <Paragraphs text={entry.description} accent={accent} />}
{graphic && <img src={graphic} alt={entry.media_alt ?? ''} />} {graphic && <img src={graphic} alt={entry.media_alt ?? ''} />}
{mapImage && <img src={mapImage} alt={mapAlt(entry)} />}
{place && ( {place && (
<p> <p>
<a href={mapLink(place)}>Open {place} in Google Maps</a> <a href={mapLink(place)}>Open {place} in Google Maps</a>
@ -286,13 +272,10 @@ export default function ScheduleBlock({
items, items,
intro, intro,
accent, accent,
presentHref,
}: { }: {
items: ContentBlockItem[] items: ContentBlockItem[]
intro?: string | null intro?: string | null
accent: string accent: string
/** Where the Present button goes; no button without it. */
presentHref?: string
}) { }) {
const days = groupByDay(items) const days = groupByDay(items)
const [active, setActive] = useState(() => todayIndex(days)) const [active, setActive] = useState(() => todayIndex(days))
@ -326,21 +309,6 @@ export default function ScheduleBlock({
</div> </div>
)} )}
{presentHref && (
<div className="flex justify-end">
<Link
to={presentHref}
target="_blank"
className="btn inline-flex items-center gap-2 border px-4 py-2 text-sm transition-colors hover:bg-tint"
style={{ borderColor: `${withAlpha(accent, 33)}`, color: accentText(accent) }}
>
<Presentation aria-hidden="true" weight="bold" className="h-4 w-4" />
Present
<span className="sr-only">(opens in a new tab)</span>
</Link>
</div>
)}
{days.length > 1 && ( {days.length > 1 && (
<div role="tablist" aria-label="Days" className="flex flex-wrap gap-2"> <div role="tablist" aria-label="Days" className="flex flex-wrap gap-2">
{days.map((day, index) => { {days.map((day, index) => {

View file

@ -1,22 +0,0 @@
/* A record's descriptor tags (070_tags.sql), eg. Online, In-Person,
as small outlined chips in its accent. Nothing when it has none. */
import type { Tag } from '../lib/useContent.ts'
import { withAlpha, accentText } from '../lib/color.ts'
export default function Tags({ tags, accent, className = '' }: { tags?: Tag[]; accent: string; className?: string }) {
if (!tags?.length) return null
return (
<ul className={`flex flex-wrap gap-1.5 ${className}`} aria-label="Tags">
{tags.map((tag) => (
<li
key={tag.id}
className="border px-2 py-0.5 text-xs font-semibold"
style={{ borderColor: withAlpha(accent, 45), color: accentText(accent) }}
>
{tag.name}
</li>
))}
</ul>
)
}

View file

@ -1,243 +0,0 @@
/* ═══════════════════════════════════════════════════════════════
CROP DIALOG
The framing step between choosing a photo and uploading it, for an
image field with `crop` (fields.tsx). The photo sits behind a frame
in the field's shape: drag it (or use the arrow keys) to place it,
zoom with the slider, or pick another shape, "As uploaded" keeping
the photo's own. "Use this framing" draws the framed part onto a
canvas and hands that file on to be uploaded; "Upload as is" hands
on the original; Cancel uploads nothing.
The crop is the file: nothing about it is saved beside the
picture, so framing again means uploading again.
═══════════════════════════════════════════════════════════════ */
import { X } from "@phosphor-icons/react";
import { useEffect, useRef, useState, type PointerEvent } from "react";
/* An image field's `crop`: width over height, or "free" for the
photo's own shape. */
export type Crop = number | "free";
const SHAPES: [string, Crop][] = [
["Square", 1],
["Portrait 4:5", 4 / 5],
["Landscape 3:2", 3 / 2],
["Wide 16:9", 16 / 9],
["As uploaded", "free"],
];
/* The frame's largest box on screen, and the zoom slider's top. */
const STAGE_W = 560;
const STAGE_H = 380;
const MAX_ZOOM = 4;
/* The longest side saved; the server shrinks to this anyway. */
const MAX_SIDE = 2400;
/* How far an arrow key moves the photo, in screen pixels. */
const KEY_STEP = 10;
type Box = { x: number; y: number };
export default function CropDialog({
file,
crop,
onDone,
}: {
file: File;
crop: Crop;
/** The file to upload (cropped or as is), or null for Cancel. */
onDone: (file: File | null) => void;
}) {
const dialogRef = useRef<HTMLDialogElement>(null);
const [img, setImg] = useState<HTMLImageElement | null>(null);
const [shape, setShape] = useState<Crop>(crop);
const [zoom, setZoom] = useState(1);
const [at, setAt] = useState<Box>({ x: 0, y: 0 });
const [saving, setSaving] = useState(false);
const drag = useRef<{ x: number; y: number; from: Box } | null>(null);
// Set when a button already answered, so closing doesn't cancel.
const answered = useRef(false);
useEffect(() => {
dialogRef.current?.showModal();
const url = URL.createObjectURL(file);
const image = new Image();
image.onload = () => setImg(image);
image.src = url;
return () => URL.revokeObjectURL(url);
}, [file]);
// The frame on screen, the photo's scale in it, and where the photo
// may sit so it always covers the frame.
const aspect = shape === "free" ? (img ? img.naturalWidth / img.naturalHeight : 1) : shape;
const stageW = Math.min(STAGE_W, window.innerWidth - 64);
const frameW = Math.min(stageW, STAGE_H * aspect);
const frameH = frameW / aspect;
const cover = img ? Math.max(frameW / img.naturalWidth, frameH / img.naturalHeight) : 1;
const scale = cover * zoom;
const imgW = img ? img.naturalWidth * scale : 0;
const imgH = img ? img.naturalHeight * scale : 0;
const clamp = (box: Box): Box => ({
x: Math.min(0, Math.max(frameW - imgW, box.x)),
y: Math.min(0, Math.max(frameH - imgH, box.y)),
});
const pos = clamp(at);
// A new shape or a loaded photo starts centered, unzoomed.
useEffect(() => {
if (!img) return;
setZoom(1);
const s = Math.max(frameW / img.naturalWidth, frameH / img.naturalHeight);
setAt({ x: (frameW - img.naturalWidth * s) / 2, y: (frameH - img.naturalHeight * s) / 2 });
}, [img, shape]);
// Zooming keeps the frame's center on the same spot of the photo.
const zoomTo = (next: number) => {
const ratio = next / zoom;
setAt({
x: frameW / 2 - (frameW / 2 - pos.x) * ratio,
y: frameH / 2 - (frameH / 2 - pos.y) * ratio,
});
setZoom(next);
};
const onPointerDown = (e: PointerEvent<HTMLDivElement>) => {
e.currentTarget.setPointerCapture(e.pointerId);
drag.current = { x: e.clientX, y: e.clientY, from: pos };
};
const onPointerMove = (e: PointerEvent<HTMLDivElement>) => {
const d = drag.current;
if (d) setAt(clamp({ x: d.from.x + e.clientX - d.x, y: d.from.y + e.clientY - d.y }));
};
const finish = (result: File | null) => {
answered.current = true;
onDone(result);
dialogRef.current?.close();
};
// The framed part, at the photo's own resolution (up to MAX_SIDE).
const save = () => {
if (!img) return;
setSaving(true);
const sw = frameW / scale;
const sh = frameH / scale;
const k = Math.min(1, MAX_SIDE / Math.max(sw, sh));
const canvas = document.createElement("canvas");
canvas.width = Math.round(sw * k);
canvas.height = Math.round(sh * k);
canvas.getContext("2d")!.drawImage(img, -pos.x / scale, -pos.y / scale, sw, sh, 0, 0, canvas.width, canvas.height);
// PNG and WebP keep their transparency; anything else goes as JPEG.
const type = file.type === "image/png" || file.type === "image/webp" ? file.type : "image/jpeg";
const name = file.name.replace(/\.[^.]+$/, "") + (type === "image/jpeg" ? ".jpg" : type === "image/png" ? ".png" : ".webp");
canvas.toBlob(
(blob) => {
setSaving(false);
if (blob) finish(new File([blob], name, { type }));
},
type,
0.92,
);
};
const button = "btn border border-brand px-4 py-1.5 text-sm text-link transition-colors hover:bg-tint";
return (
<dialog
ref={dialogRef}
aria-label="Frame the photo"
onClose={() => !answered.current && onDone(null)}
className="m-auto w-[min(40rem,calc(100vw-2rem))] p-0 backdrop:bg-[#001011]/40"
>
<div className="flex items-center gap-3 border-b border-brand/15 px-5 py-4">
<h2 className="text-lg font-bold text-link">Frame the photo</h2>
<button
type="button"
onClick={() => finish(null)}
aria-label="Cancel"
className="ml-auto flex h-8 w-8 items-center justify-center btn text-muted hover:bg-tint"
>
<X aria-hidden="true" weight="bold" className="h-4 w-4" />
</button>
</div>
<div className="space-y-4 px-5 py-4">
<div className="flex justify-center bg-tint-soft py-3">
{/* The frame: the photo moves behind it. */}
<div
tabIndex={0}
role="img"
aria-label="The framed photo. Drag it, or use the arrow keys, to place it."
onPointerDown={onPointerDown}
onPointerMove={onPointerMove}
onPointerUp={() => (drag.current = null)}
onKeyDown={(e) => {
const move = { ArrowLeft: [KEY_STEP, 0], ArrowRight: [-KEY_STEP, 0], ArrowUp: [0, KEY_STEP], ArrowDown: [0, -KEY_STEP] }[e.key];
if (!move) return;
e.preventDefault();
setAt(clamp({ x: pos.x + move[0], y: pos.y + move[1] }));
}}
className="relative cursor-move touch-none overflow-hidden outline-offset-2"
style={{ width: frameW, height: frameH }}
>
{img ? (
<img
src={img.src}
alt=""
draggable={false}
className="absolute max-w-none select-none"
style={{ left: pos.x, top: pos.y, width: imgW, height: imgH }}
/>
) : (
<div className="skeleton h-full w-full" role="status" aria-label="Loading the photo" />
)}
</div>
</div>
<div className="flex flex-wrap items-center gap-x-6 gap-y-3">
<label className="flex items-center gap-2 text-sm text-muted">
Zoom
<input
type="range"
min={1}
max={MAX_ZOOM}
step={0.01}
value={zoom}
onChange={(e) => zoomTo(Number(e.target.value))}
className="w-40"
/>
</label>
<label className="flex items-center gap-2 text-sm text-muted">
Shape
<select
value={String(shape)}
onChange={(e) => setShape(e.target.value === "free" ? "free" : Number(e.target.value))}
className="border border-muted/25 bg-surface px-2 py-1 text-body"
>
{SHAPES.map(([label, value]) => (
<option key={label} value={String(value)}>
{value === crop ? `${label} (this field's)` : label}
</option>
))}
</select>
</label>
</div>
</div>
<div className="flex flex-wrap justify-end gap-2 border-t border-brand/15 px-5 py-4">
<button type="button" onClick={() => finish(file)} className={button}>
Upload as is
</button>
<button
type="button"
onClick={save}
disabled={!img || saving}
className="btn bg-action px-4 py-1.5 text-sm text-white transition-colors hover:bg-action-hover disabled:bg-muted/25"
>
{saving ? "Framing…" : "Use this framing"}
</button>
</div>
</dialog>
);
}

View file

@ -47,7 +47,6 @@ import { useAuth } from "../../lib/auth.tsx";
import { clock, parseClock } from "../../lib/clock.ts"; import { clock, parseClock } from "../../lib/clock.ts";
import { canWrite as roleCanWrite } from "../../lib/roles.ts"; import { canWrite as roleCanWrite } from "../../lib/roles.ts";
import { useSmallImage } from "../../lib/useSmallImage.ts"; import { useSmallImage } from "../../lib/useSmallImage.ts";
import CropDialog, { type Crop } from "./CropDialog.tsx";
export type MediaItem = { export type MediaItem = {
id: number; id: number;
@ -188,41 +187,29 @@ export function UploadButton({
multiple = false, multiple = false,
label = "Upload", label = "Upload",
folder, folder,
crop,
}: { }: {
onUploaded: (item: MediaItem) => void; onUploaded: (item: MediaItem) => void;
multiple?: boolean; multiple?: boolean;
label?: string; label?: string;
/** Where it goes; blank: the server's default, images. */ /** Where it goes; blank: the server's default, images. */
folder?: string; folder?: string;
/** The field's shape: a photo is framed (CropDialog) before it goes. */
crop?: Crop;
}) { }) {
const inputRef = useRef<HTMLInputElement>(null); const inputRef = useRef<HTMLInputElement>(null);
const keepId = useId(); const keepId = useId();
const [keepOriginal, setKeepOriginal] = useState(false); const [keepOriginal, setKeepOriginal] = useState(false);
const [busy, setBusy] = useState(false); const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null); const [error, setError] = useState<string | null>(null);
const [framing, setFraming] = useState<File | null>(null);
// Captions are kept as they are, so there's no original to keep. // Captions are kept as they are, so there's no original to keep.
const captions = folder === "captions"; const captions = folder === "captions";
// A single photo for a field with a shape is framed first; SVGs and async function send(files: FileList | null) {
// GIFs (which would lose their animation) go as they are. if (!files || files.length === 0) return;
function choose(files: FileList | null) {
const one = files?.length === 1 ? files[0] : null;
if (crop && one && /^image\/(jpeg|png|webp)$/.test(one.type)) setFraming(one);
else send(files ? Array.from(files) : []);
}
async function send(files: File[]) {
if (files.length === 0) return;
setBusy(true); setBusy(true);
setError(null); setError(null);
try { try {
// One at a time: each is up to 25 MB, and a failure should // One at a time: each is up to 25 MB, and a failure should
// name the file it happened to. // name the file it happened to.
for (const file of files) { for (const file of Array.from(files)) {
try { try {
onUploaded(await uploadImage(file, keepOriginal, folder)); onUploaded(await uploadImage(file, keepOriginal, folder));
} catch (err) { } catch (err) {
@ -254,7 +241,7 @@ export function UploadButton({
accept={captions ? ".vtt,text/vtt" : "image/jpeg,image/png,image/gif,image/webp,image/svg+xml"} accept={captions ? ".vtt,text/vtt" : "image/jpeg,image/png,image/gif,image/webp,image/svg+xml"}
multiple={multiple} multiple={multiple}
className="hidden" className="hidden"
onChange={(e) => choose(e.target.files)} onChange={(e) => send(e.target.files)}
/> />
{!captions && ( {!captions && (
<label htmlFor={keepId} className="flex items-center gap-1.5 text-xs text-muted"> <label htmlFor={keepId} className="flex items-center gap-1.5 text-xs text-muted">
@ -270,17 +257,6 @@ export function UploadButton({
)} )}
</div> </div>
{error && <p className="mt-1 text-xs text-danger">{error}</p>} {error && <p className="mt-1 text-xs text-danger">{error}</p>}
{framing && crop && (
<CropDialog
file={framing}
crop={crop}
onDone={(file) => {
setFraming(null);
if (file) send([file]);
else if (inputRef.current) inputRef.current.value = "";
}}
/>
)}
</div> </div>
); );
} }
@ -559,7 +535,6 @@ export function ImageInput({
resolve, resolve,
folder, folder,
videoUrl, videoUrl,
crop,
locked, locked,
className, className,
onChange, onChange,
@ -571,8 +546,6 @@ export function ImageInput({
folder?: string; folder?: string;
/** A video link to take a frame from (the field's `frameFrom`). */ /** A video link to take a frame from (the field's `frameFrom`). */
videoUrl?: string | null; videoUrl?: string | null;
/** The field's `crop`: uploads are framed to it first. */
crop?: Crop;
locked: boolean; locked: boolean;
className: string; className: string;
onChange: (value: string) => void; onChange: (value: string) => void;
@ -614,7 +587,7 @@ export function ImageInput({
/> />
{editable && ( {editable && (
<div className="flex flex-wrap items-start gap-2"> <div className="flex flex-wrap items-start gap-2">
<UploadButton folder={folder} crop={crop} onUploaded={(item) => onChange(item.url)} /> <UploadButton folder={folder} onUploaded={(item) => onChange(item.url)} />
<button type="button" className={button} onClick={() => setPicking(true)}> <button type="button" className={button} onClick={() => setPicking(true)}>
Choose from library Choose from library
</button> </button>

View file

@ -77,9 +77,7 @@
`folder` ("logos" for logo and icon fields) is where uploads go and `folder` ("logos" for logo and icon fields) is where uploads go and
the tab the library opens on. `frameFrom` names the row's video the tab the library opens on. `frameFrom` names the row's video
link field and adds "Frame at" (a still at a typed time, saved to link field and adds "Frame at" (a still at a typed time, saved to
thumbnails/); `frameWhen` limits it to rows that match. `crop` (a thumbnails/); `frameWhen` limits it to rows that match.
width-over-height shape, or "free") frames an uploaded photo before
it goes (CropDialog.tsx); logo fields leave it off.
Two options change the box itself rather than what goes in it: Two options change the box itself rather than what goes in it:
@ -392,7 +390,6 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
value={value} value={value}
resolve={field.resolve} resolve={field.resolve}
folder={field.folder} folder={field.folder}
crop={field.crop}
videoUrl={field.frameFrom && fieldShown({ when: field.frameWhen }, row) ? getPath(row, field.frameFrom) : null} videoUrl={field.frameFrom && fieldShown({ when: field.frameWhen }, row) ? getPath(row, field.frameFrom) : null}
locked={locked} locked={locked}
className={locked ? inputLocked : common.className} className={locked ? inputLocked : common.className}

View file

@ -89,9 +89,8 @@ export const AREA_BY_CODE = Object.fromEntries(AREAS.map((a) => [a.code, a]));
one place that translates between the two, so adding a Mexico one place that translates between the two, so adding a Mexico
band later means a line here and nothing in SQL. band later means a line here and nothing in SQL.
Returns null for anything with no tile: a group with no state Returns null for anything with no tile, which covers virtual
(an online one, often) and any country not drawn. Tags, Online groups and any country not drawn.
included, don't keep a group off its state's tile.
───────────────────────────────────────────────────────────── */ ───────────────────────────────────────────────────────────── */
const COUNTRY_AREA = { const COUNTRY_AREA = {
CA: "CANADA", // ISO country code, not California CA: "CANADA", // ISO country code, not California
@ -99,6 +98,7 @@ const COUNTRY_AREA = {
export function areaForGroup(group) { export function areaForGroup(group) {
if (!group) return null; if (!group) return null;
if (group.is_online) return null;
if (group.country === "US") { if (group.country === "US") {
return AREA_BY_CODE[group.state_code] ? group.state_code : null; return AREA_BY_CODE[group.state_code] ? group.state_code : null;

View file

@ -28,7 +28,6 @@ import { frontPage } from "./adminSchema/frontPage.ts";
import { blogPosts } from "./adminSchema/blog.ts"; import { blogPosts } from "./adminSchema/blog.ts";
import { siteSettings } from "./adminSchema/siteSettings.ts"; import { siteSettings } from "./adminSchema/siteSettings.ts";
import { personTagTypes } from "./adminSchema/personTags.ts"; import { personTagTypes } from "./adminSchema/personTags.ts";
import { tags } from "./adminSchema/tags.ts";
import { contactTypes } from "./adminSchema/contactTypes.ts"; import { contactTypes } from "./adminSchema/contactTypes.ts";
import { redirects } from "./adminSchema/redirects.ts"; import { redirects } from "./adminSchema/redirects.ts";
import { import {
@ -44,7 +43,6 @@ export const ADMIN_ENTITIES: Record<string, any> = {
events, events,
people, people,
person_tag_types: personTagTypes, person_tag_types: personTagTypes,
tags,
contact_types: contactTypes, contact_types: contactTypes,
redirects, redirects,
teams, teams,

View file

@ -51,7 +51,7 @@ export const blogPosts = {
full: true, full: true,
help: "A sentence or two for the card. Default: the body's first paragraph.", help: "A sentence or two for the card. Default: the body's first paragraph.",
}, },
{ path: "cover_image", label: "Cover image", widget: "image", crop: 16 / 9, resolve: mediaUrl, full: true }, { path: "cover_image", label: "Cover image", widget: "image", resolve: mediaUrl, full: true },
{ {
path: "show_contents", path: "show_contents",
label: "Show contents", label: "Show contents",
@ -71,7 +71,7 @@ export const blogPosts = {
note: "For a writer with no People record. People who wrote it go under Authors below; both can be set.", note: "For a writer with no People record. People who wrote it go under Authors below; both can be set.",
fields: [ fields: [
{ path: "guest_author", label: "Name" }, { path: "guest_author", label: "Name" },
{ path: "guest_photo", label: "Photo", widget: "image", crop: 1, resolve: mediaUrl, full: true }, { path: "guest_photo", label: "Photo", widget: "image", resolve: mediaUrl, full: true },
], ],
}, },
{ {

View file

@ -1,5 +1,5 @@
import { mediaUrl } from "../media.ts"; import { mediaUrl } from "../media.ts";
import { PLACE_FIELDS, PUBLISHED_FIELD, LISTED_FIELD, timelineGroup, timelineDetailGroup, linksChild, hostsChild, blocksChild, tagsChild } from "./shared.ts"; import { PLACE_FIELDS, PUBLISHED_FIELD, LISTED_FIELD, timelineGroup, timelineDetailGroup, linksChild, hostsChild, blocksChild } from "./shared.ts";
/* ── Events ──────────────────────────────────────────────────── */ /* ── Events ──────────────────────────────────────────────────── */
@ -151,7 +151,6 @@ export const events = {
path: "photo", path: "photo",
label: "Event photo", label: "Event photo",
widget: "image", widget: "image",
crop: 16 / 9,
resolve: mediaUrl, resolve: mediaUrl,
full: true, full: true,
help: "16:9, eg. 1920 x 1080, shown whole: at the top of the event's page, as the front page's featured event, on featured cards, in the newsletter and when the page is shared.", help: "16:9, eg. 1920 x 1080, shown whole: at the top of the event's page, as the front page's featured event, on featured cards, in the newsletter and when the page is shared.",
@ -166,7 +165,6 @@ export const events = {
path: "card_image", path: "card_image",
label: "Card background", label: "Card background",
widget: "image", widget: "image",
crop: 1,
resolve: mediaUrl, resolve: mediaUrl,
full: true, full: true,
help: "Only behind the event's card, faded so the text stays readable and cropped to the card's shape (about square). Keep the subject centered and leave words out.", help: "Only behind the event's card, faded so the text stays readable and cropped to the card's shape (about square). Keep the subject centered and leave words out.",
@ -180,7 +178,6 @@ export const events = {
children: [ children: [
hostsChild, hostsChild,
tagsChild,
{ {
key: "event_people", key: "event_people",
label: "People at this event", label: "People at this event",

View file

@ -195,7 +195,7 @@ export const frontPage = {
title: (row) => row.caption || row.media || "New photo", title: (row) => row.caption || row.media || "New photo",
blank: { media: "", alt: "", caption: "" }, blank: { media: "", alt: "", caption: "" },
fields: [ fields: [
{ path: "media", label: "Photo", required: true, widget: "image", crop: 16 / 9, resolve: mediaUrl, full: true }, { path: "media", label: "Photo", required: true, widget: "image", resolve: mediaUrl, full: true },
{ path: "alt", label: "Description", help: "For screen readers" }, { path: "alt", label: "Description", help: "For screen readers" },
{ path: "caption", label: "Caption", full: true }, { path: "caption", label: "Caption", full: true },
{ path: "link_url", label: "Link", help: "Optional; makes the caption a link" }, { path: "link_url", label: "Link", help: "Optional; makes the caption a link" },

View file

@ -1,5 +1,5 @@
import { mediaUrl } from "../media.ts"; import { mediaUrl } from "../media.ts";
import { PLACE_FIELDS, PUBLISH_FIELDS, timelineGroup, timelineDetailGroup, linksChild, blocksChild, tagsChild } from "./shared.ts"; import { PLACE_FIELDS, PUBLISH_FIELDS, timelineGroup, timelineDetailGroup, linksChild, blocksChild } from "./shared.ts";
/* ── Organizations ───────────────────────────────────────────── */ /* ── Organizations ───────────────────────────────────────────── */
@ -89,7 +89,6 @@ export const organizations = {
], ],
children: [ children: [
tagsChild,
{ {
key: "region_areas", key: "region_areas",
label: "Map areas", label: "Map areas",

View file

@ -38,7 +38,7 @@ export const people = {
full: true, full: true,
help: "One line shown in directories, eg. Vocals, piano · Gospel, folk", help: "One line shown in directories, eg. Vocals, piano · Gospel, folk",
}, },
{ path: "photo", label: "Photo", widget: "image", crop: 1, resolve: mediaUrl, full: true }, { path: "photo", label: "Photo", widget: "image", resolve: mediaUrl, full: true },
{ {
path: "primary_org_id", path: "primary_org_id",
label: "Home organization", label: "Home organization",

View file

@ -15,6 +15,7 @@ export const PLACE_FIELDS = [
{ path: "location_label", label: "Display location", help: "Overrides the line built from city and state" }, { path: "location_label", label: "Display location", help: "Overrides the line built from city and state" },
{ path: "latitude", label: "Latitude", widget: "number" }, { path: "latitude", label: "Latitude", widget: "number" },
{ path: "longitude", label: "Longitude", widget: "number" }, { path: "longitude", label: "Longitude", widget: "number" },
{ path: "is_online", label: "Online", widget: "checkbox" },
]; ];
export const PUBLISHED_FIELD = { path: "is_published", label: "Published", widget: "checkbox" }; export const PUBLISHED_FIELD = { path: "is_published", label: "Published", widget: "checkbox" };
@ -188,7 +189,6 @@ export const featuredCardsChild = {
path: "image", path: "image",
label: "Image", label: "Image",
widget: "image", widget: "image",
crop: "free",
resolve: mediaUrl, resolve: mediaUrl,
full: true, full: true,
frameFrom: "url", frameFrom: "url",
@ -198,18 +198,6 @@ export const featuredCardsChild = {
], ],
}; };
/* An organization's or event's tags (070_tags.sql): Online,
In-Person and whatever else Data → Tags holds. */
export const tagsChild = {
key: "tags",
label: "Tags",
note: "Shown on its page, eg. Online or In-Person. Tags are made under Data → Tags.",
addLabel: "Add tag",
title: (row, options) => options?.tags?.find((t) => t.id === row.tag_id)?.label ?? "New tag",
blank: { tag_id: "" },
fields: [{ path: "tag_id", label: "Tag", widget: "select", optionsFrom: "tags", required: true }],
};
/* The two collections every entity carries. */ /* The two collections every entity carries. */
export const linksChild = { export const linksChild = {
key: "links", key: "links",
@ -364,10 +352,8 @@ export const blocksChild = {
widget: "select", widget: "select",
options: [ options: [
["body", "The page"], ["body", "The page"],
["card", "The card only (paragraphs only)"], ["card", "The card (paragraphs only)"],
["both", "The card and the page"],
], ],
help: "The card is the record's card in lists and carousels, and takes paragraphs only.",
}, },
{ {
path: "type", path: "type",
@ -404,7 +390,6 @@ export const blocksChild = {
path: "media", path: "media",
label: "Image", label: "Image",
widget: "image", widget: "image",
crop: "free",
resolve: mediaUrl, resolve: mediaUrl,
full: true, full: true,
when: { path: "type", value: ["image", "video"] }, when: { path: "type", value: ["image", "video"] },
@ -497,7 +482,6 @@ export const blocksChild = {
path: "media", path: "media",
label: "Picture", label: "Picture",
widget: "image", widget: "image",
crop: 16 / 9,
resolve: mediaUrl, resolve: mediaUrl,
full: true, full: true,
help: "Optional. Default: none, the card is text only.", help: "Optional. Default: none, the card is text only.",
@ -515,7 +499,6 @@ export const blocksChild = {
path: "media", path: "media",
label: "Graphic", label: "Graphic",
widget: "image", widget: "image",
crop: "free",
resolve: mediaUrl, resolve: mediaUrl,
full: true, full: true,
help: "Optional, in the fold-out: a map of the site, a slide, a poster", help: "Optional, in the fold-out: a map of the site, a slide, a poster",
@ -535,16 +518,6 @@ export const blocksChild = {
help: "Optional, in the fold-out: a place or address for a Google map, eg. Camp Hebron, Halifax PA", help: "Optional, in the fold-out: a place or address for a Google map, eg. Camp Hebron, Halifax PA",
when: SCHEDULE_ENTRY, when: SCHEDULE_ENTRY,
}, },
{
path: "map_image",
label: "Map image",
widget: "image",
crop: "free",
resolve: mediaUrl,
full: true,
help: "Optional: your own map, eg. the camp with the room marked. Shown in the fold-out in place of the Google map (which stays a link), and as a slide when the schedule is presented.",
when: SCHEDULE_ENTRY,
},
], ],
}, },
], ],

View file

@ -1,32 +0,0 @@
/* ── Tags (070_tags.sql) ─────────────────────────────────────────
Data → Tags: descriptors an organization or event can carry, eg.
Online, In-Person, shown on its page (and on a group's entry in
the Community map). Which records carry a tag is edited on the
record. Server side: server/src/admin-schema/tags.js. */
export const tags = {
key: "tags",
label: "Tags",
singular: "tag",
idLabel: "URL ID",
slugFrom: "name",
list: {
columns: [
{ key: "name", label: "Name", primary: true },
{ key: "sort_order", label: "Order" },
],
filters: [],
},
groups: [
{
legend: "Tag",
note: "The tag with URL ID online marks an event as online: the calendar's Online filter and its place line read it.",
fields: [
{ path: "name", label: "Name", required: true, help: "As shown, eg. In-Person" },
{ path: "sort_order", label: "Sort order", widget: "number" },
],
},
],
};

View file

@ -67,8 +67,6 @@ export type ContentBlockItem = {
/** The graphic's alt text; blank means decorative. */ /** The graphic's alt text; blank means decorative. */
media_alt?: string | null media_alt?: string | null
map?: string | null map?: string | null
/** The entry's own map picture (069), shown in place of Google's. */
map_image?: string | null
person?: { id: string; name: string; photo?: string | null; tagline?: string | null } | null person?: { id: string; name: string; photo?: string | null; tagline?: string | null } | null
} }
@ -114,9 +112,6 @@ export type EventAward = {
citation?: string | null citation?: string | null
} }
/** A descriptor tag (070_tags.sql), eg. Online or In-Person. */
export type Tag = { id: string; name: string }
export type EventRecord = { export type EventRecord = {
id: string id: string
/** Whose gathering it is: an event_scopes id. */ /** Whose gathering it is: an event_scopes id. */
@ -136,10 +131,7 @@ export type EventRecord = {
locality?: string | null locality?: string | null
state_code?: string | null state_code?: string | null
country?: string | null country?: string | null
/** The event carries the "online" tag (v_events). */
is_online: boolean is_online: boolean
/** Its tags: on the event's own page only. */
tags?: Tag[]
org_logo?: string | null org_logo?: string | null
event_logo?: string | null event_logo?: string | null
color?: string | null color?: string | null
@ -237,17 +229,13 @@ export type OrganizationRecord = {
state_code?: string | null state_code?: string | null
country?: string | null country?: string | null
location_label?: string | null location_label?: string | null
tags: Tag[] is_online: boolean
description: string[] description: string[]
blocks: ContentBlock[] blocks: ContentBlock[]
links: Link[] links: Link[]
socials: Link[] socials: Link[]
/** Every website and email row (an email's url is the bare address). */ /* splitLinks in shape.js lifts these out as bare strings: the
websites: Link[] website's url, the email's label, the instagram handle. */
emails: Link[]
/* splitLinks in shape.js lifts these out as bare strings, for
cards: the first website's url, the first email's address, the
instagram handle. */
website?: string | null website?: string | null
email?: string | null email?: string | null
instagram?: string | null instagram?: string | null

View file

@ -22,7 +22,6 @@ import PageShell, { type ShellSection } from '../components/PageShell.tsx'
import PageState from '../components/PageState.tsx' import PageState from '../components/PageState.tsx'
import PlatformIcon from '../components/PlatformIcon.tsx' import PlatformIcon from '../components/PlatformIcon.tsx'
import ContentBlocks from '../components/ContentBlocks.tsx' import ContentBlocks from '../components/ContentBlocks.tsx'
import Tags from '../components/Tags.tsx'
import PeopleTiles, { type PeopleGroupInput } from '../components/PeopleTiles.tsx' import PeopleTiles, { type PeopleGroupInput } from '../components/PeopleTiles.tsx'
import { import {
useEvent, useEvent,
@ -108,8 +107,14 @@ export default function EventDetail() {
/> />
)} )}
{event.description.map((paragraph, index) => (
<p key={index} className="leading-relaxed max-w-3xl" style={{ color: BODY }}>
{paragraph}
</p>
))}
<div className="max-w-3xl"> <div className="max-w-3xl">
<ContentBlocks blocks={event.blocks} accent={accent} presentAt={`/events/${encodeURIComponent(event.id)}/present`} /> <ContentBlocks blocks={event.blocks} accent={accent} />
</div> </div>
{event.links.length > 0 && ( {event.links.length > 0 && (
@ -238,7 +243,8 @@ export default function EventDetail() {
function Facts({ event, accent }: { event: EventRecord; accent: string }) { function Facts({ event, accent }: { event: EventRecord; accent: string }) {
const where = const where =
event.location_label || event.location_label ||
[event.locality, event.state_code].filter(Boolean).join(', ') [event.locality, event.state_code].filter(Boolean).join(', ') ||
(event.is_online ? 'Online' : null)
const schedule = seriesLabel(event.series, event.starts_on) const schedule = seriesLabel(event.series, event.starts_on)
// A series with no label of its own is described by its schedule // A series with no label of its own is described by its schedule
@ -277,7 +283,9 @@ function Facts({ event, accent }: { event: EventRecord; accent: string }) {
{when && <span style={{ color: BODY }}>{when}</span>} {when && <span style={{ color: BODY }}>{when}</span>}
{schedule && <span style={{ color: BODY }}>{schedule}</span>} {schedule && <span style={{ color: BODY }}>{schedule}</span>}
{where && <span style={{ color: BODY }}>{where}</span>} {where && <span style={{ color: BODY }}>{where}</span>}
<Tags tags={event.tags} accent={accent} /> {event.is_online && where !== 'Online' && (
<span style={{ color: BODY }}>Online too</span>
)}
{(event.hosts?.length ?? 0) > 0 && ( {(event.hosts?.length ?? 0) > 0 && (
<span style={{ color: BODY }}> <span style={{ color: BODY }}>

View file

@ -14,7 +14,6 @@
Organization page); its contact buttons are OrgContact. Organization page); its contact buttons are OrgContact.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
import type { ReactNode } from 'react'
import { Link, Navigate, useLocation, useParams } from 'react-router-dom' import { Link, Navigate, useLocation, useParams } from 'react-router-dom'
import PageShell from '../components/PageShell.tsx' import PageShell from '../components/PageShell.tsx'
@ -22,7 +21,6 @@ import PageState from '../components/PageState.tsx'
import ContentBlocks from '../components/ContentBlocks.tsx' import ContentBlocks from '../components/ContentBlocks.tsx'
import OrgTeams, { hasTeams } from '../components/OrgTeams.tsx' import OrgTeams, { hasTeams } from '../components/OrgTeams.tsx'
import OrgContact from '../components/OrgContact.tsx' import OrgContact from '../components/OrgContact.tsx'
import Tags from '../components/Tags.tsx'
import EventListCards from './sections/EventList-Cards.tsx' import EventListCards from './sections/EventList-Cards.tsx'
import { import {
useOrganization, useOrganization,
@ -84,6 +82,12 @@ export default function OrganizationDetail() {
<div className="max-w-6xl mx-auto px-6 space-y-8"> <div className="max-w-6xl mx-auto px-6 space-y-8">
<Facts org={org} accent={accent} /> <Facts org={org} accent={accent} />
{org.description.map((paragraph, index) => (
<p key={index} className="leading-relaxed max-w-3xl" style={{ color: BODY }}>
{paragraph}
</p>
))}
<div className="max-w-3xl"> <div className="max-w-3xl">
<ContentBlocks blocks={org.blocks} accent={accent} /> <ContentBlocks blocks={org.blocks} accent={accent} />
</div> </div>
@ -216,12 +220,6 @@ export default function OrganizationDetail() {
/* ── Pieces ──────────────────────────────────────────────────── */ /* ── Pieces ──────────────────────────────────────────────────── */
/* "Mid-Atlantic" reads as "Mid-Atlantic Region"; a name that already
ends in Region keeps it. */
const regionName = (name?: string | null) => (name && !/region$/i.test(name.trim()) ? `${name} Region` : name)
/* The facts at the top, framed: one labeled cell each (city, region,
ministry, meeting time, since) and the record's tags. */
function Facts({ function Facts({
org, org,
accent, accent,
@ -231,49 +229,50 @@ function Facts({
}) { }) {
const where = const where =
org.location_label || [org.locality, org.state_code].filter(Boolean).join(', ') org.location_label || [org.locality, org.state_code].filter(Boolean).join(', ')
const group = org.kind === 'group' ? org.details : null
const link = 'font-semibold hover:underline'
const facts = ([
['City', where],
[
'Part of',
group?.region_id && (
<Link to={orgHref(group.region_id, 'region')} className={link} style={{ color: accentText(group.region_color || accent) }}>
{regionName(group.region_name)}
</Link>
),
],
[
'Ministry',
group?.ministry_name &&
(group.ministry_url ? (
<a href={group.ministry_url} target="_blank" rel="noreferrer" className={link} style={{ color: accentText(accent) }}>
{group.ministry_name}
</a>
) : (
group.ministry_name
)),
],
['Meets', group?.meets],
['Since', group?.started],
] as [string, ReactNode][]).filter(([, value]) => Boolean(value))
if (facts.length === 0 && org.tags.length === 0) return null
return ( return (
<div className="max-w-3xl border-t-4 bg-raised p-5 shadow-sm" style={{ borderColor: accent }}> <div className="flex flex-wrap items-center gap-x-6 gap-y-3 text-sm">
{facts.length > 0 && ( {where && <span style={{ color: BODY }}>{where}</span>}
<dl className="grid grid-cols-1 gap-x-8 gap-y-4 sm:grid-cols-2">
{facts.map(([label, value]) => ( {org.kind === 'group' && org.details.region_id && (
<div key={label}> <span style={{ color: BODY }}>
<dt className="text-xs font-semibold uppercase tracking-wide text-muted">{label}</dt> Part of{' '}
<dd className="mt-0.5 font-semibold text-ink">{value}</dd> <Link
</div> to={orgHref(org.details.region_id, 'region')}
))} className="font-medium hover:underline"
</dl> style={{ color: org.details.region_color || accent }}
>
{org.details.region_name}
</Link>
</span>
)} )}
<Tags tags={org.tags} accent={accent} className={facts.length > 0 ? 'mt-4' : ''} />
{org.kind === 'group' && org.details.ministry_name && (
<span style={{ color: BODY }}>
Ministry:{' '}
{org.details.ministry_url ? (
<a
href={org.details.ministry_url}
target="_blank"
rel="noreferrer"
className="font-medium hover:underline"
style={{ color: accentText(accent) }}
>
{org.details.ministry_name}
</a>
) : (
org.details.ministry_name
)}
</span>
)}
{org.kind === 'group' && org.details.meets && (
<span style={{ color: BODY }}>Meets {org.details.meets}</span>
)}
{org.kind === 'group' && org.details.started && (
<span style={{ color: BODY }}>Since {org.details.started}</span>
)}
{org.is_online && <span style={{ color: BODY }}>Online</span>}
</div> </div>
) )
} }

View file

@ -85,7 +85,7 @@ export default function PersonDetail() {
<div className="max-w-6xl mx-auto px-6 space-y-8"> <div className="max-w-6xl mx-auto px-6 space-y-8">
<Facts person={person} accent={accent} /> <Facts person={person} accent={accent} />
{person.bio.map((paragraph, index) => ( {[...person.bio, ...person.description].map((paragraph, index) => (
<p key={index} className="leading-relaxed max-w-3xl" style={{ color: BODY }}> <p key={index} className="leading-relaxed max-w-3xl" style={{ color: BODY }}>
{paragraph} {paragraph}
</p> </p>

View file

@ -1,40 +0,0 @@
/* The schedule presentation's motion (SchedulePresent.tsx). The
reduced motion rule in index.css stops all of it. */
.present-in {
animation: present-in 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.present-from-below {
--present-from: translateY(2rem);
}
.present-from-left {
--present-from: translateX(-3rem);
}
.present-from-right {
--present-from: translateX(3rem);
}
@keyframes present-in {
from {
opacity: 0;
transform: var(--present-from);
}
to {
opacity: 1;
transform: none;
}
}
/* The bar along the bottom: fills over the slide's seconds (set
inline as animation-duration). */
.present-timer {
animation: present-timer linear both;
}
@keyframes present-timer {
from {
width: 0;
}
to {
width: 100%;
}
}

View file

@ -1,550 +0,0 @@
/* ═══════════════════════════════════════════════════════════════
SCHEDULE PRESENTATION: /events/:id/present?block=<n>
An event's schedule block as an endless slideshow for a screen
(digital signage), opened from the block's Present button. Outside
the site's Layout: no header, footer or backdrop.
First a setup screen: which days and entries, and how many seconds
each kind of slide stays up (0 leaves that kind out). Play writes
the choices into the address, so a signage device can bookmark it
and start the same way every time (`play=1` skips the setup).
The slides, for each day picked, in order:
overview the day's picked entries on one slide
spotlight one entry: its person beside title, time and place
graphic an entry's graphic, full screen
map an entry's own map image (069), full screen
Keys while playing: arrows step, Space pauses, Escape leaves full
screen (the browser's), S goes back to the setup.
═══════════════════════════════════════════════════════════════ */
import { ArrowsOut, CaretLeft, CaretRight, Gear, Pause, Play } from '@phosphor-icons/react'
import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
import { useParams, useSearchParams } from 'react-router-dom'
import PageState from '../components/PageState.tsx'
import { Avatar, groupByDay, mapAlt, type Day } from '../components/ScheduleBlock.tsx'
import { Paragraphs } from '../components/InlineText.tsx'
import { useEvent, type ContentBlockItem } from '../lib/useContent.ts'
import { mediaUrl } from '../lib/media.ts'
import { BRAND, accentText, readableOn } from '../lib/color.ts'
import { documentTitle } from '../lib/site.ts'
import './SchedulePresent.css'
/* Each kind of slide, its address key and seconds when unset. */
const KINDS = [
{ key: 'overview', label: 'Day overview', help: 'The whole day on one slide', seconds: 20 },
{ key: 'spotlight', label: 'Entry spotlight', help: 'One entry at a time, with its person', seconds: 12 },
{ key: 'graphic', label: 'Graphics', help: "An entry's graphic, full screen", seconds: 10 },
{ key: 'map', label: 'Map images', help: "An entry's own map, full screen", seconds: 10 },
] as const
type Kind = (typeof KINDS)[number]['key']
/* An overview with more entries than this goes to two columns. */
const ONE_COLUMN = 8
/* How long the controls stay up after the pointer last moved (ms). */
const CONTROLS_FOR = 2500
type Slide = { kind: Kind; seconds: number; day: Day; entry?: ContentBlockItem }
/* An entry's key in the address: day index, a dot, entry index. */
const entryKey = (day: number, entry: number) => `${day}.${entry}`
const list = (value: string | null) => (value ? value.split(',').filter(Boolean) : null)
function readSettings(params: URLSearchParams, days: Day[]) {
const pickedDays = list(params.get('days'))?.map(Number) ?? days.map((_, i) => i)
const hidden = new Set(list(params.get('hide')) ?? [])
const seconds = Object.fromEntries(
KINDS.map((kind) => {
const value = Number(params.get(kind.key) ?? kind.seconds)
return [kind.key, Number.isFinite(value) && value > 0 ? value : 0]
}),
) as Record<Kind, number>
return { pickedDays: new Set(pickedDays), hidden, seconds }
}
type Settings = ReturnType<typeof readSettings>
function buildSlides(days: Day[], { pickedDays, hidden, seconds }: Settings): Slide[] {
const slides: Slide[] = []
days.forEach((all, d) => {
if (!pickedDays.has(d)) return
const day = { ...all, entries: all.entries.filter((_, e) => !hidden.has(entryKey(d, e))) }
if (day.entries.length === 0) return
if (seconds.overview) slides.push({ kind: 'overview', seconds: seconds.overview, day })
for (const entry of day.entries) {
if (seconds.spotlight) slides.push({ kind: 'spotlight', seconds: seconds.spotlight, day, entry })
if (seconds.graphic && entry.media) slides.push({ kind: 'graphic', seconds: seconds.graphic, day, entry })
if (seconds.map && entry.map_image) slides.push({ kind: 'map', seconds: seconds.map, day, entry })
}
})
return slides
}
export default function SchedulePresent() {
const { id } = useParams()
const [params, setParams] = useSearchParams()
const { data: event, loading, error, notFound, reload } = useEvent(id)
const blockIndex = Number(params.get('block') ?? 0)
const schedule = event?.blocks?.filter((block) => block.type === 'schedule')[blockIndex]
const days = useMemo(() => groupByDay(schedule?.items ?? []), [schedule])
useEffect(() => {
if (event) document.title = documentTitle(`${event.title}: schedule`)
}, [event])
if (!event) {
return (
<PageState
loading={loading}
error={error}
notFound={notFound}
onRetry={reload}
noun="retreat"
backTo="/retreats"
backLabel="All retreats"
/>
)
}
const accent = event.color || BRAND
const back = `/events/${encodeURIComponent(event.id)}`
if (!schedule || days.length === 0) {
return (
<main className="min-h-screen bg-surface p-8">
<p className="notice">This event has no schedule to present.</p>
<a href={back} className="mt-4 inline-block text-link underline">
Back to {event.title}
</a>
</main>
)
}
const settings = readSettings(params, days)
if (params.get('play') === '1') {
return (
<Player
title={event.title}
accent={accent}
slides={buildSlides(days, settings)}
onSetup={() => {
const next = new URLSearchParams(params)
next.delete('play')
setParams(next)
}}
/>
)
}
return (
<Setup
title={event.title}
back={back}
accent={accent}
days={days}
settings={settings}
onPlay={(next) => {
// Full screen needs the click itself, so it's asked for here.
document.documentElement.requestFullscreen?.().catch(() => {})
const out = new URLSearchParams({ block: String(blockIndex) })
if (next.pickedDays.size < days.length) out.set('days', [...next.pickedDays].sort((a, b) => a - b).join(','))
if (next.hidden.size) out.set('hide', [...next.hidden].join(','))
for (const kind of KINDS) out.set(kind.key, String(next.seconds[kind.key]))
out.set('play', '1')
setParams(out)
}}
/>
)
}
/* ── Setup ──────────────────────────────────────────────────── */
function Setup({
title,
back,
accent,
days,
settings,
onPlay,
}: {
title: string
back: string
accent: string
days: Day[]
settings: Settings
onPlay: (settings: Settings) => void
}) {
const [pickedDays, setPickedDays] = useState(settings.pickedDays)
const [hidden, setHidden] = useState(settings.hidden)
const [seconds, setSeconds] = useState(settings.seconds)
const count = buildSlides(days, { pickedDays, hidden, seconds }).length
const toggle = <T,>(set: Set<T>, value: T) => {
const next = new Set(set)
if (next.has(value)) next.delete(value)
else next.add(value)
return next
}
return (
<main className="min-h-screen bg-surface text-body">
<div className="h-2" style={{ background: accent }} />
<div className="mx-auto max-w-4xl space-y-10 px-6 py-12">
<header>
<p className="text-sm font-semibold text-muted">Present the schedule</p>
<h1 className="text-4xl font-bold" style={{ color: accentText(accent) }}>
{title}
</h1>
<p className="mt-2 text-muted">
Pick what to show and for how long, then Play. It loops until you stop it. Bookmark the address after
pressing Play to start a screen the same way next time.
</p>
</header>
<section>
<h2 className="mb-4 text-2xl font-bold text-ink">Slides</h2>
<div className="grid gap-4 sm:grid-cols-2">
{KINDS.map((kind) => (
<label key={kind.key} className="flex items-center gap-4 bg-raised p-4 shadow-sm">
<span className="flex-1">
<span className="block font-semibold text-ink">{kind.label}</span>
<span className="text-sm text-muted">{kind.help}</span>
</span>
<input
type="number"
min={0}
max={600}
value={seconds[kind.key]}
onChange={(e) => setSeconds({ ...seconds, [kind.key]: Math.max(0, Number(e.target.value) || 0) })}
className="w-20 border border-muted/25 bg-surface px-2 py-1 text-right"
aria-describedby={`${kind.key}-unit`}
/>
<span id={`${kind.key}-unit`} className="text-sm text-muted">
sec
</span>
</label>
))}
</div>
<p className="mt-2 text-sm text-muted">0 leaves that kind of slide out.</p>
</section>
<section>
<h2 className="mb-4 text-2xl font-bold text-ink">Days and entries</h2>
<div className="space-y-6">
{days.map((day, d) => (
<fieldset key={d} className="bg-raised p-4 shadow-sm">
<legend className="sr-only">{day.name || 'Schedule'}</legend>
<label className="flex items-center gap-3 font-bold text-ink">
<input type="checkbox" checked={pickedDays.has(d)} onChange={() => setPickedDays(toggle(pickedDays, d))} />
{day.name || 'Schedule'}
</label>
<ul className="mt-3 space-y-2 pl-7">
{day.entries.map((entry, e) => (
<li key={e}>
<label className={`flex items-baseline gap-3 ${pickedDays.has(d) ? '' : 'opacity-50'}`}>
<input
type="checkbox"
disabled={!pickedDays.has(d)}
checked={!hidden.has(entryKey(d, e))}
onChange={() => setHidden(toggle(hidden, entryKey(d, e)))}
/>
<span className="w-32 shrink-0 text-sm text-muted">{entry.time}</span>
<span>{entry.text}</span>
</label>
</li>
))}
</ul>
</fieldset>
))}
</div>
</section>
<div className="flex flex-wrap items-center gap-4">
<button
type="button"
disabled={count === 0}
onClick={() => onPlay({ pickedDays, hidden, seconds })}
className="btn inline-flex items-center gap-2 px-6 py-3 disabled:opacity-50"
style={{ background: accent, color: readableOn(accent) }}
>
<Play aria-hidden="true" weight="fill" className="h-5 w-5" />
Play
</button>
<span className="text-sm text-muted">
{count === 0 ? 'Nothing picked to show.' : `${count} slide${count === 1 ? '' : 's'} in the loop`}
</span>
<a href={back} className="ml-auto text-sm text-link underline">
Back to the event
</a>
</div>
</div>
</main>
)
}
/* ── Player ─────────────────────────────────────────────────── */
function Player({
title,
accent,
slides,
onSetup,
}: {
title: string
accent: string
slides: Slide[]
onSetup: () => void
}) {
const [index, setIndex] = useState(0)
const [paused, setPaused] = useState(false)
const [controls, setControls] = useState(true)
const hideTimer = useRef(0)
const slide = slides[index % Math.max(slides.length, 1)]
const step = (by: number) => setIndex((i) => (i + by + slides.length) % slides.length)
// The next slide when this one's time is up.
useEffect(() => {
if (paused || !slide) return
const timer = window.setTimeout(() => step(1), slide.seconds * 1000)
return () => window.clearTimeout(timer)
}, [index, paused, slide?.seconds, slides.length])
useEffect(() => {
const onKey = (e: KeyboardEvent) => {
if (e.key === 'ArrowRight') step(1)
else if (e.key === 'ArrowLeft') step(-1)
else if (e.key === ' ') setPaused((p) => !p)
else if (e.key === 's' || e.key === 'S') onSetup()
else return
e.preventDefault()
}
window.addEventListener('keydown', onKey)
return () => window.removeEventListener('keydown', onKey)
})
// Keeps a signage screen from going to sleep, where the browser can.
useEffect(() => {
let lock: { release: () => Promise<void> } | null = null
const ask = () => {
if (document.visibilityState !== 'visible') return
;(navigator as any).wakeLock
?.request('screen')
.then((l: typeof lock) => (lock = l))
.catch(() => {})
}
ask()
document.addEventListener('visibilitychange', ask)
return () => {
document.removeEventListener('visibilitychange', ask)
lock?.release().catch(() => {})
}
}, [])
// The controls show while the pointer moves, then get out of the way.
const wake = () => {
setControls(true)
window.clearTimeout(hideTimer.current)
hideTimer.current = window.setTimeout(() => setControls(false), CONTROLS_FOR)
}
useEffect(() => {
wake()
return () => window.clearTimeout(hideTimer.current)
}, [])
if (!slide) {
return (
<main className="flex min-h-screen flex-col items-center justify-center gap-4 bg-surface">
<p className="notice">Nothing picked to show.</p>
<button type="button" onClick={onSetup} className="btn border border-muted/25 px-5 py-2">
Back to setup
</button>
</main>
)
}
const control = 'btn flex h-12 w-12 items-center justify-center bg-raised text-ink shadow-md'
return (
<main
onMouseMove={wake}
className={`present relative flex h-screen flex-col overflow-hidden bg-surface text-body ${controls ? '' : 'cursor-none'}`}
>
<div className="h-3 shrink-0" style={{ background: accent }} />
<div className="flex shrink-0 items-baseline justify-between gap-6 px-[4vw] pt-[2vh] text-[clamp(1rem,1.6vw,2rem)] text-muted">
<span className="font-semibold">{title}</span>
<span>{slide.day.name}</span>
</div>
{/* Keyed by index, so every slide's entrance animation plays. */}
<div key={index} className="min-h-0 flex-1 px-[4vw] py-[3vh]">
<SlideView slide={slide} accent={accent} />
</div>
{/* How long this slide has left. */}
<div className="h-1.5 shrink-0" style={{ background: `color-mix(in srgb, ${accent} 20%, transparent)` }}>
<div
key={`${index}-${paused}`}
className={paused ? 'h-full w-0' : 'present-timer h-full'}
style={{ background: accent, animationDuration: `${slide.seconds}s` }}
/>
</div>
<div
className={`absolute bottom-6 left-1/2 flex -translate-x-1/2 items-center gap-3 transition-opacity duration-300 ${
controls ? 'opacity-100' : 'pointer-events-none opacity-0'
}`}
>
<button type="button" onClick={() => step(-1)} className={control} aria-label="Previous slide">
<CaretLeft weight="bold" className="h-5 w-5" aria-hidden="true" />
</button>
<button type="button" onClick={() => setPaused((p) => !p)} className={control} aria-label={paused ? 'Play' : 'Pause'}>
{paused ? (
<Play weight="fill" className="h-5 w-5" aria-hidden="true" />
) : (
<Pause weight="bold" className="h-5 w-5" aria-hidden="true" />
)}
</button>
<button type="button" onClick={() => step(1)} className={control} aria-label="Next slide">
<CaretRight weight="bold" className="h-5 w-5" aria-hidden="true" />
</button>
<span className="bg-raised px-3 py-2 text-sm text-muted shadow-md">
{index + 1} / {slides.length}
</span>
<button
type="button"
onClick={() => document.documentElement.requestFullscreen?.().catch(() => {})}
className={control}
aria-label="Full screen"
>
<ArrowsOut weight="bold" className="h-5 w-5" aria-hidden="true" />
</button>
<button type="button" onClick={onSetup} className={control} aria-label="Back to setup">
<Gear weight="bold" className="h-5 w-5" aria-hidden="true" />
</button>
</div>
</main>
)
}
/* ── Slides ─────────────────────────────────────────────────── */
/* Fades and rises in after `order` steps, so a slide's parts arrive
one after another. */
function Rise({ order = 0, from = 'below', className = '', children }: {
order?: number
from?: 'below' | 'left' | 'right'
className?: string
children: ReactNode
}) {
return (
<div className={`present-in present-from-${from} ${className}`} style={{ animationDelay: `${order * 120}ms` }}>
{children}
</div>
)
}
function SlideView({ slide, accent }: { slide: Slide; accent: string }) {
const color = accentText(accent)
if (slide.kind === 'overview') {
const entries = slide.day.entries
const two = entries.length > ONE_COLUMN
return (
<div className="flex h-full flex-col">
<Rise>
<h1 className="mb-[3vh] text-[clamp(2rem,5vw,6rem)] font-bold leading-none" style={{ color }}>
{slide.day.name || 'Schedule'}
</h1>
</Rise>
<ul className={`grid min-h-0 flex-1 content-start gap-x-[4vw] ${two ? 'grid-cols-2' : 'grid-cols-1'}`}>
{entries.map((entry, i) => (
<li key={i}>
<Rise order={i + 1} from="left" className="flex items-baseline gap-[2vw] border-b border-brand/15 py-[1.2vh]">
<span className="w-[12vw] shrink-0 text-[clamp(1rem,1.8vw,2.4rem)] font-semibold" style={{ color }}>
{entry.time}
</span>
<span className="min-w-0 flex-1">
<span className="block text-[clamp(1.2rem,2.4vw,3rem)] font-bold leading-tight text-ink">
{entry.text}
</span>
{(entry.location || entry.person) && (
<span className="mt-1 flex flex-wrap items-center gap-x-[1.5vw] text-[clamp(0.9rem,1.4vw,1.8rem)] text-muted">
{entry.location && <span>{entry.location}</span>}
{entry.person && <span>{entry.person.name}</span>}
</span>
)}
</span>
</Rise>
</li>
))}
</ul>
</div>
)
}
const entry = slide.entry!
if (slide.kind === 'graphic' || slide.kind === 'map') {
const src = mediaUrl(slide.kind === 'map' ? entry.map_image : entry.media)
const alt = slide.kind === 'map' ? mapAlt(entry) : (entry.media_alt ?? '')
return (
<div className="flex h-full flex-col gap-[2vh]">
<Rise className="min-h-0 flex-1">
<img src={src ?? ''} alt={alt} className="h-full w-full object-contain" />
</Rise>
<Rise order={2} className="flex items-baseline gap-[2vw] text-[clamp(1.2rem,2.2vw,2.8rem)]">
<span className="font-semibold" style={{ color }}>
{entry.time}
</span>
<span className="font-bold text-ink">{entry.text}</span>
{slide.kind === 'map' && (entry.map || entry.location) && (
<span className="text-muted">{entry.map || entry.location}</span>
)}
</Rise>
</div>
)
}
// Spotlight: the person on the left, when there is one.
return (
<div className="flex h-full items-center gap-[5vw]">
{entry.person && (
<Rise from="left" className="flex w-[28vw] shrink-0 flex-col items-center text-center">
<Avatar person={entry.person} size="aspect-square w-full text-[4vw]" />
<p className="mt-[2vh] text-[clamp(1.4rem,2.6vw,3.2rem)] font-bold text-ink">{entry.person.name}</p>
{entry.person.tagline && (
<p className="text-[clamp(1rem,1.6vw,2rem)] text-muted">{entry.person.tagline}</p>
)}
</Rise>
)}
<div className="min-w-0 flex-1">
<Rise from="right">
<p className="text-[clamp(1.2rem,2.4vw,3rem)] font-semibold" style={{ color }}>
{[slide.day.name, entry.time].filter(Boolean).join(' · ')}
</p>
</Rise>
<Rise order={1} from="right">
<h1 className="mt-[1vh] text-[clamp(2.4rem,5.5vw,7rem)] font-bold leading-[1.05] text-ink">{entry.text}</h1>
</Rise>
{entry.location && (
<Rise order={2} from="right">
<p className="mt-[2vh] text-[clamp(1.2rem,2.4vw,3rem)] text-body">{entry.location}</p>
</Rise>
)}
{entry.detail && (
<Rise order={3} from="right">
<p className="mt-[1vh] text-[clamp(1rem,2vw,2.4rem)] text-muted">{entry.detail}</p>
</Rise>
)}
{entry.description && (
<Rise order={4} from="right">
<div className="mt-[3vh] line-clamp-6 space-y-3 text-[clamp(1rem,1.8vw,2.2rem)] leading-snug text-muted">
<Paragraphs text={entry.description} accent={accent} />
</div>
</Rise>
)}
</div>
</div>
)
}

View file

@ -44,7 +44,7 @@ export default function TeamDetail() {
const accent = team.color || BRAND const accent = team.color || BRAND
const hasAbout = const hasAbout =
team.blocks.length > 0 || team.links.length > 0 team.description.length > 0 || team.blocks.length > 0 || team.links.length > 0
const sections: any[] = [] const sections: any[] = []
@ -57,6 +57,12 @@ export default function TeamDetail() {
<div className="max-w-6xl mx-auto px-6 space-y-8"> <div className="max-w-6xl mx-auto px-6 space-y-8">
<Facts orgId={team.org.id} orgKind={team.org.kind} orgName={team.org.name} accent={accent} /> <Facts orgId={team.org.id} orgKind={team.org.kind} orgName={team.org.name} accent={accent} />
{team.description.map((paragraph, index) => (
<p key={index} className="leading-relaxed max-w-3xl" style={{ color: BODY }}>
{paragraph}
</p>
))}
<div className="max-w-3xl"> <div className="max-w-3xl">
<ContentBlocks blocks={team.blocks} accent={accent} /> <ContentBlocks blocks={team.blocks} accent={accent} />
</div> </div>

View file

@ -85,11 +85,6 @@ export const DATA_NAV = {
label: "People tags", label: "People tags",
blurb: "Directories people can be tagged into, eg. Musicians. Who carries a tag is edited on the person.", blurb: "Directories people can be tagged into, eg. Musicians. Who carries a tag is edited on the person.",
}, },
{
to: "/admin/tags",
label: "Tags",
blurb: "Descriptors for organizations and events, eg. Online, In-Person. Who carries a tag is edited on the record.",
},
{ {
to: "/admin/redirects", to: "/admin/redirects",
label: "Links/redirects", label: "Links/redirects",

View file

@ -592,7 +592,7 @@ export default function EventListCards({
} }
return ( return (
<div className="overflow-x-clip"> <div className="overflow-hidden">
{mixed && ( {mixed && (
<TypeFilter <TypeFilter
types={availableTypes} types={availableTypes}

View file

@ -36,12 +36,7 @@ const FALLBACK_COLOR = "#3b5456";
const CARD_MIN = "20rem"; const CARD_MIN = "20rem";
const GRID_MAX = "88rem"; const GRID_MAX = "88rem";
/* Under a block title the card names are a level below it. /* Under a block title the card names are a level below it. */
Logo first: most partners' logos carry their full name, so the
logo leads, large, and the name sits under it as the subtext (still
the card's heading, for screen readers and reading mode). With no
logo, its initials take the logo's place. */
function OrgCard({ org, accent, pageLabel, siteLabel, titled }) { function OrgCard({ org, accent, pageLabel, siteLabel, titled }) {
const color = org.color || accent; const color = org.color || accent;
const path = orgPath(org); const path = orgPath(org);
@ -55,36 +50,36 @@ function OrgCard({ org, accent, pageLabel, siteLabel, titled }) {
return ( return (
<div <div
className="relative p-4 sm:p-6 h-full flex flex-col bg-raised shadow-md transition-transform duration-200 hover:scale-[1.01]" className="p-4 sm:p-6 h-full flex flex-col transition-transform duration-200 hover:scale-[1.01]"
style={{ borderTop: `4px solid ${color}` }} style={{ border: `1px solid ${color}`, background: "var(--color-surface)" }}
> >
{/* Top-right rather than in the footer: the footer holds <div className="flex items-start gap-3 sm:gap-4">
outbound links, and the arrow goes somewhere different <OrgLogo org={org} color={color} size="h-10 w-10 sm:h-14 sm:w-14" />
in kind, deeper into this site. Reading mode has the
name's link and leaves it out. */} <div className="min-w-0 flex-1">
{path && !reading && ( <Name className="text-lg sm:text-xl font-bold leading-tight [overflow-wrap:anywhere]" style={{ color }}>
<div className="absolute top-3 right-3"> {path ? <Link to={path}>{org.name}</Link> : org.name}
</Name>
{subtitle && (
<p className="text-sm mt-0.5" style={{ color: MUTED }}>
{subtitle}
</p>
)}
</div>
{/* Top-right rather than in the footer: the footer holds
outbound links, and the arrow goes somewhere different
in kind, deeper into this site. Reading mode has the
name's link and leaves it out. */}
{path && !reading && (
<ArrowLink <ArrowLink
to={path} to={path}
label={`${org.name}: ${pageLabel}`} label={`${org.name}: ${pageLabel}`}
color={color} color={color}
/> />
</div> )}
)}
<div className="flex h-28 items-center justify-center px-10">
<OrgLogo org={org} color={color} size="h-full w-full max-w-[16rem]" fallbackSize="h-24 w-24 text-3xl" />
</div> </div>
<Name className="mt-4 text-sm font-semibold leading-snug [overflow-wrap:anywhere]" style={{ color: accentText(color) }}>
{path ? <Link to={path}>{org.name}</Link> : org.name}
</Name>
{subtitle && (
<p className="text-sm mt-0.5" style={{ color: MUTED }}>
{subtitle}
</p>
)}
{org.description?.length > 0 && ( {org.description?.length > 0 && (
<p <p
className="mt-4 text-sm leading-relaxed line-clamp-4" className="mt-4 text-sm leading-relaxed line-clamp-4"

View file

@ -1,11 +1,10 @@
import { CaretRight, MagnifyingGlass, X } from '@phosphor-icons/react'; import { CaretRight, MagnifyingGlass, X } from '@phosphor-icons/react';
import { Fragment, useMemo, useRef, useState } from "react"; import { Fragment, useEffect, useMemo, useRef, useState } from "react";
import { useCommunity } from "../../lib/useCommunity.ts"; import { useCommunity } from "../../lib/useCommunity.ts";
import { useOrganization } from "../../lib/useContent.ts"; import { useOrganization } from "../../lib/useContent.ts";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import ArrowLink from "../../components/ArrowLink.tsx"; import ArrowLink from "../../components/ArrowLink.tsx";
import OrgLogo from "../../components/OrgLogo.tsx"; import OrgLogo from "../../components/OrgLogo.tsx";
import Tags from "../../components/Tags.tsx";
import { orgPath } from "../../lib/organizations.ts"; import { orgPath } from "../../lib/organizations.ts";
import { AREAS, AREA_NAMES } from "../../data/mapGrid.ts"; import { AREAS, AREA_NAMES } from "../../data/mapGrid.ts";
import { accentText, readableOn } from '../../lib/color.ts' import { accentText, readableOn } from '../../lib/color.ts'
@ -158,7 +157,6 @@ function Tile({
count = 0, count = 0,
selected, selected,
hovered, hovered,
hoveredArea,
setSelected, setSelected,
setHovered, setHovered,
onPick, onPick,
@ -170,23 +168,19 @@ function Tile({
const ids = slices.map(s => s.regionId); const ids = slices.map(s => s.regionId);
const active = ids.includes(selected) || ids.includes(hovered); const active = ids.includes(selected) || ids.includes(hovered);
const dimmed = selected && !ids.includes(selected); const dimmed = selected && !ids.includes(selected);
// The state under the pointer, outlined in ink over its region's
// color, so both read at once.
const here = hoveredArea === code;
const clipId = `clip-${code}`; const clipId = `clip-${code}`;
// Solid, never see-through: a tile with no groups, or one dimmed // Solid, never see-through: a tile with no groups, or one dimmed
// while another region is picked, is its color mixed toward the // while another region is picked, is its color mixed toward the
// page's rather than faded, so the backdrop doesn't show through. // page's rather than faded, so the backdrop doesn't show through.
const strength = dimmed ? (count ? 35 : 15) : count ? 100 : here ? 70 : active ? 50 : 28; const strength = dimmed ? (count ? 35 : 15) : count ? 100 : active ? 50 : 28;
const tileFill = (color: string) => `color-mix(in srgb, ${color} ${strength}%, var(--color-surface))`; const tileFill = (color: string) => `color-mix(in srgb, ${color} ${strength}%, var(--color-surface))`;
// Clicking a shared tile cycles through its regions and then // Clicking a shared tile cycles through its regions and then
// clears, so every slice is reachable without a second control. // clears, so every slice is reachable without a second control.
const cycle = () => { const cycle = () => {
onPick?.(code);
const at = ids.indexOf(selected); const at = ids.indexOf(selected);
const next = at === ids.length - 1 ? null : ids[at + 1]; setSelected(at === ids.length - 1 ? null : ids[at + 1]);
onPick?.(code, next);
setSelected(next);
}; };
const name = `${AREA_NAMES[code] || code}: ${slices.map(s => s.name).join(" / ")}${ const name = `${AREA_NAMES[code] || code}: ${slices.map(s => s.name).join(" / ")}${
@ -199,14 +193,14 @@ function Tile({
return ( return (
<g <g
onClick={cycle} onClick={cycle}
onMouseEnter={() => setHovered(primary.regionId, code)} onMouseEnter={() => setHovered(primary.regionId)}
onMouseLeave={() => setHovered(null)} onMouseLeave={() => setHovered(null)}
{...(count {...(count
? { ? {
role: "button", role: "button",
tabIndex: 0, tabIndex: 0,
"aria-label": name, "aria-label": name,
onFocus: () => setHovered(primary.regionId, code), onFocus: () => setHovered(primary.regionId),
onBlur: () => setHovered(null), onBlur: () => setHovered(null),
onKeyDown: (e) => { onKeyDown: (e) => {
if (e.key !== "Enter" && e.key !== " ") return; if (e.key !== "Enter" && e.key !== " ") return;
@ -247,9 +241,9 @@ function Tile({
width={width} width={width}
height={size} height={size}
fill="none" fill="none"
stroke={here ? "var(--color-ink)" : active ? colorOf(primary) : "var(--color-surface)"} stroke={active ? colorOf(primary) : "var(--color-surface)"}
strokeOpacity={active || here ? 1 : 0.55} strokeOpacity={active ? 1 : 0.55}
strokeWidth={here ? 6 : active ? 4 : 2} strokeWidth={active ? 4 : 2}
className="transition-all duration-200" className="transition-all duration-200"
/> />
@ -310,14 +304,11 @@ function RegionMap({ slices, groupCounts, ...props }: any) {
); );
} }
function LegendButton({ region, selected, setSelected, hovered, setHovered, onPickRegion }) { function LegendButton({ region, selected, setSelected, hovered, setHovered }) {
const on = selected === region.id || hovered === region.id; const on = selected === region.id || hovered === region.id;
return ( return (
<button <button
onClick={() => { onClick={() => setSelected(selected === region.id ? null : region.id)}
if (selected !== region.id) onPickRegion(region.id);
setSelected(selected === region.id ? null : region.id);
}}
onMouseEnter={() => setHovered(region.id)} onMouseEnter={() => setHovered(region.id)}
onMouseLeave={() => setHovered(null)} onMouseLeave={() => setHovered(null)}
onFocus={() => setHovered(region.id)} onFocus={() => setHovered(region.id)}
@ -395,19 +386,9 @@ function RegionBlock({
setHovered, setHovered,
indent, indent,
regionRefs, regionRefs,
stateRefs, groupRefs,
}) { }) {
const on = selected === region.id; const on = selected === region.id;
// Each state with groups, by name, its groups under it; groups with
// no state (online, or not placed) last, with no subheading.
const areas = new Map<string, any[]>();
for (const c of groups) {
const code = c.area_code ?? "";
areas.set(code, [...(areas.get(code) ?? []), c]);
}
const byArea = [...areas].sort(([a], [b]) =>
!a ? 1 : !b ? -1 : (AREA_NAMES[a] || a).localeCompare(AREA_NAMES[b] || b),
);
return ( return (
<div <div
@ -447,68 +428,57 @@ function RegionBlock({
No groups yet. Interested in starting one? No groups yet. Interested in starting one?
</p> </p>
) : ( ) : (
<div className="ml-5 mb-4 flex flex-col gap-4"> <ul className="ml-5 mb-4 flex flex-col gap-3">
{byArea.map(([code, list]) => ( {groups.map(c => (
<div key={code} ref={el => { if (code) stateRefs.current[`${region.id}:${code}`] = el; }}> <li
{code && ( key={c.id}
<h5 className="mb-2 text-xs font-bold uppercase tracking-wide" style={{ color: MUTED }}> ref={el => groupRefs && (groupRefs.current[c.id] = el)}
{AREA_NAMES[code] || code} className="pl-3 flex items-start gap-3"
</h5> style={{ borderLeft: `2px solid ${colorOf(region)}` }}
)} >
<ul className="flex flex-col gap-3"> <div className="min-w-0 flex-1">
{list.map(c => ( <p className="font-bold">{c.name}</p>
<li <p className="text-sm" style={{ color: FALLBACK_COLOR }}>
key={c.id} {c.location_label}
className="bg-raised shadow-sm p-3 flex items-start gap-3" {c.meets ? ` · ${c.meets}` : ""}
style={{ borderLeft: `3px solid ${colorOf(region)}` }} </p>
> {(c.website || c.email) && (
<div className="min-w-0 flex-1"> <p className="text-sm mt-1 flex gap-4">
<p className="font-bold">{c.name}</p> {c.website && (
<p className="text-sm" style={{ color: FALLBACK_COLOR }}> <a
{c.location_label} href={c.website}
{c.meets ? ` · ${c.meets}` : ""} target="_blank"
</p> rel="noopener noreferrer"
<Tags tags={c.tags} accent={colorOf(region)} className="mt-1.5" /> className="font-bold underline"
{(c.website || c.email) && ( style={{ color: colorOf(region) }}
<p className="text-sm mt-1 flex gap-4"> >
{c.website && ( Details
<a </a>
href={c.website}
target="_blank"
rel="noopener noreferrer"
className="font-bold underline"
style={{ color: colorOf(region) }}
>
Details
</a>
)}
{c.email && (
<a
href={`mailto:${c.email}`}
className="font-bold underline"
style={{ color: colorOf(region) }}
>
Contact
</a>
)}
</p>
)}
</div>
{orgPath(c) && (
<ArrowLink
to={orgPath(c)}
label={`${c.name}: group page`}
color={colorOf(region)}
size="h-8 w-8"
/>
)} )}
</li> {c.email && (
))} <a
</ul> href={`mailto:${c.email}`}
</div> className="font-bold underline"
style={{ color: colorOf(region) }}
>
Contact
</a>
)}
</p>
)}
</div>
{orgPath(c) && (
<ArrowLink
to={orgPath(c)}
label={`${c.name}: group page`}
color={colorOf(region)}
size="h-8 w-8"
/>
)}
</li>
))} ))}
</div> </ul>
)} )}
</div> </div>
); );
@ -565,7 +535,6 @@ function GroupCard({ group, color, open, onOpen }) {
{group.meets} {group.meets}
</p> </p>
)} )}
<Tags tags={group.tags} accent={color} className="mt-1.5" />
</div> </div>
{/* Two controls, two destinations: the chevron opens the {/* Two controls, two destinations: the chevron opens the
@ -896,20 +865,26 @@ export default function OrgListMap({ view = "map", accent = FALLBACK_COLOR }) {
const [selected, setSelected] = useState<any>(null); const [selected, setSelected] = useState<any>(null);
const [hovered, setHovered] = useState<any>(null); const [hovered, setHovered] = useState<any>(null);
const [hoveredArea, setHoveredArea] = useState<any>(null);
const [openId, setOpenId] = useState<any>(null); // no card open on arrival const [openId, setOpenId] = useState<any>(null); // no card open on arrival
const [query, setQuery] = useState(""); const [query, setQuery] = useState("");
const reading = useReadingMode(); const reading = useReadingMode();
// The list scrolls itself to whatever the map or legend is clicked // The list scrolls itself to whatever the map or legend points at.
// on (never on hover: it would jump around as the pointer crosses).
const listRef = useRef<any>(null); const listRef = useRef<any>(null);
const regionRefs = useRef<any>({}); const regionRefs = useRef<any>({});
const stateRefs = useRef<any>({}); const groupRefs = useRef<any>({});
const hoverOn = (id, code = null) => { // Where the latest hover came from. The list follows the map and
// the legend, but hovering the list itself must not move it: the
// row would slide out from under the pointer.
const hoverFromList = useRef(false);
const hoverOnMap = id => {
hoverFromList.current = false;
setHovered(id);
};
const hoverInList = id => {
hoverFromList.current = true;
setHovered(id); setHovered(id);
setHoveredArea(code);
}; };
const scrollListTo = el => { const scrollListTo = el => {
@ -921,21 +896,30 @@ export default function OrgListMap({ view = "map", accent = FALLBACK_COLOR }) {
box.scrollTo({ top: el.offsetTop - 8, behavior: scrollBehavior() }); box.scrollTo({ top: el.offsetTop - 8, behavior: scrollBehavior() });
}; };
const pickRegion = id => scrollListTo(regionRefs.current[id]); // Hovering or selecting a region on the map or legend brings its
// block into view. After a hover in the list, nothing scrolls: not
// on the way in, and not back to the selection on the way out.
useEffect(() => {
if (hoverFromList.current) return;
const id = hovered || selected;
if (id) scrollListTo(regionRefs.current[id]);
}, [hovered, selected]);
// Clicking a tile jumps to the state's subheading under the region // Clicking a tile jumps to its first group when it has one,
// it selects when the state has groups there, otherwise to that // otherwise to the region it belongs to.
// region. Clicked back to no selection: the state under whichever const pickArea = code => {
// region has its groups, else its first region. const group = groups.find(c => c.area_code === code);
const pickArea = (code, regionId) => { if (group && groupRefs.current[group.id]) {
const id = regionId ?? groups.find(c => c.area_code === code)?.region_id ?? regionsForArea(code)[0]?.id; return scrollListTo(groupRefs.current[group.id]);
if (!id) return; }
scrollListTo(stateRefs.current[`${id}:${code}`] ?? regionRefs.current[id]); const region = regionsForArea(code)[0];
if (region) scrollListTo(regionRefs.current[region.id]);
}; };
/* The list column, built only when what it shows changes: hovering /* The list column, built only when what it shows changes: hovering
a map tile or legend entry changes `hovered`, which no row reads, a map tile or legend entry changes `hovered`, which no row reads,
so hundreds of groups aren't drawn again for every tile crossed. */ so hundreds of groups aren't drawn again for every tile crossed.
hoverInList only touches a ref and a state setter, both stable. */
const list = useMemo(() => { const list = useMemo(() => {
const match = matcher(query); const match = matcher(query);
const block = (region, indent) => { const block = (region, indent) => {
@ -946,13 +930,13 @@ export default function OrgListMap({ view = "map", accent = FALLBACK_COLOR }) {
key={region.id} key={region.id}
region={region} region={region}
groups={inRegion} groups={inRegion}
subtext={region.map_note} subtext={subtextFor(region)}
indent={indent} indent={indent}
regionRefs={regionRefs} regionRefs={regionRefs}
stateRefs={stateRefs} groupRefs={groupRefs}
selected={selected} selected={selected}
setSelected={setSelected} setSelected={setSelected}
setHovered={setHovered} setHovered={hoverInList}
/> />
); );
}; };
@ -992,7 +976,7 @@ export default function OrgListMap({ view = "map", accent = FALLBACK_COLOR }) {
)} )}
</> </>
); );
}, [domestic, international, virtual, groupsIn, selected, query]); }, [domestic, international, virtual, groupsIn, subtextFor, selected, query]);
const shell = children => ( const shell = children => (
<div className="mx-auto px-8 md:px-12" style={{ maxWidth: CONTENT_MAX }}> <div className="mx-auto px-8 md:px-12" style={{ maxWidth: CONTENT_MAX }}>
@ -1039,7 +1023,7 @@ export default function OrgListMap({ view = "map", accent = FALLBACK_COLOR }) {
); );
} }
const shared = { selected, setSelected, hovered, hoveredArea, setHovered: hoverOn }; const shared = { selected, setSelected, hovered, setHovered: hoverOnMap };
const onMapIds = new Set(regionAreas.map(a => a.region_id)); const onMapIds = new Set(regionAreas.map(a => a.region_id));
return ( return (
@ -1062,7 +1046,6 @@ export default function OrgListMap({ view = "map", accent = FALLBACK_COLOR }) {
domestic={domestic} domestic={domestic}
international={international} international={international}
onMapIds={onMapIds} onMapIds={onMapIds}
onPickRegion={pickRegion}
{...shared} {...shared}
/> />
<p className="text-sm mt-4" style={{ color: MUTED }}> <p className="text-sm mt-4" style={{ color: MUTED }}>