1- import { Box } from "@chakra-ui/layout" ;
1+ import SplitPane from "react-split-pane" ;
2+ import { Box , useBreakpointValue , Drawer , DrawerOverlay , DrawerContent , DrawerBody , IconButton } from "@chakra-ui/react" ;
23import { useState } from "react" ;
4+ import { FiMenu } from "react-icons/fi" ;
35import Chatbox from "../components/Chatbox" ;
46import MyChats from "../components/MyChats" ;
57import SideDrawer from "../components/miscellaneous/SideDrawer" ;
@@ -10,20 +12,62 @@ import "./chat.css";
1012const Chatpage = ( ) => {
1113 const [ fetchAgain , setFetchAgain ] = useState ( false ) ;
1214 const { user } = ChatState ( ) ;
15+ const [ isDrawerOpen , setDrawerOpen ] = useState ( false ) ;
16+
17+ // Responsive mode: "mobile", "medium", "large"
18+ const mode = useBreakpointValue ( {
19+ base : "mobile" ,
20+ md : "medium" ,
21+ lg : "large" ,
22+ } ) ;
1323
1424 return (
15- < div className = "chats-sec" style = { { width : "100%" , height :"100%" } } >
25+ < div className = "chats-sec" style = { { width : "100%" , height : "100vh" } } >
1626 { /* {user && <SideDrawer />} */ }
17- < div className = "chat-main" >
18- < div className = "sidebar" >
19- { user && < MyChats fetchAgain = { fetchAgain } /> }
20- </ div >
21- < div className = "chatting" >
22- { user && (
23- < Chatbox fetchAgain = { fetchAgain } setFetchAgain = { setFetchAgain } />
24- ) }
25- </ div >
26- </ div >
27+
28+ { ( mode === "mobile" || mode === "medium" ) && (
29+ < >
30+ < IconButton
31+ icon = { < FiMenu /> }
32+ aria-label = "Open My Chats"
33+ position = "fixed"
34+ top = { 4 }
35+ left = { 4 }
36+ zIndex = { 2000 }
37+ onClick = { ( ) => setDrawerOpen ( true ) }
38+ colorScheme = "blue"
39+ />
40+ < Drawer isOpen = { isDrawerOpen } placement = "left" onClose = { ( ) => setDrawerOpen ( false ) } >
41+ < DrawerOverlay />
42+ < DrawerContent bg = "#0f1924" maxWidth = { "60vw" } width = "60vw" >
43+ < DrawerBody >
44+ { user && < MyChats fetchAgain = { fetchAgain } /> }
45+ </ DrawerBody >
46+ </ DrawerContent >
47+ </ Drawer >
48+ < Box className = "chatting" w = "100%" h = "100vh" >
49+ { user && < Chatbox fetchAgain = { fetchAgain } setFetchAgain = { setFetchAgain } /> }
50+ </ Box >
51+ </ >
52+ ) }
53+
54+ { mode === "large" && (
55+ < SplitPane
56+ split = "vertical"
57+ minSize = { 200 }
58+ defaultSize = { 550 }
59+ style = { { height : "100vh" } }
60+ >
61+ < div className = "sidebar" style = { { background : "#0f1924" , height : "100%" , overflowX : "hidden" } } >
62+ { user && < MyChats fetchAgain = { fetchAgain } /> }
63+ </ div >
64+ < div className = "chatting" >
65+ { user && (
66+ < Chatbox fetchAgain = { fetchAgain } setFetchAgain = { setFetchAgain } />
67+ ) }
68+ </ div >
69+ </ SplitPane >
70+ ) }
2771 </ div >
2872 ) ;
2973} ;
0 commit comments