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
21 changes: 21 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>To Do List</title>
</head>

<body>
<h1>To Do List</h1>
<div class="container">
<input id="inputField" type="text">
<button id="addToDo"> + </button>
<div class="to-dos" id="toDoList"> </div>
</div>
Comment on lines +13 to +17
Copy link

Choose a reason for hiding this comment

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

카멜 케이스(inputFiled, addToDo)와 케밥케이스(to-dos)를 같은 파일에서 사용하시는 것은 코드의 일관성이 깨질 수 있습니다😊
하나의 케이스로 통일하시는 게 좋을 것 같습니다.
보통 classname이나 id는 케밥케이스로 잇는 경우가 많습니다.
이를 통일하기 위해 bem 방법론이나 여러 방법론을 통해 className이나 id 이름을 지을 때 기준을 정해서 협업을 하곤 합니다.
링크 첨부할테니 한번 편하게 읽어보시면 좋을 것 같습니다,
https://whales.tistory.com/33

<script src="main.js"> </script>
Copy link

Choose a reason for hiding this comment

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

script는 body에 맨 마지막에만 삽입할 수 있을까요?
맨 마지막에 삽입하면 어떤 점이 좋을까요?
이 부분은 관심이 생기면 한번 찾아보시면 브라우저가 html을 읽어 보여주는 과정이 이해가 되실 거에요

</body>

</html>
22 changes: 22 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
let inputBox = document.getElementById('inputField')
let addToDo = document.getElementById('addToDo')
let toDoList = document.getElementById('toDoList')

addToDo.addEventListener('click', function(){
var list = document.createElement('li');
if (!inputBox.value)
alert('내용을 입력하세요!');
else
Comment on lines +7 to +9
Copy link

Choose a reason for hiding this comment

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

만약 조건들이 엄청나게 많아지면 어떻게 될까요?
else if가 엄청 많아지겠죠?
이는 유지보수하기 쉽지 않습니다.
조건을 추가할 때마다 모든 조건의 종속 관계를 체크해야합니다.
이를 방지하기 위해 얼리 리턴을 하는 방식을 많이 사용하곤 합니다.
위 코드에서는


if(!inputBox.value) return alert('내용을 입력하세요!);


로 사용하면 아래 else는 필요없어지겠네요!

{
list.innerText = inputBox.value;
toDoList.appendChild(list);
inputBox.value= "";
}

list.addEventListener('click', function(){
list.style.textDecoration = "line-through";
})
Comment on lines +16 to +18
Copy link

Choose a reason for hiding this comment

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

만약 이미 line-through인 list는 line-through를 지워주고 line-through가 없는 리스트는 line-through를 넣어주려면 어떻게 해야할까요?

list.addEventListener('dblclick', function(){
toDoList.removeChild(list);
})
Comment on lines +19 to +21
Copy link

Choose a reason for hiding this comment

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

사용자는 더블클릭으로 투두리스트가 삭제된다는 것을 어떻게 알 수 있을까요?
이는 좋은 사용자 경험일까요?

})
22 changes: 22 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
html, body {
width: 50%;
margin: 0 auto;
font-family: Arial, Helvetica, sans-serif;
}

.container {
width: 360px;
}
Comment on lines +7 to +9
Copy link

Choose a reason for hiding this comment

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

어떤 기기에서나 보기 좋은 width를 설정하려면 어떻게 해야할 지 고민해보셔도 좋을 것 같아요!
여러 경우의 수를 꼼꼼하게 고민해보시면 더 많은 내용을 깊게 생각해보실 수 있을거에요!
반응형 스타일링에 대한 글을 첨부할테니 시간 나실 때 한번 읽어보셔요😊
https://www.daleseo.com/css-responsive-layouts/


#inputFiled {
width: 300px;
height: 46px;
border: 1px solid black;
outline: none;
font-size: 25px;
vertical-align: middle;
}

.to-dos {
margin-top:25px;
}
Comment on lines +20 to +22
Copy link

Choose a reason for hiding this comment

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

이 부분은 띄어쓰기가 위에 내용과 다르네요!
매번 띄어쓰기등을 생각하며 개발하는 것은 힘든 일이라고 생각합니다!

이러한 코드들의 정렬을 도와주는 prettier라는 라이브러리가 있습니다.
설정하시면 도움되실 것 같아 설정하는 방법의 링크를 첨부하겠습니다!
https://record22.tistory.com/112