'use client'; import Image from "next/image" import { PlusCircledIcon } from "@radix-ui/react-icons" import { useRouter } from 'next/navigation'; import { cn } from "@/lib/utils" import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuSeparator, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, } from "../../components/ui/context-menu" import { useAudioPlayer } from "@/app/components/AudioPlayerContext"; import { getNavidromeAPI } from "@/lib/navidrome"; import { Card, CardContent } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { useNavidrome } from '@/app/components/NavidromeContext'; import { Artist } from '@/lib/navidrome'; interface ArtistIconProps extends React.HTMLAttributes { artist: Artist size?: number imageOnly?: boolean responsive?: boolean } export function ArtistIcon({ artist, size = 150, imageOnly = false, responsive = false, className, ...props }: ArtistIconProps) { const router = useRouter(); const { addArtistToQueue } = useAudioPlayer(); const { playlists, starItem, unstarItem } = useNavidrome(); const api = getNavidromeAPI(); const handleClick = () => { router.push(`/artist/${artist.id}`); }; const handleAddToQueue = () => { addArtistToQueue(artist.id); }; const handleStar = () => { if (artist.starred) { unstarItem(artist.id, 'artist'); } else { starItem(artist.id, 'artist'); } }; // Get cover art URL with proper fallback - use higher resolution for better quality const artistImageUrl = artist.coverArt && api ? api.getCoverArtUrl(artist.coverArt, 320) : '/default-user.jpg'; // If imageOnly is true, return just the image without context menu or text if (imageOnly) { return (
{artist.name}
); } // Determine if we should use responsive layout const isResponsive = responsive; return (
handleClick()}>
{artist.name}

{artist.name}

{artist.albumCount} albums

{artist.starred ? 'Remove from Favorites' : 'Add to Favorites'} Add to Playlist New Playlist {playlists.map((playlist) => ( {playlist.name} ))} Add All Songs to Queue Play Next Play Later {artist.starred ? '★ Starred' : '☆ Star'} Share
); }