Spaces:
Running
Running
Download index.html from pakdeveloper/Static-002: direct link, hf CLI and curl.
- Browser
- Download file 7.12 kB
-
https://huggingface.co/spaces/pakdeveloper/Static-002/resolve/main/index.html
- Command line
-
hf download hf://spaces/pakdeveloper/Static-002/index.html
-
curl -L -o index.html https://huggingface.co/spaces/pakdeveloper/Static-002/resolve/main/index.html
7.12 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <title>Image Gallery</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <style> | |
| .masonry-grid { | |
| display: grid; | |
| grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); | |
| gap: 1rem; | |
| width: 100%; | |
| } | |
| .image-container { | |
| aspect-ratio: 1; | |
| position: relative; | |
| overflow: hidden; | |
| } | |
| .gallery-image { | |
| position: absolute; | |
| inset: 0; | |
| width: 100%; | |
| height: 100%; | |
| object-fit: cover; | |
| } | |
| .modal { | |
| display: none; | |
| position: fixed; | |
| inset: 0; | |
| background-color: rgba(0, 0, 0, 0.9); | |
| z-index: 50; | |
| padding: 2rem; | |
| cursor: pointer; | |
| } | |
| .modal-content { | |
| max-height: 90vh; | |
| max-width: 90vw; | |
| margin: auto; | |
| display: block; | |
| object-fit: contain; | |
| } | |
| .toast { | |
| position: fixed; | |
| bottom: 1rem; | |
| right: 1rem; | |
| padding: 1rem; | |
| border-radius: 0.5rem; | |
| color: white; | |
| animation: slideIn 0.3s ease-out; | |
| z-index: 50; | |
| } | |
| .toast-success { | |
| background-color: rgb(34, 197, 94); | |
| } | |
| .toast-error { | |
| background-color: rgb(239, 68, 68); | |
| } | |
| @keyframes slideIn { | |
| from { | |
| transform: translateX(100%); | |
| opacity: 0; | |
| } | |
| to { | |
| transform: translateX(0); | |
| opacity: 1; | |
| } | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="mx-auto max-w-7xl px-4 py-8 sm:px-6 lg:px-8"> | |
| <div class="space-y-8"> | |
| <div> | |
| <h1 class="text-4xl font-bold tracking-tight text-gray-900"> | |
| Image Gallery | |
| </h1> | |
| <p class="mt-2 text-lg text-gray-600"> | |
| Upload your images by dragging and dropping them below | |
| </p> | |
| </div> | |
| <div id="dropZone" class="relative min-h-[200px] rounded-xl border-2 border-dashed border-gray-200 hover:border-purple-500/50 transition-all duration-300 ease-in-out cursor-pointer"> | |
| <input type="file" id="fileInput" class="hidden" multiple accept="image/*"/> | |
| <div class="absolute inset-0 flex flex-col items-center justify-center space-y-4 p-6 text-center"> | |
| <div class="rounded-full bg-purple-500/10 p-4"> | |
| <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="rgb(147, 51, 234)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> | |
| <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path> | |
| <polyline points="17 8 12 3 7 8"></polyline> | |
| <line x1="12" y1="3" x2="12" y2="15"></line> | |
| </svg> | |
| </div> | |
| <div> | |
| <p class="text-lg font-medium text-gray-900"> | |
| Drag & Drop images here | |
| </p> | |
| <p class="mt-1 text-sm text-gray-500">or click anywhere to upload</p> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="space-y-4"> | |
| <h2 class="text-2xl font-semibold text-gray-900"> | |
| Your Images | |
| </h2> | |
| <div id="gallery" class="masonry-grid"> | |
| <!-- Images will be dynamically added here --> | |
| </div> | |
| <p id="noImages" class="text-center text-gray-500 py-12"> | |
| No images uploaded yet. Start by dropping some images above! | |
| </p> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Modal for full-size image view --> | |
| <div id="imageModal" class="modal" onclick="closeModal()"> | |
| <img id="modalImage" class="modal-content" src="" alt="Full size image"> | |
| </div> | |
| <script> | |
| // Initialize variables | |
| const dropZone = document.getElementById('dropZone'); | |
| const fileInput = document.getElementById('fileInput'); | |
| const gallery = document.getElementById('gallery'); | |
| const noImages = document.getElementById('noImages'); | |
| const modal = document.getElementById('imageModal'); | |
| const modalImg = document.getElementById('modalImage'); | |
| let images = []; | |
| // Toast notification function | |
| function showToast(message, type = 'success') { | |
| const toast = document.createElement('div'); | |
| toast.className = `toast toast-${type}`; | |
| toast.textContent = message; | |
| document.body.appendChild(toast); | |
| setTimeout(() => { | |
| toast.remove(); | |
| }, 3000); | |
| } | |
| // Modal functions | |
| function openModal(imageSrc) { | |
| modal.style.display = 'flex'; | |
| modalImg.src = imageSrc; | |
| } | |
| function closeModal() { | |
| modal.style.display = 'none'; | |
| } | |
| // Setup gallery grid | |
| function setupGalleryGrid() { | |
| gallery.innerHTML = ''; | |
| images.forEach((image, index) => { | |
| const imgContainer = document.createElement('div'); | |
| imgContainer.className = 'image-container rounded-lg overflow-hidden bg-gray-100 shadow-sm hover:shadow-md transition-all duration-300 cursor-pointer'; | |
| const img = document.createElement('img'); | |
| img.src = image; | |
| img.alt = `Gallery image ${index + 1}`; | |
| img.className = 'gallery-image'; | |
| img.loading = 'lazy'; | |
| imgContainer.onclick = () => openModal(image); | |
| imgContainer.appendChild(img); | |
| gallery.appendChild(imgContainer); | |
| }); | |
| // Toggle no images message | |
| noImages.style.display = images.length > 0 ? 'none' : 'block'; | |
| } | |
| // Handle file addition | |
| function handleFiles(files) { | |
| const imageFiles = Array.from(files).filter(file => file.type.startsWith('image/')); | |
| if (imageFiles.length === 0) { | |
| showToast('Please select image files only', 'error'); | |
| return; | |
| } | |
| const newImages = imageFiles.map(file => URL.createObjectURL(file)); | |
| images = [...images, ...newImages]; | |
| setupGalleryGrid(); | |
| showToast(`${imageFiles.length} image${imageFiles.length === 1 ? '' : 's'} uploaded`); | |
| } | |
| // Event Listeners | |
| dropZone.addEventListener('dragenter', (e) => { | |
| e.preventDefault(); | |
| e.stopPropagation(); | |
| dropZone.classList.add('border-purple-500', 'bg-purple-500/5'); | |
| }); | |
| dropZone.addEventListener('dragleave', (e) => { | |
| e.preventDefault(); | |
| e.stopPropagation(); | |
| dropZone.classList.remove('border-purple-500', 'bg-purple-500/5'); | |
| }); | |
| dropZone.addEventListener('dragover', (e) => { | |
| e.preventDefault(); | |
| e.stopPropagation(); | |
| }); | |
| dropZone.addEventListener('drop', (e) => { | |
| e.preventDefault(); | |
| e.stopPropagation(); | |
| dropZone.classList.remove('border-purple-500', 'bg-purple-500/5'); | |
| handleFiles(e.dataTransfer.files); | |
| }); | |
| dropZone.addEventListener('click', () => { | |
| fileInput.click(); | |
| }); | |
| fileInput.addEventListener('change', (e) => { | |
| handleFiles(e.target.files); | |
| e.target.value = ''; | |
| }); | |
| // Close modal when pressing escape key | |
| document.addEventListener('keydown', (e) => { | |
| if (e.key === 'Escape') { | |
| closeModal(); | |
| } | |
| }); | |
| // Initial setup | |
| setupGalleryGrid(); | |
| </script> | |
| </body> | |
| </html> |