"use client"; import { useState, ReactNode, memo } from "react"; import Link from "next/link"; import Image from "next/image"; import { Play, Pause, Check, Download } from "lucide-react"; import { Card, CardProps } from "./Card"; import { cn } from "@/utils/cn"; import type { ColorPalette } from "@/hooks/useImageColor"; // Lidify brand yellow for all on-page play buttons const LIDIFY_YELLOW = "#ecb200"; export interface PlayableCardProps extends Omit { href?: string; coverArt?: string | null; title: string; subtitle?: string; placeholderIcon?: ReactNode; isPlaying?: boolean; onPlay?: (e: React.MouseEvent) => void; onDownload?: (e: React.MouseEvent) => void; showPlayButton?: boolean; circular?: boolean; badge?: "owned" | "download" | null; isDownloading?: boolean; colors?: ColorPalette | null; tvCardIndex?: number; } const PlayableCard = memo(function PlayableCard({ href, coverArt, title, subtitle, placeholderIcon, isPlaying = false, onPlay, onDownload, showPlayButton = true, circular = false, badge = null, isDownloading = false, // eslint-disable-next-line @typescript-eslint/no-unused-vars colors = null, className, variant = "default", tvCardIndex, ...props }: PlayableCardProps) { const [isHovered, setIsHovered] = useState(false); // Handle Link click to prevent navigation when clicking on interactive elements const handleLinkClick = (e: React.MouseEvent) => { const target = e.target as HTMLElement; if (target.closest("button")) { e.preventDefault(); } }; const cardContent = ( <> {/* Image Container */}
setIsHovered(true)} onMouseLeave={() => setIsHovered(false)} >
{coverArt ? ( {title} ) : ( placeholderIcon || (
) )}
{/* Play Button */} {showPlayButton && onPlay && ( )}
{/* Badge */} {badge && (
{badge === "owned" && ( Owned )} {badge === "download" && ( )}
)} {/* Title and Subtitle */}

{title}

{subtitle && (

{subtitle}

)} ); const cardClassName = cn("group cursor-pointer", className); // TV navigation attributes const tvNavProps = tvCardIndex !== undefined ? { "data-tv-card": true, "data-tv-card-index": tvCardIndex, tabIndex: 0 } : {}; if (href) { return ( {cardContent} ); } return ( {cardContent} ); }); export { PlayableCard };