Spaces:
Running
Running
Download script.js from Madan08/project-spark-generator: direct link, hf CLI and curl.
- Browser
- Download file 3.48 kB
-
https://huggingface.co/spaces/Madan08/project-spark-generator/resolve/main/script.js
- Command line
-
hf download hf://spaces/Madan08/project-spark-generator/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Madan08/project-spark-generator/resolve/main/script.js
3.48 kB
| document.addEventListener('DOMContentLoaded', function() { | |
| // Mobile menu toggle | |
| const mobileMenuButton = document.querySelector('[aria-controls="mobile-menu"]'); | |
| const mobileMenu = document.createElement('div'); | |
| mobileMenu.id = 'mobile-menu'; | |
| mobileMenu.className = 'hidden sm:hidden'; | |
| mobileMenu.innerHTML = ` | |
| <div class="pt-2 pb-3 space-y-1"> | |
| <a href="#" class="bg-primary-50 border-primary-500 text-primary-500 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Home</a> | |
| <a href="#" class="border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Templates</a> | |
| <a href="#" class="border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Features</a> | |
| <a href="#" class="border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Pricing</a> | |
| </div> | |
| <div class="pt-4 pb-3 border-t border-gray-200"> | |
| <div class="flex items-center px-4"> | |
| <button class="w-full flex items-center justify-center px-4 py-2 border border-transparent text-base font-medium rounded-md text-white bg-primary-500 hover:bg-primary-600"> | |
| Get Started | |
| </button> | |
| </div> | |
| </div> | |
| `; | |
| document.querySelector('nav').appendChild(mobileMenu); | |
| mobileMenuButton.addEventListener('click', function() { | |
| const expanded = this.getAttribute('aria-expanded') === 'true'; | |
| this.setAttribute('aria-expanded', !expanded); | |
| mobileMenu.classList.toggle('hidden'); | |
| // Toggle menu icon | |
| if (expanded) { | |
| feather.replace(); | |
| } else { | |
| const menuIcon = this.querySelector('svg'); | |
| if (menuIcon) { | |
| menuIcon.replaceWith(feather.icons['x'].toSvg()); | |
| } | |
| } | |
| }); | |
| // Template card hover effect | |
| const templateCards = document.querySelectorAll('.group.relative'); | |
| templateCards.forEach(card => { | |
| card.addEventListener('mouseenter', function() { | |
| const img = this.querySelector('img'); | |
| if (img) { | |
| img.style.transform = 'scale(1.05)'; | |
| img.style.transition = 'transform 0.3s ease'; | |
| } | |
| }); | |
| card.addEventListener('mouseleave', function() { | |
| const img = this.querySelector('img'); | |
| if (img) { | |
| img.style.transform = 'scale(1)'; | |
| } | |
| }); | |
| }); | |
| // Animate hero section | |
| const heroSection = document.querySelector('.lg\\:text-left'); | |
| if (heroSection) { | |
| heroSection.classList.add('animate-fadeInUp'); | |
| } | |
| // Smooth scrolling for anchor links | |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { | |
| anchor.addEventListener('click', function(e) { | |
| e.preventDefault(); | |
| const targetId = this.getAttribute('href'); | |
| if (targetId === '#') return; | |
| const targetElement = document.querySelector(targetId); | |
| if (targetElement) { | |
| targetElement.scrollIntoView({ | |
| behavior: 'smooth' | |
| }); | |
| } | |
| }); | |
| }); | |
| }); |