Skip to content

New component #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added custom todo icons
  • Loading branch information
annapanana committed Mar 22, 2017
commit 0ee2d2ea0b2f3306b162f28cf04eb43b3c748fbb
18 changes: 18 additions & 0 deletions 3-flux/src/assets/icon_done.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions 3-flux/src/assets/icon_not_done.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions 3-flux/src/assets/icon_trash.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 11 additions & 5 deletions 3-flux/src/js/components/Todo.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,21 @@ export default class Todo extends React.Component {
super();
}

// Anna Code Start
removeTodo(e) {
// console.log(this.props.id);
//REMOVE BY ID
TodoActions.deleteTodo(this.props.id);
}

// Anna Code End
// const icon = complete ? "\u2714" : "\u2716"
render() {
const { complete, edit, text } = this.props;

const icon = complete ? "\u2714" : "\u2716"
const icon = complete ? "../../assets/icon_done.svg" : "../../assets/icon_not_done.svg";
const trash = "../../assets/icon_trash.svg";
const iconStyle = {
maxWidth: "50px",
padding: "5px"
};

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

return (
<li>
<button onClick={this.removeTodo.bind(this)}>{icon}</button>
<span><img style={iconStyle} src={icon} /></span>
<span onClick={this.removeTodo.bind(this)}><img style={iconStyle} src={trash} /></span>
<span>{text}</span>
</li>
);
Expand Down
7 changes: 6 additions & 1 deletion 3-flux/src/js/pages/Todos.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export default class Todos extends React.Component {
return <Todo key={todo.id} {...todo}/>;
});

const customUl = {
listStyle: "none",
paddingLeft: "0"
};

return (
<div>
<button onClick={this.reloadTodos.bind(this)}>Reload!</button>
Expand All @@ -60,7 +65,7 @@ export default class Todos extends React.Component {
<input type="text" value={this.state.newTodo} onChange={this.handleChange.bind(this)}/>
<button onClick={this.addTodo.bind(this)}>Add Todo</button>
</form>
<ul>{TodoComponents}</ul>
<ul style={customUl}>{TodoComponents}</ul>
</div>
);
}
Expand Down
6 changes: 3 additions & 3 deletions 3-flux/src/js/stores/TodoStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TodoStore extends EventEmitter {
{
id: 113464613,
text: "Go Shopping",
complete: false
complete: true
},
{
id: 235684679,
Expand All @@ -27,14 +27,14 @@ class TodoStore extends EventEmitter {
text,
complete: false,
});
this.emit("change");
// this.emit("change");
}

deleteTodo(id) {
this.todos = this.todos.filter((entry) => {
return entry.id !== id;
});
this.emit("change");
// this.emit("change");
}

getAll() {
Expand Down
4 changes: 4 additions & 0 deletions 3-flux/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict';
playNice() {

}