({ model, onSelect, isSelected }: HfModelCardProps)
| 8 | } |
| 9 | |
| 10 | export function HfModelCard({ model, onSelect, isSelected }: HfModelCardProps) { |
| 11 | const hasStrongQuant = model.tags.some((tag) => /q5|q6|q8|q4_k_m/i.test(tag)); |
| 12 | |
| 13 | const handleKeyDown = (e: React.KeyboardEvent) => { |
| 14 | if (e.key === 'Enter' || e.key === ' ') { |
| 15 | e.preventDefault(); |
| 16 | onSelect(); |
| 17 | } |
| 18 | }; |
| 19 | |
| 20 | return ( |
| 21 | <div |
| 22 | onClick={onSelect} |
| 23 | onKeyDown={handleKeyDown} |
| 24 | role="button" |
| 25 | tabIndex={0} |
| 26 | aria-pressed={isSelected} |
| 27 | className={`bg-dark-surface border rounded-lg p-4 cursor-pointer transition-colors focus:outline-none focus:ring-2 focus:ring-dark-accent ${ |
| 28 | isSelected |
| 29 | ? 'border-dark-accent bg-dark-accent/10' |
| 30 | : 'border-dark-border hover:border-dark-accent' |
| 31 | }`} |
| 32 | > |
| 33 | <div className="flex items-start justify-between gap-3 mb-2"> |
| 34 | <h3 className="text-dark-text font-semibold truncate">{model.id}</h3> |
| 35 | {hasStrongQuant && ( |
| 36 | <span className="px-2 py-0.5 bg-green-600 text-white text-[10px] font-semibold rounded-full whitespace-nowrap"> |
| 37 | Strong GGUF |
| 38 | </span> |
| 39 | )} |
| 40 | </div> |
| 41 | |
| 42 | <div className="flex items-center gap-4 mb-2 text-sm text-dark-text-secondary"> |
| 43 | <div className="flex items-center gap-1"> |
| 44 | <svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true"> |
| 45 | <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" /> |
| 46 | </svg> |
| 47 | <span>{model.downloads.toLocaleString()}</span> |
| 48 | </div> |
| 49 | |
| 50 | <div className="flex items-center gap-1"> |
| 51 | <svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true"> |
| 52 | <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z" /> |
| 53 | </svg> |
| 54 | <span>{model.likes.toLocaleString()}</span> |
| 55 | </div> |
| 56 | </div> |
| 57 | |
| 58 | <p className="text-dark-text-secondary text-xs mb-2"> |
| 59 | Updated: {formatTimestamp(model.last_modified)} |
| 60 | </p> |
| 61 | |
| 62 | {model.tags.length > 0 && ( |
| 63 | <div className="flex flex-wrap gap-1"> |
| 64 | {model.tags.slice(0, 3).map((tag) => ( |
| 65 | <span |
| 66 | key={tag} |
| 67 | className="px-2 py-0.5 bg-dark-bg text-dark-text-secondary text-xs rounded" |
nothing calls this directly
no test coverage detected