Spaces:
Running
Running
Download components/ResultsList.js from powerllm/anycoder-cf48624d: direct link, hf CLI and curl.
- Browser
- Download file 2.28 kB
-
https://huggingface.co/spaces/powerllm/anycoder-cf48624d/resolve/main/components/ResultsList.js
- Command line
-
hf download hf://spaces/powerllm/anycoder-cf48624d/components/ResultsList.js
-
curl -L -o ResultsList.js https://huggingface.co/spaces/powerllm/anycoder-cf48624d/resolve/main/components/ResultsList.js
2.28 kB
| export default function ResultsList({ results, onSelect, selectedId }) { | |
| if (results.length === 0) { | |
| return ( | |
| <div className="card h-full flex flex-col items-center justify-center text-center p-12 border-dashed"> | |
| <div className="w-16 h-16 bg-dark-800 rounded-full flex items-center justify-center mb-4"> | |
| <svg className="w-8 h-8 text-dark-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"> | |
| <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10" /> | |
| </svg> | |
| </div> | |
| <h3 className="text-lg font-medium text-white mb-2">No results found</h3> | |
| <p className="text-dark-400 text-sm">Try adjusting your search terms or browse all documents.</p> | |
| </div> | |
| ) | |
| } | |
| return ( | |
| <div className="space-y-3"> | |
| <h2 className="text-sm font-semibold text-dark-400 uppercase tracking-wider mb-4"> | |
| Results ({results.length}) | |
| </h2> | |
| {results.map((doc) => ( | |
| <button | |
| key={doc.id} | |
| onClick={() => onSelect(doc)} | |
| className={`w-full text-left card p-4 group ${ | |
| selectedId === doc.id ? 'ring-2 ring-primary-500 bg-dark-800' : 'hover:bg-dark-800' | |
| }`} | |
| > | |
| <div className="flex justify-between items-start mb-2"> | |
| <h3 className="font-semibold text-white group-hover:text-primary-400 transition-colors line-clamp-1"> | |
| {doc.title} | |
| </h3> | |
| <span className="text-xs text-dark-500 bg-dark-900 px-2 py-1 rounded"> | |
| {doc.score ? `${(doc.score * 100).toFixed(0)}%` : 'Match'} | |
| </span> | |
| </div> | |
| <p className="text-sm text-dark-400 line-clamp-2 mb-3"> | |
| {doc.snippet || doc.content?.substring(0, 150)}... | |
| </p> | |
| <div className="flex flex-wrap gap-2"> | |
| {doc.tags?.split(',').slice(0, 3).map((tag, i) => ( | |
| <span key={i} className="text-xs text-primary-400 bg-primary-500/10 px-2 py-0.5 rounded"> | |
| #{tag.trim()} | |
| </span> | |
| ))} | |
| </div> | |
| </button> | |
| ))} | |
| </div> | |
| ) | |
| } |