Skip to content

Commit 0023eb8

Browse files
committed
now handles input
1 parent 0155a55 commit 0023eb8

File tree

4 files changed

+48
-10
lines changed

4 files changed

+48
-10
lines changed

src/components/Pinboard.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const Postits = styled.ul`
1212
const Pinboard = props => {
1313
const newNote = function(noteId) {
1414
return {
15-
noteText: "",
15+
noteText: "Another new note",
1616
noteColour: "yellow",
1717
id: noteId,
1818
x: 100,

src/components/Postit.js

+40-8
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,43 @@ const ColourOffering = styled.li`
3636
width: 40px;
3737
background: blue;
3838
`;
39+
const Input = styled.input`
40+
border: none;
41+
background: none;
42+
padding: 20px;
43+
&:focus {
44+
outline: 0;
45+
}
46+
`;
3947

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+
}) => {
4158
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+
/>
4471
<RemoveNote onClick={() => removeNote(note.id)}>Remove note</RemoveNote>
45-
<ToggleListButton onClick={() => setCount(!count)}>
72+
<ToggleListButton onClick={() => toggleColourPicker(!isColorPickerShown)}>
4673
change color
4774
</ToggleListButton>
48-
{count && (
75+
{isColorPickerShown && (
4976
<ColourPicker>
5077
<ColourOffering onClick={() => setPostitColour("yellow")}>
5178
yellow
@@ -62,12 +89,17 @@ const Posit = ({ note, setPostitColour, removeNote, setCount, count }) => {
6289
);
6390
};
6491
const enhance = compose(
65-
withState("count", "setCount", false),
92+
withState("isColorPickerShown", "toggleColourPicker", false),
93+
withState("isPostitActive", "highLightPostit", false),
6694
withHandlers({
6795
setPostitColour: props => colour => {
6896
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 => {}
71103
})
72104
);
73105

src/index.css

+6
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@ body {
44
font-family: sans-serif;
55
background: aquamarine;
66
}
7+
8+
*,
9+
*:after,
10+
*:before {
11+
box-sizing: border-box;
12+
}

src/reducers/reducer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as types from "../constants/actionTypes";
22

33
const initialState = {
4-
notes: [{ noteText: "hello", id: 5, noteColour: "yellow" }],
4+
notes: [{ noteText: "A new note", id: 5, noteColour: "yellow" }],
55
loading: false,
66
currentLocation: "home"
77
};

0 commit comments

Comments
 (0)