summaryrefslogtreecommitdiff
path: root/ui/lib/components/CreateChannelForm.svelte
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2024-10-10 21:51:10 -0400
committerOwen Jacobson <owen@grimoire.ca>2024-10-10 21:52:26 -0400
commit215b0c5cb2ff0ef0b2c7b5549704e23d651a4df9 (patch)
tree356484ce699539f2937b768d1a1c9b83f0c7a402 /ui/lib/components/CreateChannelForm.svelte
parent4401dce2b5545ce8117818812d8e3c8919f5f7fd (diff)
Hoist the UI one step up further
Diffstat (limited to 'ui/lib/components/CreateChannelForm.svelte')
-rw-r--r--ui/lib/components/CreateChannelForm.svelte23
1 files changed, 23 insertions, 0 deletions
diff --git a/ui/lib/components/CreateChannelForm.svelte b/ui/lib/components/CreateChannelForm.svelte
new file mode 100644
index 0000000..ddcf486
--- /dev/null
+++ b/ui/lib/components/CreateChannelForm.svelte
@@ -0,0 +1,23 @@
+<script>
+ import { createChannel } from '$lib/apiServer';
+
+ let name = '';
+ let disabled = false;
+
+ async function handleSubmit(event) {
+ disabled = true;
+ const response = await createChannel(name);
+ if (200 <= response.status && response.status < 300) {
+ name = '';
+ }
+ disabled = false;
+ }
+</script>
+
+<form on:submit|preventDefault={handleSubmit} class="form form-row flex-nowrap">
+ <input type="text" placeholder="create channel" bind:value={name} disabled={disabled} class="input flex-auto h-6 w-9/12" />
+ <button type="submit" class="flex-none w-6 h-6">&#x2795;</button>
+</form>
+
+<style>
+</style>