Spaces:
Running
Running
Download components/Sidebar.js from powerllm/anycoder-3dfb5929: direct link, hf CLI and curl.
- Browser
- Download file 5.43 kB
-
https://huggingface.co/spaces/powerllm/anycoder-3dfb5929/resolve/main/components/Sidebar.js
- Command line
-
hf download hf://spaces/powerllm/anycoder-3dfb5929/components/Sidebar.js
-
curl -L -o Sidebar.js https://huggingface.co/spaces/powerllm/anycoder-3dfb5929/resolve/main/components/Sidebar.js
5.43 kB
| import React from 'react'; | |
| const Sidebar = ({ | |
| selectedCategory, | |
| onSelectCategory, | |
| categories, | |
| activeConceptId, | |
| onConceptSelect, | |
| concepts, | |
| filteredConcepts, | |
| onAddFile | |
| }) => { | |
| return ( | |
| <aside className="w-80 bg-gray-800 border-r border-gray-700 flex flex-col h-full shadow-xl z-40"> | |
| <div className="p-4 border-b border-gray-700 bg-gray-800"> | |
| <div className="flex items-center justify-between mb-4"> | |
| <h3 className="text-xs font-bold uppercase tracking-wider text-gray-400">ICT Knowledge Base</h3> | |
| <span className="text-xs text-gray-500 bg-gray-900 px-2 py-0.5 rounded-md">{filteredConcepts.length} results</span> | |
| </div> | |
| <div className="flex items-center justify-between mb-4"> | |
| <div className="flex items-center gap-2 text-gray-400 text-xs"> | |
| <i className="fa-solid fa-database"></i> | |
| <span>{concepts.length} loaded</span> | |
| </div> | |
| <button | |
| onClick={onAddFile} | |
| className="text-[10px] text-blue-400 hover:text-blue-300 hover:underline" | |
| title="Simulate adding a new JSON file" | |
| > | |
| + Add File | |
| </button> | |
| </div> | |
| <div className="space-y-1"> | |
| {categories.map((category) => ( | |
| <button | |
| key={category.id} | |
| onClick={() => onSelectCategory(category.id)} | |
| className={`w-full text-left px-3 py-2 rounded-md text-sm font-medium transition-all duration-200 ${ | |
| selectedCategory === category.id | |
| ? 'bg-blue-600/20 text-blue-400 border border-blue-500/30 shadow-sm' | |
| : 'text-gray-300 hover:bg-gray-700/50 hover:text-gray-100' | |
| }`} | |
| > | |
| {category.name} | |
| {category.id === 'all' && <span className="ml-2 text-xs opacity-60">({concepts.length})</span>} | |
| </button> | |
| ))} | |
| </div> | |
| </div> | |
| <div className="flex-1 overflow-y-auto p-3 space-y-2 scrollbar-thin scrollbar-thumb-gray-700 scrollbar-track-transparent"> | |
| {filteredConcepts.length === 0 ? ( | |
| <div className="flex flex-col items-center justify-center h-full text-gray-500 text-sm p-4"> | |
| <i className="fa-regular fa-folder-open text-4xl mb-3 opacity-20"></i> | |
| <p>No concepts found matching criteria</p> | |
| </div> | |
| ) : ( | |
| filteredConcepts.map((concept) => ( | |
| <div | |
| key={concept.id} | |
| onClick={() => onConceptSelect(concept.id)} | |
| className={`group relative p-3 rounded-lg cursor-pointer transition-all duration-200 border hover:shadow-md ${ | |
| activeConceptId === concept.id | |
| ? 'bg-gradient-to-br from-blue-600/10 to-blue-700/5 border-blue-500/40 shadow-lg shadow-blue-900/20' | |
| : 'border-gray-700/50 hover:bg-gray-700 hover:border-gray-600' | |
| }`} | |
| > | |
| <div className="flex items-start gap-3"> | |
| <div className={`mt-1 p-1.5 rounded text-sm ${ | |
| concept.type === 'core_concept' ? 'bg-blue-500/20 text-blue-400' : | |
| concept.type === 'strategy' ? 'bg-purple-500/20 text-purple-400' : | |
| concept.type === 'risk_management' ? 'bg-red-500/20 text-red-400' : | |
| 'bg-orange-500/20 text-orange-400' | |
| }`}> | |
| <i className={`fa-solid ${getIconForType(concept.type)}`}></i> | |
| </div> | |
| <div className="flex-1 min-w-0"> | |
| <h4 className="font-medium text-gray-200 truncate text-sm">{concept.title}</h4> | |
| <p className="text-xs text-gray-400 mt-1 line-clamp-2 leading-relaxed">{concept.description}</p> | |
| <div className="flex items-center gap-2 mt-2"> | |
| <span className="text-[10px] px-2 py-0.5 rounded-full bg-green-500/10 text-green-400 border border-green-500/20 font-medium"> | |
| {concept.confidence}% Confidence | |
| </span> | |
| <span className="text-[10px] px-2 py-0.5 rounded-full bg-gray-700 text-gray-300 border border-gray-600 uppercase tracking-wide"> | |
| {concept.type.replace('_', ' ')} | |
| </span> | |
| </div> | |
| </div> | |
| </div> | |
| <div className="absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity"> | |
| <i className="fa-solid fa-chevron-right text-xs text-gray-500"></i> | |
| </div> | |
| </div> | |
| )) | |
| )} | |
| </div> | |
| <div className="p-3 border-t border-gray-700 bg-gray-800/50 text-xs text-gray-500 flex justify-between items-center"> | |
| <div className="flex items-center gap-2"> | |
| <i className="fa-solid fa-server"></i> | |
| <span>v1.0.4</span> | |
| </div> | |
| <div className="flex items-center gap-2"> | |
| <div className="w-2 h-2 rounded-full bg-green-500"></div> | |
| <span>Synced</span> | |
| </div> | |
| </div> | |
| </aside> | |
| ); | |
| }; | |
| const getIconForType = (type) => { | |
| const icons = { | |
| core_concept: 'fa-book', | |
| supporting_concept: 'fa-bookmark', | |
| strategy: 'fa-chart-line', | |
| risk_management: 'fa-shield-halved', | |
| session_analysis: 'fa-clock' | |
| }; | |
| return icons[type] || 'fa-file'; | |
| }; | |
| export default Sidebar; |