8dc105ff3e
- Delete React files (App.jsx, main.jsx, App.css) - Create modular vanilla JS structure in client/src/: - state.js (global state object) - api.js (all fetch calls) - sse.js (SSE connection management) - ui/auth.js (authentication UI) - ui/downloads.js (downloads rendering) - ui/history.js (history section) - ui/statusPanel.js (status panel) - ui/webhooks.js (webhook management) - ui/filters.js (download client filter) - ui/theme.js (theme switching) - ui/tabs.js (tab navigation) - utils/format.js (formatting utilities) - utils/storage.js (localStorage helpers) - main.js (DOMContentLoaded bootstrap) - Update vite.config.js for vanilla build outputting to ../public/app.js - Build succeeds: 14 modules, 43.88 kB output
28 lines
728 B
JavaScript
28 lines
728 B
JavaScript
// Copyright (c) 2026 Gordon Bolton. MIT License.
|
|
|
|
import { getTheme, saveTheme } from '../utils/storage.js';
|
|
|
|
// Apply saved theme immediately on load
|
|
(function applyTheme() {
|
|
const theme = getTheme();
|
|
if (theme) {
|
|
document.documentElement.setAttribute('data-theme', theme);
|
|
}
|
|
})();
|
|
|
|
export function initThemeSwitcher() {
|
|
const themeToggle = document.getElementById('theme-toggle');
|
|
if (!themeToggle) return;
|
|
|
|
themeToggle.addEventListener('click', () => {
|
|
const currentTheme = getTheme();
|
|
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
|
|
setTheme(newTheme);
|
|
});
|
|
}
|
|
|
|
export function setTheme(theme) {
|
|
document.documentElement.setAttribute('data-theme', theme);
|
|
saveTheme(theme);
|
|
}
|