CaffeinatedCoding commited on
Commit
5331e6f
·
verified ·
1 Parent(s): 9b38acd

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. frontend/app.js +14 -0
  2. frontend/index.html +7 -0
  3. frontend/style.css +70 -0
frontend/app.js CHANGED
@@ -5,12 +5,18 @@ const API_BASE = ""; // "" = same origin (HF Spaces). "http://localhost:8000" fo
5
  let sessions = []; // [{id, title, messages:[]}]
6
  let activeSessionId = null;
7
  let isLoading = false;
 
8
 
9
  // ── Init ────────────────────────────────────────────────────────
10
  const textarea = document.getElementById("query-input");
11
  const sendBtn = document.getElementById("send-btn");
12
  const msgsList = document.getElementById("messages-list");
13
 
 
 
 
 
 
14
  textarea.addEventListener("input", () => {
15
  textarea.style.height = "auto";
16
  textarea.style.height = Math.min(textarea.scrollHeight, 140) + "px";
@@ -26,6 +32,14 @@ function showScreen(name) {
26
  document.getElementById("screen-" + name).classList.add("active");
27
  }
28
 
 
 
 
 
 
 
 
 
29
  // ── Session management ───────────────────────────────────────────
30
  function createSession(firstQuery) {
31
  const id = Date.now();
 
5
  let sessions = []; // [{id, title, messages:[]}]
6
  let activeSessionId = null;
7
  let isLoading = false;
8
+ let sidebarCollapsed = localStorage.getItem("sidebarCollapsed") === "true";
9
 
10
  // ── Init ────────────────────────────────────────────────────────
11
  const textarea = document.getElementById("query-input");
12
  const sendBtn = document.getElementById("send-btn");
13
  const msgsList = document.getElementById("messages-list");
14
 
15
+ // Apply sidebar collapsed state on load
16
+ if (sidebarCollapsed) {
17
+ document.getElementById("sidebar").classList.add("collapsed");
18
+ }
19
+
20
  textarea.addEventListener("input", () => {
21
  textarea.style.height = "auto";
22
  textarea.style.height = Math.min(textarea.scrollHeight, 140) + "px";
 
32
  document.getElementById("screen-" + name).classList.add("active");
33
  }
34
 
35
+ // ── Sidebar toggle ───────────────────────────────────────────────
36
+ function toggleSidebar() {
37
+ const sidebar = document.getElementById("sidebar");
38
+ sidebarCollapsed = !sidebarCollapsed;
39
+ sidebar.classList.toggle("collapsed");
40
+ localStorage.setItem("sidebarCollapsed", sidebarCollapsed);
41
+ }
42
+
43
  // ── Session management ───────────────────────────────────────────
44
  function createSession(firstQuery) {
45
  const id = Date.now();
frontend/index.html CHANGED
@@ -20,6 +20,13 @@
20
  <span class="brand-name">NyayaSetu</span>
21
  <span class="brand-sub">Legal Research</span>
22
  </div>
 
 
 
 
 
 
 
23
  </div>
24
 
25
  <button class="new-chat-btn" onclick="newChat()">
 
20
  <span class="brand-name">NyayaSetu</span>
21
  <span class="brand-sub">Legal Research</span>
22
  </div>
23
+ <button class="sidebar-toggle" onclick="toggleSidebar()" title="Toggle sidebar">
24
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
25
+ <line x1="3" y1="6" x2="21" y2="6"></line>
26
+ <line x1="3" y1="12" x2="21" y2="12"></line>
27
+ <line x1="3" y1="18" x2="21" y2="18"></line>
28
+ </svg>
29
+ </button>
30
  </div>
31
 
32
  <button class="new-chat-btn" onclick="newChat()">
frontend/style.css CHANGED
@@ -52,6 +52,53 @@ body {
52
  flex-direction: column;
53
  flex-shrink: 0;
54
  overflow: hidden;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  }
56
 
57
  .sidebar-brand {
@@ -60,6 +107,29 @@ body {
60
  gap: 12px;
61
  padding: 16px 16px 12px;
62
  border-bottom: 1px solid var(--border);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  }
64
 
65
  .brand-mark {
 
52
  flex-direction: column;
53
  flex-shrink: 0;
54
  overflow: hidden;
55
+ transition: width 0.3s ease;
56
+ }
57
+
58
+ .sidebar.collapsed {
59
+ width: 60px;
60
+ }
61
+
62
+ .sidebar.collapsed .brand-text,
63
+ .sidebar.collapsed .new-chat-btn span:not(.new-chat-icon),
64
+ .sidebar.collapsed .sidebar-section-label,
65
+ .sidebar.collapsed .session-label,
66
+ .sidebar.collapsed .session-count,
67
+ .sidebar.collapsed .footer-disclaimer,
68
+ .sidebar.collapsed .footer-meta {
69
+ display: none;
70
+ }
71
+
72
+ .sidebar.collapsed .new-chat-btn {
73
+ width: calc(100% - 16px);
74
+ margin: 12px 8px;
75
+ padding: 8px;
76
+ justify-content: center;
77
+ }
78
+
79
+ .sidebar.collapsed .analytics-btn {
80
+ width: calc(100% - 16px);
81
+ margin: 0 8px 8px;
82
+ padding: 10px 8px;
83
+ justify-content: center;
84
+ }
85
+
86
+ .sidebar.collapsed .new-chat-icon,
87
+ .sidebar.collapsed .analytics-icon {
88
+ margin: 0;
89
+ }
90
+
91
+ .sidebar.collapsed .sessions-list {
92
+ padding: 0 8px;
93
+ }
94
+
95
+ .sidebar.collapsed .session-item {
96
+ padding: 9px 10px;
97
+ justify-content: center;
98
+ }
99
+
100
+ .sidebar.collapsed .sidebar-footer {
101
+ padding: 8px 8px;
102
  }
103
 
104
  .sidebar-brand {
 
107
  gap: 12px;
108
  padding: 16px 16px 12px;
109
  border-bottom: 1px solid var(--border);
110
+ position: relative;
111
+ }
112
+
113
+ .sidebar-toggle {
114
+ position: absolute;
115
+ right: 8px;
116
+ top: 50%;
117
+ transform: translateY(-50%);
118
+ background: none;
119
+ border: none;
120
+ color: var(--text-3);
121
+ cursor: pointer;
122
+ padding: 6px;
123
+ border-radius: 6px;
124
+ display: flex;
125
+ align-items: center;
126
+ justify-content: center;
127
+ transition: color var(--transition), background var(--transition);
128
+ }
129
+
130
+ .sidebar-toggle:hover {
131
+ color: var(--text-1);
132
+ background: var(--navy-3);
133
  }
134
 
135
  .brand-mark {