diff options
| author | Adam Soltys <[email protected]> | 2024-11-07 21:16:25 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-11-08 09:27:40 -0800 |
| commit | 32fcc461cd43c8907df5e306d520bb671307eab1 (patch) | |
| tree | 0253780c569998b6c1a5f43026586e94916c3fee /src/components/ItemForm.svelte | |
| parent | be5aa52cea1d57c875cfb22d25c6a866b8de2239 (diff) | |
| download | coinos-ui-32fcc461cd43c8907df5e306d520bb671307eab1.tar.gz coinos-ui-32fcc461cd43c8907df5e306d520bb671307eab1.zip | |
svelte 5
Diffstat (limited to 'src/components/ItemForm.svelte')
| -rw-r--r-- | src/components/ItemForm.svelte | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/components/ItemForm.svelte b/src/components/ItemForm.svelte index 7e0f58d8..d3ea88c0 100644 --- a/src/components/ItemForm.svelte +++ b/src/components/ItemForm.svelte @@ -1,15 +1,16 @@ <script> + import { preventDefault } from 'svelte/legacy'; + import { t } from "$lib/translations"; import { upload } from "$lib/upload"; import { fail } from "$lib/utils"; import { applyAction, deserialize } from "$app/forms"; import Spinner from "$comp/Spinner.svelte"; - export let item; - export let user; + let { item = $bindable(), user } = $props(); - let fileInput, formElement, file, submitting, progress; + let fileInput = $state(), formElement = $state(), file, submitting = $state(), progress; let select = () => fileInput.click(); - let src; + let src = $state(); let tooLarge = {}; let handleFile = async ({ target }, type) => { @@ -67,7 +68,7 @@ <form method="POST" class="space-y-5" - on:submit|preventDefault={handleSubmit} + onsubmit={preventDefault(handleSubmit)} bind:this={formElement} > <input type="hidden" name="id" bind:value={item.id} /> @@ -104,24 +105,24 @@ {src} alt={item.name} class="object-cover w-full h-full" - on:click={select} - on:keydown={select} + onclick={select} + onkeydown={select} /> {:else if item.image} <img src={`/api/public/${item.image}.webp`} alt={item.name} class="object-cover w-full h-full" - on:click={select} - on:keydown={select} + onclick={select} + onkeydown={select} /> {:else} <div class="bg-gradient-to-r from-primary to-gradient mb-4 cursor-pointer hover:opacity-80 w-full h-full" - on:click={select} - on:keydown={select} + onclick={select} + onkeydown={select} alt="Banner" - /> +></div> {/if} </div> </div> @@ -130,7 +131,7 @@ type="file" class="hidden" bind:this={fileInput} - on:change={(e) => handleFile(e, "item")} + onchange={(e) => handleFile(e, "item")} /> </div> |
