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주차] 이효린 미션 제출합니다. #7

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f77ec81
Feat: Initial Setting
hyorish03 Sep 3, 2024
283fb0d
Feat: Vite 기본 마진 제거
hyorish03 Sep 3, 2024
2084c35
Revert "Feat: Vite 기본 마진 제거"
hyorish03 Sep 3, 2024
88b2c19
Feat: Vite 기본 마진 제거 및 StrictMode 제거
hyorish03 Sep 3, 2024
b8dda23
Feat: Header UI 구현
hyorish03 Sep 3, 2024
84775e7
Feat: TodoList UI 구현
hyorish03 Sep 3, 2024
b078703
Feat: DoneList UI 구현
hyorish03 Sep 3, 2024
c93b636
Feat: Header, TodoList, DoneList 컴포넌트 App.jsx에 import
hyorish03 Sep 3, 2024
c50916b
Feat: LocalStorage에 대한 get, set 함수 구현
hyorish03 Sep 3, 2024
af732c8
Fix: setLocalStorage 함수 내의 id 지정 방식 수정
hyorish03 Sep 3, 2024
fea26ee
Feat: addTodo 기능 구현
hyorish03 Sep 3, 2024
85abe44
Feat:TodoList 렌더링 기능 구현
hyorish03 Sep 3, 2024
031827f
Fix: localStorage에서 데이터를 불러와 todoList 상태 초기화
hyorish03 Sep 3, 2024
a7a470c
Refactor: useState 초기값으로 localStorage 데이터 사용하여 todoList 상태 초기화
hyorish03 Sep 3, 2024
f85502f
Refactor: 함수명 변경 setLocalStorage -> addToLocalStorage
hyorish03 Sep 3, 2024
f65969a
Fix: onKeyDown 한글 입력 시 두 번 실행되는 오류 수정
hyorish03 Sep 3, 2024
d957d87
Feat: todoList 완료여부 상태 변경 기능 구현
hyorish03 Sep 3, 2024
0de0688
Feat: Todo 삭제 기능 구현
hyorish03 Sep 3, 2024
eaf3c16
Feat: App에서 미완료/완료 리스트 구분 후 list 컴포넌트의 props로 전달하도록 수정
hyorish03 Sep 3, 2024
779bed8
Feat: 스타일링 수정 및 삭제버튼, todoItem 모듈화
hyorish03 Sep 3, 2024
5fd92bc
Refactor: Todo 항목 렌더링 모듈화
hyorish03 Sep 3, 2024
29b4b6e
Fix: 배경 색 스타일링 수정
hyorish03 Sep 3, 2024
b835b2d
Fix: 웹 사이트 아이콘 변경
hyorish03 Sep 3, 2024
32fe0fd
Feat: 배포확인용 커밋
hyorish03 Sep 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Feat: Todo 삭제 기능 구현
hyorish03 committed Sep 3, 2024
commit 0de068874540709fc6299bc6b49dbb84185aa3a7
19 changes: 13 additions & 6 deletions src/Components/DoneList.jsx
Original file line number Diff line number Diff line change
@@ -2,12 +2,9 @@
import { css } from '@emotion/react';
import { updateFromLocalStorage } from '../utils/updateFromLocalStorage';
import { getLocalStorage } from '../utils/getLocalStorage';
import { deleteFromLocalStorage } from '../utils/deleteFromLocalStorage';

function DoneList({ doneTodoList, setTodoList }) {
const goNotDone = (id) => {
updateFromLocalStorage(id);
setTodoList(getLocalStorage());
};
return (
<div
css={css({
@@ -42,11 +39,21 @@ function DoneList({ doneTodoList, setTodoList }) {
*
<div
css={css({ textDecoration: 'line-through' })}
onClick={() => goNotDone(todo.id)}
onClick={() => {
updateFromLocalStorage(todo.id);
setTodoList(getLocalStorage());
}}
>
{todo.todo}
</div>
<div>❌</div>
<div
onClick={() => {
deleteFromLocalStorage(todo.id);
setTodoList(getLocalStorage());
}}
>
</div>
</div>
</div>
))}
20 changes: 18 additions & 2 deletions src/Components/TodoList.jsx
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
import { css } from '@emotion/react';
import { updateFromLocalStorage } from '../utils/updateFromLocalStorage';
import { getLocalStorage } from '../utils/getLocalStorage';
import { deleteFromLocalStorage } from '../utils/deleteFromLocalStorage';

function TodoList({ notDoneTodoList, setTodoList }) {
const doneTodo = (id) => {
@@ -50,8 +51,23 @@ function TodoList({ notDoneTodoList, setTodoList }) {
width: '100%',
})}
>
*<div onClick={() => doneTodo(todo.id)}>{todo.todo}</div>
<div>❌</div>
*
<div
onClick={() => {
updateFromLocalStorage(todo.id);
setTodoList(getLocalStorage());
}}
>
{todo.todo}
</div>
<div
onClick={() => {
deleteFromLocalStorage(todo.id);
setTodoList(getLocalStorage());
}}
>
</div>
</div>
</div>
))}
8 changes: 8 additions & 0 deletions src/utils/deleteFromLocalStorage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { getLocalStorage } from './getLocalStorage';

export const deleteFromLocalStorage = (id) => {
const prevTodo = getLocalStorage();
const newTodo = prevTodo.filter((todo) => todo.id !== id);
localStorage.setItem('todo', JSON.stringify(newTodo));
alert('삭제되었습니다.');
};
Comment on lines +1 to +8
Copy link

Choose a reason for hiding this comment

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

함수 이름인 addToLocalStorage, deleteFromLocalStorage, getLocalStorage, updateFromLocalStorage가 각 함수의 역할을 명확하게 설명하고 있어서 코드를 이해하기 정말 쉬웠습니다! 함수 이름을 짓는 기준이 혹시 있으신가요? 저도 다음번에는 더 직관적이게 개선하고싶어요!