2024-02-04 01:01:37 -05:00
|
|
|
<script lang="ts">
|
|
|
|
|
export let mediaItem: MediaItem
|
|
|
|
|
|
|
|
|
|
import IconButton from '$lib/components/util/iconButton.svelte'
|
2024-02-05 12:27:46 -05:00
|
|
|
import { goto } from '$app/navigation'
|
2024-02-04 01:01:37 -05:00
|
|
|
|
2024-03-09 01:44:22 -05:00
|
|
|
let image: HTMLImageElement, captionText: HTMLDivElement
|
2024-02-04 01:01:37 -05:00
|
|
|
|
2024-03-09 01:44:22 -05:00
|
|
|
const checkSongOrAlbum = (item: MediaItem): item is Song | Album => {
|
|
|
|
|
return item.type === 'song' || item.type === 'album'
|
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}
|
|
|
|
|
<img bind:this={image} id="card-image" on:load={() => (captionText.style.width = `${image.width}px`)} class="h-full rounded transition-all" src={mediaItem.thumbnail} alt="{mediaItem.name} thumbnail" />
|
|
|
|
|
{: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-02-05 12:27:46 -05:00
|
|
|
<IconButton halo={true}>
|
|
|
|
|
<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;">
|
|
|
|
|
{#if checkSongOrAlbum(mediaItem) && '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-03-24 16:03:31 -04:00
|
|
|
<a class="text-sm hover:underline focus:underline" href="/details/artist?id={artist.id}&connection={mediaItem.connection.id}">{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}
|
|
|
|
|
{/if}
|
2024-02-04 01:01:37 -05:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<style>
|
2024-03-09 01:44:22 -05:00
|
|
|
#thumbnail:focus-within #card-image {
|
2024-02-04 01:01:37 -05:00
|
|
|
filter: brightness(50%);
|
|
|
|
|
}
|
2024-03-09 01:44:22 -05:00
|
|
|
#thumbnail:focus-within #play-button {
|
2024-02-04 01:01:37 -05:00
|
|
|
opacity: 1;
|
|
|
|
|
}
|
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>
|