mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 03:52:50 +08:00
feat: complete M008 web ux and demo
This commit is contained in:
1 parent
277fa9d8fe
commit
cab7707e51
7 files changed
+238
-19
No files matched your search
@@ -0,0 +1,24 @@
|
||||
export type ThemeMode = "system" | "light" | "dark";
|
||||
|
||||
const THEME_KEY = "webspeak:theme";
|
||||
|
||||
export function getStoredTheme(): ThemeMode {
|
||||
const value = typeof localStorage === "undefined" ? "" : localStorage.getItem(THEME_KEY);
|
||||
return value === "light" || value === "dark" || value === "system" ? value : "system";
|
||||
}
|
||||
|
||||
export function applyTheme(theme: ThemeMode): void {
|
||||
if (typeof document === "undefined") return;
|
||||
document.documentElement.dataset.theme = theme;
|
||||
}
|
||||
|
||||
export function saveTheme(theme: ThemeMode): void {
|
||||
if (typeof localStorage !== "undefined") localStorage.setItem(THEME_KEY, theme);
|
||||
applyTheme(theme);
|
||||
}
|
||||
|
||||
export function nextTheme(theme: ThemeMode): ThemeMode {
|
||||
return theme === "system" ? "light" : theme === "light" ? "dark" : "system";
|
||||
}
|
||||
|
||||
applyTheme(getStoredTheme());
|
||||
Reference in new issue
Block a user