From 06b16944a54804a64b43c936d51de8422faedba7 Mon Sep 17 00:00:00 2001 From: hursuhyun Date: Fri, 17 Sep 2021 20:12:38 +0900 Subject: [PATCH 1/5] added todolist --- src/App.js | 3 ++- src/components/Todo/Todo.js | 18 ++++++++++++++++++ src/containers/TodoList/TodoList.js | 29 +++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/App.js b/src/App.js index e358583..0a0545e 100644 --- a/src/App.js +++ b/src/App.js @@ -1,10 +1,11 @@ import React from 'react'; -import logo from './logo.svg'; import './App.css'; +import TodoList from './containers/TodoList/TodoList'; function App() { return (
+
); } diff --git a/src/components/Todo/Todo.js b/src/components/Todo/Todo.js index e69de29..ddae302 100644 --- a/src/components/Todo/Todo.js +++ b/src/components/Todo/Todo.js @@ -0,0 +1,18 @@ +import React from 'react'; + +import './Todo.css'; + +const Todo = (props) => { + return ( +
+
+ {props.title} +
+ {props.done &&
} +
+ ); +}; + +export default Todo; \ No newline at end of file diff --git a/src/containers/TodoList/TodoList.js b/src/containers/TodoList/TodoList.js index e69de29..3e4d903 100644 --- a/src/containers/TodoList/TodoList.js +++ b/src/containers/TodoList/TodoList.js @@ -0,0 +1,29 @@ +import React, { Component } from 'react'; + +import Todo from '../../components/Todo/Todo'; +import './TodoList.css'; + +class TodoList extends Component { + state = { + todos: [ + { id: 1, title: 'SWPP', content: 'take swpp class', done: true }, + { id: 2, title: 'Movie', content: 'watch movie', done: false }, + { id: 3, title: 'Dinner', content: 'eat dinner', done: false } + ], + } + + render(){ + const todos = this.state.todos.map((td) => { + return (); + }); + return ( +
+
{this.props.title}
+
{todos}
+
+ ) + } +} + + +export default TodoList; \ No newline at end of file From 86af5adea6c40fec53eb825eaa945427ada30de1 Mon Sep 17 00:00:00 2001 From: hursuhyun Date: Fri, 17 Sep 2021 20:40:14 +0900 Subject: [PATCH 2/5] added details --- src/components/TodoDetail/TodoDetail.js | 29 ++++++++++++++++++++++++ src/containers/TodoList/TodoList.js | 30 +++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/src/components/TodoDetail/TodoDetail.js b/src/components/TodoDetail/TodoDetail.js index e69de29..02b5d83 100644 --- a/src/components/TodoDetail/TodoDetail.js +++ b/src/components/TodoDetail/TodoDetail.js @@ -0,0 +1,29 @@ +import React from 'react'; +import './TodoDetail.css'; + +const TodoDetail = (props) => { + return( +
+
+
+ Name: +
+
+ {props.title} +
+
+ +
+
+ Content: +
+
+ {props.content} +
+
+ +
+ ) +} + +export default TodoDetail; \ No newline at end of file diff --git a/src/containers/TodoList/TodoList.js b/src/containers/TodoList/TodoList.js index 3e4d903..8a80c1c 100644 --- a/src/containers/TodoList/TodoList.js +++ b/src/containers/TodoList/TodoList.js @@ -2,6 +2,8 @@ import React, { Component } from 'react'; import Todo from '../../components/Todo/Todo'; import './TodoList.css'; +import TodoDetail from '../../components/TodoDetail/TodoDetail'; + class TodoList extends Component { state = { @@ -10,16 +12,40 @@ class TodoList extends Component { { id: 2, title: 'Movie', content: 'watch movie', done: false }, { id: 3, title: 'Dinner', content: 'eat dinner', done: false } ], - } + selectedTodo : null, + } + + clickTodoHandler = (td) => { + if (this.state.selectedTodo === td) { + this.setState({...this.state, selectedTodo: null }); + } else { + this.setState({...this.state, selectedTodo: td}); + } + } render(){ const todos = this.state.todos.map((td) => { - return (); + return ( + this.clickTodoHandler(td)} + />); }); + + let todoDetail = null; + if (this.state.selectedTodo) { + todoDetail = + } + return (
{this.props.title}
{todos}
+ {todoDetail}
) } From ee6f17823aff83ebf3f90be6c1f0cdd1dcbd52e2 Mon Sep 17 00:00:00 2001 From: hursuhyun Date: Fri, 17 Sep 2021 20:51:07 +0900 Subject: [PATCH 3/5] added NewTodo --- src/containers/TodoList/NewTodo/NewTodo.js | 29 ++++++++++++++++++++++ src/containers/TodoList/TodoList.js | 3 ++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/containers/TodoList/NewTodo/NewTodo.js b/src/containers/TodoList/NewTodo/NewTodo.js index e69de29..3b69e54 100644 --- a/src/containers/TodoList/NewTodo/NewTodo.js +++ b/src/containers/TodoList/NewTodo/NewTodo.js @@ -0,0 +1,29 @@ +import React, { Component } from 'react'; + +import './NewTodo.css'; + +class NewTodo extends Component { + state = { + title: '', + content: '', + submitted: false, + } + + render(){ + return( +
+

Add a Todo

+ + this.setState({title: event.target.value})} /> + +