Spaces:
Sleeping
Sleeping
Commit ·
da24067
1
Parent(s): 2d03bb5
Fied Sidebar
Browse files
frontend/src/components/MainLayout.jsx
CHANGED
|
@@ -1,13 +1,35 @@
|
|
| 1 |
-
import React from "react";
|
| 2 |
import Navbar from "./Navbar";
|
|
|
|
| 3 |
import ChatAssistant from "../pages/ChatAssistant";
|
| 4 |
|
| 5 |
export default function MainLayout({ children }) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
return (
|
| 7 |
-
<div className="
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
</div>
|
| 12 |
);
|
| 13 |
-
}
|
|
|
|
| 1 |
+
import React, { useState } from "react";
|
| 2 |
import Navbar from "./Navbar";
|
| 3 |
+
import Sidebar from "./Sidebar"; // Import your sidebar
|
| 4 |
import ChatAssistant from "../pages/ChatAssistant";
|
| 5 |
|
| 6 |
export default function MainLayout({ children }) {
|
| 7 |
+
// 1. Create the state for Sidebar
|
| 8 |
+
const [isMobileOpen, setIsMobileOpen] = useState(false);
|
| 9 |
+
const [collapsed, setCollapsed] = useState(false);
|
| 10 |
+
|
| 11 |
return (
|
| 12 |
+
<div className="min-h-screen bg-[#020617] flex">
|
| 13 |
+
{/* 2. Add Sidebar and pass the states */}
|
| 14 |
+
<Sidebar
|
| 15 |
+
collapsed={collapsed}
|
| 16 |
+
setCollapsed={setCollapsed}
|
| 17 |
+
isMobileOpen={isMobileOpen}
|
| 18 |
+
setIsMobileOpen={setIsMobileOpen}
|
| 19 |
+
/>
|
| 20 |
+
|
| 21 |
+
{/* 3. Main content area needs flex-1 to fill remaining space */}
|
| 22 |
+
<div className="flex-1 flex flex-col min-w-0">
|
| 23 |
+
{/* 4. Pass setIsMobileOpen to Navbar so the toggle works */}
|
| 24 |
+
<Navbar setIsMobileOpen={setIsMobileOpen} />
|
| 25 |
+
|
| 26 |
+
{/* 5. Add pt-20 to children to prevent them from hiding under the fixed Navbar */}
|
| 27 |
+
<main className="flex-1 pt-20">
|
| 28 |
+
{children}
|
| 29 |
+
</main>
|
| 30 |
+
|
| 31 |
+
<ChatAssistant />
|
| 32 |
+
</div>
|
| 33 |
</div>
|
| 34 |
);
|
| 35 |
+
}
|