Give gadget UIs the Workshop's theme, as gatekeeper apps already have #535
hx-natthawat
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Gatekeeper apps receive the Workshop's appearance explicitly —
GatekeeperAppThemeReceiver.setTheme({ mode, accentColor })inworkshop-shared/src/theme.ts, pushed fromSandboxedGatekeeperApp.tsxon every change. Gadget UIs do not. Their iframe (GadgetUI.tsx) is handed a MessagePort, a console relay and an Escape relay, and nothing about the theme.That matters because the theme cannot be inferred from inside the frame. Measured in headless Chrome with a page that sets
color-schemeon<html>the waytheme.tsdoes, embedding an iframe with GadgetUI's sandbox attributes that reportsmatchMedia('(prefers-color-scheme: dark)').matches:color-schemeprefers-color-scheme: darkdarklightA sandboxed frame follows the OS, not the embedder. So a gadget or a format blueprint that wants a dark variant today has two bad choices: follow the OS and contradict the Workshop's toggle, or stay light.
Proposal
Extend the existing handshake rather than add a channel:
GadgetUI.tsx, once the handshake port arrives, post{ type: 'theme', mode, accentColor }into the frame (iframe.contentWindow.postMessage), and again wheneverresolvedThemeMode/ accent change — the same triggerSandboxedGatekeeperAppalready uses.document.documentElement.style.colorScheme = modeso UA widgets andlight-dark()follow, keep the latest value somewhere gadget code can read synchronously (e.g.globalThis.workshopTheme), and dispatch aworkshopthemeevent onwindowso a gadget can re-render on change.GatekeeperAppTheme— same shape, same semantics; nothing new to learn.Two small hunks in one file plus a type re-use. Gadgets that ignore it see no change; the bundled format blueprints (
workspace-slidesfirst) can then carry a dark chrome that agrees with the app around them.Happy to open the PR if this is wanted; asking first per CONTRIBUTING.
All reactions