2024-02-04 01:01:37 -05:00
|
|
|
<script lang="ts">
|
2024-04-05 02:00:17 -04:00
|
|
|
export let mediaItem: Song | Album | Artist | Playlist
|
2024-02-04 01:01:37 -05:00
|
|
|
|
|
|
|
|
import IconButton from '$lib/components/util/iconButton.svelte'
|
2024-02-05 12:27:46 -05:00
|
|
|
import { goto } from '$app/navigation'
|
2024-04-15 22:26:38 -04:00
|
|
|
import { queue } from '$lib/stores'
|
2024-02-04 01:01:37 -05:00
|
|
|
|
2024-04-22 14:18:42 -04:00
|
|
|
let queueRef = $queue // This nonsense is to prevent an bug that causes svelte to throw an error when setting a property of the queue directly
|
|
|
|
|
|
2024-03-09 01:44:22 -05:00
|
|
|
let image: HTMLImageElement, captionText: HTMLDivElement
|
2024-02-04 01:01:37 -05:00
|
|
|
</script>
|
|
|
|
|
|
2024-03-09 01:44:22 -05:00
|
|
|
<div id="card-wrapper" class="flex-shrink-0">
|
2024-03-26 01:10:13 -04:00
|
|
|
<button id="thumbnail" class="relative h-52 transition-all duration-200 ease-out" on:click={() => goto(`/details/${mediaItem.type}?id=${mediaItem.id}`)}>
|
2024-03-09 01:44:22 -05:00
|
|
|
{#if mediaItem.thumbnail}
|
2024-04-09 14:22:14 -04:00
|
|
|
<img
|
|
|
|
|
bind:this={image}
|
|
|
|
|
id="card-image"
|
|
|
|
|
on:load={() => (captionText.style.width = `${image.width}px`)}
|
|
|
|
|
class="h-full rounded transition-all"
|
|
|
|
|
src="/api/remoteImage?url={mediaItem.thumbnail}"
|
|
|
|
|
alt="{mediaItem.name} thumbnail"
|
|
|
|
|
/>
|
2024-03-09 01:44:22 -05:00
|
|
|
{:else}
|
|
|
|
|
<div id="card-image" class="grid aspect-square h-full place-items-center rounded-lg bg-lazuli-primary transition-all">
|
|
|
|
|
<i class="fa-solid fa-compact-disc text-7xl" />
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
<span id="play-button" class="absolute left-1/2 top-1/2 h-12 -translate-x-1/2 -translate-y-1/2 opacity-0 transition-opacity duration-200 ease-out">
|
2024-04-15 22:26:38 -04:00
|
|
|
<IconButton
|
|
|
|
|
halo={true}
|
|
|
|
|
on:click={() => {
|
2024-04-22 14:18:42 -04:00
|
|
|
if (mediaItem.type === 'song') queueRef.current = mediaItem
|
2024-04-15 22:26:38 -04:00
|
|
|
}}
|
|
|
|
|
>
|
2024-02-05 12:27:46 -05:00
|
|
|
<i slot="icon" class="fa-solid fa-play text-xl" />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</span>
|
2024-03-09 01:44:22 -05:00
|
|
|
</button>
|
|
|
|
|
<div bind:this={captionText} class="w-56 p-1">
|
|
|
|
|
<div class="mb-0.5 line-clamp-2 text-wrap text-sm" title={mediaItem.name}>{mediaItem.name}</div>
|
|
|
|
|
<div class="leading-2 line-clamp-2 text-neutral-400" style="font-size: 0;">
|
2024-03-27 23:53:59 -04:00
|
|
|
{#if 'artists' in mediaItem && mediaItem.artists}
|
2024-02-08 21:47:54 -05:00
|
|
|
{#each mediaItem.artists as artist}
|
|
|
|
|
{@const listIndex = mediaItem.artists.indexOf(artist)}
|
2024-04-03 23:28:38 -04:00
|
|
|
<a class="text-sm hover:underline focus:underline" href="/details/artist?id={artist.id}&connection={mediaItem.connection}">{artist.name}</a>
|
2024-03-09 01:44:22 -05:00
|
|
|
{#if listIndex < mediaItem.artists.length - 1}
|
2024-02-08 21:47:54 -05:00
|
|
|
<span class="mr-0.5 text-sm">,</span>
|
|
|
|
|
{/if}
|
|
|
|
|
{/each}
|
2024-04-09 00:10:23 -04:00
|
|
|
{:else if 'createdBy' in mediaItem && mediaItem.createdBy}
|
|
|
|
|
<span class="text-sm">{mediaItem.createdBy.name}</span>
|
2024-02-08 21:47:54 -05:00
|
|
|
{/if}
|
2024-02-04 01:01:37 -05:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<style>
|
2024-03-09 01:44:22 -05:00
|
|
|
#thumbnail:hover {
|
2024-02-04 01:01:37 -05:00
|
|
|
scale: 1.05;
|
|
|
|
|
}
|
2024-03-09 01:44:22 -05:00
|
|
|
#thumbnail:hover #card-image {
|
2024-02-04 01:01:37 -05:00
|
|
|
filter: brightness(50%);
|
|
|
|
|
}
|
2024-03-09 01:44:22 -05:00
|
|
|
#thumbnail:hover #play-button {
|
2024-02-04 01:01:37 -05:00
|
|
|
opacity: 1;
|
|
|
|
|
}
|
|
|
|
|
</style>
|