mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-22 03:04:03 +00:00
f53550fc6c
- Remove confusing "preview mode" - channels switch and save immediately - Eliminate complex localStorage channel persistence logic - Reduce update reload time from 10+ seconds to 3 seconds - Remove redundant "Switch to X & Update" buttons - Make channel switching instant with immediate feedback Users can now simply change the dropdown to switch channels instantly, then click Apply Update for a fast 3-second reload experience. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
PulseApp.theme = (() => {
|
|
const htmlElement = document.documentElement;
|
|
const prefersDarkScheme = window.matchMedia('(prefers-color-scheme: dark)');
|
|
let themeToggleButton = null;
|
|
|
|
function applyTheme(theme) {
|
|
if (theme === 'dark') {
|
|
htmlElement.classList.add('dark');
|
|
localStorage.setItem('theme', 'dark');
|
|
} else {
|
|
htmlElement.classList.remove('dark');
|
|
localStorage.setItem('theme', 'light');
|
|
}
|
|
}
|
|
|
|
function init() {
|
|
themeToggleButton = document.getElementById('theme-toggle-button');
|
|
const savedTheme = localStorage.getItem('theme');
|
|
const initialTheme = savedTheme || (prefersDarkScheme.matches ? 'dark' : 'light');
|
|
applyTheme(initialTheme);
|
|
|
|
if (themeToggleButton) {
|
|
themeToggleButton.addEventListener('click', function() {
|
|
const currentIsDark = htmlElement.classList.contains('dark');
|
|
applyTheme(currentIsDark ? 'light' : 'dark');
|
|
});
|
|
}
|
|
}
|
|
|
|
return {
|
|
init
|
|
};
|
|
})();
|