import { imageProps } from '@/lib/images'; import { SmartImage } from '@/components/ui/smart-image'; import { glyphForFamily } from '@/lib/image-glyph'; import Link from 'next/link'; import type { MarketRow } from '@/lib/queries/markets'; import { fmtNum, cn } from '@/lib/format'; import { Delta } from '@/components/ui/primitives'; import { Sparkline } from '@/components/charts/sparkline'; /** Browse-by-category tiles: representative image, live counts, 30-day change and an optional sparkline. */ export function CategoryGrid({ rows, thumbs, className, limit, sparklines, mobileLimit }: { rows: MarketRow[]; thumbs: Map; className?: string; limit?: number; sparklines?: Map; /** hide tiles beyond this index below the sm breakpoint */ mobileLimit?: number }) { const sorted = [...rows].sort((a, b) => b.counts.sales - a.counts.sales || b.counts.assets - a.counts.assets || a.node.sortOrder - b.node.sortOrder); const shown = limit ? sorted.slice(0, limit) : sorted; return (
{shown.map(({ node, counts, snapshot }, idx) => { const hiddenOnMobile = mobileLimit !== undefined && idx >= mobileLimit; const empty = counts.assets === 0; const src = thumbs.get(node.slug); const spark = sparklines?.get(node.slug); return ( {(() => { const ip = imageProps(src, { maxWidth: 384 }); return ; })()} {spark && spark.length > 2 ? ( ) : null} {node.name} {snapshot?.change30d != null ? : null} {empty ? 'catalogue pending' : `${fmtNum(counts.assets, { compact: true })} assets${counts.sales ? ` · ${fmtNum(counts.sales, { compact: true })} sales` : counts.priced ? ` · ${fmtNum(counts.priced, { compact: true })} priced` : ''}`} ); })}
); }