]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/blob
4c3bd780764885299e7de1c675ab26a52234e203
[pkg/ggml/sources/llama.cpp] /
1 <script lang="ts">
2 import { Music, FileText } from '@lucide/svelte';
3 import { HorizontalScrollCarousel } from '$lib/components/app/misc';
4
5 interface PreviewItem {
6 id: string;
7 name: string;
8 isImage: boolean;
9 isAudio: boolean;
10 preview?: string;
11 }
12
13 interface Props {
14 items: PreviewItem[];
15 currentIndex: number;
16 onNavigate: (index: number) => void;
17 }
18
19 let { items, currentIndex, onNavigate }: Props = $props();
20
21 function getFileExtension(name: string): string {
22 const parts = name.split('.');
23 if (parts.length > 1) {
24 return parts.pop()?.toUpperCase() ?? '';
25 }
26 return '';
27 }
28 </script>
29
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)}
34 <button
35 data-thumbnail-index={index}
36 class={[
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'
40 ]}
41 onclick={() => onNavigate(index)}
42 aria-label={`Go to ${item.name}`}
43 >
44 {#if item.isImage && item.preview}
45 <img src={item.preview} alt={item.name} class="h-12 w-12 object-cover" />
46 {:else}
47 <div
48 class="bg-foreground-muted/50 flex h-12 w-12 flex-col items-center justify-center gap-0.5 py-1"
49 >
50 {#if item.isAudio}
51 <Music class="h-4 w-4 text-white/70" />
52 {:else}
53 <FileText class="h-4 w-4 text-white/70" />
54 {/if}
55
56 <span class="font-mono text-[9px] text-white/60">{getFileExtension(item.name)}</span>
57 </div>
58 {/if}
59 </button>
60 {/each}
61 </HorizontalScrollCarousel>
62 </div>
63 {/if}