File tree Expand file tree Collapse file tree 6 files changed +48
-23
lines changed Expand file tree Collapse file tree 6 files changed +48
-23
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ function App() {
107
107
}
108
108
109
109
function addStroke ( e ) {
110
- if ( e . target . id === "stroke " ) {
110
+ if ( e . target . id === "penColor " ) {
111
111
const newColor = e . target . value ;
112
112
color = newColor ;
113
113
ctx . strokeStyle = newColor ;
@@ -125,14 +125,16 @@ function App() {
125
125
return (
126
126
< div id = "container" >
127
127
< Sidebar
128
+ addStroke = { addStroke }
129
+
128
130
addLineWidth = { addLineWidth }
129
131
clearOnClick = { clearOnClick }
130
132
ref = { sidebarRef }
131
133
id = "clear"
132
134
toggleMenu = { toggleMenu }
133
135
> </ Sidebar >
134
136
< Canvas canvasRef = { canvasRef } > </ Canvas >
135
- { showMenu && < Menu > </ Menu > }
137
+ { showMenu && < Menu > </ Menu > }
136
138
</ div >
137
139
) ;
138
140
}
Original file line number Diff line number Diff line change
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 ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
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 ;
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ function Sidebar(props){
14
14
clearOnClick = { props . clearOnClick }
15
15
id = { props . id }
16
16
addLineWidth = { props . addLineWidth }
17
+ addStroke = { props . addStroke }
17
18
> </ Toolbar >
18
19
< LoginAndLogout > </ LoginAndLogout >
19
20
</ div >
Original file line number Diff line number Diff line change 1
1
/* eslint-disable react/prop-types */
2
- import ColorPicker from "./ColorPicker" ;
3
2
import StrokeWidthPicker from "./StrokeWidthPicker" ;
4
3
import ClearBtn from "./ClearBtn" ;
5
4
import Eraser from "./Eraser" ;
5
+ import CanvasColor from "./CanvasColor" ;
6
+ import PenColor from "./PenColor" ;
6
7
7
8
function Toolbar ( props ) {
8
9
return (
9
10
< 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 >
12
13
< Eraser > </ Eraser >
13
- < StrokeWidthPicker addLineWidth = { props . addLineWidth } > </ StrokeWidthPicker >
14
+ < StrokeWidthPicker
15
+ addLineWidth = { props . addLineWidth }
16
+ > </ StrokeWidthPicker >
14
17
< ClearBtn clearOnClick = { props . clearOnClick } id = { props . id } > </ ClearBtn >
15
18
</ div >
16
19
) ;
You can’t perform that action at this time.
0 commit comments