blob: 0da78d4b83b34f9df88325950079c4e40e5d3360 (
plain)
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
|
<script>
import { tick } from 'svelte';
import { postToChannel } from '$lib/apiServer';
export let channel = null;
let input;
let value;
let sending = false;
$: disabled = (channel === null);
async function handleSubmit() {
if (channel !== null) {
sending = true;
// TODO try/catch:
await postToChannel(channel, value);
sending = false;
value = '';
await tick();
input.focus();
}
}
</script>
<form on:submit|preventDefault={handleSubmit} class="flex flex-row flex-nowrap">
<input bind:this={input} bind:value={value} disabled={sending || disabled} type="search" class="flex-auto h-6 input rounded-r-none" />
<button color="primary variant-filled-secondary" type="submit" class="flex-none w-6 h-6 btn-icon variant-filled rounded-l-none">»</button>
</form>
|