team-1/frontend/src/lib/components/SuggestionInput.svelte

42 lines
1.3 KiB
Svelte
Raw Normal View History

2025-08-01 21:10:03 +02:00
<script lang="ts">
2025-08-02 09:53:24 +02:00
import { LoaderCircle } from "@lucide/svelte"
2025-08-02 02:12:41 +02:00
2025-08-02 09:53:24 +02:00
let { roomId } = $props()
2025-08-02 02:12:41 +02:00
let input = $state("")
2025-08-02 09:53:24 +02:00
let disabled: boolean = $state(false)
2025-08-02 02:12:41 +02:00
async function sendSong() {
2025-08-02 10:28:11 +02:00
disabled = true
2025-08-02 09:19:39 +02:00
await fetch(`/api/addsong?room=${roomId}&query=${input}`, { method: "POST" })
2025-08-02 02:12:41 +02:00
input = ""
2025-08-02 10:28:11 +02:00
disabled = false
2025-08-02 02:12:41 +02:00
}
2025-08-01 21:10:03 +02:00
</script>
2025-08-02 10:50:35 +02:00
<div
class={`flex h-full w-full flex-row items-center gap-2 rounded-md border-dark-pine-muted bg-light-pine-overlay hover:bg-dark-pine-base/20 dark:bg-dark-pine-overlay hover:dark:bg-light-pine-base/20 ${disabled ? "disabled" : ""}`}
>
2025-08-02 09:19:39 +02:00
<input
type="text"
placeholder="Song & Artist"
class="h-[50px] w-3/4 rounded px-4 font-bold text-white outline-none"
bind:value={input}
onkeydown={(e) => {
if (e.key == "Enter") {
sendSong()
}
}}
2025-08-02 09:53:24 +02:00
{disabled}
2025-08-02 09:19:39 +02:00
/>
2025-08-02 09:53:24 +02:00
{#if disabled}
<span class="animate-spin">
<LoaderCircle />
</span>
{/if}
2025-08-02 10:50:35 +02:00
<button class="i-lucide-check h-[40px] w-1/4 cursor-pointer rounded border border-0 font-semibold shadow-xl duration-100 hover:scale-105 active:scale-90 dark:bg-dark-pine-blue" onclick={sendSong}
>Add</button
2025-08-02 04:34:45 +02:00
>
<span class="i-lucide-chevrons-left"></span>
2025-08-01 21:10:03 +02:00
</div>