Skip to content
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

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": true
}
230 changes: 222 additions & 8 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"react-scripts": "^5.0.1",
"styled-components": "^5.3.9",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<!-- <link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> -->
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
Expand Down
Binary file removed public/logo192.png
Binary file not shown.
Binary file removed public/logo512.png
Binary file not shown.
48 changes: 44 additions & 4 deletions src/App.js
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;
7 changes: 7 additions & 0 deletions src/components/Done.js
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;
59 changes: 59 additions & 0 deletions src/components/Form.js
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()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

공백 예외 처리 좋네요! ㅎㅎ

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저번 주 과제 코드 리뷰때 채연님이 알려주셔서 적용했습니다!! :)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 이부분은 입력이 있을 경우를 처리하면
인덴테이션이 깊어지니까

입력이 비어있을 경우 먼저 처리해서 return으로 끊어줘도 좋을 것 같아요 😆
(실제로 카카오나 네이버 등 클린 코드 작성을 위해 인덴테이션을 최소화하라고 권장하고 있다고 해요! 😃 )

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오~!! 확실히 그런 경우로 작성하면 코드 양이 훨씬 줄어들겠네요!! 좋은 아이디어 감사합니당!!😆

getTodo(value);
console.log(value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console.log 은 일부러 남겨두신 걸까요?

Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기 최상위에 div 태그로 한번 더 감싸준 이유가 있을까요?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

하이고... 무의식중에 div 태그를 막 써 버리는 습관이 고스란히 나타났네요...ㅜㅜ 알려주셔서 감사합니다!!

);
}
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;
7 changes: 7 additions & 0 deletions src/components/Todo.js
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;
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ ReactDOM.render(
<App />
</React.StrictMode>,
document.getElementById('root')
);
);