button and spacer block
visual changes
This commit is contained in:
parent
1b3ef17800
commit
5a0ffe20df
11 changed files with 190 additions and 22 deletions
|
|
@ -11,15 +11,33 @@
|
|||
}>();
|
||||
|
||||
let dragIndex = $state<number | null>(null);
|
||||
let holdingId = $state('');
|
||||
let holdTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
function startHold(id: string) {
|
||||
holdingId = id;
|
||||
holdTimer = setTimeout(() => {
|
||||
const idx = blocks.findIndex((b) => b.id === id);
|
||||
onDelete(id);
|
||||
onSelect(blocks[idx + 1]?.id || blocks[idx - 1]?.id || '');
|
||||
holdingId = '';
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
function endHold() {
|
||||
if (holdTimer) clearTimeout(holdTimer);
|
||||
holdingId = '';
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="space-y-3">
|
||||
{#each blocks as block, i (block.id)}
|
||||
<div
|
||||
role="listitem"
|
||||
class="rounded-box border bg-base-100 p-3 shadow-sm"
|
||||
class="rounded-box border bg-base-100 p-3 shadow-sm cursor-pointer"
|
||||
class:border-primary={selectedId === block.id}
|
||||
draggable="true"
|
||||
onclick={() => onSelect(block.id)}
|
||||
ondragstart={() => (dragIndex = i)}
|
||||
ondragover={(e) => e.preventDefault()}
|
||||
ondrop={() => { if (dragIndex !== null && dragIndex !== i) onMove(dragIndex, i); dragIndex = null; }}
|
||||
|
|
@ -27,8 +45,18 @@
|
|||
<div class="flex items-center gap-2">
|
||||
<span class="cursor-grab text-xl text-base-content/40">☰</span>
|
||||
<div class="flex-1 font-semibold">{blockLabels[block.type as BlockType]}</div>
|
||||
<button class="btn btn-xs" type="button" onclick={() => onSelect(block.id)}>Edit</button>
|
||||
<button class="btn btn-xs btn-error btn-outline" type="button" onclick={() => onDelete(block.id)}>Delete</button>
|
||||
<button
|
||||
class="btn btn-xs btn-error btn-outline relative overflow-hidden"
|
||||
class:btn-disabled={holdingId && holdingId !== block.id}
|
||||
class:delete-holding={holdingId === block.id}
|
||||
type="button"
|
||||
onpointerdown={() => startHold(block.id)}
|
||||
onpointerup={endHold}
|
||||
onpointerleave={endHold}
|
||||
>
|
||||
<span class="delete-fill" class:animating={holdingId === block.id}></span>
|
||||
<span class="relative z-10 text-error">Delete</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue