diff --git a/frontend/src/lib/components/GalleryView.svelte b/frontend/src/lib/components/GalleryView.svelte index 35bd06f..c6d0a0c 100644 --- a/frontend/src/lib/components/GalleryView.svelte +++ b/frontend/src/lib/components/GalleryView.svelte @@ -19,9 +19,35 @@ let videoExists = $state(false); let cacheBust = $state(Date.now()); + let lightboxIndex = $state(null); + let lightboxImage = $derived(lightboxIndex !== null ? images[lightboxIndex] : null); + let selectedCount = $derived(selectedImages.size); let allSelected = $derived(images.length > 0 && selectedImages.size === images.length); + function openLightbox(index) { + lightboxIndex = index; + } + + function closeLightbox() { + lightboxIndex = null; + } + + function lightboxPrev() { + if (lightboxIndex > 0) lightboxIndex--; + } + + function lightboxNext() { + if (lightboxIndex < images.length - 1) lightboxIndex++; + } + + function handleLightboxKeydown(e) { + if (lightboxIndex === null) return; + if (e.key === 'Escape') closeLightbox(); + else if (e.key === 'ArrowLeft') lightboxPrev(); + else if (e.key === 'ArrowRight') lightboxNext(); + } + async function loadImages() { loading = true; error = null; @@ -93,7 +119,10 @@ } async function compileVideo() { - if (!confirm('Compile video from these images?')) { + const message = videoExists + ? 'Compile video from these images? This will overwrite the previous video.' + : 'Compile video from these images?'; + if (!confirm(message)) { return; } @@ -173,24 +202,27 @@