Spaces:
Running
Running
File size: 2,653 Bytes
ac4cd88 9586cdd ac4cd88 9586cdd ac4cd88 9586cdd ac4cd88 9586cdd ac4cd88 9586cdd ac4cd88 9586cdd ac4cd88 9586cdd ac4cd88 9586cdd ac4cd88 9586cdd ac4cd88 9586cdd |
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
// Initialize Feather Icons
document.addEventListener('DOMContentLoaded', function() {
feather.replace();
// Theme toggle functionality
const themeToggle = document.getElementById('theme-toggle');
if (themeToggle) {
themeToggle.addEventListener('click', function() {
document.documentElement.classList.toggle('dark');
localStorage.setItem('theme', document.documentElement.classList.contains('dark') ? 'dark' : 'light');
});
}
// Check for saved theme preference
if (localStorage.getItem('theme') === 'dark' ||
(!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.classList.add('dark');
} else {
document.documentElement.classList.remove('dark');
}
// Gallery interaction
const galleryItems = document.querySelectorAll('.gallery-item');
galleryItems.forEach(item => {
item.addEventListener('click', function() {
// Remove active class from all items
galleryItems.forEach(i => i.classList.remove('ring-2', 'ring-primary'));
// Add active class to clicked item
this.classList.add('ring-2', 'ring-primary');
// Update preview area with selected item
const previewArea = document.querySelector('.preview-placeholder');
if (previewArea) {
previewArea.innerHTML = `
<div class="w-full h-full bg-gradient-to-br from-purple-900 to-blue-800 rounded-lg flex items-center justify-center">
<div class="text-center">
<i data-feather="check-circle" class="w-12 h-12 mx-auto text-white mb-2"></i>
<p class="text-white">Selected: ${this.querySelector('p').textContent}</p>
</div>
</div>
`;
feather.replace();
}
});
});
// Generate button animation
const generateButtons = document.querySelectorAll('button.flex.items-center.justify-center');
generateButtons.forEach(button => {
button.addEventListener('click', function() {
const originalText = this.innerHTML;
this.innerHTML = '<i data-feather="loader" class="mr-2 animate-spin"></i> Generating...';
feather.replace();
// Simulate processing time
setTimeout(() => {
this.innerHTML = originalText;
feather.replace();
}, 2000);
});
});
}); |