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