Spaces:
Running
Running
File size: 1,363 Bytes
70ce5e4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | document.addEventListener('DOMContentLoaded', () => {
// Initialize color mode toggle functionality
const colorModeToggle = document.getElementById('color-mode-toggle');
if (colorModeToggle) {
colorModeToggle.addEventListener('click', () => {
document.documentElement.classList.toggle('dark');
// Update icon
const icon = colorModeToggle.querySelector('i');
if (document.documentElement.classList.contains('dark')) {
icon.setAttribute('data-feather', 'sun');
} else {
icon.setAttribute('data-feather', 'moon');
}
feather.replace();
// Store preference
localStorage.setItem('darkMode', document.documentElement.classList.contains('dark'));
});
}
// Check for saved color mode preference
if (localStorage.getItem('darkMode') === 'true') {
document.documentElement.classList.add('dark');
}
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
}); |