Something went wrong. Try again.
A warm, tech-dystopian color scheme inspired by corrupted hardware and failing systems. digitalrust.katsuricata.com
theme color-scheme color-theme warm color
Something went wrong. Try again.
1.2 kB · 39 lines
TypeScript
at main
12345678910111213141516171819202122232425262728293031323334353637383940// SPDX-FileCopyrightText: 2025-2026 Kat Suricata <https://KatSuricata.com/>// SPDX-License-Identifier: (CC-BY-4.0+ OR Apache-2.0+)
import { activeScheme, applyScheme, platformScheme, savedScheme, type Scheme} from '#lib/scheme.js';
/** * The mode on screen. Components read `scheme.current` and call `setScheme`. * * `src/app.html` applies the same mode before the first paint, so the value * here syncs the controls with the page rather than changing the page. */export const scheme = $state<{ current: Scheme }>({ current: 'dark' });
let listening = false;
/** Syncs the store with the page. Call once from a component, on the client. */export function startScheme(): void { scheme.current = activeScheme(); if (listening) return; listening = true;
// Follow the platform while the reader has saved no mode. const media = window.matchMedia('(prefers-color-scheme: light)'); media.addEventListener('change', () => { if (!savedScheme()) scheme.current = platformScheme(); });}
/** Saves a mode, applies it to the root element, and updates the store. */export function setScheme(next: Scheme): void { scheme.current = next; applyScheme(next);}