Skip to content

Commit 49073be

Browse files
authored
Merge pull request #26 from apsinghdev/Feat/add-strokeColor-functionality
Feat/add stroke color functionality
2 parents 592ff51 + 4682fd6 commit 49073be

File tree

6 files changed

+48
-23
lines changed

6 files changed

+48
-23
lines changed

client/src/App.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function App() {
107107
}
108108

109109
function addStroke(e) {
110-
if (e.target.id === "stroke") {
110+
if (e.target.id === "penColor") {
111111
const newColor = e.target.value;
112112
color = newColor;
113113
ctx.strokeStyle = newColor;
@@ -125,14 +125,16 @@ function App() {
125125
return (
126126
<div id="container">
127127
<Sidebar
128+
addStroke={addStroke}
129+
128130
addLineWidth={addLineWidth}
129131
clearOnClick={clearOnClick}
130132
ref={sidebarRef}
131133
id="clear"
132134
toggleMenu={toggleMenu}
133135
></Sidebar>
134136
<Canvas canvasRef={canvasRef}></Canvas>
135-
{ showMenu && <Menu></Menu>}
137+
{showMenu && <Menu></Menu>}
136138
</div>
137139
);
138140
}

client/src/components/CanvasColor.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 CanvasColor(props) {
3+
return (
4+
<div className="flex p-1 items-center justify-around mt-3">
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-10 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 CanvasColor;

client/src/components/ColorPicker.jsx

Lines changed: 0 additions & 17 deletions
This file was deleted.

client/src/components/PenColor.jsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* eslint-disable react/prop-types */
2+
function PenColor(props) {
3+
return (
4+
<div className="flex p-1 items-center justify-around mt-3">
5+
<h1 className="font-sans text-lg antialiased font-semibold text-white">
6+
{props.name}
7+
</h1>
8+
<input
9+
id="penColor"
10+
type="color"
11+
onChange={props.addStroke}
12+
value={props.defaultColor}
13+
className="p-1 h-10 w-10 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"
14+
></input>
15+
</div>
16+
);
17+
}
18+
19+
export default PenColor;

client/src/components/Sidebar.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ function Sidebar(props){
1414
clearOnClick={props.clearOnClick}
1515
id={props.id}
1616
addLineWidth={props.addLineWidth}
17+
addStroke={props.addStroke}
1718
></Toolbar>
1819
<LoginAndLogout></LoginAndLogout>
1920
</div>

client/src/components/Toolbar.jsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
/* eslint-disable react/prop-types */
2-
import ColorPicker from "./ColorPicker";
32
import StrokeWidthPicker from "./StrokeWidthPicker";
43
import ClearBtn from "./ClearBtn";
54
import Eraser from "./Eraser";
5+
import CanvasColor from "./CanvasColor";
6+
import PenColor from "./PenColor";
67

78
function Toolbar(props){
89
return (
910
<div className="block w-full mt-20 align-center">
10-
<ColorPicker name="Colors :" defaultColor="#000000"></ColorPicker>
11-
<ColorPicker name="Canvas :" defaultColor="#FFFFFF"></ColorPicker>
11+
<PenColor addStroke={props.addStroke} name="Color :"></PenColor>
12+
<CanvasColor name="Canvas :"></CanvasColor>
1213
<Eraser></Eraser>
13-
<StrokeWidthPicker addLineWidth={props.addLineWidth} ></StrokeWidthPicker>
14+
<StrokeWidthPicker
15+
addLineWidth={props.addLineWidth}
16+
></StrokeWidthPicker>
1417
<ClearBtn clearOnClick={props.clearOnClick} id={props.id}></ClearBtn>
1518
</div>
1619
);

0 commit comments

Comments
 (0)