From a0eb9d7e495df00995236d16cb324513ec33f80a Mon Sep 17 00:00:00 2001 From: Zaldimmar Date: Thu, 12 Nov 2026 05:58:49 -0600 Subject: [PATCH] Image block: a Size (small, medium, large), centered - image_size (101): blank the column's full width, else up to 20, 32 or 48rem, centered and never wider than the column Co-Authored-By: Claude Opus 5.5 --- docs/updating-data-in-code.md | 1 + server/src/admin-schema/columns.js | 2 ++ server/src/migrations/101_image_size.sql | 15 +++++++++++++++ server/src/shape.js | 3 ++- src/components/ContentBlocks.tsx | 5 ++++- src/lib/adminSchema/shared.ts | 13 +++++++++++++ src/lib/useContent.ts | 2 ++ 7 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 server/src/migrations/101_image_size.sql diff --git a/docs/updating-data-in-code.md b/docs/updating-data-in-code.md index 812b9fa..ccdf11b 100644 --- a/docs/updating-data-in-code.md +++ b/docs/updating-data-in-code.md @@ -183,6 +183,7 @@ also in `server/src/admin-schema/` and a CHECK): | Content blocks → Shown in (slot) | card, body | **yes** | `paragraphs()` in `server/src/shape.js` (card), `ContentBlocks.tsx` (body) | | Content blocks → Type | heading, subheading, paragraph, list, links, quote, image, divider, video, button, callout, schedule, table, cards, people, map, events, organizations | **yes**, `BLOCK_TYPES` (with each type's description) | `ContentBlocks.tsx` (one renderer per type). Which fields each type shows is `when` on the fields in `blocksChild` (`src/lib/adminSchema/shared.ts`). | | Content blocks → Schedule items → Type | (blank: normal entry), block, break, heading | **yes**, migration 086 | `SCHEDULE_KINDS` in `src/lib/adminSchema/shared.ts`; drawn by `ScheduleBlock.tsx` and `EventPresent.tsx` (which slides each kind gets; the presentation cuts the event's page into sections at its Heading blocks). A block's sub-items are `content_block_subitems`. A schedule's own tags (087) are `content_block_tags`, rows of the block typed in the admin (not a fixed list); entries name them by `tag_key`, made in the admin as the tag is added. A schedule's Venue (088) lends its locations (Data → Venues, `venue_locations`) to its entries' Map location, named by `location_key` the same way; an entry's Event (a workshop) fills what it leaves blank in `shape.js` (`attachEvents`). | +| Content blocks → Image → Size | (blank: the column's full width), small (20rem), medium (32rem), large (48rem) | **yes**, migration 101 | The `image_size` field in `src/lib/adminSchema/shared.ts`; `IMAGE_SIZE` in `ContentBlocks.tsx` sets the widths | | Content blocks → List → Style | (blank: bold text, normal detail), plain (plain text, gray detail) | **yes**, migration 092 | The Style field in `src/lib/adminSchema/shared.ts`; drawn by the `list` case in `ContentBlocks.tsx`. | | Content blocks (an event's) → Shown | (blank: the page and the presentation), page, presentation | **yes**, migration 099 | `PRESENT_BLOCK_FIELDS` in `src/lib/adminSchema/shared.ts`; `ContentBlocks.tsx` leaves out a presentation-only block on the page and a page-only one presented, `sectionsOf` in `src/pages/EventPresent.tsx` too | | Content blocks (an event's) → Map → Location slides | (blank: each marked location), picked (the Locations with a slide), none | **yes**, migration 095 | `PRESENT_BLOCK_FIELDS` in `src/lib/adminSchema/shared.ts`; read by `mapSlides` in `src/pages/EventPresent.tsx` | diff --git a/server/src/admin-schema/columns.js b/server/src/admin-schema/columns.js index 5e00110..bb911c8 100644 --- a/server/src/admin-schema/columns.js +++ b/server/src/admin-schema/columns.js @@ -179,6 +179,8 @@ export const blocksChild = (ownerKind) => ({ text("venue_id"), // List blocks (092): null bold text, 'plain' the old look. enumeration("list_style", ["plain"]), + // Image blocks (101): null full width, else a narrower size. + enumeration("image_size", ["small", "medium", "large"]), // Organizations blocks (093): the kind listed when none are picked. enumeration("org_kind", ["region", "group", "partner", "ministry"]), // How it's presented (095): EventPresent.tsx. diff --git a/server/src/migrations/101_image_size.sql b/server/src/migrations/101_image_size.sql new file mode 100644 index 0000000..5000b55 --- /dev/null +++ b/server/src/migrations/101_image_size.sql @@ -0,0 +1,15 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 101 AN IMAGE BLOCK'S SIZE +-- +-- How wide an image block shows, centered in the column: +-- +-- null the column's full width (as before) +-- small up to 20rem +-- medium up to 32rem +-- large up to 48rem +-- +-- Never wider than the column. Other block types ignore it. +-- ═══════════════════════════════════════════════════════════════ + +ALTER TABLE content_blocks ADD COLUMN image_size TEXT + CHECK (image_size IN ('small', 'medium', 'large')); diff --git a/server/src/shape.js b/server/src/shape.js index a622323..adb5e66 100644 --- a/server/src/shape.js +++ b/server/src/shape.js @@ -87,7 +87,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) { const blockRows = db .prepare( `SELECT id, owner_id, type, text, media, href, alt, cite, captions, team_id, venue_id, - word_motion, word_direction, word_seconds, list_style, org_kind, + word_motion, word_direction, word_seconds, list_style, image_size, org_kind, present_show, present_text, present_map_split, present_map_no_list, present_map_no_details, present_places, present_place_keys FROM content_blocks @@ -112,6 +112,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) { team_id: row.team_id, venue_id: row.venue_id, list_style: row.list_style, + image_size: row.image_size, org_kind: row.org_kind, // Its rotating words' motion (084), when it has its own. words: row.word_motion || row.word_direction || row.word_seconds diff --git a/src/components/ContentBlocks.tsx b/src/components/ContentBlocks.tsx index 36286bb..6764ba7 100644 --- a/src/components/ContentBlocks.tsx +++ b/src/components/ContentBlocks.tsx @@ -76,6 +76,9 @@ import { usePresenting } from '../lib/presenting.ts' const BODY = 'var(--color-muted)' +/* An image block's Size (101): its widest, centered. */ +const IMAGE_SIZE = { small: 'max-w-[20rem]', medium: 'max-w-[32rem]', large: 'max-w-[48rem]' } as const + export default function ContentBlocks({ blocks, accent = BRAND, @@ -579,7 +582,7 @@ function Block({ /> ) return ( -
+
{block.href ? {img} : img}
diff --git a/src/lib/adminSchema/shared.ts b/src/lib/adminSchema/shared.ts index f469cf4..5f63bcd 100644 --- a/src/lib/adminSchema/shared.ts +++ b/src/lib/adminSchema/shared.ts @@ -659,6 +659,19 @@ export const blocksChild = { when: { path: "type", value: "video" }, help: "A WebVTT (.vtt) file, for an uploaded video; YouTube, Vimeo and Facebook show their own. Default: none.", }, + { + path: "image_size", + label: "Size", + widget: "select", + options: [ + ["small", "Small (up to 20rem)"], + ["medium", "Medium (up to 32rem)"], + ["large", "Large (up to 48rem)"], + ], + blankLabel: "Default: the column's full width", + help: "A smaller one is centered. Never wider than the column.", + when: { path: "type", value: "image" }, + }, { path: "alt", label: "Alt text", diff --git a/src/lib/useContent.ts b/src/lib/useContent.ts index b95c9d5..3daaef8 100644 --- a/src/lib/useContent.ts +++ b/src/lib/useContent.ts @@ -57,6 +57,8 @@ export type ContentBlock = { cite?: string | null /** A list block's style (092): null bold text, 'plain' the old look. */ list_style?: 'plain' | null + /** An image block's size (101): null the column's width. */ + image_size?: 'small' | 'medium' | 'large' | null /** An organizations block's kind, listed when none are picked (093). */ org_kind?: 'region' | 'group' | 'partner' | 'ministry' | null /** A video block's WebVTT file, for an uploaded video (066). */