@@ -36,16 +36,43 @@ const ColourOffering = styled.li`
36
36
width: 40px;
37
37
background: blue;
38
38
` ;
39
+ const Input = styled . input `
40
+ border: none;
41
+ background: none;
42
+ padding: 20px;
43
+ &:focus {
44
+ outline: 0;
45
+ }
46
+ ` ;
39
47
40
- const Posit = ( { note, setPostitColour, removeNote, setCount, count } ) => {
48
+ const Posit = ( {
49
+ note,
50
+ setPostitColour,
51
+ removeNote,
52
+ toggleColourPicker,
53
+ isColorPickerShown,
54
+ isPostitActive,
55
+ handleInputChange,
56
+ highLightPostit
57
+ } ) => {
41
58
return (
42
- < Postit style = { { background : note . noteColour } } >
43
- < input value = { note . noteText } />
59
+ < Postit
60
+ style = { {
61
+ background : note . noteColour ,
62
+ border : isPostitActive ? "1px solid red" : "0"
63
+ } }
64
+ >
65
+ < Input
66
+ value = { note . noteText }
67
+ onChange = { handleInputChange }
68
+ onFocus = { ( ) => highLightPostit ( ! isPostitActive ) }
69
+ onBlur = { ( ) => highLightPostit ( ! isPostitActive ) }
70
+ />
44
71
< RemoveNote onClick = { ( ) => removeNote ( note . id ) } > Remove note</ RemoveNote >
45
- < ToggleListButton onClick = { ( ) => setCount ( ! count ) } >
72
+ < ToggleListButton onClick = { ( ) => toggleColourPicker ( ! isColorPickerShown ) } >
46
73
change color
47
74
</ ToggleListButton >
48
- { count && (
75
+ { isColorPickerShown && (
49
76
< ColourPicker >
50
77
< ColourOffering onClick = { ( ) => setPostitColour ( "yellow" ) } >
51
78
yellow
@@ -62,12 +89,17 @@ const Posit = ({ note, setPostitColour, removeNote, setCount, count }) => {
62
89
) ;
63
90
} ;
64
91
const enhance = compose (
65
- withState ( "count" , "setCount" , false ) ,
92
+ withState ( "isColorPickerShown" , "toggleColourPicker" , false ) ,
93
+ withState ( "isPostitActive" , "highLightPostit" , false ) ,
66
94
withHandlers ( {
67
95
setPostitColour : props => colour => {
68
96
props . updateNoteColour ( { id : props . note . id , noteColour : colour } ) ;
69
- props . setCount ( ) ;
70
- }
97
+ props . toggleColourPicker ( ) ;
98
+ } ,
99
+ handleInputChange : props => event => {
100
+ props . updateNoteText ( { id : props . note . id , noteText : event . value } ) ;
101
+ } ,
102
+ highLightPostIt : props => event => { }
71
103
} )
72
104
) ;
73
105
0 commit comments