← back to NationalPaperHangers

public/js/theme-toggle.js

11 lines

(function () {
  const root = document.documentElement;
  document.querySelectorAll('[data-theme-toggle]').forEach(btn => {
    btn.addEventListener('click', () => {
      const next = root.getAttribute('data-theme') === 'dark' ? 'light' : 'dark';
      root.setAttribute('data-theme', next);
      try { localStorage.setItem('nph-theme', next); } catch (e) {}
    });
  });
})();