Add dark mode support to Python app
- Implement CSS custom properties for theming - Add comprehensive light and dark color schemes - Create theme toggle button in header - Add theme persistence with localStorage - Support system color scheme preference - Smooth transitions between themes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,42 @@
|
||||
(() => {
|
||||
// Theme management
|
||||
const themeToggle = document.getElementById("themeToggle");
|
||||
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)");
|
||||
|
||||
function getTheme() {
|
||||
const saved = localStorage.getItem("theme");
|
||||
if (saved) return saved;
|
||||
return prefersDark.matches ? "dark" : "light";
|
||||
}
|
||||
|
||||
function setTheme(theme) {
|
||||
document.documentElement.setAttribute("data-theme", theme);
|
||||
localStorage.setItem("theme", theme);
|
||||
if (themeToggle) {
|
||||
themeToggle.textContent = theme === "dark" ? "☀️ Light Mode" : "🌙 Dark Mode";
|
||||
}
|
||||
}
|
||||
|
||||
function toggleTheme() {
|
||||
const current = document.documentElement.getAttribute("data-theme") || "light";
|
||||
setTheme(current === "dark" ? "light" : "dark");
|
||||
}
|
||||
|
||||
// Initialize theme
|
||||
setTheme(getTheme());
|
||||
|
||||
// Listen for theme toggle
|
||||
if (themeToggle) {
|
||||
themeToggle.addEventListener("click", toggleTheme);
|
||||
}
|
||||
|
||||
// Listen for system theme changes
|
||||
prefersDark.addEventListener("change", (e) => {
|
||||
if (!localStorage.getItem("theme")) {
|
||||
setTheme(e.matches ? "dark" : "light");
|
||||
}
|
||||
});
|
||||
|
||||
let qs = new URLSearchParams(window.location.search);
|
||||
const qInput = document.getElementById("q");
|
||||
const channelDropdown = document.getElementById("channelDropdown");
|
||||
|
||||
Reference in New Issue
Block a user