-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[2주차] 이예지 미션 제출합니다. #1
base: master
Are you sure you want to change the base?
Changes from 2 commits
6d1a3b2
fc416fc
12db561
df6b999
aec04ea
1ee930a
df64c45
b622e79
e168bb1
47b73a7
ae0aa85
3983cfd
63e9b97
ef373ff
ac0f9ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"trailingComma": "es5", | ||
"tabWidth": 2, | ||
"semi": true, | ||
"singleQuote": true | ||
} |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,49 @@ | ||
import React, { useState } from 'react'; | ||
import styled, { createGlobalStyle } from 'styled-components'; | ||
import Form from './components/Form'; | ||
import Todo from './components/Todo'; | ||
import Done from './components/Done'; | ||
|
||
function App() { | ||
const [list, setList] = useState([]); | ||
|
||
const getTodo = (value) => { | ||
const newTodo = { | ||
id: Date.now(), | ||
title: value, | ||
completed: false, | ||
}; | ||
setList((prev) => [...prev, newTodo]); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<h1>17기 프론트 화이팅~ 우하하</h1> | ||
</div> | ||
<> | ||
<GlobalStyle /> | ||
<Conatiner> | ||
<Form getTodo={getTodo}></Form> | ||
<Todo></Todo> | ||
<Done></Done> | ||
</Conatiner> | ||
</> | ||
); | ||
} | ||
const GlobalStyle = createGlobalStyle` | ||
body { | ||
background-color: rgb(186, 191, 225); | ||
height: 100vh; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
`; | ||
const Conatiner = styled.div` | ||
background-color: white; | ||
display: flex; | ||
flex-direction: column; | ||
height: 650px; | ||
width: 350px; | ||
border-radius: 20px; | ||
box-shadow: 1px 1px 15px rgba(73, 71, 71, 0.5); | ||
`; | ||
|
||
export default App; | ||
export default App; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react'; | ||
|
||
function Done() { | ||
return <div>Done</div>; | ||
} | ||
|
||
export default Done; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React, { useState } from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
function Form({ getTodo }) { | ||
const [value, setValue] = useState(''); | ||
|
||
const submitTodo = (e) => { | ||
e.preventDefault(); | ||
|
||
if (value.trim()) { | ||
getTodo(value); | ||
console.log(value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. console.log 은 일부러 남겨두신 걸까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 엇 이 부분 이전에 pending 된 코멘트라 같이 들어갔네요 😅😅 |
||
setValue(''); | ||
} else { | ||
alert('Enter your todo'); | ||
} | ||
}; | ||
const handleChange = (e) => { | ||
setValue(e.target.value); | ||
}; | ||
return ( | ||
<div> | ||
<Enter> | ||
<form onSubmit={submitTodo}> | ||
<h2>Todo List ✔</h2> | ||
<input | ||
type="text" | ||
value={value} | ||
placeholder=" Enter your to do" | ||
onChange={handleChange} | ||
id="input-todo" | ||
/> | ||
<button type="submit" id="button"> | ||
➕ | ||
</button> | ||
</form> | ||
</Enter> | ||
</div> | ||
Comment on lines
+19
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기 최상위에 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 하이고... 무의식중에 |
||
); | ||
} | ||
const Enter = styled.div` | ||
padding: 0px 20px 15px 20px; | ||
#input-todo { | ||
border: none; | ||
background-color: rgb(205, 222, 241); | ||
border-radius: 20px; | ||
height: 35px; | ||
font-size: 15px; | ||
width: 85%; | ||
} | ||
#button { | ||
border: none; | ||
background: none; | ||
font-size: 18px; | ||
width: 30px; | ||
} | ||
`; | ||
|
||
export default Form; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react'; | ||
|
||
function Todo() { | ||
return <div>Todo</div>; | ||
} | ||
|
||
export default Todo; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ ReactDOM.render( | |
<App /> | ||
</React.StrictMode>, | ||
document.getElementById('root') | ||
); | ||
); |
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.
공백 예외 처리 좋네요! ㅎㅎ
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.
저번 주 과제 코드 리뷰때 채연님이 알려주셔서 적용했습니다!! :)
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.
혹시 이부분은 입력이 있을 경우를 처리하면
인덴테이션이 깊어지니까
입력이 비어있을 경우 먼저 처리해서 return으로 끊어줘도 좋을 것 같아요 😆
(실제로 카카오나 네이버 등 클린 코드 작성을 위해 인덴테이션을 최소화하라고 권장하고 있다고 해요! 😃 )
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.
오~!! 확실히 그런 경우로 작성하면 코드 양이 훨씬 줄어들겠네요!! 좋은 아이디어 감사합니당!!😆