Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 58x 58x 58x 8x 12x 1x | import { cn } from '../lib/utils'
interface SourceFilterChipsProps {
sites: Record<string, number>
selectedSource: string | null
onSelectSource: (source: string | null) => void
}
export default function SourceFilterChips({
sites,
selectedSource,
onSelectSource,
}: SourceFilterChipsProps) {
const sortedSites = Object.entries(sites).sort(([, a], [, b]) => b - a)
const allSourcesCount = Object.values(sites).reduce((sum, n) => sum + n, 0)
if (sortedSites.length === 0) return null
return (
<div className="mb-6 flex flex-wrap gap-2">
<button
onClick={() => onSelectSource(null)}
className={cn(
'rounded-full px-3 py-1.5 text-sm font-medium transition-colors',
selectedSource === null
? 'bg-primary text-primary-foreground'
: 'bg-muted text-muted-foreground hover:bg-muted/80'
)}
>
All Sources ({allSourcesCount})
</button>
{sortedSites.map(([site, count]) => (
<button
key={site}
onClick={() => onSelectSource(site)}
className={cn(
'rounded-full px-3 py-1.5 text-sm font-medium transition-colors',
selectedSource === site
? 'bg-primary text-primary-foreground'
: 'bg-muted text-muted-foreground hover:bg-muted/80'
)}
>
{site} ({count})
</button>
))}
</div>
)
}
|