From b76f2a57075c8d02a72f2de1fb6264827ed11523 Mon Sep 17 00:00:00 2001 From: Zaldimmar Date: Thu, 12 Nov 2026 04:14:14 -0600 Subject: [PATCH] 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 --- server/src/admin-schema/events.js | 14 ++- .../src/migrations/096_presentation_dark.sql | 24 ++++++ .../src/migrations/097_presentation_inset.sql | 20 +++++ server/src/routes/content.js | 18 ++++ src/lib/adminSchema/events.ts | 39 +++++++++ src/lib/darkTheme.ts | 15 ++++ src/lib/useContent.ts | 5 ++ src/pages/EventPresent.tsx | 86 ++++++++++++++++--- 8 files changed, 209 insertions(+), 12 deletions(-) create mode 100644 server/src/migrations/096_presentation_dark.sql create mode 100644 server/src/migrations/097_presentation_inset.sql create mode 100644 src/lib/darkTheme.ts diff --git a/server/src/admin-schema/events.js b/server/src/admin-schema/events.js index 581ef98..21dc3a9 100644 --- a/server/src/admin-schema/events.js +++ b/server/src/admin-schema/events.js @@ -1,4 +1,4 @@ -import { text, int, bool, date, time, enumeration, placeColumns, timelineExtension, linksChild, blocksChild, hostsChild } from "./columns.js"; +import { text, int, real, bool, date, time, enumeration, placeColumns, timelineExtension, linksChild, blocksChild, hostsChild } from "./columns.js"; import { tagsChild } from "./tags.js"; /* ── Events ──────────────────────────────────────────────────── */ @@ -77,6 +77,18 @@ export const events = { text("present_accent"), text("present_text_color"), text("present_logo"), + // The same in the dark theme (096), null the above. + text("present_background_dark"), + text("present_background_color_dark"), + int("present_dim_dark"), + text("present_accent_dark"), + text("present_text_color_dark"), + text("present_logo_dark"), + // Room clear at each edge, eg. inside a frame picture (097). + real("present_inset_top"), + real("present_inset_right"), + real("present_inset_bottom"), + real("present_inset_left"), // A repeating schedule. Columns rather than a side table: the // schedule is always exactly one per event, and the public view diff --git a/server/src/migrations/096_presentation_dark.sql b/server/src/migrations/096_presentation_dark.sql new file mode 100644 index 0000000..69e2b24 --- /dev/null +++ b/server/src/migrations/096_presentation_dark.sql @@ -0,0 +1,24 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 096 PRESENTATION SETTINGS IN THE DARK THEME +-- +-- The same as 095's, for a screen in the dark theme (the device's +-- setting, or the setup's Theme pick). Each one null takes the +-- light theme's (095), so only what differs needs setting. +-- +-- present_background_dark the image behind every slide +-- present_background_color_dark the slides' background color +-- present_dim_dark percent of the color over the +-- image, 0 to 90 +-- present_accent_dark in place of the accent +-- present_text_color_dark the slides' text +-- present_logo_dark the bottom-right logo, eg. a +-- light version +-- ═══════════════════════════════════════════════════════════════ + +ALTER TABLE events ADD COLUMN present_background_dark TEXT; +ALTER TABLE events ADD COLUMN present_background_color_dark TEXT; +ALTER TABLE events ADD COLUMN present_dim_dark INTEGER + CHECK (present_dim_dark BETWEEN 0 AND 90); +ALTER TABLE events ADD COLUMN present_accent_dark TEXT; +ALTER TABLE events ADD COLUMN present_text_color_dark TEXT; +ALTER TABLE events ADD COLUMN present_logo_dark TEXT; diff --git a/server/src/migrations/097_presentation_inset.sql b/server/src/migrations/097_presentation_inset.sql new file mode 100644 index 0000000..5f2b043 --- /dev/null +++ b/server/src/migrations/097_presentation_inset.sql @@ -0,0 +1,20 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 097 PRESENTATION CONTENT INSET +-- +-- Room kept clear at each edge of a presented slide, so its content +-- sits inside a background image that is a frame (eg. a 1920x1080 +-- picture with a border drawn in it). Percent of the screen: top +-- and bottom of its height, left and right of its width, 0 to 45. +-- Null is 0. With any set, the background image is stretched to the +-- screen rather than cropped, so the frame stays where the inset +-- expects it. Both themes share them. +-- ═══════════════════════════════════════════════════════════════ + +ALTER TABLE events ADD COLUMN present_inset_top REAL + CHECK (present_inset_top BETWEEN 0 AND 45); +ALTER TABLE events ADD COLUMN present_inset_right REAL + CHECK (present_inset_right BETWEEN 0 AND 45); +ALTER TABLE events ADD COLUMN present_inset_bottom REAL + CHECK (present_inset_bottom BETWEEN 0 AND 45); +ALTER TABLE events ADD COLUMN present_inset_left REAL + CHECK (present_inset_left BETWEEN 0 AND 45); diff --git a/server/src/routes/content.js b/server/src/routes/content.js index a8c7963..140ceae 100644 --- a/server/src/routes/content.js +++ b/server/src/routes/content.js @@ -604,6 +604,24 @@ content.get("/events/:id", (c) => { accent: row.present_accent, text_color: row.present_text_color, logo: row.present_logo, + // Room clear at each edge, percent of the screen (097). + inset: [row.present_inset_top, row.present_inset_right, row.present_inset_bottom, row.present_inset_left].some((n) => n) + ? { + top: row.present_inset_top ?? 0, + right: row.present_inset_right ?? 0, + bottom: row.present_inset_bottom ?? 0, + left: row.present_inset_left ?? 0, + } + : null, + // In the dark theme (096); null takes the above. + dark: { + background: row.present_background_dark, + background_color: row.present_background_color_dark, + dim: row.present_dim_dark, + accent: row.present_accent_dark, + text_color: row.present_text_color_dark, + logo: row.present_logo_dark, + }, }, blocks: body, people, diff --git a/src/lib/adminSchema/events.ts b/src/lib/adminSchema/events.ts index b170549..2ab4407 100644 --- a/src/lib/adminSchema/events.ts +++ b/src/lib/adminSchema/events.ts @@ -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] }, diff --git a/src/lib/darkTheme.ts b/src/lib/darkTheme.ts new file mode 100644 index 0000000..0ac6bc2 --- /dev/null +++ b/src/lib/darkTheme.ts @@ -0,0 +1,15 @@ +/* Whether the site is in its dark theme: , + 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) diff --git a/src/lib/useContent.ts b/src/lib/useContent.ts index c26abcc..071eb3a 100644 --- a/src/lib/useContent.ts +++ b/src/lib/useContent.ts @@ -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> } export type MapSection = { name: string; keys: string[] } diff --git a/src/pages/EventPresent.tsx b/src/pages/EventPresent.tsx index b6b7917..7c2de3a 100644 --- a/src/pages/EventPresent.tsx +++ b/src/pages/EventPresent.tsx @@ -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 @@ -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 ( (null) const slides = ordered(buildSlides(sections, schedules, { skipped, hidden, seconds, only }), order) const count = slides.length @@ -567,6 +596,28 @@ function Setup({

0 leaves that kind of slide out.

+
+

Theme

+ +
+ {tags.length > 0 && (

Tags

@@ -720,7 +771,7 @@ function Setup({