mirror of
https://github.com/garraflavatra/rolens.git
synced 2025-07-19 22:18:03 +00:00
Moved text input dialog to frontend
This commit is contained in:
38
frontend/src/dialogs/input.svelte
Normal file
38
frontend/src/dialogs/input.svelte
Normal file
@ -0,0 +1,38 @@
|
||||
<script>
|
||||
import Modal from '$components/modal.svelte';
|
||||
import { createEventDispatcher, onMount, tick } from 'svelte';
|
||||
|
||||
export let title = '';
|
||||
export let description = '';
|
||||
export let value = '';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
let input;
|
||||
|
||||
function submit() {
|
||||
dispatch('submit', { value });
|
||||
}
|
||||
|
||||
function close() {
|
||||
dispatch('close');
|
||||
}
|
||||
|
||||
onMount(() => tick().then(() => input.select()));
|
||||
</script>
|
||||
|
||||
<Modal {title} on:close width="350px">
|
||||
{#if description}
|
||||
<p>{description}</p>
|
||||
{/if}
|
||||
|
||||
<form on:submit|preventDefault={submit}>
|
||||
<label class="field">
|
||||
<input type="text" bind:value bind:this={input} spellcheck="false" />
|
||||
</label>
|
||||
</form>
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
<button on:click={submit} class="btn">OK</button>
|
||||
<button on:click={close} class="btn secondary">Cancel</button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
Reference in New Issue
Block a user