1.0 KiB · text History 9174a13
// Theme registry shared by the site chrome and the reveal.js decks.
// Persisted under localStorage "theme", matching neiam.co.
window.NeiamThemes = (function () {
  // blueprint/light/dark are Diogramos' own, so embedded diagrams can match.
  const themes = ["blueprint", "her", "afterdark", "forest", "sky", "clays", "stones", "light", "dark"];
  const emoji = {
    her: "❤️", afterdark: "💜", forest: "💚",
    sky: "🩵", clays: "🧡", stones: "🩶",
    light: "🤍", dark: "🖤", blueprint: "💙",
  };
  const html = document.documentElement;

  function current() {
    return html.getAttribute("data-theme") || themes[0];
  }

  function set(name) {
    if (!themes.includes(name)) return;
    html.setAttribute("data-theme", name);
    try { localStorage.setItem("theme", name); } catch (e) { /* private mode */ }
    window.dispatchEvent(new CustomEvent("themechange", { detail: name }));
  }

  function next() {
    set(themes[(themes.indexOf(current()) + 1) % themes.length]);
  }

  return { themes, emoji, current, set, next };
})();