Discover dark mode automatically
All checks were successful
Build and Deploy / build-and-push (push) Successful in 1m14s
All checks were successful
Build and Deploy / build-and-push (push) Successful in 1m14s
This commit is contained in:
@@ -1,33 +1,4 @@
|
||||
function syncThemeToggleButton(btn, isDark) {
|
||||
if (!btn) return;
|
||||
const icon = btn.querySelector('i');
|
||||
if (icon) icon.className = isDark ? 'fas fa-sun' : 'fas fa-moon';
|
||||
btn.setAttribute('aria-label', isDark ? 'Włącz jasny motyw' : 'Włącz ciemny motyw');
|
||||
btn.title = isDark ? 'Jasny motyw' : 'Ciemny motyw';
|
||||
}
|
||||
|
||||
function setupThemeToggle() {
|
||||
const btn = document.getElementById('nav-theme-toggle');
|
||||
if (!btn) return;
|
||||
|
||||
btn.addEventListener('click', () => {
|
||||
const html = document.documentElement;
|
||||
const isDark = html.classList.toggle('dark');
|
||||
localStorage.setItem('theme', isDark ? 'dark' : 'light');
|
||||
|
||||
syncThemeToggleButton(btn, isDark);
|
||||
|
||||
const meta = document.querySelector('meta[name="theme-color"]');
|
||||
if (meta) {
|
||||
const varName = isDark ? '--sunken-deep-rgb' : '--app-bg-rgb';
|
||||
const rgb = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
|
||||
if (rgb) meta.setAttribute('content', `rgb(${rgb})`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function getBottomNavHTML() {
|
||||
const isDark = document.documentElement.classList.contains('dark');
|
||||
return `
|
||||
<nav id="app-bottom-nav" aria-label="Główna nawigacja">
|
||||
<div class="bottom-dock">
|
||||
@@ -51,11 +22,6 @@ export function getBottomNavHTML() {
|
||||
<i class="fas fa-cart-shopping" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="nav-slot">
|
||||
<button type="button" id="nav-theme-toggle" class="nav-action" aria-label="${isDark ? 'Włącz jasny motyw' : 'Włącz ciemny motyw'}" title="${isDark ? 'Jasny motyw' : 'Ciemny motyw'}">
|
||||
<i class="${isDark ? 'fas fa-sun' : 'fas fa-moon'}" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
`;
|
||||
@@ -99,7 +65,6 @@ export function setupBottomNav({ refreshPantry, refreshShoppingList } = {}) {
|
||||
if (TABS.includes(tab)) apply(tab);
|
||||
});
|
||||
|
||||
setupThemeToggle();
|
||||
apply('planner');
|
||||
|
||||
window.refreshStockViews = () => {
|
||||
|
||||
Reference in New Issue
Block a user