Skip to content

Commit 2c75109

Browse files
committed
Implement position and size of the Menu
1 parent 88a5a47 commit 2c75109

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

client/src/App.jsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1-
import { useEffect, useRef } from "react";
1+
import { useEffect, useRef, useState } from "react";
22
import "./App.css";
33
import { io } from "socket.io-client";
44

55
const socket = io("http://localhost:8000");
66

77
import Sidebar from "./components/Sidebar";
88
import Canvas from "./components/Canvas";
9+
import Menu from "./components/Menu";
910

1011
function App() {
12+
13+
const [showMenu, setShowMenu ] = useState(false);
14+
15+
function toggleMenu(){
16+
setShowMenu(!showMenu);
17+
}
18+
1119
const canvasRef = useRef(null);
1220
const sidebarRef = useRef(null);
1321
let color = '#000000'
@@ -120,8 +128,10 @@ function App() {
120128
clearOnClick={clearOnClick}
121129
ref={sidebarRef}
122130
id="clear"
131+
toggleMenu={toggleMenu}
123132
></Sidebar>
124133
<Canvas canvasRef={canvasRef}></Canvas>
134+
{ showMenu && <Menu></Menu>}
125135
</div>
126136
);
127137
}

client/src/components/Canvas.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
/* eslint-disable react/prop-types */
2+
import Menu from "./Menu";
3+
24
function Canvas(props){
35
return (
46
<div className="flex justify-center items-center h-full w-80vw overflow-hidden">
57
<canvas
68
className="h-full w-86vw bg-yellow-600"
79
ref={props.canvasRef}
810
></canvas>
11+
{props.showMenu && <Menu></Menu>}
912
</div>
1013
);
1114
}

client/src/components/Header.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
/* eslint-disable react/prop-types */
12
import { FaBars } from "react-icons/fa";
23

3-
function Header() {
4+
function Header(props) {
45
return (
56
<div className="flex py-5 justify-around bg-gradient-to-r from-indigo-500 from-10% via-sky-500 via-30% to-emerald-500 to-90% w-full items-center">
67
<h1 className="font-sans text-2xl antialiased font-extrabold text-white">
78
drawRTC
89
</h1>
910
<div className="" id="options">
10-
<FaBars size={25} />
11+
<FaBars size={25} onClick={props.toggleMenu}/>
1112
</div>
1213
</div>
1314
);

client/src/components/Menu.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Socials from "./Socials";
33

44
function Menu(){
55
return (
6-
<div className="w-20 h-auto bg-white z-100">
6+
<div className="w-52 h-56 bg-green-500 absolute left-52 top-8 rounded-lg shadow-xl">
77
<MenuItem feat="Start Collaboration"></MenuItem>
88
<MenuItem feat="Start Chat"></MenuItem>
99
<MenuItem feat="Save as pdf"></MenuItem>

client/src/components/Sidebar.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import LoginAndLogout from "./LoginAndLogout";
66
function Sidebar(props){
77
return (
88
<div className="flex flex-col w-64 bg-zinc-800 relative" ref={props.ref}>
9-
<Header></Header>
9+
<Header toggleMenu={props.toggleMenu}></Header>
1010
<Toolbar clearOnClick={props.clearOnClick} id={props.id}></Toolbar>
1111
<LoginAndLogout></LoginAndLogout>
1212
</div>

0 commit comments

Comments
 (0)