diff --git a/src/lib/elements/forms/inputFile.svelte b/src/lib/elements/forms/inputFile.svelte index bb1431cd4..2dc8da1b6 100644 --- a/src/lib/elements/forms/inputFile.svelte +++ b/src/lib/elements/forms/inputFile.svelte @@ -1,17 +1,74 @@ - - {label} - - + + + + {#if label} + {label} + {/if} + (hovering = false)}> + + + + + + Drag and drop files here to upload + + input.click()}> + + Choose File + + + {#if files?.length} + + {files.item(0).name} + (files = null)} + type="button" + class="x-button" + aria-label="remove file" + title="Remove file"> + + + + {/if} + + + - + diff --git a/src/routes/console/project-[project]/functions/function/[function]/create.svelte b/src/routes/console/project-[project]/functions/function/[function]/create.svelte index d4c0e646a..d2bcb48b5 100644 --- a/src/routes/console/project-[project]/functions/function/[function]/create.svelte +++ b/src/routes/console/project-[project]/functions/function/[function]/create.svelte @@ -1,6 +1,6 @@ @@ -45,7 +85,7 @@ You can deploy your function from the Appwrite CLI using Unix, CMD, or PowerShell. Check out our Documentation to learn more about deploying your functions {category} - Code + {/each} @@ -71,7 +116,7 @@ id="entrypoint" bind:value={entrypoint} required /> - + import { page } from '$app/stores'; import { Modal } from '$lib/components'; - import { Button, Form } from '$lib/elements/forms'; + import { Button, Form, InputFile } from '$lib/elements/forms'; import { addNotification } from '$lib/stores/notifications'; import { createEventDispatcher } from 'svelte'; import { variableList } from '../../../store'; @@ -10,9 +10,7 @@ const dispatch = createEventDispatcher(); const functionId = $page.params.function; - let list = new DataTransfer(); let files: FileList; - let input: HTMLInputElement; const handleSubmit = async () => { if (files?.length) { @@ -51,29 +49,8 @@ return variables; } } - - function dropHandler(ev: DragEvent) { - ev.preventDefault(); - if (ev.dataTransfer.items) { - // Use DataTransferItemList interface to access the file(s) - for (let i = 0; i < ev.dataTransfer.items.length; i++) { - // If dropped items aren't files, reject them - if (ev.dataTransfer.items[i].kind === 'file') { - list.items.clear(); - list.items.add(ev.dataTransfer.items[i].getAsFile()); - files = list.files; - } - } - } - } - - function dragOverHandler(ev: DragEvent) { - ev.preventDefault(); - } - - Upload Variables @@ -82,37 +59,7 @@ runtime. - Attach a file - - - - - - - Drag and drop files here to upload - - input.click()}> - - Choose File - - {#if files?.length} - {files.item(0).name} - (files = null)} - type="button" - class="x-button" - aria-label="remove file" - title="Remove file"> - - - {/if} - - - - + (show = false)}>Cancel diff --git a/src/routes/console/project-[project]/storage/bucket/[bucket]/_create.svelte b/src/routes/console/project-[project]/storage/bucket/[bucket]/_create.svelte index 2a5b9b0aa..6fc923157 100644 --- a/src/routes/console/project-[project]/storage/bucket/[bucket]/_create.svelte +++ b/src/routes/console/project-[project]/storage/bucket/[bucket]/_create.svelte @@ -1,5 +1,5 @@
{label}
Drag and drop files here to upload
You can deploy your function from the Appwrite CLI using Unix, CMD, or PowerShell. Check out our Documentation to learn more about deploying your functions {category} - Code + {/each} @@ -71,7 +116,7 @@ id="entrypoint" bind:value={entrypoint} required /> - + import { page } from '$app/stores'; import { Modal } from '$lib/components'; - import { Button, Form } from '$lib/elements/forms'; + import { Button, Form, InputFile } from '$lib/elements/forms'; import { addNotification } from '$lib/stores/notifications'; import { createEventDispatcher } from 'svelte'; import { variableList } from '../../../store'; @@ -10,9 +10,7 @@ const dispatch = createEventDispatcher(); const functionId = $page.params.function; - let list = new DataTransfer(); let files: FileList; - let input: HTMLInputElement; const handleSubmit = async () => { if (files?.length) { @@ -51,29 +49,8 @@ return variables; } } - - function dropHandler(ev: DragEvent) { - ev.preventDefault(); - if (ev.dataTransfer.items) { - // Use DataTransferItemList interface to access the file(s) - for (let i = 0; i < ev.dataTransfer.items.length; i++) { - // If dropped items aren't files, reject them - if (ev.dataTransfer.items[i].kind === 'file') { - list.items.clear(); - list.items.add(ev.dataTransfer.items[i].getAsFile()); - files = list.files; - } - } - } - } - - function dragOverHandler(ev: DragEvent) { - ev.preventDefault(); - } - - Upload Variables @@ -82,37 +59,7 @@ runtime.
Attach a file