your personal website on atproto - mirror blento.app

Implement Rocksky cards, add links to tracks and album art

Harry L 34ca48ec e13bca21

+20 -17
+2 -2
src/lib/cards/media/RockskyPlaysCard/AlbumArt.svelte
··· 1 <script lang="ts"> 2 - let { releaseMbId, alt }: { releaseMbId?: string; alt: string } = $props(); 3 4 let isLoading = $state(true); 5 let hasError = $state(false); ··· 25 </div> 26 {:else} 27 <img 28 - src="https://coverartarchive.org/release/{releaseMbId}/front-250" 29 {alt} 30 class="h-10 w-10 rounded-lg object-cover {isLoading && 'hidden'}" 31 onload={() => {
··· 1 <script lang="ts"> 2 + let { albumArtUrl, alt }: { albumArtUrl?: string; alt: string } = $props(); 3 4 let isLoading = $state(true); 5 let hasError = $state(false); ··· 25 </div> 26 {:else} 27 <img 28 + src="{albumArtUrl}" 29 {alt} 30 class="h-10 w-10 rounded-lg object-cover {isLoading && 'hidden'}" 31 onload={() => {
+18 -15
src/lib/cards/media/RockskyPlaysCard/RockskyPlaysCard.svelte
··· 3 import { onMount } from 'svelte'; 4 import { getAdditionalUserData, getDidContext, getHandleContext } from '$lib/website/context'; 5 import { CardDefinitionsByType } from '../..'; 6 - // import AlbumArt from './AlbumArt.svelte'; 7 import { RelativeTime } from '@foxui/time'; 8 9 interface Artist { 10 - artistName: string; 11 } 12 13 interface PlayValue { 14 - releaseMbId?: string; 15 - trackName: string; 16 - playedTime?: string; 17 artists?: Artist[]; 18 - originUrl?: string; 19 } 20 21 interface Play { ··· 52 {#snippet musicItem(play: Play)} 53 <div class="flex w-full items-center gap-3"> 54 <div class="size-10 shrink-0"> 55 - <AlbumArt releaseMbId={play.value.releaseMbId} alt="" /> 56 </div> 57 <div class="min-w-0 flex-1"> 58 <div class="inline-flex w-full max-w-full justify-between gap-2"> 59 <div 60 class="text-accent-500 accent:text-accent-950 min-w-0 flex-1 shrink truncate font-semibold" 61 > 62 - {play.value.trackName} 63 </div> 64 65 - {#if play.value.playedTime} 66 <div class="shrink-0 text-xs"> 67 <RelativeTime 68 date={new Date( 69 - isNumeric(play.value.playedTime) 70 - ? parseInt(play.value.playedTime) * 1000 71 - : play.value.playedTime 72 )} 73 locale="en-US" 74 /> ago ··· 78 {/if} 79 </div> 80 <div class="my-1 min-w-0 gap-2 truncate text-xs whitespace-nowrap"> 81 - {(play?.value?.artists ?? []).map((a) => a.artistName).join(', ')} 82 </div> 83 </div> 84 </div> ··· 87 <div class="z-10 flex h-full w-full flex-col gap-4 overflow-y-scroll p-4"> 88 {#if feed && feed.length > 0} 89 {#each feed as play (play.uri)} 90 - {#if play.value.originUrl} 91 - <a href={play.value.originUrl} target="_blank" rel="noopener noreferrer" class="w-full"> 92 {@render musicItem(play)} 93 </a> 94 {:else}
··· 3 import { onMount } from 'svelte'; 4 import { getAdditionalUserData, getDidContext, getHandleContext } from '$lib/website/context'; 5 import { CardDefinitionsByType } from '../..'; 6 + import AlbumArt from './AlbumArt.svelte'; 7 import { RelativeTime } from '@foxui/time'; 8 9 interface Artist { 10 + artist: string; 11 } 12 13 interface PlayValue { 14 + mbid?: string; 15 + title: string; 16 + createdAt?: string; 17 artists?: Artist[]; 18 + albumArtUrl?: string; 19 + spotifyLink?: string; 20 } 21 22 interface Play { ··· 53 {#snippet musicItem(play: Play)} 54 <div class="flex w-full items-center gap-3"> 55 <div class="size-10 shrink-0"> 56 + <AlbumArt albumArtUrl={play.value.albumArtUrl} alt="" /> 57 </div> 58 <div class="min-w-0 flex-1"> 59 <div class="inline-flex w-full max-w-full justify-between gap-2"> 60 <div 61 class="text-accent-500 accent:text-accent-950 min-w-0 flex-1 shrink truncate font-semibold" 62 > 63 + {play.value.title} 64 </div> 65 66 + {#if play.value.createdAt} 67 <div class="shrink-0 text-xs"> 68 <RelativeTime 69 date={new Date( 70 + isNumeric(play.value.createdAt) 71 + ? parseInt(play.value.createdAt) * 1000 72 + : play.value.createdAt 73 )} 74 locale="en-US" 75 /> ago ··· 79 {/if} 80 </div> 81 <div class="my-1 min-w-0 gap-2 truncate text-xs whitespace-nowrap"> 82 + {(play?.value?.artists ?? []).map((a) => a.name).join(', ')} 83 </div> 84 </div> 85 </div> ··· 88 <div class="z-10 flex h-full w-full flex-col gap-4 overflow-y-scroll p-4"> 89 {#if feed && feed.length > 0} 90 {#each feed as play (play.uri)} 91 + {#if play.uri} 92 + <a href="https://rocksky.app/{did}/scrobble/{play.uri.split('/').at(-1)}" target="_blank" rel="noopener noreferrer" class="w-full"> 93 + <!-- {#if play.value.spotifyLink} 94 + <a href={play.value.spotifyLink} target="_blank" rel="noopener noreferrer" class="w-full"> --> 95 {@render musicItem(play)} 96 </a> 97 {:else}