style: fix formatting via prettier

This commit is contained in:
2026-08-28 14:29:54 +05:00
parent 10278981ba
commit ada96b3534
124 changed files with 8211 additions and 5662 deletions
+15 -10
View File
@@ -1,20 +1,22 @@
export type ThemeChoice = 'light' | 'dark';
export type ThemeChoice = "light" | "dark";
const STORAGE_KEY = 'theme';
const STORAGE_KEY = "theme";
let theme = $state<ThemeChoice>('light');
let theme = $state<ThemeChoice>("light");
function storage(): Storage | null {
return typeof localStorage === 'undefined' ? null : localStorage;
return typeof localStorage === "undefined" ? null : localStorage;
}
function systemTheme(): ThemeChoice {
if (typeof window === 'undefined' || !window.matchMedia) return 'light';
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
if (typeof window === "undefined" || !window.matchMedia) return "light";
return window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "light";
}
function apply(): void {
if (typeof document === 'undefined') return;
if (typeof document === "undefined") return;
document.documentElement.dataset.theme = theme;
}
@@ -34,8 +36,11 @@ export function setTheme(next: ThemeChoice): void {
* чтобы кнопка в шапке отражала реальную тему.
*/
export function initTheme(): void {
if (typeof window === 'undefined') return;
const attr = typeof document !== 'undefined' ? document.documentElement.dataset.theme : undefined;
theme = attr === 'dark' || attr === 'light' ? attr : systemTheme();
if (typeof window === "undefined") return;
const attr =
typeof document !== "undefined"
? document.documentElement.dataset.theme
: undefined;
theme = attr === "dark" || attr === "light" ? attr : systemTheme();
apply();
}