Spaces:
Running
Running
Download script.js from Abanee/reactshop-bazaar: direct link, hf CLI and curl.
- Browser
- Download file 816 Bytes
-
https://huggingface.co/spaces/Abanee/reactshop-bazaar/resolve/main/script.js
- Command line
-
hf download hf://spaces/Abanee/reactshop-bazaar/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Abanee/reactshop-bazaar/resolve/main/script.js
816 Bytes
| // Theme toggle functionality | |
| 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'); | |
| } | |
| // Theme toggle button event listener will be handled in navbar component | |
| }); | |
| // Utility function to toggle theme | |
| function toggleTheme() { | |
| const html = document.documentElement; | |
| html.classList.toggle('dark'); | |
| // Save preference to localStorage | |
| const isDark = html.classList.contains('dark'); | |
| localStorage.setItem('theme', isDark ? 'dark' : 'light'); | |
| } |