This repository was archived by the owner on Sep 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
[2주차] 김남일 미션 제출합니다. #2
Open
simyeen
wants to merge
15
commits into
CEOS-Developers:simyeen
Choose a base branch
from
simyeen:namil-todo
base: simyeen
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0f3b884
component간 인자 전달
simyeen c601aa0
'todo-input.js'
simyeen d9ff6b3
'index.js-1'
simyeen 72ece24
'index.js'
simyeen ed2b7d7
using useRef
simyeen 1106209
using state for index
simyeen a8973c4
remove include #useRef
simyeen d3c7a30
Modified inputWrapper -> wrapper
simyeen 0f781e5
Modified css
simyeen 294ab06
Modifed css EnterBtn -> SubmitButton
simyeen cf27bb9
Modified changeInputData -> handleFormChange
simyeen 2d09456
Modified index.js
simyeen 5792c81
Modified index.js
simyeen a4d9fa2
Modified input.js
simyeen 732ba71
Modified All
simyeen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,3 +28,5 @@ yarn-error.log* | |
| .env.development.local | ||
| .env.test.local | ||
| .env.production.local | ||
|
|
||
| .now | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| {"orgId":"vC0ivr1sq0T0zKJytpWAmdFN","projectId":"QmU68M4LipQZeiFKBEhK7WmUX9o8wjXK3RGeuiZ8PSWDDK"} | ||
| {"projectId":"QmafwEK3iPMVU8DtcfaHw2MH2wR9YwUNmTarDgEAk3aA2g","orgId":"xr2CldXR2AS9O2w9aQ48bloY"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,9 @@ | ||
| # react-todo-11th | ||
|
|
||
| ## 실행 방법 | ||
|
|
||
| ``` | ||
| npm install | ||
| npm run dev | ||
| ``` | ||
|
|
||
| - npm install : 필요한 모든 패키지를 설치합니다. 처음 1번만 실행하면 됩니다. | ||
| - npm run dev : react 어플리케이션을 브라우저에서 실행합니다. | ||
|
|
||
| ## 배포 방법 | ||
|
|
||
| - now에 회원가입하고 now를 설치합니다. | ||
|
|
||
| 1. https://zeit.co 에서 회원가입합니다. | ||
| 2. 터미널에서 npm i -g now를 입력해 now를 글로벌로 설치합니다. | ||
| 3. 명령 프롬프트에서 프로젝트 폴더에 들어간 후 now를 입력합니다. | ||
| 4. ID/PW를 입력합니다. | ||
| 5. zeit 가입시 입력한 이메일에서 인증 링크를 클릭합니다. <인증완료> | ||
| 6. 다시 프로젝트 폴더에서 now를 입력하면 자동으로 생성된 url에 배포됩니다! | ||
|
|
||
| ## 미션 설명 | ||
|
|
||
| [미션 설명](./docs/mission-description/README.md) | ||
|
|
||
| ## 미션 제출 방법 | ||
|
|
||
| [미션 제출 방법](./docs/how-to-submit/README.md) | ||
| 이번 미션을 통해서 느낀점은 확실히 저번 미션을 통해 CSS와 기본 틀짜기는 매우 숙달됬지만 아직 props 전달은 미숙하다고 생각했습니다. | ||
| 특히 이번 과제에서 처음에는 input에서 data들을 바로 index로 올려주는 식으로 생각했다가 싹다 갈아엎고 다시 했습니다. | ||
| index에서 input태그에 함수를 인자를 넣어주고 data를 받는 식으로 하니 확실히 전체적인 관리가 편해진 것 같습니다. | ||
| 또한 왜 구글링 할때마다 extend Component와 render()가 나오는지 궁금했었는데 지금까지 Hook를 사용하고 있는지도 모르고 계속 | ||
| 사용했네요... | ||
|
|
||
| 확실히 Hook에 대해서 알고 사용해보니 전부 function Component만 쓰므로 가독성도 올라가고 Hook자체 기능또한 다양하고 좋았던 것 같습니다. | ||
| 처음에 todoRemove를 구성할 때는 useRef를 id로 주고 filter로 처리하려 했는데 안돼서 하는 수 없이 새로운 state를 id를 주니까는 잘 되었습니다. | ||
| 왜 useRef로 id를 줬을 때는 안돌아가는지 궁금하네요 ㅠㅠㅜㅜㅠㅠ 또 number타입 일때는 length기능들이 다 막혀서 String으로 변환하고 했는데 코드 돌아가는데는 딱히 상관없던 것 같습니다. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,85 @@ | ||
| import React from "react"; | ||
| import React, { useState } from 'react'; | ||
|
|
||
| import styled from "styled-components"; | ||
|
|
||
| export default function TodoInput() { | ||
| export default function TodoInput({onSubmit}){ | ||
|
|
||
| const [newTodo, setNewTodo] = useState({}); | ||
|
|
||
| const handleFormChange = (e) => { | ||
| setNewTodo({...newTodo, [e.target.name]:e.target.value}); | ||
| } | ||
|
|
||
| return ( | ||
| <Wrapper> | ||
| 리액트-투두 | ||
| <br /> | ||
| 시간을 입력하는 칸 | ||
| <br /> | ||
| Todo를 입력하는 칸 | ||
| <Row> | ||
| <Lable>시간</Lable> | ||
| <Input | ||
| name="date" | ||
| type="number" | ||
| placeholder="날짜를 입력하세요 (ex.20200404)" | ||
| onChange={handleFormChange} | ||
| /> | ||
| </Row> | ||
| <Row> | ||
| <Lable>TODO</Lable> | ||
| <Textarea | ||
| name="content" | ||
| placeholder='할 일을 입력하세요' | ||
| onChange={handleFormChange} | ||
| /> | ||
| </Row> | ||
| <SunmitButton onClick={() => onSubmit({...newTodo})}>등록</SunmitButton> | ||
| </Wrapper> | ||
| ); | ||
| } | ||
|
|
||
|
|
||
| const Wrapper = styled.div` | ||
| border: solid 1px; | ||
| font-size: 18px; | ||
| flex: 1; | ||
| width: 100%; | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| height: 37rem; | ||
| flex: 1 | ||
| border: 1px, solid, black; | ||
| padding: 1rem 2rem; | ||
| `; | ||
|
|
||
| const Row = styled.div` | ||
| width: 100%; | ||
| display: flex; | ||
| flex-direction: row; | ||
| justify-content: space-between; | ||
| align-items: flex-start; | ||
| margin-bottom: 3rem; | ||
| `; | ||
|
|
||
| const Lable = styled.p` | ||
| font-size: 1.5rem; | ||
| margin: 0px; | ||
| `; | ||
|
|
||
| const Input= styled.input` | ||
| width: 80%; | ||
| border: 1px, soild, rgb(97, 97, 97); | ||
| padding: 0.5rem 0.8rem; | ||
| `; | ||
|
|
||
| const Textarea = styled.textarea` | ||
| width: 80%; | ||
| height: 30vh; | ||
| resize: none; | ||
| border: 1px, solid, rgb(97, 97, 97); | ||
| padding: 0.5rem 0.8rem; | ||
| `; | ||
|
|
||
| const SunmitButton = styled.button` | ||
| color : white; | ||
| background-color: rgb(97, 97, 97); | ||
| font-size: 1.5rem; | ||
| outline: none; | ||
| border: none; | ||
| padding: 0.5rem 1rem; | ||
| border-radius: 0.3rem; | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,56 @@ | ||
| import React from "react"; | ||
| import React, { useState } from 'react'; | ||
|
|
||
| import styled from "styled-components"; | ||
|
|
||
| export default function TodoItem() { | ||
| return <Wrapper>Todo</Wrapper>; | ||
| export default function TodoItem({todo ,onDelete}) { | ||
| return ( | ||
| <Wrapper> | ||
| <Row> | ||
| <Todo>{content}</Todo> | ||
| <Date>{date}</Date> | ||
| </Row> | ||
| <DeleteButton onClick={onDelete}> 완료 </DeleteButton> | ||
| </Wrapper> | ||
| ); | ||
| } | ||
|
|
||
| const Wrapper = styled.div` | ||
| font-size: 18px; | ||
| border: solid 1px; | ||
| display: flex; | ||
| `; | ||
|
|
||
| const Row = styled.div` | ||
| width: 100%; | ||
| display: flex; | ||
| flex-direction: row; | ||
| justify-content: space-between; | ||
| margin-bottom: 3rem; | ||
| padding: 1rem 2rem; | ||
| border: 1px, solid, black; | ||
| `; | ||
|
|
||
| const Todo= styled.p` | ||
| font-size: 1.5rem; | ||
| display: flex; | ||
| flex-direction: column; | ||
| padding: 0px; | ||
| margin: 0px; | ||
| `; | ||
|
|
||
| const Date= styled.p` | ||
| font-size: 1.5rem; | ||
| display: flex; | ||
| flex-direction: column; | ||
| padding: 0px; | ||
| margin: 0px; | ||
| `; | ||
|
|
||
| const DeleteButton = styled.button` | ||
| color: white; | ||
| background-color: rgb(97, 97, 97); | ||
| font-size: 1.5rem; | ||
| outline: none; | ||
| padding: 0.5rem 1rem; | ||
| border: none; | ||
| border-radius: 0.3rem; | ||
| margin-left: auto; | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,19 @@ | ||
| import React from "react"; | ||
| import styled from "styled-components"; | ||
| import React, { useState } from 'react'; | ||
|
|
||
| import TodoItem from "./todo-item"; | ||
|
|
||
| export default function TodoList() { | ||
| import styled from "styled-components"; | ||
|
|
||
| export default function TodoList({todos, onDelete}) { | ||
|
|
||
| return ( | ||
| <Wrapper> | ||
| Todo list가 들어가는 자리입니다! | ||
| <TodoItem /> | ||
| {todos.map((todo, index) => <TodoItem key={JSON.stringify(todo)} {...{todo}} onDelete={onDelete(index)} />)} | ||
| </Wrapper> | ||
| ); | ||
| } | ||
|
|
||
| const Wrapper = styled.div` | ||
| border: solid 1px; | ||
| font-size: 18px; | ||
| flex: 1; | ||
| flex: 1 1 0%; | ||
| `; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,72 @@ | ||
| import React from "react"; | ||
| import React, {useState} from 'react'; | ||
|
|
||
| import TodoInput from "../components/todo-input"; | ||
| import TodoList from "../components/todo-list"; | ||
|
|
||
| import styled from "styled-components"; | ||
|
|
||
| export default function Home() { | ||
|
|
||
| const [todos, setTodos] = useState([]); | ||
|
|
||
| const handleAdd = (todo) => { | ||
|
|
||
| const {content, date} = todo; | ||
|
|
||
| if (content === "" || date === "") { | ||
| alert('모든 항목을 입력해주세요!'); | ||
| return; | ||
| } | ||
|
|
||
| else if (String(date).length != 8){ | ||
| alert('날짜를 올바른 형식으로 입력해주세요!'); | ||
| return; | ||
| } | ||
|
|
||
| const newTodo = { | ||
| content, | ||
| date | ||
| } | ||
|
|
||
| setTodos(todos.concat(newTodo)); | ||
| alert('입력 완료!') | ||
| } | ||
|
|
||
| const handleDelete = (index) = () => { | ||
| setTodos([...todo.slice(0,index), ...todo.slice(index+1, todo.length)]); | ||
| } | ||
|
|
||
| return ( | ||
| <Wrapper> | ||
| <Header>리액트-투두</Header> | ||
| <Contents> | ||
| <TodoInput /> | ||
| <TodoList /> | ||
| <TodoInput onSubmit = {handleAdd}/> | ||
| <Space/> | ||
| <TodoList {...{todos}} onDelete = {handleDelete}/> | ||
| </Contents> | ||
| </Wrapper> | ||
| ); | ||
| } | ||
|
|
||
| const Wrapper = styled.div` | ||
| height: 100vh; | ||
| min-height: 100vh; | ||
| background-color: rgb(155, 197, 195); | ||
| padding: 4rem 5rem; | ||
| `; | ||
|
|
||
| const Contents = styled.div` | ||
| border: solid 1px black; | ||
| display: flex; | ||
| flex-direction: row; | ||
| justify-content: space-between; | ||
| padding: 10px 20px; | ||
| margin: 20px 10px; | ||
|
|
||
| `; | ||
|
|
||
| const Header = styled.h1` | ||
| font-size: 3rem; | ||
| font-weight: 600; | ||
| margin: 0px 0px 3rem; | ||
| `; | ||
|
|
||
| const Space = styled.div` | ||
| flex: 1; | ||
| `; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flex: 1은flex: 1 1 0%와 똑같습니다. 참고