import Image from 'next/image'; import Link from 'next/link'; import { ExternalLink } from 'lucide-react'; import { cn, fmtMoney } from '@/lib/format'; import { catName, gradeLabel } from '@/lib/taxonomy'; import { Badge } from '@/components/ui/primitives'; /** Small shared building blocks for market tables and cards. */ export function Thumb({ src, alt, size = 40, className, rounded = 'rounded-sm' }: { src: string | null | undefined; alt: string; size?: number; className?: string; rounded?: string }) { return ( {src ? {alt} : n/a} ); } export function CategoryTag({ slug, className }: { slug: string | null | undefined; className?: string }) { if (!slug) return null; return ( {catName(slug)} ); } export function GradeBadge({ grader, grade, className }: { grader: string | null | undefined; grade: string | null | undefined; className?: string }) { const label = gradeLabel(grader, grade); if (!label) return —; return ( {label} ); } /** §178: source attribution with outbound link. */ export function SourceLink({ name, url, className }: { name: string; url: string | null | undefined; className?: string }) { if (!url) return {name}; return ( {name} ); } export function PriceCell({ usd, native, currency, className }: { usd: number | null | undefined; native?: number | null; currency?: string | null; className?: string }) { const showNative = native !== null && native !== undefined && currency && currency !== 'USD'; return ( {fmtMoney(usd)} {showNative ? {fmtMoney(native, currency!)} : null} ); } export function AssetTitleCell({ slug, title, categorySlug, image, sub, size = 36 }: { slug: string; title: string; categorySlug?: string | null; image?: string | null; sub?: string | null; size?: number }) { return ( {title} {categorySlug ? catName(categorySlug) : null} {sub ? (categorySlug ? ` · ${sub}` : sub) : null} ); }