Spaces:
Running
Running
File size: 1,527 Bytes
579f9e1 | 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 37 38 39 40 41 42 43 44 45 46 47 48 49 | // Theme toggle functionality
document.addEventListener('DOMContentLoaded', () => {
// Check for saved theme preference or use system preference
const savedTheme = localStorage.getItem('theme') ||
(window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
document.documentElement.classList.add(savedTheme);
// Update theme toggle button state
const themeToggle = document.getElementById('theme-toggle');
if (themeToggle) {
themeToggle.checked = savedTheme === 'dark';
}
});
function toggleTheme() {
const html = document.documentElement;
const isDark = html.classList.contains('dark');
if (isDark) {
html.classList.remove('dark');
localStorage.setItem('theme', 'light');
} else {
html.classList.add('dark');
localStorage.setItem('theme', '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'
});
});
});
// Initialize panel animations
document.addEventListener('DOMContentLoaded', () => {
const panels = document.querySelectorAll('.panel-card');
panels.forEach((panel, index) => {
panel.style.setProperty('--order', index);
});
// Initialize Feather icons
if (window.feather) {
feather.replace();
}
});
|