From 2be3416baa83db5f202b8a187b1d99e3e378b23c Mon Sep 17 00:00:00 2001 From: bankjaneo
Date: Sun, 10 May 2026 10:22:18 +0700 Subject: [PATCH] ui: add auto theme switch mode based on system theme (#741) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- ui-svelte/src/App.svelte | 4 +- ui-svelte/src/components/Header.svelte | 17 ++++--- ui-svelte/src/stores/theme.ts | 65 ++++++++++++++++++++++++-- 3 files changed, 76 insertions(+), 10 deletions(-) diff --git a/ui-svelte/src/App.svelte b/ui-svelte/src/App.svelte index 6ea0606c..b251258a 100644 --- a/ui-svelte/src/App.svelte +++ b/ui-svelte/src/App.svelte @@ -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); }; }); diff --git a/ui-svelte/src/components/Header.svelte b/ui-svelte/src/components/Header.svelte index 08bbe5f2..10665e8e 100644 --- a/ui-svelte/src/components/Header.svelte +++ b/ui-svelte/src/components/Header.svelte @@ -1,6 +1,6 @@