Spaces:
Running
Running
Download script.js from datads/pixelperfect-palette-pro: direct link, hf CLI and curl.
- Browser
- Download file 1.2 kB
-
https://huggingface.co/spaces/datads/pixelperfect-palette-pro/resolve/main/script.js
- Command line
-
hf download hf://spaces/datads/pixelperfect-palette-pro/script.js
-
curl -L -o script.js https://huggingface.co/spaces/datads/pixelperfect-palette-pro/resolve/main/script.js
1.2 kB
| // 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' | |
| }); | |
| }); | |
| }); |