Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 22 additions & 0 deletions mission002/kimjieun/components/TodoCheck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ACTIVE, COMPLETED, ALLSELECTED } from '../utils/constants.js'

export default class TodoCheck {
constructor({ $selector }) {
this.$selector = $selector

this.init()
}

init = () => {
this.$selector.addEventListener('click', (e) => {
switch (e.target.className) {
case ACTIVE:
return this.onTodoCheck(ACTIVE)
case COMPLETED:
return this.onTodoCheck(COMPLETED)
default:
return this.onTodoCheck(ALLSELECTED)
}
})
}
}
13 changes: 13 additions & 0 deletions mission002/kimjieun/components/TodoCount.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default class TodoCount {
constructor({ $selector }) {
this.$selector = $selector
}

createHtmlString = (data) => {
return `총 <strong>${data.length}</strong> 개`
}

createTodoCount = (data) => {
this.$selector.innerHTML = this.createHtmlString(data)
}
}
13 changes: 13 additions & 0 deletions mission002/kimjieun/components/TodoInput.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default class TodoInput {
constructor({ $selector }) {
this.$selector = $selector

this.init()
}

init() {
this.$selector.addEventListener('keydown', (e) => {
this.onKeyDown(e)
})
}
}
33 changes: 33 additions & 0 deletions mission002/kimjieun/components/TodoList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { DESTROY, TOGGLE } from '../utils/constants.js'

export default class TodoList {
constructor({ $selector }) {
this.$selector = $selector
this.init()
}

init = () => {
this.$selector.addEventListener('click', (e) => {
if (e.target.className === DESTROY) return this.onDeleteTodo(e.target.parentNode.dataset.idx)
if (e.target.className === TOGGLE) return this.onToggleTodo(e.target.parentNode.dataset.idx)
})
}

createLiClassName = (isCompleted) => isCompleted ? 'completed' : 'view'

createTodoListHtmlString = ({ content, isCompleted, _id }) => {
return `<li class=${this.createLiClassName(isCompleted)}>
<div data-idx=${_id} class="view">
<input class="toggle" type="checkbox" ${isCompleted === true && 'checked'}>
Copy link
Collaborator

@YongHoonJJo YongHoonJJo Jan 7, 2020

Choose a reason for hiding this comment

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

isCompoled 가 false 면 <input class="toggle" type="checkbox" false> 이런식으로 남게 되지 않을까요? (전에 제가 이렇게 했었지만요..ㅎ)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ㅎㅎ 테스트해보겠습니다! ㅎ

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

false 안남는것으로 확인했습니다 ㅎㅎ

<label class="label">${content}</label>
<button class="destroy"></button>
</div>
<input class="edit" value="${content}">
</li>`
}

render = (data) => {
const $todoList = document.querySelector('#todo-list')
$todoList.innerHTML = data.map(this.createTodoListHtmlString).join('')
}
}
Loading