Files
gpx.studio/website/src/lib/components/FileList.svelte

41 lines
991 B
Svelte
Raw Normal View History

2024-04-18 10:52:45 +02:00
<script lang="ts">
2024-04-18 15:30:19 +02:00
import { files, selectedFiles, addSelectFile, selectFile } from '$lib/stores';
2024-04-18 10:52:45 +02:00
import { ScrollArea } from '$lib/components/ui/scroll-area/index.js';
2024-04-19 17:06:36 +02:00
import Sortable from 'sortablejs';
import { onMount } from 'svelte';
let tabs: HTMLDivElement;
onMount(() => {
Sortable.create(tabs, {
forceAutoScrollFallback: true
});
});
2024-04-18 10:52:45 +02:00
</script>
2024-04-19 17:06:36 +02:00
<div class="absolute h-10 -translate-y-10 w-fit max-w-full bg-secondary rounded-t">
2024-04-19 16:13:08 +02:00
<ScrollArea orientation="horizontal" class="w-full h-full" scrollbarXClasses="h-2">
2024-04-19 17:06:36 +02:00
<div bind:this={tabs} class="flex flex-row gap-1">
2024-04-18 15:30:19 +02:00
{#each $files as file}
2024-04-19 16:13:08 +02:00
<button
class="my-1 px-1.5 py-1 rounded {$selectedFiles.has(file)
? 'bg-background shadow'
2024-04-19 17:06:36 +02:00
: 'bg-secondary'} first:ml-1 last:mr-1"
2024-04-18 15:30:19 +02:00
on:click={(e) => {
if (e.shiftKey) {
addSelectFile(file);
} else {
selectFile(file);
}
}}
>
{file.metadata.name}
2024-04-19 16:13:08 +02:00
</button>
2024-04-18 15:30:19 +02:00
{/each}
</div>
</ScrollArea>
</div>