Add in-tab display mode toggle for users

Let signed-in visitors override the OS color scheme from
the account menu without persisting across reloads, and
keep themed logos in sync with the effective mode.

Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
Émile Ré
2026-07-29 12:51:53 +02:00
parent 7c6ab85916
commit 1d19879b51
21 changed files with 229 additions and 49 deletions

View File

@@ -13,12 +13,15 @@
</script>
<script>
// FOUC guard: apply the OS preference before JS bundles load. Runtime
// overrides (and further system-preference changes) are owned by
// src/lib/displayMode/displayMode.ts once the app boots.
(function () {
if (!window.matchMedia) return;
var mq = window.matchMedia("(prefers-color-scheme: dark)");
var apply = function () { document.documentElement.classList.toggle("dark", mq.matches); };
apply();
mq.addEventListener("change", apply);
document.documentElement.classList.toggle(
"dark",
window.matchMedia("(prefers-color-scheme: dark)").matches,
);
})();
</script>