Skip to content

Commit 3b32300

Browse files
committed
implement colorpicker and strokePicker components
1 parent fdab9c2 commit 3b32300

File tree

5 files changed

+53
-18
lines changed

5 files changed

+53
-18
lines changed

client/src/App.jsx

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

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

77
import Header from "./components/Header";
8+
import Toolbar from "./components/Toolbar";
89

910
function App() {
1011
const canvasRef = useRef(null);
@@ -117,25 +118,12 @@ function App() {
117118
<div id="container" style={{ display: "flex" }}>
118119
<div
119120
id="sidebar"
120-
className="flex flex-col w-64 bg-gray-900"
121+
className="flex flex-col w-64 bg-zinc-800"
121122
ref={sidebarRef}
122123
>
123124
<Header></Header>
124-
<h1 id="drawRTC">drawRTC</h1>
125-
<div className="input-container" id="colorpicker">
126-
<label htmlFor="stroke">Stroke</label>
127-
<input id="stroke" name="stroke" type="color" onChange={addStroke} />
128-
</div>
129-
<div className="input-container" id="linewidth">
130-
<label htmlFor="lineWidth">Line Width</label>
131-
<input
132-
id="lineWidth"
133-
name="lineWidth"
134-
type="number"
135-
defaultValue="3"
136-
onChange={addLineWidth}
137-
/>
138-
</div>
125+
<Toolbar></Toolbar>
126+
139127
<button id="clear" onClick={clearOnClick}>
140128
Clear
141129
</button>

client/src/components/ColorPicker.jsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* eslint-disable react/prop-types */
2+
function ColorPicker(props){
3+
return (
4+
<div className="flex p-1 items-center justify-around">
5+
<h1 className="font-sans text-lg antialiased font-semibold text-white">
6+
{props.name}
7+
</h1>
8+
<input
9+
type="color"
10+
value={props.defaultColor}
11+
className="p-1 h-10 w-14 block bg-white border border-gray-800 cursor-pointer rounded-lg disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-800 dark:border-neutral-700"
12+
></input>
13+
</div>
14+
);
15+
}
16+
17+
export default ColorPicker;

client/src/components/Header.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { FaBars } from "react-icons/fa";
22

33
function Header() {
44
return (
5-
<div className="flex border-b-2 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">
5+
<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">
66
<h1 className="font-sans text-2xl antialiased font-extrabold text-white">
77
drawRTC
88
</h1>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function StrokeWidthPicker(){
2+
return (
3+
<div className="flex p-1 items-center justify-around">
4+
<h1 className="font-sans text-lg antialiased font-semibold text-white">
5+
Stroke :
6+
</h1>
7+
<input
8+
type="number"
9+
placeholder="2"
10+
defaultValue={2}
11+
className="w-12 p-1 h-7 block border border-gray-800 cursor-pointer rounded-lg"
12+
></input>
13+
</div>
14+
);
15+
}
16+
17+
export default StrokeWidthPicker;

client/src/components/Toolbar.jsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import ColorPicker from "./ColorPicker";
2+
import StrokeWidthPicker from "./StrokeWidthPicker";
3+
4+
function Toolbar(){
5+
return (
6+
<div className="block w-full mt-20">
7+
<ColorPicker name="Colors :" defaultColor="#000000"></ColorPicker>
8+
<ColorPicker name="Canvas :" defaultColor="#FFFFFF"></ColorPicker>
9+
<StrokeWidthPicker></StrokeWidthPicker>
10+
</div>
11+
);
12+
}
13+
export default Toolbar;

0 commit comments

Comments
 (0)