From 8a792069984c48300dd66166ccd2af80af9acde7 Mon Sep 17 00:00:00 2001 From: Zaldimmar Date: Wed, 11 Nov 2026 02:57:26 -0600 Subject: [PATCH] Events block: featured events open in full above the cards, under a heading Migration 090 adds heading and subheading to content_block_items. An events block's item ticked Featured shows in full above the cards, under its heading and subheading when set. Co-Authored-By: Claude Opus 5.5 --- server/src/admin-schema/columns.js | 3 + .../migrations/090_featured_event_items.sql | 15 ++++ server/src/shape.js | 11 ++- src/components/ContentBlocks.tsx | 75 ++++++++++++------- src/lib/adminSchema/shared.ts | 9 +++ src/lib/useContent.ts | 3 + 6 files changed, 88 insertions(+), 28 deletions(-) create mode 100644 server/src/migrations/090_featured_event_items.sql diff --git a/server/src/admin-schema/columns.js b/server/src/admin-schema/columns.js index f15ffa7..80e5956 100644 --- a/server/src/admin-schema/columns.js +++ b/server/src/admin-schema/columns.js @@ -207,6 +207,9 @@ export const blocksChild = (ownerKind) => ({ // block's venue map (088). text("event_id"), text("location_key"), + // A featured event's heading and subheading (090). + text("heading"), + text("subheading"), ], children: [ { diff --git a/server/src/migrations/090_featured_event_items.sql b/server/src/migrations/090_featured_event_items.sql new file mode 100644 index 0000000..864615d --- /dev/null +++ b/server/src/migrations/090_featured_event_items.sql @@ -0,0 +1,15 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 090 FEATURED EVENTS IN AN EVENTS BLOCK +-- +-- An events block's item ticked Featured (086's `featured`) shows +-- opened in full above the cards, under its own heading and +-- subheading, both optional: +-- +-- heading eg. This year's keynote +-- subheading a line under it +-- +-- Other item kinds ignore both. +-- ═══════════════════════════════════════════════════════════════ + +ALTER TABLE content_block_items ADD COLUMN heading TEXT; +ALTER TABLE content_block_items ADD COLUMN subheading TEXT; diff --git a/server/src/shape.js b/server/src/shape.js index f3f89cd..0afbd86 100644 --- a/server/src/shape.js +++ b/server/src/shape.js @@ -116,7 +116,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) { const itemRows = db .prepare( - `SELECT i.id, i.block_id, i.day, i.kind, ${ENTRY_FIELDS} + `SELECT i.id, i.block_id, i.day, i.kind, i.heading, i.subheading, ${ENTRY_FIELDS} FROM content_block_items i LEFT JOIN v_people_public p ON p.id = i.person_id AND p.is_published = 1 WHERE i.block_id IN (${placeholders(blockIds.length)}) @@ -128,7 +128,14 @@ export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) { // ride along anyway rather than branching on the block's type. const itemsById = new Map(); for (const row of itemRows) { - const item = { ...scheduleEntry(row), day: row.day, kind: row.kind ?? "entry", items: [] }; + const item = { + ...scheduleEntry(row), + day: row.day, + kind: row.kind ?? "entry", + heading: row.heading, + subheading: row.subheading, + items: [], + }; itemsById.set(row.id, item); byId.get(row.block_id)?.items.push(item); } diff --git a/src/components/ContentBlocks.tsx b/src/components/ContentBlocks.tsx index 9fb8e65..8b0ebbc 100644 --- a/src/components/ContentBlocks.tsx +++ b/src/components/ContentBlocks.tsx @@ -266,8 +266,9 @@ function EventInFull({ item, accent, level }: { item: ContentBlockItem; accent: } /* An events block (088): its events as cards; one opened shows in - full under them, scrolled into view. Reading mode has them all in - full. */ + full under them, scrolled into view. A featured one (090) is + already open, above the cards, under its own heading and + subheading. Reading mode has them all in full. */ function EventsBlock({ items, accent, level }: { items: ContentBlockItem[]; accent: string; level: 3 | 4 | 5 }) { const [open, setOpen] = useState(null) const panelId = useId() @@ -277,33 +278,55 @@ function EventsBlock({ items, accent, level }: { items: ContentBlockItem[]; acce if (open != null) panel.current?.scrollIntoView({ behavior: 'smooth', block: 'nearest' }) }, [open]) - if (reading) { - return ( -
- {items.map((item, i) => ( - - ))} -
- ) - } + const featured = reading ? items : items.filter((item) => item.featured) + const cards = reading ? [] : items.filter((item) => !item.featured) + return (
-
    - {items.map((item, i) => ( -
  • - setOpen(open === i ? null : i)} - /> -
  • - ))} -
-
- {open != null && items[open] && } + {featured.map((item, i) => ( + + ))} + {cards.length > 0 && ( + <> +
    + {cards.map((item, i) => ( +
  • + setOpen(open === i ? null : i)} + /> +
  • + ))} +
+
+ {open != null && cards[open] && } +
+ + )} +
+ ) +} + +/* A featured event: its heading and subheading, if set, then the + event in full, its title a level under the heading. */ +function FeaturedEvent({ item, accent, level }: { item: ContentBlockItem; accent: string; level: 3 | 4 | 5 }) { + if (!item.heading && !item.subheading) return + const Heading = `h${level}` as 'h3' + const color = item.event?.color || accent + return ( +
+
+ {item.heading && ( + + {item.heading} + + )} + {item.subheading &&

{item.subheading}

}
+
) } diff --git a/src/lib/adminSchema/shared.ts b/src/lib/adminSchema/shared.ts index cf1fddb..ec9c3ab 100644 --- a/src/lib/adminSchema/shared.ts +++ b/src/lib/adminSchema/shared.ts @@ -760,6 +760,15 @@ export const blocksChild = { }, { path: "featured", label: "Featured", widget: "checkbox", help: "Makes the row stand out", when: SCHEDULE_ENTRY }, { ...TAGS_FIELD, when: SCHEDULE_ENTRY }, + { + path: "featured", + label: "Featured", + widget: "checkbox", + help: "Shows it opened in full above the cards, under the heading and subheading below", + when: EVENT_ITEM, + }, + { path: "heading", label: "Heading", help: "Featured only, eg. This year's keynote. Default: none", when: EVENT_ITEM }, + { path: "subheading", label: "Subheading", help: "Featured only: a line under the heading. Default: none", full: true, when: EVENT_ITEM }, ], children: [ { diff --git a/src/lib/useContent.ts b/src/lib/useContent.ts index 38ffde3..4605ee0 100644 --- a/src/lib/useContent.ts +++ b/src/lib/useContent.ts @@ -130,6 +130,9 @@ export type ContentBlockItem = { start_time?: string | null end_time?: string | null featured?: boolean + /** A featured event's heading and subheading (090). */ + heading?: string | null + subheading?: string | null /** A block entry's sub-items. */ items?: ContentBlockItem[] /** Its block's tags it has, by key (087). */