~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

Readers choose to see the console light or dark

Merged
Merged chadtmiller.com asked to merge into feature/branding from chadtmiller.com/group-host:branding/appearance

Readers can now choose to see the console light or dark, from Appearance in the menu under their handle. The choice is kept in a cookie and every page is drawn in it from its first byte, so it never flashes the other scheme. This is the last part of feature/branding; it's stacked on the colours pull, whose commits the diff shows until that one lands.

Claude Opus 5.5 · high effort

What changes

  • The menu. UserMenu shows Appearance (System, Light, Dark) in its full form, between the ways around the console and signing out. It isn't on the approval page, whose menu holds only the accounts. The Appearance molecule is a radio group drawn as three small buttons, the chosen one washed in the colour that acts.
  • Choosing. #lib/appearance.ts sets data-theme on <html> at once and keeps the choice in an appearance cookie (light or dark) for a year. Choosing System deletes the cookie.
  • Drawing. hooks.server.ts reads the cookie and fills a new %theme% in app.html with data-theme="…", or nothing. The CSS for a forced scheme was already in tokens.css, and the colours pull's rules follow it.
  • Data. A new +layout.server.ts reads the cookie for the menu to show what's chosen, and +layout.ts passes it on as appearance.

Why

The console already had light and dark tokens and a forced-scheme selector, but nothing let a reader use them. Doing it on the server, not in a script after load, keeps a dark choice from flashing light.

How it was checked

  • A new e2e flow: Dark chosen from the menu turns the page dark, the reloaded page's HTML carries data-theme="dark", the radio shows it chosen, and System takes it away again across a reload.
  • The full e2e suite: 36 passed.
  • svelte-check, layers, strings.
  • just look of the open menu.

Shortcomings

  • Someone signed out has no menu, so they get their device's scheme.
  • Without JavaScript the radios do nothing.
Approved

This adds an Appearance radio group (System, Light, Dark) to the user menu. The choice is kept in an appearance cookie, and hooks.server.ts writes data-theme into <html> from that cookie. I read the whole diff, including the stacked colours commits, and found nothing that must change.

  • Cookie value: it is whitelisted to light or dark in appearanceOf, so nothing else reaches the data-theme="…" the hook interpolates into the HTML.
  • Menu state: the <details> menu stays mounted, so the radios keep the choice within a page. page.data.appearance comes from the server load, which doesn't rerun after choose() sets the cookie client-side. If the header is ever remounted without a reload, it would show the earlier value. The e2e flow reloads before checking the radio, so it wouldn't catch this. It isn't a bug today.
  • Brand: brandStyle only lets hex colours into the inline <style>, which is why {@html} is safe there.

The change file, docs, strings and e2e flow are all there.

Merged as b31ced0