Spaces:
Running
Running
Download script.js from michaelcboyer/chromadream-ui: direct link, hf CLI and curl.
- Browser
- Download file 1.52 kB
-
https://huggingface.co/spaces/michaelcboyer/chromadream-ui/resolve/main/script.js
- Command line
-
hf download hf://spaces/michaelcboyer/chromadream-ui/script.js
-
curl -L -o script.js https://huggingface.co/spaces/michaelcboyer/chromadream-ui/resolve/main/script.js
1.52 kB
| // Theme initialization | |
| document.addEventListener('DOMContentLoaded', () => { | |
| // Check for saved theme preference or use system preference | |
| const savedTheme = localStorage.getItem('theme'); | |
| const systemPrefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches; | |
| if (savedTheme === 'dark' || (!savedTheme && systemPrefersDark)) { | |
| document.documentElement.classList.add('dark'); | |
| } | |
| }); | |
| // Function to toggle theme with animation | |
| function toggleTheme() { | |
| const html = document.documentElement; | |
| // Add transition class | |
| html.classList.add('theme-transition'); | |
| // Toggle theme after short delay | |
| setTimeout(() => { | |
| html.classList.toggle('dark'); | |
| // Save preference to localStorage | |
| const isDark = html.classList.contains('dark'); | |
| localStorage.setItem('theme', isDark ? 'dark' : 'light'); | |
| // Remove transition class after animation | |
| setTimeout(() => { | |
| html.classList.remove('theme-transition'); | |
| }, 500); | |
| }, 50); | |
| } | |
| // Animate features on scroll | |
| document.addEventListener('DOMContentLoaded', () => { | |
| const observer = new IntersectionObserver((entries) => { | |
| entries.forEach(entry => { | |
| if (entry.isIntersecting) { | |
| entry.target.classList.add('animate-fade-in-up'); | |
| } | |
| }); | |
| }, { threshold: 0.1 }); | |
| document.querySelectorAll('#features .card').forEach(card => { | |
| observer.observe(card); | |
| }); | |
| }); | |