// Beatmapset-style card: soft resting shadow, lifts on hover/selection; the cover is a real (not a CSS background string) so a failed/missing cover degrades to the plain surface color instead of rendering nothing; keyboard-operable when clickable. import { motion } from "framer-motion"; import { useState, type KeyboardEvent, type ReactNode } from "react"; export interface CardProps { children: ReactNode; onClick?: () => void; coverUrl?: string; selected?: boolean; label?: string; } export function Card({ children, onClick, coverUrl, selected, label }: CardProps) { const [coverFailed, setCoverFailed] = useState(false); const showCover = !!coverUrl && !coverFailed; function handleKeyDown(e: KeyboardEvent) { if (!onClick) return; if (e.key === "Enter" || e.key === " ") { e.preventDefault(); onClick(); } } return ( {showCover && ( <> setCoverFailed(true)} style={{ position: "absolute", inset: 0, width: "100%", height: "100%", objectFit: "cover", zIndex: 0, }} />
)}
{children}
); }