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:
@@ -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);
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user