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