Present: dark theme settings, a Theme pick, and a content inset

- Event Presentation, dark theme (096): background image and color,
  dim, accent, text color and logo for a dark screen; blank takes the
  light one
- Setup's Theme holds a screen light or dark while it plays (`theme=`)
- Inset top, right, bottom and left (097), percent of the screen, so
  the slides sit inside a frame drawn in the background image; with
  any set the image is stretched to the screen

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-11-12 04:14:14 -06:00
parent 7e21a0dd40
commit b76f2a5707
8 changed files with 209 additions and 12 deletions

View file

@ -54,7 +54,9 @@
give its Presentation text, leave it out, and say how a map is
shown. The blocks themselves are drawn for a screen (Presenting):
links as their text, people as round photos and names,
organizations as their logos.
their logos. In the dark theme the event's dark settings (096)
take the place of any they set (lookFor); the setup's Theme
(`theme=light|dark`) holds a screen in one theme while it plays.
Keys while playing: arrows step, Space pauses, Escape leaves full
screen (the browser's), S goes back to the setup.
@ -94,6 +96,7 @@ import {
import { mediaUrl } from '../lib/media.ts'
import { BRAND, accentText, readableOn, withAlpha } from '../lib/color.ts'
import { documentTitle } from '../lib/site.ts'
import { useDarkTheme } from '../lib/darkTheme.ts'
import './EventPresent.css'
/* Each kind of slide, its address key and seconds when unset. */
@ -126,6 +129,16 @@ const STARTS_SECTION = new Set(['heading', 'tab'])
const FILLER = new Set(['subheading', 'divider'])
/* Percent of the background color over the background image, unset. */
const DIM = 60
/* The themes a screen can be held in (`theme`). */
const THEMES = ['light', 'dark'] as const
/* The event's look in the theme shown: in the dark one, its dark
settings (096) over the light ones. */
function lookFor(look: EventPresentLook | undefined, dark: boolean): EventPresentLook | undefined {
if (!look || !dark || !look.dark) return look
const picked = Object.entries(look.dark).filter(([, value]) => value != null && value !== '')
return { ...look, ...Object.fromEntries(picked) }
}
/* Seconds a long slide takes to scroll one screenful, when unset. */
const PER_SCREEN = 8
@ -206,6 +219,7 @@ function readSettings(params: URLSearchParams) {
screen: Number.isFinite(screen) && screen > 0 ? screen : PER_SCREEN,
only: params.get('only') || null,
order: list(params.get('order')),
theme: THEMES.find((theme) => theme === params.get('theme')) ?? null,
}
}
type Settings = ReturnType<typeof readSettings>
@ -387,6 +401,19 @@ export default function EventPresent() {
if (event) document.title = documentTitle(`${event.title}: present`)
}, [event])
// The setup's Theme, while playing; the device's again after.
const held = params.get('play') === '1' ? params.get('theme') : null
useEffect(() => {
if (held !== 'light' && held !== 'dark') return
const root = document.documentElement
const was = root.dataset.theme
root.dataset.theme = held
return () => {
if (was) root.dataset.theme = was
}
}, [held])
const dark = useDarkTheme()
if (!event) {
return (
<PageState
@ -401,7 +428,7 @@ export default function EventPresent() {
)
}
const look = event.present
const look = lookFor(event.present, dark)
const accent = look?.accent || event.color || BRAND
const back = `/events/${encodeURIComponent(event.id)}`
@ -452,6 +479,7 @@ export default function EventPresent() {
// Not 'tag': that's the tag slides' seconds.
if (next.only) out.set('only', next.only)
if (next.order?.length) out.set('order', next.order.join(','))
if (next.theme) out.set('theme', next.theme)
out.set('play', '1')
setParams(out)
}}
@ -484,6 +512,7 @@ function Setup({
const [only, setOnly] = useState(settings.only)
const [screen, setScreen] = useState(settings.screen)
const [order, setOrder] = useState(settings.order)
const [theme, setTheme] = useState(settings.theme)
const [dragging, setDragging] = useState<number | null>(null)
const slides = ordered(buildSlides(sections, schedules, { skipped, hidden, seconds, only }), order)
const count = slides.length
@ -567,6 +596,28 @@ function Setup({
<p className="mt-2 text-sm text-muted">0 leaves that kind of slide out.</p>
</section>
<section>
<h2 className="mb-4 text-2xl font-bold text-ink">Theme</h2>
<label className="flex flex-wrap items-center gap-4 bg-raised p-4 shadow-sm">
<span className="flex-1">
<span className="block font-semibold text-ink">Light or dark</span>
<span className="text-sm text-muted">
The slides in this theme whatever the screen is set to. The event's Presentation, dark theme settings
apply in the dark one.
</span>
</span>
<select
value={theme ?? ''}
onChange={(e) => setTheme(THEMES.find((t) => t === e.target.value) ?? null)}
className="border border-muted/25 bg-surface px-2 py-1"
>
<option value="">Default: the screen's own</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label>
</section>
{tags.length > 0 && (
<section>
<h2 className="mb-4 text-2xl font-bold text-ink">Tags</h2>
@ -720,7 +771,7 @@ function Setup({
<button
type="button"
disabled={count === 0}
onClick={() => onPlay({ skipped, hidden, seconds, screen, only, order })}
onClick={() => onPlay({ skipped, hidden, seconds, screen, only, order, theme })}
className="btn inline-flex items-center gap-2 px-6 py-3 disabled:opacity-50"
style={{ background: accent, color: readableOn(accent) }}
>
@ -889,15 +940,25 @@ function Player({
const frame = look?.frame ?? null
const background = mediaUrl(look?.background)
const label = slide.label === title || slide.label === slide.title ? '' : slide.label
// Room clear at each edge, eg. inside a frame picture (097).
const inset = look?.inset
return (
<main
onMouseMove={wake}
style={lookTokens(look)}
style={{
...lookTokens(look),
...(inset ? { padding: `${inset.top}vh ${inset.right}vw ${inset.bottom}vh ${inset.left}vw` } : {}),
}}
className={`present relative isolate flex h-screen flex-col overflow-hidden bg-surface text-body ${controls ? '' : 'cursor-none'}`}
>
{/* The background image, the background color over it at Dim. */}
{background && (
<div aria-hidden="true" className="absolute inset-0 -z-10 bg-cover bg-center" style={{ backgroundImage: `url("${background}")` }}>
<div
aria-hidden="true"
// Stretched with an inset, so a frame in it meets the inset.
className={`absolute inset-0 -z-10 bg-center ${inset ? 'bg-[length:100%_100%]' : 'bg-cover'}`}
style={{ backgroundImage: `url("${background}")` }}
>
<div className="absolute inset-0 bg-surface" style={{ opacity: (look?.dim ?? DIM) / 100 }} />
</div>
)}
@ -944,12 +1005,15 @@ function Player({
)}
{look?.logo && (
<Logo
src={mediaUrl(look.logo)}
className={`pointer-events-none absolute right-[3vw] h-[8vh] w-auto max-w-[16vw] object-contain ${
frame === 'border' ? 'bottom-[4vh]' : 'bottom-[3vh]'
}`}
/>
<span
className="pointer-events-none absolute"
style={{
right: `calc(3vw + ${inset?.right ?? 0}vw)`,
bottom: `calc(${frame === 'border' ? 4 : 3}vh + ${inset?.bottom ?? 0}vh)`,
}}
>
<Logo src={mediaUrl(look.logo)} className="block h-[8vh] w-auto max-w-[16vw] object-contain" />
</span>
)}
<div