blob: 16b4ec8fe697af459811fd78a6feb8a091bc5390 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
<script lang="ts">
import { clearAllParameters } from '$lib/Utility/parameters';
import { onMount } from 'svelte';
export let field: string;
export let submission: string;
export let event: string;
export let submitText: string;
export let saveParameters: string[] = [];
export let onSubmit = () => {
return;
};
export let prompt = `Enter a ${field.toLowerCase()} to search for to continue.`;
let input = '';
onMount(() => clearAllParameters(saveParameters));
</script>
<div class="card">
<p>
<input
type="text"
placeholder={field}
bind:value={input}
on:keypress={(e) => {
if (e.key === 'Enter') {
submission = input;
onSubmit();
}
}}
/>
<button
class="button-lined"
on:click={() => (submission = input)}
title="Or click your Enter key"
data-umami-event={event}
>
{submitText}
</button>
</p>
{#if submission !== ''}
<slot />
{:else}
<p />
{prompt}
{/if}
</div>
|