This commit is contained in:
1 parent
d3fb95457c
commit
78f065ad08
1 file changed
+37
-1
@@ -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 isUploading = $state(false);
|
||||||
let fileInput: HTMLInputElement;
|
let fileInput: HTMLInputElement;
|
||||||
|
|
||||||
@@ -95,7 +122,10 @@
|
|||||||
<div class="file-card">
|
<div class="file-card">
|
||||||
<div class="file-preview">
|
<div class="file-preview">
|
||||||
{#if isImage}
|
{#if isImage}
|
||||||
<img src={url} alt={file.filename} loading="lazy" />
|
<!-- eslint-disable-next-line svelte/no-navigation-without-resolve -->
|
||||||
|
<a data-fancybox="gallery" data-caption={file.filename} href={url}>
|
||||||
|
<img src={url} alt={file.filename} loading="lazy" />
|
||||||
|
</a>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="file-icon">
|
<div class="file-icon">
|
||||||
<File size={48} stroke-width={1.5} aria-hidden="true" />
|
<File size={48} stroke-width={1.5} aria-hidden="true" />
|
||||||
@@ -242,6 +272,12 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.file-preview a {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.file-preview img {
|
.file-preview img {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|||||||
Reference in new issue
Block a user