-
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주차] 송은수 미션 제출합니다. #5
Open
songess
wants to merge
15
commits into
CEOS-Developers:master
Choose a base branch
from
songess:songess
base: master
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 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
79ed2cb
chore: .prettierrc 파일 생성
songess 995bc45
chore: styled-components 설치
songess 122f0ef
feat: Globalc
songess af5e888
feat: TodoCard 구현
songess a53b8bf
feat: layout 설정
songess 8e29f33
feat: TodoHeader 컴포넌트 구현
songess 894d517
feat: TodoSection 구현
songess 6258efd
feat: TodoFooter 컴포넌트 구현
songess 4a468ae
feat: localstorage 커스텀훅 생성
songess a7f0614
feat: todo 입력창 구현
songess 8eaa40a
feat: todoCard 추가 및 삭제 구현
songess f16e3fe
feat: todoCard 이동 구현
songess b815e76
refactor: 필요없는 코드 제거, useEffect 의존성 추가
songess ddf341f
feat: README 작성
songess 2f10cad
style: 반응형 구현
songess 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 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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React, { useState } from 'react'; | ||
import styled from 'styled-components'; | ||
import useLocalStorage from '../hooks/useLocalStorage'; | ||
|
||
let AddTodoLayout = styled.div` | ||
width: 100%; | ||
height: 50px; | ||
padding: 0 1rem; | ||
display: flex; | ||
align-items: center; | ||
gap: 0.5rem; | ||
margin-bottom: 0.5rem; | ||
`; | ||
|
||
let TodoInput = styled.input` | ||
width: 100%; | ||
border: none; | ||
border: 1px solid #e0e0e0; | ||
font-size: 1rem; | ||
flex-grow: 1; | ||
outline: none; | ||
border-radius: 0.5rem; | ||
padding: 0.5rem 1rem; | ||
`; | ||
|
||
let AddButton = styled.button` | ||
width: 2rem; | ||
height: 2rem; | ||
font-size: 1.5rem; | ||
border: none; | ||
border-radius: 50%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
font-weight: 600; | ||
cursor: pointer; | ||
&:hover { | ||
background-color: #f5f5f5; | ||
} | ||
`; | ||
|
||
export default function AddTodo() { | ||
const { getTodoFromLocalStorage, setTodoToLocalStorage } = useLocalStorage(); | ||
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 [inputValue, setInputValue] = useState(''); | ||
const addButtonHandler = () => { | ||
if (inputValue.trim() === '') { | ||
return; | ||
} | ||
let todoList = getTodoFromLocalStorage('todoList'); | ||
todoList.push({ todo: inputValue, isdone: false }); | ||
setTodoToLocalStorage('todoList', todoList); | ||
setInputValue(''); | ||
}; | ||
return ( | ||
<AddTodoLayout> | ||
<TodoInput | ||
placeholder="할 일을 입력해주세요..." | ||
value={inputValue} | ||
onChange={(e) => { | ||
setInputValue((prev) => e.target.value); | ||
}} | ||
onKeyPress={(e) => { | ||
if (e.key === 'Enter') { | ||
addButtonHandler(); | ||
} | ||
}} | ||
/> | ||
<AddButton>+</AddButton> | ||
</AddTodoLayout> | ||
); | ||
} |
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.
저는 리엑트 기능 구현에 집중하느라 이번엔 절대단위로만 개발했는데
상대단위를 자유롭게 잘 활용하시는 것 같아 인상깊습니다!