Скилл переносится из ~/.claude/skills/aura-design в репозиторий обвязки: SKILL.md, справочники reference/ и набор kit/ (токены, base.css, компоненты React, оболочка AppShell, тест токенов, test-setup, примеры входа). install.sh ставит его в ~/.claude/skills/aura-design, --check его видит. tests/test-aura-design.sh проверяет структуру и инварианты набора. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
1.3 KiB
TypeScript
30 lines
1.3 KiB
TypeScript
// тема интерфейса: "" — системная, light, dark. Ключ хранилища поменяй на свой (по одному на приложение).
|
|
// Тот же ключ читает встроенный скрипт в index.html, чтобы тёмная тема не мигала светлой при загрузке.
|
|
export const THEMES = ["", "light", "dark"] as const;
|
|
export type Theme = (typeof THEMES)[number];
|
|
export const THEME_KEY = "app-theme";
|
|
const KEY = THEME_KEY;
|
|
|
|
export function readTheme(): Theme {
|
|
let v: string | null = null;
|
|
try { v = localStorage.getItem(KEY); } catch { /* закрытое хранилище */ }
|
|
return (THEMES as readonly string[]).includes(v ?? "") ? ((v ?? "") as Theme) : "";
|
|
}
|
|
|
|
export function saveTheme(t: Theme): void {
|
|
try { localStorage.setItem(KEY, t); } catch { /* закрытое хранилище */ }
|
|
}
|
|
|
|
export function applyTheme(t: Theme): void {
|
|
if (t) document.documentElement.setAttribute("data-theme", t);
|
|
else document.documentElement.removeAttribute("data-theme");
|
|
}
|
|
|
|
export function systemDark(): boolean {
|
|
return typeof matchMedia === "function" && matchMedia("(prefers-color-scheme: dark)").matches;
|
|
}
|
|
|
|
export function effectiveDark(t: Theme): boolean {
|
|
return t === "dark" || (t === "" && systemDark());
|
|
}
|