Image block: a dark theme picture; presented pictures centered

- media_dark (102): shown in place of the image while the site is
  dark, the block's alt text and caption shared
- Present: pictures beside text centered on the slide's height, and a
  section of only pictures centered both ways

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-11-12 06:40:40 -06:00
parent a59702b7f3
commit f46deac3cc
7 changed files with 41 additions and 8 deletions

View file

@ -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) {

View file

@ -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",

View file

@ -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). */

View file

@ -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<HTMLDivElement>(null)
const inner = useRef<HTMLDivElement>(null)
useLayoutEffect(() => {
@ -1457,8 +1457,10 @@ function Fit({ className = '', children }: { className?: string; children: React
return () => watch.disconnect()
}, [])
return (
<div ref={box} className={`min-h-0 flex-1 overflow-hidden ${className}`}>
<div ref={inner}>{children}</div>
<div ref={box} className={`min-h-0 flex-1 overflow-hidden ${center ? 'flex flex-col' : ''} ${className}`}>
<div ref={inner} className={center ? 'my-auto' : undefined}>
{children}
</div>
</div>
)
}
@ -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 (
<div className="flex h-full flex-col text-center">
<Scroll center>
@ -1620,7 +1622,7 @@ function SlideView({ slide, accent }: { slide: Slide; accent: string }) {
<div className="flex h-full flex-col">
<SlideTitle color={color}>{slide.label}</SlideTitle>
<Rise order={1} className="flex min-h-0 flex-1 flex-col">
<Fit>
<Fit center>
<div
className={`grid items-center gap-[3vw] ${left ? 'grid-cols-[2fr_3fr]' : 'grid-cols-[3fr_2fr]'}`}
style={{ zoom }}