2025-12-22 02:36:48 +01:00
|
|
|
<script lang="ts">
|
2023-09-24 13:20:04 +00:00
|
|
|
import { flip } from 'svelte/animate';
|
2025-12-22 02:36:48 +01:00
|
|
|
import { settings } from '../utils/settings-store';
|
2023-09-24 13:20:04 +00:00
|
|
|
import { dndzone } from 'svelte-dnd-action';
|
2025-11-01 15:49:29 +01:00
|
|
|
import GripVerticalIcon from '@lucide/svelte/icons/grip-vertical';
|
2024-05-01 07:38:23 +01:00
|
|
|
import { t } from '$lib/utils/functions/translations';
|
2024-11-21 14:25:52 +01:00
|
|
|
|
2025-12-22 02:36:48 +01:00
|
|
|
interface Props {
|
|
|
|
|
onchange: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let { onchange }: Props = $props();
|
2023-09-24 13:20:04 +00:00
|
|
|
|
|
|
|
|
const flipDurationMs = 300;
|
|
|
|
|
|
|
|
|
|
function handleDndConsider(e) {
|
|
|
|
|
$settings.tabs = e.detail.items;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleDndFinalize(e) {
|
|
|
|
|
$settings.tabs = e.detail.items;
|
2024-11-21 14:25:52 +01:00
|
|
|
|
2025-12-22 02:36:48 +01:00
|
|
|
onchange();
|
2023-09-24 13:20:04 +00:00
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<section
|
|
|
|
|
use:dndzone={{
|
|
|
|
|
items: $settings.tabs,
|
|
|
|
|
flipDurationMs,
|
|
|
|
|
dropTargetStyle: {
|
|
|
|
|
'border-style': 'dashed'
|
|
|
|
|
}
|
|
|
|
|
}}
|
2025-11-01 15:49:29 +01:00
|
|
|
onconsider={handleDndConsider}
|
|
|
|
|
onfinalize={handleDndFinalize}
|
2025-12-22 02:36:48 +01:00
|
|
|
class="ui:bg-muted ui:text-muted-foreground inline-flex h-12 w-fit items-center justify-start gap-2 rounded-lg px-2 py-1"
|
2023-09-24 13:20:04 +00:00
|
|
|
>
|
|
|
|
|
{#each $settings.tabs as item (item.id)}
|
|
|
|
|
<div
|
|
|
|
|
animate:flip={{ duration: flipDurationMs }}
|
2025-12-22 02:36:48 +01:00
|
|
|
class="ui:bg-background ui:dark:text-foreground ui:border-input flex h-[calc(100%-3px)] items-center justify-start gap-2 rounded-md px-3 py-1 text-sm font-medium transition-[color,box-shadow]"
|
2023-09-24 13:20:04 +00:00
|
|
|
>
|
2025-12-22 02:36:48 +01:00
|
|
|
<GripVerticalIcon size={16} class="custom text-primary" />
|
2024-05-01 07:38:23 +01:00
|
|
|
{$t(item.name)}
|
2023-09-24 13:20:04 +00:00
|
|
|
</div>
|
|
|
|
|
{/each}
|
|
|
|
|
</section>
|