diff --git a/frontend/components/App.js b/frontend/components/App.js
index 38b7a2f5..54548433 100644
--- a/frontend/components/App.js
+++ b/frontend/components/App.js
@@ -1,11 +1,75 @@
-import React from 'react'
+import React from 'react';
+import TodoList from './TodoList';
+import Form from './Form';
+
+const todoList = [
+ {
+ name: 'Brush Teeth',
+ id: new Date().getTime(),
+ completed: false
+ }
+];
export default class App extends React.Component {
+ constructor(){
+ super();
+ this.state = {
+ todoList: todoList,
+ inputValue: '',
+ hideCompleted: false
+ }
+ }
+
+ toggleHidden = ()=>{
+ this.setState({
+ ...this.state,
+ hideCompleted: !this.state.hideCompleted
+ })
+
+ }
+
+ toggleCompleted = (itemId)=>{
+ this.setState({
+ todoList: this.state.todoList.map(item => {
+ if(itemId === item.id) {
+ return {
+ ...item,
+ completed: !item.completed
+ };
+ };
+ return {...item};
+ })
+ });
+ };
+
+ inputChange = (e)=>{
+ this.setState({
+ ...this.state,
+ inputValue: e.target.value
+ })
+ }
+
+ handleSubmit = (e)=>{
+ e.preventDefault();
+ const newListItem = {
+ name: this.state.inputValue,
+ id: new Date().getTime(),
+ completed: false
+ }
+ this.setState({
+ ...this.state,
+ todoList: [...this.state.todoList, newListItem],
+ inputValue: ''
+ })
+ }
+
render() {
return (
-
- Todo App
+
+
+
+
)
}
-}
+};
diff --git a/frontend/components/Form.js b/frontend/components/Form.js
index 30fbc48d..1e4da403 100644
--- a/frontend/components/Form.js
+++ b/frontend/components/Form.js
@@ -3,9 +3,13 @@ import React from 'react'
export default class Form extends React.Component {
render() {
return (
-
- Form
-
+
)
}
}
diff --git a/frontend/components/Todo.js b/frontend/components/Todo.js
index ca86f981..3fe78ebd 100644
--- a/frontend/components/Todo.js
+++ b/frontend/components/Todo.js
@@ -1,10 +1,18 @@
-import React from 'react'
+import React, {useEffect} from 'react'
export default class Todo extends React.Component {
+ constructor(){
+ super();
+ }
render() {
return (
-
- Todo
+
this.props.toggleCompleted(this.props.todoItem.id)}
+ >
+ {this.props.todoItem.name}{this.props.todoItem.completed ? ' ✓' : ''}
+
+
)
}
diff --git a/frontend/components/TodoList.js b/frontend/components/TodoList.js
index 95410373..caafa7d6 100644
--- a/frontend/components/TodoList.js
+++ b/frontend/components/TodoList.js
@@ -1,10 +1,20 @@
-import React from 'react'
+import React from 'react';
+import Todo from './Todo';
export default class TodoList extends React.Component {
+ constructor(){
+ super();
+ }
+
render() {
return (
-
- TodoList
+
+ Todos:
+
+
+ {this.props.todoItems.map(item => {
+ return
+ })}
)
}
diff --git a/frontend/styles/styles.css b/frontend/styles/styles.css
index fda8a420..58e057e3 100644
--- a/frontend/styles/styles.css
+++ b/frontend/styles/styles.css
@@ -83,3 +83,11 @@ ul, form {
.todo:hover {
cursor: pointer;
}
+
+.list-item {
+ margin-left: 1rem;
+}
+
+.hidden {
+ display: none;
+}
\ No newline at end of file