Present: a section's pictures left or right of its text, fitted

- Setup, per section with pictures and text: Pictures in the text,
  left of it or right of it (`pictures`), in a column beside the rest
- That slide shrinks to fit (Fit), measured again as pictures load

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-11-12 06:04:48 -06:00
parent a0eb9d7e49
commit a59702b7f3

View file

@ -30,6 +30,9 @@
i<section>.<block>) and ticks its items on and off (`hide`,
l<section>.<block>.<item>). A people block shows each one's role
or title when the setup ticks it (`titles`, <section>.<block>).
A section with pictures (image blocks) and other text can have the
setup put its pictures in a column left or right of the rest
(`pictures`, <section>:left|right), the slide shrunk to fit.
callout a callout block the setup picks for a slide of its
own (`lists`, q<section>.<block>): its text centered
under its heading (the subheading above it in the
@ -174,6 +177,11 @@ const ownSlides = (block: ContentBlock, lists: Set<string>, s: number, b: number
(block.type === 'list' && (lists.has(overviewKey(s, b)) || lists.has(itemsKey(s, b))) ? 'List' : null) ??
(block.type === 'callout' && lists.has(calloutKey(s, b)) ? 'Callout' : null)
/* Where a section's pictures can go beside its text. */
const SIDES = ['left', 'right'] as const
type Side = (typeof SIDES)[number]
const isPicture = (block: ContentBlock) => block.type === 'image'
/* Blocks that start a section. */
const STARTS_SECTION = new Set(['heading', 'tab'])
/* Text that alone makes no section slide: the heading titles what
@ -219,6 +227,8 @@ type Slide = {
days?: Day[]
tags?: ScheduleTag[]
blocks?: ContentBlock[]
/* A section's pictures in a column beside its text (the setup). */
pictures?: Side
venue?: Venue
location?: VenueLocation
items?: ContentBlockItem[]
@ -275,11 +285,17 @@ function readSettings(params: URLSearchParams) {
order: list(params.get('order')),
lists: new Set(list(params.get('lists')) ?? []),
titles: new Set(list(params.get('titles')) ?? []),
pictures: new Map(
(list(params.get('pictures')) ?? []).flatMap((pick) => {
const [at, side] = pick.split(':')
return SIDES.includes(side as Side) ? [[Number(at), side as Side] as const] : []
}),
),
theme: THEMES.find((theme) => theme === params.get('theme')) ?? null,
}
}
type Settings = ReturnType<typeof readSettings>
type Picks = Pick<Settings, 'skipped' | 'hidden' | 'seconds' | 'only' | 'lists' | 'titles'>
type Picks = Pick<Settings, 'skipped' | 'hidden' | 'seconds' | 'only' | 'lists' | 'titles' | 'pictures'>
/* An entry or sub-item with its key (key()), carried through the
picks and the tag filter, which copy blocks. */
@ -372,7 +388,7 @@ function mapSlides(slides: Slide[], block: ContentBlock, at: string, label: stri
o, k, s, g and m a schedule's overview, block, spotlight, graphic
and map image, and x its tag slides, by key(). */
function buildSlides(sections: Section[], schedules: Map<ContentBlock, Schedule>, picks: Picks): Slide[] {
const { skipped, seconds, hidden, lists, titles } = picks
const { skipped, seconds, hidden, lists, titles, pictures } = picks
const slides: Slide[] = []
sections.forEach((section, s) => {
if (skipped.has(s)) return
@ -385,7 +401,11 @@ function buildSlides(sections: Section[], schedules: Map<ContentBlock, Schedule>
})
// Nothing but a heading: it titles the slides that follow.
const own = text.some((block) => !FILLER.has(block.type))
if (seconds.section && own) slides.push({ id: `t${s}`, kind: 'section', seconds: seconds.section, label, blocks: text })
if (seconds.section && own) {
// Pictures beside the text, when picked and there are both.
const side = text.some(isPicture) && text.some((block) => !isPicture(block)) ? pictures.get(s) : undefined
slides.push({ id: `t${s}`, kind: 'section', seconds: seconds.section, label, blocks: text, pictures: side })
}
const title = section.headed && !own ? label : null
section.blocks.forEach((block, b) => {
const at = `${s}.${b}`
@ -568,6 +588,7 @@ export default function EventPresent() {
if (next.theme) out.set('theme', next.theme)
if (next.lists.size) out.set('lists', [...next.lists].join(','))
if (next.titles.size) out.set('titles', [...next.titles].join(','))
if (next.pictures.size) out.set('pictures', [...next.pictures].map(([at, side]) => `${at}:${side}`).join(','))
out.set('play', '1')
setParams(out)
}}
@ -603,8 +624,9 @@ function Setup({
const [theme, setTheme] = useState(settings.theme)
const [lists, setLists] = useState(settings.lists)
const [titles, setTitles] = useState(settings.titles)
const [pictures, setPictures] = useState(settings.pictures)
const [dragging, setDragging] = useState<number | null>(null)
const slides = ordered(buildSlides(sections, schedules, { skipped, hidden, seconds, only, lists, titles }), order)
const slides = ordered(buildSlides(sections, schedules, { skipped, hidden, seconds, only, lists, titles, pictures }), order)
const count = slides.length
// Moves a slide in the list, which then names every slide shown.
const move = (from: number, to: number) => {
@ -750,6 +772,29 @@ function Setup({
<span className="font-bold text-ink">{section.title}</span>
<span className="text-xs text-muted">{kinds.join(', ')}</span>
</label>
{/* Pictures and other text: where the pictures go. */}
{section.blocks.some(isPicture) &&
section.blocks.some((block, b) => !isPicture(block) && !ownSlides(block, lists, s, b)) && (
<label className={`mt-3 flex flex-wrap items-center gap-3 pl-7 ${on ? '' : 'opacity-50'}`}>
<span className="text-sm">Pictures</span>
<select
disabled={!on}
value={pictures.get(s) ?? ''}
onChange={(e) => {
const next = new Map(pictures)
const side = SIDES.find((one) => one === e.target.value)
if (side) next.set(s, side)
else next.delete(s)
setPictures(next)
}}
className="border border-muted/25 bg-surface px-2 py-1 text-sm"
>
<option value="">Default: in the text, as on the page</option>
<option value="left">Left of the text</option>
<option value="right">Right of the text</option>
</select>
</label>
)}
{section.blocks.map((block, b) => {
// A list: its own slides if picked, then its items.
if (block.type === 'list' && block.items?.length) {
@ -1001,7 +1046,7 @@ function Setup({
<button
type="button"
disabled={count === 0}
onClick={() => onPlay({ skipped, hidden, seconds, screen, only, order, theme, lists, titles })}
onClick={() => onPlay({ skipped, hidden, seconds, screen, only, order, theme, lists, titles, pictures })}
className="btn inline-flex items-center gap-2 px-6 py-3 disabled:opacity-50"
style={{ background: accent, color: readableOn(accent) }}
>
@ -1387,7 +1432,8 @@ function Scroll({ center = false, className = '', children }: {
/* A slide's part shrunk to fit the room it has, never scrolled:
zoomed down until its content is no taller than its box (a few
passes, since text narrower in zoom wraps less). */
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 }) {
const box = useRef<HTMLDivElement>(null)
const inner = useRef<HTMLDivElement>(null)
@ -1395,6 +1441,7 @@ function Fit({ className = '', children }: { className?: string; children: React
const outer = box.current
const content = inner.current
if (!outer || !content) return
const fit = () => {
let zoom = 1
content.style.zoom = '1'
for (let pass = 0; pass < 4; pass++) {
@ -1403,6 +1450,11 @@ function Fit({ className = '', children }: { className?: string; children: React
zoom *= outer.clientHeight / tall
content.style.zoom = String(zoom)
}
}
fit()
const watch = new ResizeObserver(fit)
watch.observe(content)
return () => watch.disconnect()
}, [])
return (
<div ref={box} className={`min-h-0 flex-1 overflow-hidden ${className}`}>
@ -1551,6 +1603,36 @@ function SlideView({ slide, accent }: { slide: Slide; accent: string }) {
</div>
)
}
// Pictures in a column beside the text, shrunk to fit the slide.
if (slide.pictures) {
const pics = (
<div className="min-w-0">
<ContentBlocks blocks={slide.blocks!.filter(isPicture)} accent={accent} />
</div>
)
const rest = (
<div className="min-w-0">
<ContentBlocks blocks={slide.blocks!.filter((block) => !isPicture(block))} accent={accent} />
</div>
)
const left = slide.pictures === 'left'
return (
<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>
<div
className={`grid items-center gap-[3vw] ${left ? 'grid-cols-[2fr_3fr]' : 'grid-cols-[3fr_2fr]'}`}
style={{ zoom }}
>
{left ? pics : rest}
{left ? rest : pics}
</div>
</Fit>
</Rise>
</div>
)
}
return (
<div className="flex h-full flex-col">
<SlideTitle color={color}>{slide.label}</SlideTitle>