File tree Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -8,4 +8,9 @@ export const eraserState = atom({
8
8
export const cursorPosition = atom ( {
9
9
key : "cursor-position" ,
10
10
default : { x : 0 , y : 0 }
11
- } )
11
+ } )
12
+
13
+ export const canvasColors = atom ( {
14
+ key : "canvasColor" ,
15
+ default : "#D2B55B" ,
16
+ } ) ;
Original file line number Diff line number Diff line change 1
1
/* eslint-disable react/prop-types */
2
2
import Menu from "./Menu" ;
3
+ import { useRecoilValue } from "recoil" ;
4
+ import { canvasColors } from "../atoms" ;
3
5
4
6
function Canvas ( props ) {
7
+ const canvasColor = useRecoilValue ( canvasColors ) ;
5
8
return (
6
9
< div className = "flex justify-center items-center h-full w-80vw overflow-hidden" >
7
10
< canvas
8
- className = "h-full w-86vw bg-yellow-600"
11
+ className = "h-full w-86vw"
12
+ style = { { backgroundColor : `${ canvasColor } ` } }
9
13
ref = { props . canvasRef }
10
14
> </ canvas >
11
15
{ props . showMenu && < Menu > </ Menu > }
Original file line number Diff line number Diff line change 1
1
/* eslint-disable react/prop-types */
2
+ import { useRecoilState } from "recoil" ;
3
+ import { canvasColors } from "../atoms" ;
4
+
5
+
2
6
function CanvasColor ( props ) {
7
+
8
+ const [ canvasColor , setCanvasColor ] = useRecoilState ( canvasColors ) ;
9
+
10
+ function changeHandler ( e ) {
11
+ setCanvasColor ( e . target . value ) ;
12
+ }
13
+
3
14
return (
4
15
< div className = "flex p-1 items-center justify-around mt-3" >
5
16
< h1 className = "font-sans text-lg antialiased font-semibold text-white" >
6
17
{ props . name }
7
18
</ h1 >
8
19
< input
9
20
type = "color"
10
- value = { props . defaultColor }
21
+ value = { canvasColor }
22
+ onChange = { changeHandler }
11
23
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
24
> </ input >
13
25
</ div >
You can’t perform that action at this time.
0 commit comments