Commit ·
c372e45
1
Parent(s): 2333c19
Add ChatArea component to integrate ChatScreen and Sidebar with toggle functionality
Browse files
src/pages/chatArea/index.tsx
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Box } from "@mui/material";
|
| 2 |
+
import React, { useState } from "react";
|
| 3 |
+
|
| 4 |
+
import ChatScreen from "./components/ChatScreen";
|
| 5 |
+
import Sidebar from "./components/Sidebar";
|
| 6 |
+
|
| 7 |
+
export default function ChatArea() {
|
| 8 |
+
const [isSidebarOpen, setIsSidebarOpen] = useState<boolean>(false);
|
| 9 |
+
|
| 10 |
+
const toggleSidebar = () => {
|
| 11 |
+
setIsSidebarOpen(!isSidebarOpen);
|
| 12 |
+
};
|
| 13 |
+
|
| 14 |
+
return (
|
| 15 |
+
<Box
|
| 16 |
+
sx={{
|
| 17 |
+
display: "flex",
|
| 18 |
+
height: "100vh",
|
| 19 |
+
bgcolor: "#f9f9f9",
|
| 20 |
+
transition: "all 0.3s ease-in-out",
|
| 21 |
+
}}
|
| 22 |
+
>
|
| 23 |
+
<Box
|
| 24 |
+
sx={{
|
| 25 |
+
width: isSidebarOpen ? "250px" : "0",
|
| 26 |
+
overflow: "hidden",
|
| 27 |
+
transition: "width 0.3s ease-in-out",
|
| 28 |
+
bgcolor: "#ffffff",
|
| 29 |
+
borderRight: "1px solid #e0e0e0",
|
| 30 |
+
}}
|
| 31 |
+
>
|
| 32 |
+
<Sidebar isOpen={isSidebarOpen} toggleSidebar={toggleSidebar} />
|
| 33 |
+
</Box>
|
| 34 |
+
<Box
|
| 35 |
+
sx={{
|
| 36 |
+
display: "flex",
|
| 37 |
+
flexDirection: "column",
|
| 38 |
+
flexGrow: 1,
|
| 39 |
+
transition: "all 0.3s ease-in-out",
|
| 40 |
+
}}
|
| 41 |
+
>
|
| 42 |
+
<ChatScreen isOpen={isSidebarOpen} toggleSidebar={toggleSidebar} />
|
| 43 |
+
</Box>
|
| 44 |
+
</Box>
|
| 45 |
+
);
|
| 46 |
+
}
|
src/pages/chatArea/interfaces/index.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export interface IMessage {
|
| 2 |
+
text: string;
|
| 3 |
+
sender: "user" | "bot";
|
| 4 |
+
}
|
| 5 |
+
|
| 6 |
+
export interface IChatScreenProps {
|
| 7 |
+
isOpen: boolean;
|
| 8 |
+
toggleSidebar: () => void;
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
export interface ISidebarProps {
|
| 12 |
+
isOpen: boolean;
|
| 13 |
+
toggleSidebar: () => void;
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
export interface IChat {
|
| 17 |
+
id: number;
|
| 18 |
+
name: string;
|
| 19 |
+
}
|