Skip to content

Commit c4eee11

Browse files
committed
complete UI of drawing board
1 parent be9f5fd commit c4eee11

File tree

3 files changed

+116
-27
lines changed

3 files changed

+116
-27
lines changed

client/src/App.css

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
2+
#root {
3+
max-width: 1280px;
4+
margin: 0 auto;
5+
padding: 2rem;
6+
height: 70vh;
7+
width: 100vh;
8+
/* text-align: center; */
9+
}
10+
11+
#sidebar * {
12+
margin-bottom: 6px;
13+
}
14+
15+
#sidebar h1 {
16+
margin-top: '20px';
17+
background: #7F7FD5;
18+
background: -webkit-linear-gradient(to right, #91EAE4, #86A8E7, #7F7FD5);
19+
background: linear-gradient(to right, #91EAE4, #86A8E7, #7F7FD5);
20+
background-clip: text;
21+
-webkit-background-clip: text;
22+
-webkit-text-fill-color: transparent;
23+
}
24+
25+
#linewidth{
26+
margin-top: 10px !important;
27+
}
28+
29+
#container{
30+
height: 100%;
31+
display: flex;
32+
width: 100%;
33+
}
34+
35+
#sidebar{
36+
display: flex;
37+
flex-direction: column;
38+
padding: 5px;
39+
width: 250px;
40+
background-color: #202020;
41+
padding-left: 15px;
42+
}
43+
.input-container {
44+
display: block;
45+
margin-top: 40px;
46+
}
47+
48+
.input-container label {
49+
display: block;
50+
color: white;
51+
}
52+
53+
.input-container input {
54+
display: block;
55+
width: 60%;
56+
}
57+
58+
#clear {
59+
display: block;
60+
width: 60%;
61+
margin-top: 20px;
62+
}
63+
64+
.canvas-container {
65+
display: flex;
66+
justify-content: center;
67+
align-items: center;
68+
height: 100%;
69+
width: 100%;
70+
}
71+
72+
.canvas {
73+
height: 100%;
74+
width: 100%;
75+
border: 0px solid black;
76+
box-shadow: 0 0 4px #000;
77+
}
78+
79+
/* #colorpicker{
80+
margin-top: '40px';
81+
} */
82+
83+

client/src/App.jsx

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useEffect, useRef } from "react";
2+
import './App.css'
23

34
function App() {
45
const canvasRef = useRef(null);
@@ -20,19 +21,18 @@ function App() {
2021
}
2122

2223
function handleMouseover(e) {
23-
if(isDrawing){
24-
const endX = e.clientX-canvas.getBoundingClientRect().left;
25-
const endY = e.clientY-canvas.getBoundingClientRect().top;
26-
drawLine(startX, startY, endX, endY);
27-
startX = endX;
28-
startY = endY;
29-
}
24+
if (!isDrawing) return;
25+
const endX = e.clientX - canvas.getBoundingClientRect().left;
26+
const endY = e.clientY - canvas.getBoundingClientRect().top;
27+
drawLine(startX, startY, endX, endY);
28+
startX = endX;
29+
startY = endY;
3030
}
3131

3232
function handleMousedown(e) {
3333
isDrawing = true;
34-
startX = e.clientX-canvas.getBoundingClientRect().left;
35-
startY = e.clientY-canvas.getBoundingClientRect().top;
34+
startX = e.clientX - canvas.getBoundingClientRect().left;
35+
startY = e.clientY - canvas.getBoundingClientRect().top;
3636
}
3737
function handleMouseup(e) {
3838
isDrawing = false;
@@ -50,25 +50,24 @@ function App() {
5050
}, []);
5151

5252
return (
53-
<div
54-
style={{
55-
display: "flex",
56-
justifyContent: "center",
57-
alignItems: "center",
58-
height: "700px",
59-
width: "100%",
60-
}}
61-
>
62-
<canvas
63-
style={{
64-
height: "70vh",
65-
width: "70vh",
66-
border: "0px solid black",
67-
boxShadow: "0 0 4px #000",
68-
}}
69-
ref={canvasRef}
70-
></canvas>
53+
<div id="container" style={{ display: 'flex' }}>
54+
<div id="sidebar">
55+
<h1 id="drawRTC">drawRTC</h1>
56+
<div className="input-container" id='colorpicker'>
57+
<label htmlFor="stroke">Stroke</label>
58+
<input id="stroke" name="stroke" type="color" />
7159
</div>
60+
<div className="input-container" id='linewidth'>
61+
<label htmlFor="lineWidth">Line Width</label>
62+
<input id="lineWidth" name="lineWidth" type="number" value="5" />
63+
</div>
64+
<button id="clear">Clear</button>
65+
</div>
66+
<div className="canvas-container">
67+
<canvas className="canvas" ref={canvasRef}></canvas>
68+
</div>
69+
</div>
70+
7271
);
7372
}
7473

client/src/index.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
body {
2+
margin: 0;
3+
display: flex;
4+
place-items: center;
5+
min-width: 320px;
6+
min-height: 100vh;
7+
}

0 commit comments

Comments
 (0)