Skip to content

Commit e1ec0d5

Browse files
authored
Merge pull request #17 from apsinghdev/Feat/add-sidebar-canvas-components
Feat/add sidebar canvas components
2 parents 4e5bac1 + d4b40a9 commit e1ec0d5

File tree

6 files changed

+44
-33
lines changed

6 files changed

+44
-33
lines changed

client/src/App.css

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,6 @@
5555
width: 60%;
5656
margin-top: 20px;
5757
}
58-
59-
.canvas-container {
60-
display: flex;
61-
justify-content: center;
62-
align-items: center;
63-
height: 100%;
64-
width: 100%;
65-
}
66-
67-
.canvas {
68-
height: 100%;
69-
width: 86vw;
70-
background-color: rgb(212, 212, 13);
71-
}
7258

7359

7460

client/src/App.jsx

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import Header from "./components/Header";
88
import Toolbar from "./components/Toolbar";
99
import Socials from "./components/Socials";
1010
import LoginAndLogout from "./components/LoginAndLogout";
11+
import Sidebar from "./components/Sidebar";
12+
import Canvas from "./components/Canvas";
1113

1214
function App() {
1315
const canvasRef = useRef(null);
@@ -117,23 +119,13 @@ function App() {
117119
}
118120

119121
return (
120-
<div id="container" style={{ display: "flex" }}>
121-
<div
122-
id="sidebar"
123-
className="flex flex-col w-64 bg-zinc-800 relative"
122+
<div id="container">
123+
<Sidebar
124+
clearOnClick={clearOnClick}
124125
ref={sidebarRef}
125-
>
126-
<Header></Header>
127-
<Toolbar></Toolbar>
128-
<Socials></Socials>
129-
<button id="clear" onClick={clearOnClick}>
130-
Clear
131-
</button>
132-
<LoginAndLogout></LoginAndLogout>
133-
</div>
134-
<div className="canvas-container">
135-
<canvas className="canvas" ref={canvasRef}></canvas>
136-
</div>
126+
id="clear"
127+
></Sidebar>
128+
<Canvas canvasRef={canvasRef}></Canvas>
137129
</div>
138130
);
139131
}

client/src/components/Canvas.jsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* eslint-disable react/prop-types */
2+
function Canvas(props){
3+
return (
4+
<div className="flex justify-center items-center h-full w-80vw overflow-hidden">
5+
<canvas
6+
className="h-full w-86vw bg-yellow-600"
7+
ref={props.canvasRef}
8+
></canvas>
9+
</div>
10+
);
11+
}
12+
13+
export default Canvas;

client/src/components/ClearBtn.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
function ClearBtn(){
1+
/* eslint-disable react/prop-types */
2+
function ClearBtn(props){
23
return (
34
<div className="border block flex items-center justify-center mt-5">
45
<button
56
type="button"
67
className="text-white bg-gradient-to-r from-red-400 via-red-500 to-red-600 hover:bg-gradient-to-br font-medium rounded-lg text-sm px-5 py-2.5 text-center"
8+
onClick={props.clearOnClick}
9+
id={props.id}
710
>
811
Clear
912
</button>

client/src/components/Sidebar.jsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* eslint-disable react/prop-types */
2+
import Header from "./Header";
3+
import Toolbar from "./Toolbar";
4+
import LoginAndLogout from "./LoginAndLogout";
5+
6+
function Sidebar(props){
7+
return (
8+
<div className="flex flex-col w-64 bg-zinc-800 relative" ref={props.ref}>
9+
<Header></Header>
10+
<Toolbar clearOnClick={props.clearOnClick} id={props.id}></Toolbar>
11+
<LoginAndLogout></LoginAndLogout>
12+
</div>
13+
);
14+
}
15+
16+
export default Sidebar;

client/src/components/Toolbar.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
/* eslint-disable react/prop-types */
12
import ColorPicker from "./ColorPicker";
23
import StrokeWidthPicker from "./StrokeWidthPicker";
34
import ClearBtn from "./ClearBtn";
45

5-
function Toolbar(){
6+
function Toolbar(props){
67
return (
78
<div className="block w-full mt-20 border align-center">
89
<ColorPicker name="Colors :" defaultColor="#000000"></ColorPicker>
910
<ColorPicker name="Canvas :" defaultColor="#FFFFFF"></ColorPicker>
1011
<StrokeWidthPicker></StrokeWidthPicker>
11-
<ClearBtn></ClearBtn>
12+
<ClearBtn clearOnClick={props.clearOnClick} id={props.id}></ClearBtn>
1213
</div>
1314
);
1415
}

0 commit comments

Comments
 (0)