Mostly get drag and drop working

This commit is contained in:
ZXY101
2023-09-13 16:57:52 +02:00
parent 3c8ab90b06
commit 3a37b62a38
9 changed files with 284 additions and 146 deletions

View File

@@ -1,5 +1,7 @@
<script lang="ts">
export let files: FileList | null | undefined = undefined;
import { A, Fileupload, Label } from 'flowbite-svelte';
export let files: FileList | undefined = undefined;
export let onUpload: ((files: FileList) => void) | undefined = undefined;
let input: HTMLInputElement;
@@ -13,38 +15,15 @@
function onClick() {
input.click();
}
function onDrop(event: DragEvent) {
const items = event.dataTransfer?.items;
// TODO
}
</script>
<input type="file" bind:files bind:this={input} on:change={handleChange} {...$$restProps} />
<input
type="file"
bind:files
bind:this={input}
on:change={handleChange}
{...$$restProps}
class="hidden"
/>
<button
on:click={onClick}
on:dragover|preventDefault
on:drop|preventDefault|stopPropagation={onDrop}
>
<p><slot>Upload</slot></p>
</button>
<style lang="scss">
input {
display: none;
}
button {
width: 100%;
height: 100px;
border-radius: 12px;
border: 2px dashed $secondary-color;
}
p {
font-weight: bold;
font-size: 16px;
color: $secondary-color;
}
</style>
<A on:click={onClick}><slot>Upload</slot></A>