Skip to content

Commit 0ee2d2e

Browse files
committed
added custom todo icons
1 parent 6153ab4 commit 0ee2d2e

File tree

7 files changed

+78
-9
lines changed

7 files changed

+78
-9
lines changed

3-flux/src/assets/icon_done.svg

Lines changed: 18 additions & 0 deletions
Loading

3-flux/src/assets/icon_not_done.svg

Lines changed: 18 additions & 0 deletions
Loading

3-flux/src/assets/icon_trash.svg

Lines changed: 18 additions & 0 deletions
Loading

3-flux/src/js/components/Todo.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,21 @@ export default class Todo extends React.Component {
77
super();
88
}
99

10+
// Anna Code Start
1011
removeTodo(e) {
11-
// console.log(this.props.id);
12-
//REMOVE BY ID
1312
TodoActions.deleteTodo(this.props.id);
1413
}
15-
14+
// Anna Code End
15+
// const icon = complete ? "\u2714" : "\u2716"
1616
render() {
1717
const { complete, edit, text } = this.props;
1818

19-
const icon = complete ? "\u2714" : "\u2716"
19+
const icon = complete ? "../../assets/icon_done.svg" : "../../assets/icon_not_done.svg";
20+
const trash = "../../assets/icon_trash.svg";
21+
const iconStyle = {
22+
maxWidth: "50px",
23+
padding: "5px"
24+
};
2025

2126
if (edit) {
2227
return (
@@ -28,7 +33,8 @@ export default class Todo extends React.Component {
2833

2934
return (
3035
<li>
31-
<button onClick={this.removeTodo.bind(this)}>{icon}</button>
36+
<span><img style={iconStyle} src={icon} /></span>
37+
<span onClick={this.removeTodo.bind(this)}><img style={iconStyle} src={trash} /></span>
3238
<span>{text}</span>
3339
</li>
3440
);

3-flux/src/js/pages/Todos.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ export default class Todos extends React.Component {
5252
return <Todo key={todo.id} {...todo}/>;
5353
});
5454

55+
const customUl = {
56+
listStyle: "none",
57+
paddingLeft: "0"
58+
};
59+
5560
return (
5661
<div>
5762
<button onClick={this.reloadTodos.bind(this)}>Reload!</button>
@@ -60,7 +65,7 @@ export default class Todos extends React.Component {
6065
<input type="text" value={this.state.newTodo} onChange={this.handleChange.bind(this)}/>
6166
<button onClick={this.addTodo.bind(this)}>Add Todo</button>
6267
</form>
63-
<ul>{TodoComponents}</ul>
68+
<ul style={customUl}>{TodoComponents}</ul>
6469
</div>
6570
);
6671
}

3-flux/src/js/stores/TodoStore.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class TodoStore extends EventEmitter {
99
{
1010
id: 113464613,
1111
text: "Go Shopping",
12-
complete: false
12+
complete: true
1313
},
1414
{
1515
id: 235684679,
@@ -27,14 +27,14 @@ class TodoStore extends EventEmitter {
2727
text,
2828
complete: false,
2929
});
30-
this.emit("change");
30+
// this.emit("change");
3131
}
3232

3333
deleteTodo(id) {
3434
this.todos = this.todos.filter((entry) => {
3535
return entry.id !== id;
3636
});
37-
this.emit("change");
37+
// this.emit("change");
3838
}
3939

4040
getAll() {

3-flux/test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
'use strict';
2+
playNice() {
3+
4+
}

0 commit comments

Comments
 (0)