diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2024-10-05 18:17:25 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2024-10-05 18:17:25 -0400 |
| commit | 0c0cd1daa0c6640e81bb6282ae4a1c574cf135f4 (patch) | |
| tree | d6b4195cc7be249fb55cb1160f01db0a6daa84f1 /hi-ui/src/lib/MessageInput.svelte | |
| parent | 54a542df2164e421e78b48d7229a6bfabbc5c26b (diff) | |
| parent | 40cc35bcc9b881a61ca62c67e107bb17c2748f57 (diff) | |
Merge branch 'wip/ui'
Diffstat (limited to 'hi-ui/src/lib/MessageInput.svelte')
| -rw-r--r-- | hi-ui/src/lib/MessageInput.svelte | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/hi-ui/src/lib/MessageInput.svelte b/hi-ui/src/lib/MessageInput.svelte new file mode 100644 index 0000000..9a8475c --- /dev/null +++ b/hi-ui/src/lib/MessageInput.svelte @@ -0,0 +1,31 @@ +<script> + import { Input, ButtonGroup, Button } from 'flowbite-svelte'; + import { CaretRightSolid } from 'flowbite-svelte-icons'; + + import { tick } from 'svelte'; + import { postToChannel } from '../apiServer'; + import { activeChannel } from '../store'; + + let self; + let input; + $: disabled = $activeChannel == null; + + async function handleSubmit(event) { + disabled = true; + // TODO try/catch: + await postToChannel($activeChannel?.id, input); + input = ''; + disabled = false; + await tick(); + self.focus(); + } +</script> + +<form on:submit|preventDefault={handleSubmit} class="w-full"> + <ButtonGroup> + <Input disabled={disabled} bind:this={self} bind:value={input} /> + <Button color="primary" type="submit"> + <CaretRightSolid class="w-5 h-5" /> + </Button> + </ButtonGroup> +</form> |
