feat: add system theme mode
This commit is contained in:
1 parent
7ce2cf2163
commit
b0a808bc14
8 files changed
+159
-27
No files matched your search
@@ -0,0 +1,20 @@
|
||||
import type { Theme } from "@tauri-apps/api/window";
|
||||
|
||||
export const APP_THEME_STORAGE_KEY = "dbx-theme";
|
||||
|
||||
export type AppThemeMode = "light" | "dark" | "system";
|
||||
export type AppThemeAppearance = "light" | "dark";
|
||||
|
||||
export function normalizeAppThemeMode(value: string | null): AppThemeMode {
|
||||
if (value === "dark" || value === "light" || value === "system") return value;
|
||||
return "light";
|
||||
}
|
||||
|
||||
export function resolveAppThemeAppearance(mode: AppThemeMode, systemPrefersDark: boolean): AppThemeAppearance {
|
||||
if (mode === "system") return systemPrefersDark ? "dark" : "light";
|
||||
return mode;
|
||||
}
|
||||
|
||||
export function getTauriThemeForMode(mode: AppThemeMode): Theme | null {
|
||||
return mode === "system" ? null : mode;
|
||||
}
|
||||
Reference in new issue
Block a user