Spaces:
Running
Running
Upload components/Sidebar.js with huggingface_hub
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980import React from 'react';const Sidebar = ({ files, selectedId, onSelect, filter, setFilter }) => {const getStatusColor = (status) => {switch (status) {case 'added': return 'bg-status-added/15 text-status-added border-status-added/20';case 'modified': return 'bg-status-modified/15 text-status-modified border-status-modified/20';case 'deleted': return 'bg-status-deleted/15 text-status-deleted border-status-deleted/20';default: return 'bg-gray-700/20 text-gray-400 border-gray-700/20';}};const getIcon = (type, status) => {if (status === 'deleted') return 'fa-trash-can';switch (type) {case 'css': return 'fa-css3-alt';case 'js': return 'fa-brands fa-js';case 'ts': return 'fa-brands fa-js'; // Using JS icon for TS for simplicitycase 'json': return 'fa-brands fa-node-js';default: return 'fa-file-code';}};const filteredFiles = files.filter(file => {if (filter === 'all') return true;return file.status === filter;});return (<aside className="w-80 bg-app-sidebar border-r border-app-border flex flex-col h-full transition-all duration-300"><div className="p-6 border-b border-app-border"><h3 className="text-xs font-bold uppercase tracking-wider text-app-muted mb-4">Changed Files</h3><div className="flex gap-2">{['all', 'modified', 'added', 'deleted'].map((status) => (<buttonkey={status}onClick={() => setFilter(status)}className={`flex-1 py-1.5 text-xs font-medium rounded-md transition-colors border ${filter === status? 'bg-app-panel text-app-text border-app-muted': 'bg-transparent text-app-muted border-app-border hover:bg-app-panel hover:text-app-text'}`}>{status === 'all' ? 'All' : status.charAt(0).toUpperCase() + status.slice(1)}</button>))}</div></div><div className="flex-1 overflow-y-auto p-3 space-y-1">{filteredFiles.length === 0 ? (<div className="flex flex-col items-center justify-center h-full text-app-muted text-sm"><i className="fa-regular fa-folder-open text-4xl mb-3 opacity-20"></i><p>No files found</p></div>) : (filteredFiles.map((file) => (<divkey={file.id}onClick={() => onSelect(file.id)}className={`group relative flex items-center justify-between p-3 rounded-lg cursor-pointer transition-all duration-200 border ${selectedId === file.id? 'bg-app-panel border-accent-primary shadow-lg shadow-accent-primary/5': 'border-transparent hover:bg-app-panel hover:border-app-border'} ${file.status === 'modified' && selectedId !== file.id ? 'border-l-4 border-l-status-modified' : ''}`}><div className="flex items-center gap-3 overflow-hidden"><i className={`fa-solid ${getIcon(file.type, file.status)} text-lg text-app-muted w-5 text-center`}></i><span className="font-mono text-sm text-app-text truncate pr-2">{file.name}</span></div><span className={`text-[10px] px-2 py-0.5 rounded-full border font-bold uppercase tracking-wide ${getStatusColor(file.status)}`}>{file.status === 'added' ? 'New' : file.status === 'modified' ? 'Edited' : file.status === 'deleted' ? 'Del' : 'Unch'}</span></div>)))}</div></aside>);};123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990import React from 'react';const Sidebar = ({selectedCategory,onSelectCategory,categories,activeConceptId,onConceptSelect,concepts}) => {return (<aside className="w-80 bg-gray-800 border-r border-gray-700 flex flex-col h-full"><div className="p-4 border-b border-gray-700"><h3 className="text-xs font-bold uppercase tracking-wider text-gray-400 mb-4">ICT Knowledge Base</h3><div className="space-y-1">{categories.map((category) => (<buttonkey={category.id}onClick={() => onSelectCategory(category.id)}className={`w-full text-left px-3 py-2 rounded-md text-sm font-medium transition-colors ${selectedCategory === category.id? 'bg-blue-600/20 text-blue-400 border border-blue-500/30': 'text-gray-300 hover:bg-gray-700'}`}>{category.name}</button>))}</div></div><div className="flex-1 overflow-y-auto p-3 space-y-1">{concepts.length === 0 ? (<div className="flex flex-col items-center justify-center h-full text-gray-500 text-sm"><i className="fa-regular fa-folder-open text-4xl mb-3 opacity-20"></i><p>No concepts found</p></div>) : (concepts.map((concept) => (<divkey={concept.id}onClick={() => onConceptSelect(concept.id)}className={`group relative p-3 rounded-lg cursor-pointer transition-all duration-200 border ${activeConceptId === concept.id? 'bg-blue-600/10 border-blue-500/30 shadow-lg shadow-blue-500/5': 'border-transparent hover:bg-gray-700 hover:border-gray-600'}`}><div className="flex items-start gap-3"><div className="mt-1 p-1.5 bg-gray-700 rounded text-gray-300"><i className={`fa-solid ${getIconForType(concept.type)}`}></i></div><div className="flex-1 min-w-0"><h4 className="font-medium text-gray-200 truncate">{concept.title}</h4><p className="text-xs text-gray-400 mt-1 line-clamp-2">{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">{concept.confidence}%</span><span className="text-[10px] px-2 py-0.5 rounded-full bg-blue-500/10 text-blue-400 border border-blue-500/20">{concept.type}</span></div></div></div></div>)))}</div><div className="p-4 border-t border-gray-700"><div className="flex items-center gap-2 text-xs text-gray-400"><i className="fa-solid fa-database"></i><span>{concepts.length} concepts loaded</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';};
components/Sidebar.js+66-56