diff --git a/server/src/admin-schema/columns.js b/server/src/admin-schema/columns.js index bb911c8..d7d1672 100644 --- a/server/src/admin-schema/columns.js +++ b/server/src/admin-schema/columns.js @@ -164,6 +164,8 @@ export const blocksChild = (ownerKind) => ({ ), text("text"), text("media"), + // Image blocks (102): shown in place of media in the dark theme. + text("media_dark"), url("href"), text("alt"), text("cite"), diff --git a/server/src/migrations/102_image_dark.sql b/server/src/migrations/102_image_dark.sql new file mode 100644 index 0000000..a4f457f --- /dev/null +++ b/server/src/migrations/102_image_dark.sql @@ -0,0 +1,13 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 102 AN IMAGE BLOCK'S DARK THEME PICTURE +-- +-- media_dark shown in place of media while the site is in its +-- dark theme (the visitor's setting, or a presentation +-- held dark), eg. a chart or a logo drawn light on +-- dark. Null shows media in both themes. +-- +-- Image blocks only; other types ignore it. Its alt text and caption +-- are the block's, so it should show the same thing. +-- ═══════════════════════════════════════════════════════════════ + +ALTER TABLE content_blocks ADD COLUMN media_dark TEXT; diff --git a/server/src/shape.js b/server/src/shape.js index adb5e66..1e78ef2 100644 --- a/server/src/shape.js +++ b/server/src/shape.js @@ -86,7 +86,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, + `SELECT id, owner_id, type, text, media, media_dark, href, alt, cite, captions, team_id, venue_id, 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 @@ -105,6 +105,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) { type: row.type, text: row.text, media: row.media, + media_dark: row.media_dark, href: row.href, alt: row.alt, cite: row.cite, diff --git a/src/components/ContentBlocks.tsx b/src/components/ContentBlocks.tsx index 6764ba7..c99eb3a 100644 --- a/src/components/ContentBlocks.tsx +++ b/src/components/ContentBlocks.tsx @@ -73,6 +73,7 @@ import { useReadingMode } from '../lib/readingMode.ts' import { WordMotion, Words } from './RotatingWords.tsx' import OrgListCards, { OrgLogoRow } from '../pages/sections/OrgList-Card.tsx' import { usePresenting } from '../lib/presenting.ts' +import { useDarkTheme } from '../lib/darkTheme.ts' const BODY = 'var(--color-muted)' @@ -396,6 +397,8 @@ function Block({ // On a screen: links are their text, people and organizations // just pictures and names (095). const presenting = usePresenting() + // An image block's dark theme picture (102). + const dark = useDarkTheme() switch (block.type) { // A blog post's tab marker (BlogPost.tsx splits the post at @@ -560,7 +563,7 @@ function Block({ ) case 'image': { - const src = mediaUrl(block.media) + const src = mediaUrl((dark && block.media_dark) || block.media) if (!src) return null // The reader leaves out a picture with no alt, and its link with it. if (reading && block.href && !block.alt) { diff --git a/src/lib/adminSchema/shared.ts b/src/lib/adminSchema/shared.ts index 5f63bcd..24c2fae 100644 --- a/src/lib/adminSchema/shared.ts +++ b/src/lib/adminSchema/shared.ts @@ -659,6 +659,16 @@ 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: "media_dark", + label: "Dark theme image", + widget: "image", + crop: "free", + resolve: mediaUrl, + full: true, + when: { path: "type", value: "image" }, + help: "Shown in place of the image while the site is dark, eg. a chart drawn light on dark. Same alt text and caption. Default: the image above in both themes.", + }, { path: "image_size", label: "Size", diff --git a/src/lib/useContent.ts b/src/lib/useContent.ts index 3daaef8..663b439 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 picture for the dark theme (102). */ + media_dark?: string | 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). */ diff --git a/src/pages/EventPresent.tsx b/src/pages/EventPresent.tsx index 6fb705b..20ceb56 100644 --- a/src/pages/EventPresent.tsx +++ b/src/pages/EventPresent.tsx @@ -1434,7 +1434,7 @@ function Scroll({ center = false, className = '', children }: { zoomed down until its content is no taller than its box (a few passes, since text narrower in zoom wraps less). Again whenever its size changes, eg. a picture loading. */ -function Fit({ className = '', children }: { className?: string; children: ReactNode }) { +function Fit({ center = false, className = '', children }: { center?: boolean; className?: string; children: ReactNode }) { const box = useRef(null) const inner = useRef(null) useLayoutEffect(() => { @@ -1457,8 +1457,10 @@ function Fit({ className = '', children }: { className?: string; children: React return () => watch.disconnect() }, []) return ( -
-
{children}
+
+
+ {children} +
) } @@ -1587,9 +1589,9 @@ function SlideView({ slide, accent }: { slide: Slide; accent: string }) { // The page's own blocks, zoomed up from the page's size. The // zoom is inside Scroll, so it measures what the screen shows. const zoom = Math.max(1, window.innerWidth / TEXT_WIDTH) - // Only people: the title and their photos in the middle of the + // Only people or pictures: the title and them in the middle of the // slide, both ways. - if (slide.blocks!.every((block) => block.type === 'people' || FILLER.has(block.type))) { + if (slide.blocks!.every((block) => block.type === 'people' || isPicture(block) || FILLER.has(block.type))) { return (
@@ -1620,7 +1622,7 @@ function SlideView({ slide, accent }: { slide: Slide; accent: string }) {
{slide.label} - +