sortable file tabs

This commit is contained in:
vcoppe
2024-04-19 17:06:36 +02:00
parent 13af33903b
commit 39f0871362
3 changed files with 38 additions and 8 deletions

View File

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