ui: add auto theme switch mode based on system theme (#741)

Add system theme detection with automatic switching when OS theme
changes.

- Add ThemeMode type with "light", "dark", and "system" options
- Add system theme listener using matchMedia API
- Update theme toggle to cycle through System → Light → Dark
- Add combined sun/moon icon for system theme mode
- Migrate existing theme preferences to new format
This commit is contained in:
bankjaneo
2026-05-10 10:22:18 +07:00
committed by GitHub
parent 7e3e94a08a
commit 2be3416baa
3 changed files with 76 additions and 10 deletions
+3 -1
View File
@@ -9,7 +9,7 @@
import Playground from "./routes/Playground.svelte";
import PlaygroundStub from "./routes/PlaygroundStub.svelte";
import { enableAPIEvents } from "./stores/api";
import { initScreenWidth, isDarkMode, appTitle, connectionState } from "./stores/theme";
import { initScreenWidth, initSystemThemeListener, isDarkMode, appTitle, connectionState } from "./stores/theme";
import { currentRoute } from "./stores/route";
const routes = {
@@ -37,10 +37,12 @@
onMount(() => {
const cleanupScreenWidth = initScreenWidth();
const cleanupSystemTheme = initSystemThemeListener();
enableAPIEvents(true);
return () => {
cleanupScreenWidth();
cleanupSystemTheme();
enableAPIEvents(false);
};
});