Spaces:
Running

File size: 5,427 Bytes
683049f
 
d55f065
 
 
 
 
 
0b186a3
ba24127
 
d55f065
683049f
ba24127
 
0b186a3
 
ba24127
0b186a3
ba24127
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d55f065
 
683049f
d55f065
 
ba24127
d55f065
ba24127
 
683049f
 
d55f065
0b186a3
683049f
 
 
 
d55f065
ba24127
0b186a3
ba24127
683049f
ba24127
683049f
 
0b186a3
683049f
d55f065
 
ba24127
d55f065
ba24127
 
d55f065
683049f
d55f065
ba24127
 
 
 
 
 
d55f065
 
 
ba24127
 
d55f065
ba24127
 
d55f065
ba24127
 
d55f065
 
 
683049f
ba24127
 
 
683049f
 
 
 
d55f065
ba24127
 
 
 
 
 
 
 
d55f065
 
683049f
 
d55f065
 
 
 
 
 
 
 
 
 
 
55f8724
 
 
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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;