Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7909d23
fix: getter reference 반환 수정
chchaeun Feb 20, 2023
30fd145
refactor: 상수 객체로 관리
chchaeun Feb 20, 2023
c34d19f
refactor: 이벤트 함수 메서드로 선언
chchaeun Feb 20, 2023
74cc90c
refactor: EditForm 컴포넌트 분리
chchaeun Feb 20, 2023
3a915fb
refactor: Title string return 함수로 수정
chchaeun Feb 20, 2023
92213d5
refactor: closest 이용한 todoId 반환 함수 추가
chchaeun Feb 20, 2023
9ee680d
refactor: 컴포넌트 컨테이너 id 상수 객체 생성
chchaeun Feb 20, 2023
d5ecf11
fix: object key 존재여부 판단으로 hasOwnProperty 사용
chchaeun Feb 20, 2023
276925c
refactor: 함수 이름 declare -> mounted로 변경
chchaeun Feb 20, 2023
73601bf
fix: 동작 오류 수정
chchaeun Feb 26, 2023
8d8272f
feat: 참조 반환 방지로 Object.freeze 사용
chchaeun Feb 26, 2023
69fed8c
feat: redux 구현
chchaeun Mar 6, 2023
ebe47be
fix: redux 사이드이펙트 제거
chchaeun Mar 7, 2023
883aa3c
refactor: import 코드 간략화
chchaeun Mar 7, 2023
f345d2d
refactor: redux 사이드이펙트 제거
chchaeun Mar 7, 2023
5736bd1
fix: return 값 오류 수정
chchaeun Mar 7, 2023
12ef860
feat: 메서드 private 선언
chchaeun Mar 7, 2023
fd7ea32
fix: console.log 제거
chchaeun Mar 7, 2023
6f6011c
feat: frozen 함수 추가
chchaeun Mar 9, 2023
90976f4
feat: HistoryRouter 구현
chchaeun Mar 9, 2023
b09d993
Delete todo.js
chchaeun Mar 9, 2023
a9bd216
refactor: 함수명 변경
chchaeun Mar 21, 2023
7895710
refactor: 필요없는 액션 삭제
chchaeun Mar 21, 2023
6a9583e
refactor: 커스텀 이벤트 상수화
chchaeun Mar 21, 2023
3182da7
refactor: 상태변경 유틸 함수화
chchaeun Mar 21, 2023
2654efd
refactor: URL API로 router 관리
chchaeun Mar 21, 2023
b152c9a
feat: 필터 기능 추가
chchaeun Mar 21, 2023
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
3 changes: 1 addition & 2 deletions vanilla-todo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
</head>
<body>
<div id="App"></div>
<script src="./src/App.js" type="module"></script>
<script src="./src/observer.js" type="module"></script>
<script src="./src/route.js" type="module"></script>
</body>
</html>
86 changes: 0 additions & 86 deletions vanilla-todo/src/App.js

This file was deleted.

48 changes: 0 additions & 48 deletions vanilla-todo/src/Component.js

This file was deleted.

36 changes: 23 additions & 13 deletions vanilla-todo/src/components/AddForm.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
import Component from "../Component.js";
import Selector from "../constants/Selector.js";
import Component from "../core/Component.js";
import { SELECTOR } from "../constants/_index.js";
import { store, SET_TODO, todoService } from "../store.js";

export default class AddForm extends Component {
html() {
return `
<form id="addForm">
<form id="${SELECTOR.ADD_FORM_ID}">
<input placeholder="Enter Todo..." />
<button type="submit">Submit</button>
</form>`;
}
setEvent() {
const handleSubmitAdding = (event) => {
event.preventDefault();

const $addForm = document.getElementById(Selector.ADD_FORM_ID);
const $todoInput = $addForm.querySelector("input");
event() {
return [
{
type: "submit",
target: `#${SELECTOR.ADD_FORM_ID}`,
handler: this.handleSubmitAdding.bind(this),
},
];
}
handleSubmitAdding(event) {
event.preventDefault();

this.props.addTodo($todoInput.value);
const $addForm = document.getElementById(SELECTOR.ADD_FORM_ID);
const $todoInput = $addForm.querySelector("input");

$todoInput.value = "";
};
this.addEvent("submit", `#${Selector.ADD_FORM_ID}`, handleSubmitAdding);
store.dispatch({
type: SET_TODO,
payload: todoService.addTodo($todoInput.value),
});
$todoInput.value = "";
}
}
44 changes: 44 additions & 0 deletions vanilla-todo/src/components/EditForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import Component from "../core/Component.js";
import { SELECTOR } from "../constants/_index.js";
import { store, SET_TODO, SET_EDITING_NULL, todoService } from "../store.js";

export default class EditForm extends Component {
html() {
const { editingId, todos } = store.getState();
if (!editingId) {
return;
}

const editingTodo = todos.find((value) => value.id === editingId);

return `
<form class="${SELECTOR.EDIT_FORM_CLASSNAME}">
<input value="${editingTodo.content}">
<button type="submit">Submit</button>
</form>
`;
}
event() {
return [
{
type: "submit",
target: `.${SELECTOR.EDIT_FORM_CLASSNAME}`,
handler: this.handleSubmitEditing.bind(this),
},
];
}

handleSubmitEditing(event) {
event.preventDefault();
store.dispatch({
type: SET_TODO,
payload: todoService.editTodo({
content: event.target[0].value,
id: store.getState().editingId,
}),
});
store.dispatch({
type: SET_EDITING_NULL,
});
}
}
27 changes: 27 additions & 0 deletions vanilla-todo/src/components/Filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Component from "../core/Component.js";
import { CONTAINER, TODO_FILTER } from "../constants/_index.js";
import { SET_FILTER, store } from "../store.js";
export default class Filter extends Component {
html() {
return `
<button id="${TODO_FILTER.TODO}">To do</button>
<button id="${TODO_FILTER.DONE}">Done</button>
<button id="${TODO_FILTER.ALL}">All</button>
`;
}
event() {
return [
{
type: "click",
target: `#${CONTAINER.FILTER}`,
handler: this.handleClickFilter.bind(this),
},
];
}
handleClickFilter(event) {
store.dispatch({
type: SET_FILTER,
payload: event.target.id,
});
}
}
10 changes: 3 additions & 7 deletions vanilla-todo/src/components/Title.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import Component from "../Component.js";
export default class Title extends Component {
html() {
return `
<h1>To do List</h1>`;
}
}
const Title = () => `<h1>To do List</h1>`;

export default Title;
Loading