Spaces:
Running
Running
The sidebar goes inside the chat section of the site. Fix it to the left so that it doesn't conflict with the chat section.
Browse files- index.html +1 -1
- script.js +36 -2
- style.css +5 -1
index.html
CHANGED
|
@@ -63,7 +63,7 @@
|
|
| 63 |
<div class="flex h-screen relative z-10">
|
| 64 |
<custom-sidebar></custom-sidebar>
|
| 65 |
<!-- Main Chat Area -->
|
| 66 |
-
<main class="flex-1 flex flex-col bg-zinc-950 relative overflow-hidden max-h-screen"
|
| 67 |
<!-- Messages Container -->
|
| 68 |
<div id="chatContainer" class="flex-1 overflow-y-auto scroll-smooth p-4 space-y-4" style="scrollbar-width: thin; scrollbar-color: #525252 #18181b;">
|
| 69 |
<!-- AI Welcome Message -->
|
|
|
|
| 63 |
<div class="flex h-screen relative z-10">
|
| 64 |
<custom-sidebar></custom-sidebar>
|
| 65 |
<!-- Main Chat Area -->
|
| 66 |
+
<main class="flex-1 flex flex-col bg-zinc-950 relative overflow-hidden max-h-screen">
|
| 67 |
<!-- Messages Container -->
|
| 68 |
<div id="chatContainer" class="flex-1 overflow-y-auto scroll-smooth p-4 space-y-4" style="scrollbar-width: thin; scrollbar-color: #525252 #18181b;">
|
| 69 |
<!-- AI Welcome Message -->
|
script.js
CHANGED
|
@@ -8,12 +8,13 @@ let webSearchEnabled = false;
|
|
| 8 |
let isGenerating = false;
|
| 9 |
let currentTokenCount = 0;
|
| 10 |
const maxTokens = 4096;
|
|
|
|
| 11 |
// Initialize
|
| 12 |
document.addEventListener('DOMContentLoaded', function() {
|
| 13 |
initializeApp();
|
| 14 |
setupEventListeners();
|
|
|
|
| 15 |
});
|
| 16 |
-
|
| 17 |
function initializeApp() {
|
| 18 |
// Load chat history from localStorage
|
| 19 |
const savedHistory = localStorage.getItem('chatHistory');
|
|
@@ -28,7 +29,6 @@ function initializeApp() {
|
|
| 28 |
// Initialize tooltips and other UI elements
|
| 29 |
initializeTooltips();
|
| 30 |
}
|
| 31 |
-
|
| 32 |
function setupEventListeners() {
|
| 33 |
// Keyboard shortcuts
|
| 34 |
document.addEventListener('keydown', function(e) {
|
|
@@ -48,6 +48,12 @@ function setupEventListeners() {
|
|
| 48 |
e.preventDefault();
|
| 49 |
showHelp();
|
| 50 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
});
|
| 52 |
|
| 53 |
// Auto-resize textarea
|
|
@@ -57,6 +63,34 @@ function setupEventListeners() {
|
|
| 57 |
this.style.height = Math.min(this.scrollHeight, 120) + 'px';
|
| 58 |
});
|
| 59 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
function sendMessage() {
|
| 61 |
const input = document.getElementById('messageInput');
|
| 62 |
const message = input.value.trim();
|
|
|
|
| 8 |
let isGenerating = false;
|
| 9 |
let currentTokenCount = 0;
|
| 10 |
const maxTokens = 4096;
|
| 11 |
+
let sidebarCollapsed = false;
|
| 12 |
// Initialize
|
| 13 |
document.addEventListener('DOMContentLoaded', function() {
|
| 14 |
initializeApp();
|
| 15 |
setupEventListeners();
|
| 16 |
+
initializeSidebarToggle();
|
| 17 |
});
|
|
|
|
| 18 |
function initializeApp() {
|
| 19 |
// Load chat history from localStorage
|
| 20 |
const savedHistory = localStorage.getItem('chatHistory');
|
|
|
|
| 29 |
// Initialize tooltips and other UI elements
|
| 30 |
initializeTooltips();
|
| 31 |
}
|
|
|
|
| 32 |
function setupEventListeners() {
|
| 33 |
// Keyboard shortcuts
|
| 34 |
document.addEventListener('keydown', function(e) {
|
|
|
|
| 48 |
e.preventDefault();
|
| 49 |
showHelp();
|
| 50 |
}
|
| 51 |
+
|
| 52 |
+
// Ctrl/Cmd + B to toggle sidebar
|
| 53 |
+
if ((e.ctrlKey || e.metaKey) && e.key === 'b') {
|
| 54 |
+
e.preventDefault();
|
| 55 |
+
toggleSidebar();
|
| 56 |
+
}
|
| 57 |
});
|
| 58 |
|
| 59 |
// Auto-resize textarea
|
|
|
|
| 63 |
this.style.height = Math.min(this.scrollHeight, 120) + 'px';
|
| 64 |
});
|
| 65 |
}
|
| 66 |
+
|
| 67 |
+
function initializeSidebarToggle() {
|
| 68 |
+
// Add sidebar toggle functionality for responsive design
|
| 69 |
+
const main = document.querySelector('main');
|
| 70 |
+
const sidebar = document.querySelector('.sidebar');
|
| 71 |
+
|
| 72 |
+
if (window.innerWidth < 768) {
|
| 73 |
+
sidebarCollapsed = true;
|
| 74 |
+
main.style.marginLeft = '0';
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
function toggleSidebar() {
|
| 79 |
+
const sidebar = document.querySelector('.sidebar');
|
| 80 |
+
const main = document.querySelector('main');
|
| 81 |
+
|
| 82 |
+
sidebarCollapsed = !sidebarCollapsed;
|
| 83 |
+
|
| 84 |
+
if (sidebarCollapsed) {
|
| 85 |
+
sidebar.style.transform = 'translateX(-100%)';
|
| 86 |
+
main.style.marginLeft = '0';
|
| 87 |
+
main.style.width = '100%';
|
| 88 |
+
} else {
|
| 89 |
+
sidebar.style.transform = 'translateX(0)';
|
| 90 |
+
main.style.marginLeft = '260px';
|
| 91 |
+
main.style.width = 'calc(100% - 260px)';
|
| 92 |
+
}
|
| 93 |
+
}
|
| 94 |
function sendMessage() {
|
| 95 |
const input = document.getElementById('messageInput');
|
| 96 |
const message = input.value.trim();
|
style.css
CHANGED
|
@@ -151,7 +151,6 @@ main {
|
|
| 151 |
overflow: hidden;
|
| 152 |
max-height: 100vh;
|
| 153 |
}
|
| 154 |
-
|
| 155 |
/* Desktop layout - fixed sidebar */
|
| 156 |
@media (min-width: 769px) {
|
| 157 |
main {
|
|
@@ -159,6 +158,11 @@ main {
|
|
| 159 |
width: calc(100% - 260px);
|
| 160 |
}
|
| 161 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
/* Sidebar Transitions */
|
| 163 |
.sidebar {
|
| 164 |
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
|
|
| 151 |
overflow: hidden;
|
| 152 |
max-height: 100vh;
|
| 153 |
}
|
|
|
|
| 154 |
/* Desktop layout - fixed sidebar */
|
| 155 |
@media (min-width: 769px) {
|
| 156 |
main {
|
|
|
|
| 158 |
width: calc(100% - 260px);
|
| 159 |
}
|
| 160 |
}
|
| 161 |
+
|
| 162 |
+
/* Ensure main content accounts for fixed sidebar */
|
| 163 |
+
main {
|
| 164 |
+
transition: margin-left 0.3s ease;
|
| 165 |
+
}
|
| 166 |
/* Sidebar Transitions */
|
| 167 |
.sidebar {
|
| 168 |
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|