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:
parent
7e21a0dd40
commit
b76f2a5707
8 changed files with 209 additions and 12 deletions
|
|
@ -226,6 +226,17 @@ export const events = {
|
|||
],
|
||||
blankLabel: "Default: a bar on top, the title line and the timer",
|
||||
},
|
||||
...([
|
||||
["top", "Inset top", "of the screen's height"],
|
||||
["right", "Inset right", "of the screen's width"],
|
||||
["bottom", "Inset bottom", "of the screen's height"],
|
||||
["left", "Inset left", "of the screen's width"],
|
||||
] as const).map(([side, label, of]) => ({
|
||||
path: `present_inset_${side}`,
|
||||
label,
|
||||
widget: "number",
|
||||
help: `Room kept clear at this edge, in percent ${of} (0 to 45), eg. to keep the slides inside a frame drawn in the background image. With any inset the image is stretched to the screen, not cropped. Default: 0.`,
|
||||
})),
|
||||
{ path: "present_accent", label: "Accent", widget: "color", help: "Default: the event's color" },
|
||||
{
|
||||
path: "present_text_color",
|
||||
|
|
@ -244,6 +255,34 @@ export const events = {
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
legend: "Presentation, dark theme",
|
||||
note: "For a screen in the dark theme (its own setting, or the Theme picked when presenting). Each one left blank uses the one above.",
|
||||
fields: [
|
||||
{
|
||||
path: "present_background_dark",
|
||||
label: "Background image",
|
||||
widget: "image",
|
||||
crop: "free",
|
||||
resolve: mediaUrl,
|
||||
full: true,
|
||||
help: "Default: the background image above",
|
||||
},
|
||||
{ path: "present_background_color_dark", label: "Background color", widget: "color", help: "Default: the one above, else the site's dark background" },
|
||||
{ path: "present_dim_dark", label: "Dim", widget: "number", help: "0 to 90 percent. Default: the one above" },
|
||||
{ path: "present_accent_dark", label: "Accent", widget: "color", help: "Default: the accent above" },
|
||||
{ path: "present_text_color_dark", label: "Text color", widget: "color", help: "Default: the one above" },
|
||||
{
|
||||
path: "present_logo_dark",
|
||||
label: "Logo",
|
||||
widget: "image",
|
||||
folder: "logos",
|
||||
resolve: mediaUrl,
|
||||
full: true,
|
||||
help: "eg. a light version of the logo. Default: the logo above",
|
||||
},
|
||||
],
|
||||
},
|
||||
timelineGroup("event"),
|
||||
timelineDetailGroup("event"),
|
||||
{ legend: "Publishing", fields: [PUBLISHED_FIELD, LISTED_FIELD] },
|
||||
|
|
|
|||
15
src/lib/darkTheme.ts
Normal file
15
src/lib/darkTheme.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/* Whether the site is in its dark theme: <html data-theme="dark">,
|
||||
set before the first paint (index.html) and by ThemeToggle. A
|
||||
hook, so a page redraws the moment it changes. */
|
||||
|
||||
import { useSyncExternalStore } from 'react'
|
||||
|
||||
const read = () => document.documentElement.dataset.theme === 'dark'
|
||||
|
||||
function subscribe(onChange: () => void) {
|
||||
const observer = new MutationObserver(onChange)
|
||||
observer.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] })
|
||||
return () => observer.disconnect()
|
||||
}
|
||||
|
||||
export const useDarkTheme = (): boolean => useSyncExternalStore(subscribe, read, () => false)
|
||||
|
|
@ -99,6 +99,11 @@ export type EventPresentLook = {
|
|||
accent: string | null
|
||||
text_color: string | null
|
||||
logo: string | null
|
||||
/** Room clear at each edge (097): percent of the screen's height
|
||||
* (top, bottom) and width (left, right); null none. */
|
||||
inset?: { top: number; right: number; bottom: number; left: number } | null
|
||||
/** In the dark theme (096); a null one takes the above. */
|
||||
dark?: Partial<Omit<EventPresentLook, 'frame' | 'dark' | 'inset'>>
|
||||
}
|
||||
|
||||
export type MapSection = { name: string; keys: string[] }
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue