Fix some drag & drop issues before demo

This commit is contained in:
Mattias Granlund 2023-06-13 13:18:24 +02:00
parent 707707ba52
commit d4e4f9749a
4 changed files with 34 additions and 21 deletions

View File

@ -52,7 +52,7 @@
id: `${Date.now()}-${file.id}-commit`,
description: '',
kind: 'commit',
files: [file],
files: [{ ...file, isDndShadowItem: false }],
isDndShadowItem: !isFinal
}
]

View File

@ -36,9 +36,9 @@
for (const file of fileItems) {
commitItems.push({
id: `${Date.now()}-${file.id}`,
description: '',
description: 'New commit',
kind: 'commit',
files: [file],
files: [{ ...file, isDndShadowItem: false }],
isDndShadowItem: !isFinal
});
}

View File

@ -50,24 +50,26 @@
}
</script>
<div
id="commit-{id}"
class="flex flex-grow flex-col gap-y-2 border border-zinc-700 bg-zinc-900/70 p-2"
use:dndzone={{
items: files,
flipDurationMs,
zoneTabIndex: -1,
types: ['file'],
receives: ['file', 'hunk']
}}
on:consider={(e) => handleDndEvent(e, false)}
on:finalize={(e) => handleDndEvent(e, true)}
>
{#each files.filter((x) => x.hunks) as file, idx (file.id)}
<div animate:flip={{ duration: flipDurationMs }}>
<FileCard bind:file on:empty={handleEmpty} />
</div>
{/each}
<div class="flex flex-col gap-y-2 border border-zinc-700 bg-zinc-900/70 p-2">
<div
class="flex flex-col gap-y-2"
id="commit-{id}"
use:dndzone={{
items: files,
flipDurationMs,
zoneTabIndex: -1,
types: ['file'],
receives: ['file', 'hunk']
}}
on:consider={(e) => handleDndEvent(e, false)}
on:finalize={(e) => handleDndEvent(e, true)}
>
{#each files.filter((x) => x.hunks) as file, idx (file.id)}
<div animate:flip={{ duration: flipDurationMs }}>
<FileCard bind:file on:empty={handleEmpty} />
</div>
{/each}
</div>
<div>
{description}
</div>

View File

@ -0,0 +1,11 @@
import type { Commit, File } from './types';
export function createCommit(files: File[], isShadow: boolean): Commit {
return {
id: `commit-${Date.now()}`,
description: '',
kind: 'commit',
files: files,
isDndShadowItem: isShadow
};
}