File size: 973 Bytes
effb90e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<script lang="ts">
	import { createEventDispatcher, onMount } from 'svelte';

	const dispatch = createEventDispatcher();

	let textInput: string = '';
	let inputEl: HTMLInputElement;

	function onSubmit(event: Event) {
		event.stopPropagation();
		event.preventDefault();
		event.stopImmediatePropagation();

		if (textInput.trim() !== '') {
			dispatch('submitMessage', textInput);
			textInput = '';
		}
	}
	onMount(() => {
		inputEl.focus();
	});
</script>

<form class="mt-auto flex w-full gap-2 border-t px-3 pt-4 pb-6" on:submit={onSubmit}>
	<input
		bind:value={textInput}
		bind:this={inputEl}
		on:click|stopPropagation
		type="text"
		class="flex h-11 flex-1 items-center rounded-full border bg-gray-100 px-4 text-black"
		placeholder="Type here"
		title="Type here to send a message"
	/>
	<button
		title="Send your message"
		type="submit"
		class="rounded-full bg-black dark:bg-white dark:text-black px-4 font-semibold text-gray-200">Submit</button
	>
</form>