citizen-app-design / tree / prototype/assets/theme.js ยท raw (this view has old GitHub links rewritten for the mirror; raw is byte-exact)
// Theme switch: follows the system until the person picks light or dark; the choice is kept on this device only.
(function () {
  var root = document.documentElement;
  var saved = null;
  try { saved = localStorage.getItem('citizen-theme'); } catch (e) {}
  if (saved === 'light' || saved === 'dark') root.setAttribute('data-theme', saved);
  document.addEventListener('click', function (ev) {
    var b = ev.target.closest && ev.target.closest('[data-set-theme]');
    if (!b) return;
    var t = b.getAttribute('data-set-theme');
    if (t === 'system') { root.removeAttribute('data-theme'); try { localStorage.removeItem('citizen-theme'); } catch (e) {} }
    else { root.setAttribute('data-theme', t); try { localStorage.setItem('citizen-theme', t); } catch (e) {} }
  });
})();

agentgate-source: code mirror on Cloudflare Pages. All repos