Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions index.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ body {
padding: 0;
box-sizing: border-box;
}

* {
box-sizing: border-box;
}
18 changes: 18 additions & 0 deletions src/Components/DeleteButton.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/** @jsxImportSource @emotion/react */
import { css } from '@emotion/react';
import { deleteFromLocalStorage } from '../utils/deleteFromLocalStorage';
import { getLocalStorage } from '../utils/getLocalStorage';

export const DeleteButton = ({ id, setTodoList }) => {
return (
<div
css={css({ cursor: 'pointer' })}
onClick={() => {
deleteFromLocalStorage(id);
setTodoList(getLocalStorage());
Comment on lines +11 to +12

Choose a reason for hiding this comment

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

LocalStorage를 왜 사용하는지 생각해보셨으면 좋겠습니다. LocalStorage를 데이터 원본 저장소처럼 활용하고 있는데요. 성능 면이나 관리 면에서 그냥 메모리에 있는 상태를 원본으로 두고 LocalStorage는 백업 용도로 사용하는 것이 좋겠습니다.

저라면 Todo State를 변경하고 그에 대한 Effect로 LocalStorage에 상태를 저장할 것 같네요.
그렇게 되면 여기서는 위에서 말한 deleteTodo 함수만 호출하면 됩니다.

}}
>
Copy link

Choose a reason for hiding this comment

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

uills부분 한번 더 배우고갑니다! onClick이벤트 핸들러를 통해로컬 스토리지 적용한 부분 정말 간결하고 저도 이렇게 작성하고싶어요!

🗑️
</div>
);
};
65 changes: 17 additions & 48 deletions src/Components/DoneList.jsx
Original file line number Diff line number Diff line change
@@ -1,62 +1,31 @@
/** @jsxImportSource @emotion/react */
import { css } from '@emotion/react';
import { updateFromLocalStorage } from '../utils/updateFromLocalStorage';
import { getLocalStorage } from '../utils/getLocalStorage';
import { deleteFromLocalStorage } from '../utils/deleteFromLocalStorage';
import { TodoItem } from './TodoItem';

