diff --git a/package.json b/package.json index bcaefee..7c14644 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,8 @@ "dependencies": { "react": "^17.0.2", "react-dom": "^17.0.2", + "react-router": "^5.2.1", + "react-router-dom": "^5.3.0", "react-scripts": "4.0.3" }, "scripts": { diff --git a/src/App.js b/src/App.js index e358583..fb46721 100644 --- a/src/App.js +++ b/src/App.js @@ -1,11 +1,24 @@ import React from 'react'; -import logo from './logo.svg'; import './App.css'; +import TodoList from './containers/TodoList/TodoList'; +import { BrowserRouter, Route, Redirect, Switch} from 'react-router-dom'; +import NewTodo from './containers/NewTodo/NewTodo'; +import TodoDetail from './components/TodoDetail/TodoDetail'; function App() { return ( -
-
+ +
+ + } /> + + + +

Not Found

} /> +
+
+
+ ); } diff --git a/src/components/Todo/Todo.js b/src/components/Todo/Todo.js index e69de29..4973961 100644 --- a/src/components/Todo/Todo.js +++ b/src/components/Todo/Todo.js @@ -0,0 +1,14 @@ +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/components/TodoDetail/TodoDetail.js b/src/components/TodoDetail/TodoDetail.js index e69de29..08404df 100644 --- a/src/components/TodoDetail/TodoDetail.js +++ b/src/components/TodoDetail/TodoDetail.js @@ -0,0 +1,26 @@ +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/NewTodo/NewTodo.css b/src/containers/NewTodo/NewTodo.css new file mode 100644 index 0000000..ba6acd5 --- /dev/null +++ b/src/containers/NewTodo/NewTodo.css @@ -0,0 +1,41 @@ +.NewTodo { + width: 80%; + margin: 20px auto; + border: 1px solid #eee; + box-shadow: 0 2px 3px #ccc; + text-align: center; + } + + .NewTodo label { + display: block; + margin: 10px auto; + text-align: center; + font-weight: bold; + } + + .NewTodo input, + .NewTodo textarea { + display: block; + width: 80%; + box-sizing: border-box; + border: 1px solid black; + outline: none; + font: inherit; + margin: auto; + } + + .NewTodo button { + margin: 5px 0; + padding: 10px; + font: inherit; + border: 1px solid #fa923f; + background-color: transparent; + color: #fa923f; + cursor: pointer; + } + + .NewTodo button:hover, + .NewTodo button:active { + color: white; + background-color: #fa923f; + } \ No newline at end of file diff --git a/src/containers/NewTodo/NewTodo.js b/src/containers/NewTodo/NewTodo.js new file mode 100644 index 0000000..c093d2c --- /dev/null +++ b/src/containers/NewTodo/NewTodo.js @@ -0,0 +1,37 @@ +import React, { Component } from 'react'; +import './NewTodo.css' +import { Redirect } from 'react-router-dom' + +class NewTodo extends Component { + state = { + title: '', + content: '', + submitted: false, + } + + postTodoHandler = () => { + const data = { + title: this.state.title, content: this.state.content + }; + alert('Submitted\n' + data.title + '\n' + data.content); + this.setState( {submitted: true}); + } + render() { + if(this.state.submitted) { + return + } + return ( +
+

Add a Todo

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