2 import { Music, Video, FileText } from '@lucide/svelte';
3 import { HorizontalScrollCarousel } from '$lib/components/app/misc';
5 interface PreviewItem {
17 onNavigate: (index: number) => void;
20 let { items, currentIndex, onNavigate }: Props = $props();
22 function getFileExtension(name: string): string {
23 const parts = name.split('.');
24 if (parts.length > 1) {
25 return parts.pop()?.toUpperCase() ?? '';
31 {#if items.length > 1}
32 <div class="sticky bottom-0 z-10 mt-4 flex-shrink-0">
33 <HorizontalScrollCarousel class="max-w-full">
34 {#each items as item, index (item.id)}
36 data-thumbnail-index={index}
38 'relative flex-shrink-0 cursor-pointer overflow-hidden rounded border-2 bg-black/80 backdrop-blur-sm transition-all hover:opacity-90',
39 index === currentIndex ? 'border-white' : 'border-transparent opacity-60',
40 '[&:not(:first-child)]:last:mr-4 [&:not(:last-child)]:first:ml-4'
42 onclick={() => onNavigate(index)}
43 aria-label={`Go to ${item.name}`}
45 {#if item.isImage && item.preview}
46 <img src={item.preview} alt={item.name} class="h-12 w-12 object-cover" />
49 class="bg-foreground-muted/50 flex h-12 w-12 flex-col items-center justify-center gap-0.5 py-1"
52 <Music class="h-4 w-4 text-white/70" />
53 {:else if item.isVideo}
54 <Video class="h-4 w-4 text-white/70" />
56 <FileText class="h-4 w-4 text-white/70" />
59 <span class="font-mono text-[9px] text-white/60">{getFileExtension(item.name)}</span>
64 </HorizontalScrollCarousel>