diff --git a/src/routes/admin/files/+page.svelte b/src/routes/admin/files/+page.svelte index 7da9460..347bedd 100644 --- a/src/routes/admin/files/+page.svelte +++ b/src/routes/admin/files/+page.svelte @@ -17,6 +17,33 @@ } }); + $effect(() => { + if ( + typeof window !== 'undefined' && + data.files.some((f: any) => f.mime_type?.startsWith('image/')) + ) { + (async () => { + const { Fancybox } = await import('@fancyapps/ui/dist/index.js'); + await import('@fancyapps/ui/dist/fancybox/fancybox.css'); + Fancybox.bind('[data-fancybox="gallery"]', { + mainStyle: { '--f-carousel-slide-padding': '24px 0' }, + Carousel: { + Toolbar: { absolute: false }, + Thumbs: { type: 'scrollable', showOnStart: false } + } + }); + })(); + } + return () => { + if (typeof window !== 'undefined') { + import('@fancyapps/ui/dist/index.js').then(({ Fancybox }) => { + Fancybox.unbind('[data-fancybox="gallery"]'); + Fancybox.close(); + }); + } + }; + }); + let isUploading = $state(false); let fileInput: HTMLInputElement; @@ -95,7 +122,10 @@