From e96b249f0476d6c73709af18f130f7dae1500cdd Mon Sep 17 00:00:00 2001 From: Namnamseo Date: Fri, 18 Sep 2020 16:21:54 +0900 Subject: [PATCH] Lab 3 --- package.json | 3 + src/App.js | 10 +- src/components/Todo/Todo.css | 31 + src/components/Todo/Todo.js | 13 + src/components/TodoDetail/TodoDetail.js | 16 + src/containers/TodoList/NewTodo/NewTodo.css | 41 + src/containers/TodoList/NewTodo/NewTodo.js | 24 + src/containers/TodoList/TodoList.css | 16 + src/containers/TodoList/TodoList.js | 42 + yarn.lock | 5246 +++++++++++-------- 10 files changed, 3141 insertions(+), 2301 deletions(-) create mode 100644 src/components/Todo/Todo.css create mode 100644 src/components/Todo/Todo.js create mode 100644 src/components/TodoDetail/TodoDetail.js create mode 100644 src/containers/TodoList/NewTodo/NewTodo.css create mode 100644 src/containers/TodoList/NewTodo/NewTodo.js create mode 100644 src/containers/TodoList/TodoList.css create mode 100644 src/containers/TodoList/TodoList.js diff --git a/package.json b/package.json index 6c050f8..ae2822d 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,13 @@ { "name": "swppfront", + "homepage": ".", "version": "0.1.0", "private": true, "dependencies": { "react": "^16.9.0", "react-dom": "^16.9.0", + "react-router": "^5.2.0", + "react-router-dom": "^5.2.0", "react-scripts": "3.1.1" }, "scripts": { diff --git a/src/App.js b/src/App.js index e358583..4b17082 100644 --- a/src/App.js +++ b/src/App.js @@ -1,11 +1,15 @@ import React from 'react'; -import logo from './logo.svg'; +import { BrowserRouter, Route, Redirect, Switch } from 'react-router-dom'; +// import logo from './logo.svg'; import './App.css'; function App() { return ( -
-
+ +
+ } /> +
+
); } diff --git a/src/components/Todo/Todo.css b/src/components/Todo/Todo.css new file mode 100644 index 0000000..f2105b8 --- /dev/null +++ b/src/components/Todo/Todo.css @@ -0,0 +1,31 @@ +.Todo { + border-top: 1px solid #f1f3f5; + padding: 1rem; + display: flex; + align-items: center; + transition: all 0.15s; +} + +.Todo .text { + flex: 1; + text-align: left; + word-break: break-all; + cursor: pointer; +} + +.Todo .text:hover { + color: orange; +} + +.Todo .done { + text-decoration: line-through; + color: #adb5bd; +} + +.Todo .done-mark { + font-size: 1.5rem; + line-height: 1rem; + margin-left: 1rem; + color: orange; + font-weight: 800; +} \ No newline at end of file diff --git a/src/components/Todo/Todo.js b/src/components/Todo/Todo.js new file mode 100644 index 0000000..7f05202 --- /dev/null +++ b/src/components/Todo/Todo.js @@ -0,0 +1,13 @@ +import React from 'react'; +import './Todo.css'; +const Todo = props => { + return ( +
+
+ {props.title} +
+ {props.done &&
} +
+ ); +} +export default Todo; diff --git a/src/components/TodoDetail/TodoDetail.js b/src/components/TodoDetail/TodoDetail.js new file mode 100644 index 0000000..409cbfd --- /dev/null +++ b/src/components/TodoDetail/TodoDetail.js @@ -0,0 +1,16 @@ +import React from 'react'; +import './TodoDetail.css'; +const TodoDetail = (props) => { + return (
+
+
Name:
+
{props.title}
+
+
+
Content:
+
{props.content}
+
+
+ ); +}; +export default TodoDetail; diff --git a/src/containers/TodoList/NewTodo/NewTodo.css b/src/containers/TodoList/NewTodo/NewTodo.css new file mode 100644 index 0000000..9b81330 --- /dev/null +++ b/src/containers/TodoList/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/TodoList/NewTodo/NewTodo.js b/src/containers/TodoList/NewTodo/NewTodo.js new file mode 100644 index 0000000..2caa0d9 --- /dev/null +++ b/src/containers/TodoList/NewTodo/NewTodo.js @@ -0,0 +1,24 @@ +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 })} /> + +