diff --git a/.gitignore b/.gitignore index 3c03c07..d093c4a 100644 --- a/.gitignore +++ b/.gitignore @@ -31,7 +31,7 @@ data/ *.swp *.swo .codex - +AGENTS.md # Claude Code — share skills/agents/rules/hooks/settings; keep local permissions and worktrees out .claude/settings.local.json diff --git a/public/index.html b/public/index.html index e4a50ca..953a94c 100644 --- a/public/index.html +++ b/public/index.html @@ -48,6 +48,8 @@ document.documentElement.setAttribute('data-theme', 'dark'); } else if (stored === 'light') { document.documentElement.setAttribute('data-theme', 'light'); + } else { + document.documentElement.removeAttribute('data-theme'); } // System/null: tokens.css @media (prefers-color-scheme: dark) übernimmt })(); diff --git a/public/pages/settings.js b/public/pages/settings.js index a265fa2..47f65b8 100644 --- a/public/pages/settings.js +++ b/public/pages/settings.js @@ -1788,15 +1788,7 @@ function currentTheme() { } function applyTheme(value) { - localStorage.setItem('oikos-theme', value); - if (value === 'dark') { - document.documentElement.setAttribute('data-theme', 'dark'); - } else if (value === 'light') { - document.documentElement.setAttribute('data-theme', 'light'); - } else { - document.documentElement.removeAttribute('data-theme'); - // tokens.css @media (prefers-color-scheme: dark) übernimmt sofort - } + window.oikos?.applyTheme(value); } function showError(el, msg) { diff --git a/public/router.js b/public/router.js index 613824f..961d6a3 100644 --- a/public/router.js +++ b/public/router.js @@ -1199,6 +1199,16 @@ if (/iPhone|iPad|iPod/.test(navigator.userAgent)) { // -------------------------------------------------------- (async () => { try { + // Vorab-Theme-Anwendung ohne Abhängigkeit von window.oikos + const stored = localStorage.getItem('oikos-theme'); + if (stored === 'dark') { + document.documentElement.setAttribute('data-theme', 'dark'); + } else if (stored === 'light') { + document.documentElement.setAttribute('data-theme', 'light'); + } else { + document.documentElement.removeAttribute('data-theme'); + } + await initI18n(); navigate(location.pathname, false); } catch (err) { @@ -1214,6 +1224,16 @@ window.oikos = { navigate, showToast, setThemeColor, + applyTheme: (value) => { + localStorage.setItem('oikos-theme', value); + if (value === 'dark') { + document.documentElement.setAttribute('data-theme', 'dark'); + } else if (value === 'light') { + document.documentElement.setAttribute('data-theme', 'light'); + } else { + document.documentElement.removeAttribute('data-theme'); + } + }, restoreThemeColor: () => { const route = ROUTES.find((r) => r.path === currentPath); updateThemeColorForRoute(route);