-
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주차] 노이진 미션 제출합니다. #4
base: master
Are you sure you want to change the base?
Changes from all commits
bc4c2b0
aa2ebda
56c2327
3afba64
8b3083f
daf05bf
4af4cb2
8469b17
fd36c10
d467527
1807a90
047c963
d3442df
868ff78
83d5cf6
54b79c2
f543e6b
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
node_modules | ||
/node_modules | ||
package-lock.json | ||
.DS_Store |
This file was deleted.
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. 파비콘이 귀엽습니다..! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import React from "react"; | ||
import Todo from "./components/Todo"; | ||
import "./index.css"; | ||
|
||
function App() { | ||
return ( | ||
<div> | ||
<h1>18기 프론트 화이팅~ 푸하항ㅋ</h1> | ||
</div> | ||
); | ||
return <Todo />; | ||
} | ||
|
||
export default App; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import styled from "styled-components"; | ||
import { format } from "date-fns"; | ||
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. 저는 Date, time관련해서는 |
||
|
||
const ClockText = styled.span` | ||
font-family: "Pretendard-SemiBold"; | ||
font-size: 13px; | ||
text-align: center; | ||
line-height: 1.5em; | ||
margin-top: 5px; | ||
`; | ||
|
||
export default function Clock() { | ||
const [now, setNow] = useState(new Date()); | ||
|
||
//1초마다 now 다시 set | ||
useEffect(() => { | ||
const time = setInterval(() => { | ||
setNow(new Date()); | ||
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. 이 부분은 매초 Date객체를 생성하는데, 기존의 time에서 1초를 더해주는 코드로 대체해도 괜찮을 것 같아요~! |
||
}, 1000); | ||
return () => clearInterval(time); | ||
}, []); | ||
|
||
let clockFormat = format(now, "hh:mm aa"); | ||
|
||
return <ClockText>{clockFormat}</ClockText>; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
import { format } from "date-fns"; | ||
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. 오오 date-fns 처음 보는데, 저도 다음에 한 번 date-fns 써봐야겠어요! |
||
|
||
const DateField = styled.div` | ||
display: flex; | ||
width: 100%; | ||
height: 10%; | ||
background-color: #e0e0e0; | ||
color: #302e2e; | ||
border: 0.5px solid #736e6e; | ||
margin-bottom: 5px; | ||
border-radius: 10px; | ||
align-items: center; | ||
justify-content: center; | ||
box-sizing: border-box; | ||
`; | ||
|
||
const DateText = styled.span` | ||
font-family: "Pretendard-SemiBold"; | ||
letter-spacing: 1px; | ||
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. 디테일....👍🏻 |
||
font-size: 13px; | ||
padding-top: 3px; | ||
`; | ||
|
||
export default function DailyDate() { | ||
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. function문법도 문제 없지만 더 최신 문법인 ES6의 arrow function을 써보는 것을 추천드려요~! |
||
const week = new Array("sun", "mon", "tue", "wed", "thu", "fri", "sat"); | ||
|
||
const now = new Date(); | ||
const day = week[now.getDay()]; | ||
|
||
let formatDate = format(now, "yyyy-MM-dd"); | ||
|
||
return ( | ||
<DateField> | ||
<DateText> | ||
{formatDate} {day} | ||
</DateText> | ||
</DateField> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React from "react"; | ||
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. REACT17이 release되면서 이제 더이상 모든 파일에서 React를 import하지 않아도 된다고 합니다 🚀 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. 그렇군요.. 저도 배워갑니당:) |
||
import styled from "styled-components"; | ||
import { useState, useCallback } from "react"; | ||
|
||
const Container = styled.form` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
margin-bottom: 5px; | ||
background-color: #e0e0e0; | ||
border-radius: 10px; | ||
padding: 5px; | ||
height: 10%; | ||
box-sizing: border-box; | ||
border: 0.5px solid #736e6e; | ||
`; | ||
|
||
const InputField = styled.input` | ||
width: 90%; | ||
padding: 3px; | ||
border: none; | ||
border-bottom: 1px solid #555252; | ||
background-color: transparent; | ||
color: #555252; | ||
font-family: "Pretendard-Regular"; | ||
margin-left: 3px; | ||
box-sizing: border-box; | ||
&:focus { | ||
outline-style: none; | ||
} | ||
`; | ||
|
||
const AddButton = styled.button` | ||
margin-top: 3px; | ||
width: 20px; | ||
height: 30px; | ||
background-color: transparent; | ||
color: #555252; | ||
border: none; | ||
border-radius: 50%; | ||
cursor: pointer; | ||
`; | ||
|
||
export default function TodoInput({ createTodo }) { | ||
const [value, setValue] = useState(""); | ||
|
||
const onChange = useCallback( | ||
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. useCallback을 사용해본 적이 없는데, 앞으로 성능 측면도 고려하며 구현해보겠습니다! 새로 배워갑니다 👍 |
||
(e) => { | ||
setValue(e.target.value); | ||
}, | ||
[value] | ||
); | ||
Comment on lines
+47
to
+52
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. useCallback의 두번째 인자에 value를 dependency로 넣어주셨는데, |
||
|
||
const onSubmit = useCallback( | ||
(e) => { | ||
e.preventDefault(); | ||
|
||
//입력한 값이 없을 때 alert 추가 | ||
if (value.trim() == "") { | ||
alert("할일을 입력해주세요."); | ||
} else { | ||
createTodo(value); | ||
setValue(""); | ||
} | ||
}, | ||
[value] | ||
); | ||
|
||
return ( | ||
<Container onSubmit={onSubmit}> | ||
<InputField | ||
onChange={onChange} | ||
value={value} | ||
placeholder="할 일을 입력하세요" | ||
/> | ||
<AddButton type="submit">+</AddButton> | ||
</Container> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
import { faCircle, faCircleCheck } from "@fortawesome/free-regular-svg-icons"; | ||
import { faTrashCan, faRotateLeft } from "@fortawesome/free-solid-svg-icons"; | ||
Comment on lines
+3
to
+4
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. fa icon들을 더 편하게 불러올 수 있는 |
||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
|
||
const Item = styled.div` | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
margin-bottom: 5px; | ||
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. 사용자의 더 나은 경험 (UX)를 위해 최근 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. 리스트 아이템들이 이동 아이콘 바로 옆쪽에 왼쪽으로 정렬되면 더 보기 편할 것 같아요! |
||
width: 100%; | ||
box-sizing: border-box; | ||
cursor: pointer; | ||
`; | ||
|
||
const ItemText = styled.span` | ||
font-family: "Pretendard-Regular"; | ||
font-size: 13px; | ||
margin: 3px 8px 0px 8px; | ||
`; | ||
|
||
const ClickedText = styled.span` | ||
font-family: "Pretendard-Regular"; | ||
font-size: 13px; | ||
margin: 3px 8px 0px 8px; | ||
text-decoration: line-through; | ||
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 IconBox = styled.div` | ||
display: flex; | ||
`; | ||
|
||
export default function ListItem({ input, onClick, isClicked, deleteList }) { | ||
//삭제할 때 alert | ||
const OpenConfirm = () => { | ||
if (window.confirm("정말 삭제하시겠습니까?")) { | ||
deleteList(); | ||
} | ||
}; | ||
Comment on lines
+36
to
+40
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. 항상 alert를 이용해서 메세지 창을 띄웠는데 새로운 방법이네요! 또 배워갑니다 👍 |
||
|
||
return ( | ||
<Item> | ||
{isClicked ? ( | ||
<FontAwesomeIcon icon={faCircleCheck} style={{ height: 13 }} /> | ||
) : ( | ||
<FontAwesomeIcon | ||
onClick={onClick} | ||
icon={faCircle} | ||
style={{ height: 13 }} | ||
/> | ||
)} | ||
{isClicked ? ( | ||
<ClickedText>{input}</ClickedText> | ||
) : ( | ||
<ItemText>{input}</ItemText> | ||
)} | ||
|
||
{isClicked ? ( | ||
<IconBox> | ||
<FontAwesomeIcon | ||
icon={faRotateLeft} | ||
style={{ height: 13, marginRight: 3 }} | ||
onClick={onClick} | ||
/> | ||
<FontAwesomeIcon | ||
icon={faTrashCan} | ||
style={{ height: 13 }} | ||
onClick={OpenConfirm} | ||
/> | ||
</IconBox> | ||
) : ( | ||
<FontAwesomeIcon | ||
icon={faTrashCan} | ||
style={{ height: 13 }} | ||
onClick={OpenConfirm} | ||
/> | ||
)} | ||
</Item> | ||
); | ||
} |
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.
package-lock.json파일은 개인 프로젝트를 하는 경우(혼자 작업하는경우)에는 상관이 없지만
협업을 하는 경우에는 gitignore에 올리지 않는 것이 좋다고 합니다!!
참고자료 놓고 갈게요~!!