Files
wordsearch/static/js/theme.js
T
Mathew Sir Guest the bestandClaude Opus 4.6 9319f08875 feat: expand to 1014 words, add title-case display and 2 new themes
- Move word data from hardcoded seed.py to data/words.json
- Expand from 210 words across 7 categories to 1014 words across 14
  categories (animals, food, colors, sports, space, nature, music,
  science, countries, occupations, ocean, weather, mythology, technology)
- Word list sidebar now shows title case (Tiger) while grid stays
  uppercase; text input remains case-insensitive
- Add Ocean theme (light, blue accents) and Forest theme (dark, amber
  accents on deep green)
- Replace hardcoded rgba values with --coral-bg CSS variable so
  selection highlighting adapts per theme

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-07 02:43:43 -06:00

35 lines
1.0 KiB
JavaScript

(function () {
"use strict";
var themes = ["indigo", "dark", "light", "ocean", "forest"];
var icons = {
indigo: "bi-moon-stars",
dark: "bi-circle-half",
light: "bi-sun",
ocean: "bi-water",
forest: "bi-tree"
};
var lightThemes = { light: true, ocean: true };
var btn = document.getElementById("theme-toggle");
var current = localStorage.getItem("ws-theme") || "indigo";
function apply(theme) {
document.documentElement.setAttribute("data-theme", theme);
document.documentElement.setAttribute(
"data-bs-theme",
lightThemes[theme] ? "light" : "dark"
);
btn.querySelector("i").className = "bi " + icons[theme];
btn.title = theme.charAt(0).toUpperCase() + theme.slice(1) + " theme";
localStorage.setItem("ws-theme", theme);
current = theme;
}
apply(current);
btn.addEventListener("click", function () {
var idx = (themes.indexOf(current) + 1) % themes.length;
apply(themes[idx]);
});
})();