
- Modified multiple HTML files for dark mode support - Updated styles.css with dark mode styling - Added dark-mode.js for toggle functionality - Work still in progress, saving current state 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
35 lines
No EOL
1.1 KiB
JavaScript
35 lines
No EOL
1.1 KiB
JavaScript
// Apply saved theme immediately to prevent flash
|
|
(function() {
|
|
const savedTheme = localStorage.getItem('theme');
|
|
if (savedTheme === 'dark') {
|
|
document.documentElement.setAttribute('data-theme', 'dark');
|
|
}
|
|
})();
|
|
|
|
// Dark mode toggle functionality
|
|
function toggleDarkMode() {
|
|
const html = document.documentElement;
|
|
const button = document.querySelector('.dark-mode-toggle');
|
|
|
|
if (html.getAttribute('data-theme') === 'dark') {
|
|
html.removeAttribute('data-theme');
|
|
button.textContent = '🌙';
|
|
localStorage.setItem('theme', 'light');
|
|
} else {
|
|
html.setAttribute('data-theme', 'dark');
|
|
button.textContent = '☀️';
|
|
localStorage.setItem('theme', 'dark');
|
|
}
|
|
}
|
|
|
|
// Load saved theme on page load
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const savedTheme = localStorage.getItem('theme');
|
|
const button = document.querySelector('.dark-mode-toggle');
|
|
|
|
if (savedTheme === 'dark') {
|
|
button.textContent = '☀️';
|
|
} else {
|
|
button.textContent = '🌙';
|
|
}
|
|
}); |