Spaces:
Running
Running
| 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' | |
| }); | |
| }); | |
| }); | |
| }); |