From 2695de25a32fa14b371f3bf1b1b33f634bfc8f9f Mon Sep 17 00:00:00 2001 From: grabowski Date: Thu, 9 Apr 2026 16:52:19 +0700 Subject: [PATCH] Add image lightbox: click any image to view full-screen Reusable ImageLightbox component with dark overlay, close on click/Escape, zoom-in cursor on thumbnails. Applied to both device and component detail pages. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/lib/components/ui/ImageLightbox.svelte | 28 +++++++++++++++++++ src/routes/(app)/components/[id]/+page.svelte | 11 +++++++- src/routes/(app)/devices/[id]/+page.svelte | 11 +++++++- 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 src/lib/components/ui/ImageLightbox.svelte diff --git a/src/lib/components/ui/ImageLightbox.svelte b/src/lib/components/ui/ImageLightbox.svelte new file mode 100644 index 0000000..4449e44 --- /dev/null +++ b/src/lib/components/ui/ImageLightbox.svelte @@ -0,0 +1,28 @@ + + + + + + +
+ + + e.stopPropagation()} /> +
diff --git a/src/routes/(app)/components/[id]/+page.svelte b/src/routes/(app)/components/[id]/+page.svelte index f8afa58..338c15b 100644 --- a/src/routes/(app)/components/[id]/+page.svelte +++ b/src/routes/(app)/components/[id]/+page.svelte @@ -4,6 +4,9 @@ import { formatDate, timeAgo } from '$lib/utils/date.js'; import ImageUpload from '$lib/components/ui/ImageUpload.svelte'; import DocumentUpload from '$lib/components/ui/DocumentUpload.svelte'; + import ImageLightbox from '$lib/components/ui/ImageLightbox.svelte'; + + let lightboxSrc = $state(null); let { data, form } = $props(); const c = $derived(data.component); @@ -100,7 +103,9 @@
{#each data.images as img}
- {img.caption +
+ +{#if lightboxSrc} + (lightboxSrc = null)} /> +{/if} diff --git a/src/routes/(app)/devices/[id]/+page.svelte b/src/routes/(app)/devices/[id]/+page.svelte index 3a55334..ce689a0 100644 --- a/src/routes/(app)/devices/[id]/+page.svelte +++ b/src/routes/(app)/devices/[id]/+page.svelte @@ -3,6 +3,9 @@ import { DEVICE_CONDITIONS, DEVICE_LOG_TYPES } from '$lib/constants.js'; import ImageUpload from '$lib/components/ui/ImageUpload.svelte'; import DocumentUpload from '$lib/components/ui/DocumentUpload.svelte'; + import ImageLightbox from '$lib/components/ui/ImageLightbox.svelte'; + + let lightboxSrc = $state(null); import { formatDate, timeAgo } from '$lib/utils/date.js'; let { data, form } = $props(); @@ -160,7 +163,9 @@
{#each data.images as img}
- {img.caption + @@ -707,3 +712,7 @@
+ +{#if lightboxSrc} + (lightboxSrc = null)} /> +{/if}