export function getBottomNavHTML() { return ` `; } export function setupBottomNav({ refreshPantry, refreshShoppingList } = {}) { const main = document.getElementById('main-view'); const planner = document.getElementById('planner-view'); const pantry = document.getElementById('pantry-view'); const shopping = document.getElementById('shopping-view'); const nav = document.getElementById('app-bottom-nav'); if (!main || !planner || !pantry || !shopping || !nav) return; const TABS = ['recipes', 'planner', 'pantry', 'shopping']; const apply = (tab) => { main.classList.toggle('hidden', tab !== 'recipes'); planner.classList.toggle('hidden', tab !== 'planner'); pantry.classList.toggle('hidden', tab !== 'pantry'); shopping.classList.toggle('hidden', tab !== 'shopping'); if (tab === 'pantry' && typeof refreshPantry === 'function') refreshPantry(); if (tab === 'shopping' && typeof refreshShoppingList === 'function') refreshShoppingList(); nav.querySelectorAll('.nav-tab[data-tab]').forEach((btn) => { const id = btn.getAttribute('data-tab'); if (btn.hasAttribute('disabled')) return; if (TABS.includes(id)) { const isActive = id === tab; btn.classList.toggle('is-active', isActive); if (isActive) btn.setAttribute('aria-current', 'page'); else btn.removeAttribute('aria-current'); } }); }; nav.addEventListener('click', (e) => { const btn = e.target.closest('.nav-tab[data-tab]'); if (!btn || btn.hasAttribute('disabled')) return; const tab = btn.getAttribute('data-tab'); if (TABS.includes(tab)) apply(tab); }); apply('planner'); window.refreshStockViews = () => { if (typeof refreshPantry === 'function') refreshPantry(); }; }