function DoneList({ doneTodoList, setTodoList }) {
return (
<div
css={css({
height: '235px',
height: '220px',
width: '100%',
borderBottom: 'solid 1px lightgray',
padding: '18px 18px 0 18px',
})}
>
<div css={css({ fontSize: '18px' })}>🗑️ DONE ({doneTodoList.length})</div>
<div css={css({ width: '100%', height: '156px', overflowY: 'scroll' })}>
{doneTodoList.map((todo, index) => (
<div
key={index}
css={css({
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
height: '20px',
width: '80%',
})}
>
<div
css={css({
display: 'flex',
flexDirection: 'row',
textAlign: 'center',
alignItems: 'center',
width: '100%',
})}
>
*
<div
css={css({ textDecoration: 'line-through' })}
onClick={() => {
updateFromLocalStorage(todo.id);
setTodoList(getLocalStorage());
}}
>
{todo.todo}
</div>
<div
onClick={() => {
deleteFromLocalStorage(todo.id);
setTodoList(getLocalStorage());
}}
>
</div>
</div>
</div>
))}
<div css={css({ fontSize: '18px', marginBottom: '15px' })}>
💿 DONE ({doneTodoList.length})
</div>
<div
css={css({
width: '100%',
height: '156px',
overflowY: 'scroll',
display: 'flex',
flexDirection: 'column',
gap: '10px',
paddingRight: '20px',
})}
>
<TodoItem todoList={doneTodoList} setTodoList={setTodoList} />
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function Header({ setTodoList }) {
}, []);

return (
<div>
<div css={css({ height: '118px' })}>
<div css={css({ fontSize: '24px', margin: '18px 18px 0 18px' })}>
📚 투두리스트
</div>
Expand Down
45 changes: 45 additions & 0 deletions src/Components/TodoItem.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/** @jsxImportSource @emotion/react */
import { css } from '@emotion/react';
import { DeleteButton } from './DeleteButton';
import { updateFromLocalStorage } from '../utils/updateFromLocalStorage';
import { getLocalStorage } from '../utils/getLocalStorage';
export const TodoItem = ({ todoList, setTodoList }) =>
todoList.map((todo, index) => (
Comment on lines +7 to +8

Choose a reason for hiding this comment

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

위에서 이어서, todo를 받고 todo에 대한 UI를 렌더링 하는 역할을 하는 것이 적절해보입니다.

<div
key={index}
css={css({
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
height: '20px',
width: '100%',
})}
>
<div
css={css({
display: 'flex',
flexDirection: 'row',
textAlign: 'center',
alignItems: 'center',
width: '100%',
justifyContent: 'space-between',
})}
>
<div
css={css({
cursor: 'pointer',
textDecoration: todo.done ? 'line-through' : 'none',
Comment on lines +29 to +32
Copy link

Choose a reason for hiding this comment

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

할 일 항목 완료여부에 따라 동적으로 설정하신 부분도 명확하게 보여서 너무 좋아요!!!!!

color: todo.done ? '#D3D3D3' : '#000',
textAlign: 'center',
})}
onClick={() => {
updateFromLocalStorage(todo.id);
setTodoList(getLocalStorage());
Comment on lines +37 to +38
Copy link
Contributor

Choose a reason for hiding this comment

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

현재 순서가 로컬 스토리지에 반영 -> 로컬 스토리지에서 불러오기 -> 불러온 값으로 state 변경이 되고 있는데,
state 변경 -> 변경된 state를 로컬 스토리지에 적용 하는 방식이 더욱 간단할 것 같아요!

}}
>
• {todo.todo}
</div>
<DeleteButton id={todo.id} setTodoList={setTodoList} />
</div>
</div>
));
54 changes: 5 additions & 49 deletions src/Components/TodoList.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
/** @jsxImportSource @emotion/react */
import { css } from '@emotion/react';
import { updateFromLocalStorage } from '../utils/updateFromLocalStorage';
import { getLocalStorage } from '../utils/getLocalStorage';
import { deleteFromLocalStorage } from '../utils/deleteFromLocalStorage';
import { TodoItem } from './TodoItem';

function TodoList({ notDoneTodoList, setTodoList }) {
const doneTodo = (id) => {
updateFromLocalStorage(id);
setTodoList(getLocalStorage());
};
return (
<div
css={css({
height: '235px',
width: '324px',
height: '220px',
width: '100%',
borderBottom: 'solid 1px lightgray',
padding: '18px 18px 0 18px',
})}
Expand All @@ -29,48 +23,10 @@ function TodoList({ notDoneTodoList, setTodoList }) {
display: 'flex',
flexDirection: 'column',
gap: '10px',
paddingRight: '20px',
})}
>
{notDoneTodoList.map((todo, index) => (
<div
key={index}
css={css({
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
height: '20px',
width: '80%',
})}
>
<div
css={css({
display: 'flex',
flexDirection: 'row',
textAlign: 'center',
alignItems: 'center',
width: '100%',
})}
>
*
<div
onClick={() => {
updateFromLocalStorage(todo.id);
setTodoList(getLocalStorage());
}}
>
{todo.todo}
</div>
<div
onClick={() => {
deleteFromLocalStorage(todo.id);
setTodoList(getLocalStorage());
}}
>
</div>
</div>
</div>
))}
<TodoItem todoList={notDoneTodoList} setTodoList={setTodoList} />
Copy link

Choose a reason for hiding this comment

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

DoneList, TodoList, TodoItem를 따로 분리하셨는데 따로 분리하신 이유가 있으실까요??? 이렇게 분리해서 관리하면 더 편할까요???(๑•̀ㅂ•́)و✧

</div>
</div>
);
Expand Down