-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathTodo.js
More file actions
45 lines (37 loc) · 963 Bytes
/
Todo.js
File metadata and controls
45 lines (37 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import React from "react";
import * as TodoActions from "../actions/TodoActions";
export default class Todo extends React.Component {
constructor(props) {
super();
}
deleteTodo(e) {
TodoActions.deleteTodo(this.props.id);
}
render() {
const { complete, edit, text } = this.props;
const icon = complete ? "../../assets/icon_done.svg" : "../../assets/icon_not_done.svg";
const trash = "../../assets/icon_trash.svg";
const iconStyle = {
maxWidth: "50px",
padding: "5px"
};
const checkboxStyle = {
maxWidth: "50px",
padding: "10px"
}
if (edit) {
return (
<li>
<input value={text} focus="focused"/>
</li>
);
}
return (
<li>
<span><img style={checkboxStyle} src={icon} /></span>
<span onClick={this.deleteTodo.bind(this)}><img style={iconStyle} src={trash} /></span>
<span>{text}</span>
</li>
);
}
}