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

40 lines
1.8 KiB
Svelte
Raw Normal View History

2025-08-01 21:10:03 +02:00
<script lang="ts">
2025-08-02 00:52:13 +02:00
import { type Song, createEmptySong } from "$lib/types"
2025-08-02 03:54:26 +02:00
let { queueSongs, playingIndex } = $props()
2025-08-01 21:10:03 +02:00
2025-08-02 00:52:13 +02:00
let displaySongs = $derived<Song[]>([
2025-08-02 03:54:26 +02:00
playingIndex > 0 ? queueSongs[playingIndex - 1] : createEmptySong(),
queueSongs[playingIndex],
playingIndex == queueSongs.length - 1 ? createEmptySong() : queueSongs[playingIndex + 1],
2025-08-01 21:10:03 +02:00
])
</script>
<div class="relative flex w-full justify-center overflow-hidden">
<div class="flex w-fit flex-row gap-4">
{#each displaySongs as song, i}
2025-08-02 00:52:13 +02:00
{#if song?.title && song.title != ""}
<div class={`relative flex flex-col items-center transition-all duration-300 ${i === 1 ? "z-10" : "z-0 scale-85 opacity-50"}`}>
2025-08-02 00:52:13 +02:00
<div
class={`flex h-[60vw] max-h-[250px] w-[60vw] max-w-[250px] items-center justify-center ${i === 1 ? "spin-slower rounded-full border-2 border-black" : "rounded"} object-cover`}
>
{#if i === 1}
<div class="absolute z-20 h-16 w-16 rounded-full border-2 border-black bg-white"></div>
{/if}
2025-08-02 02:12:41 +02:00
<img class={`h-full overflow-hidden ${i === 1 ? "rounded-full" : "rounded"}`} src={`https://lastfm.freetls.fastly.net/i/u/174s/${song.image_id}.png`} alt="Song cover" />
2025-08-02 00:52:13 +02:00
</div>
2025-08-01 21:10:03 +02:00
{#if i === 1}
2025-08-02 00:52:13 +02:00
<h1 class="mt-2">{song.title} - {song.artist}</h1>
2025-08-01 21:10:03 +02:00
{/if}
</div>
{:else}
2025-08-02 00:52:13 +02:00
<div class="flex h-[60vw] max-h-[250px] w-[60vw] max-w-[250px] items-center justify-center">
{#if i === 1}
<p>No song in queue</p>
{/if}
</div>
2025-08-01 21:10:03 +02:00
{/if}
{/each}
</div>
</div>