-
Notifications
You must be signed in to change notification settings - Fork 10
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
[1주차] 김선영 미션 제출합니다. #2
base: master
Are you sure you want to change the base?
Changes from all commits
0e5fc47
e8f1e88
1ff10fd
f2b41ba
ffb2f3a
bfaea76
bba2e11
73a6c43
d218dca
62ac982
786d267
9bfc4f2
52a1efa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,22 @@ | |
</head> | ||
|
||
<body> | ||
<div class="container"></div> | ||
<div class="container"> | ||
<div class="box"> | ||
<form id="todo-form"> | ||
<h2>☑️ 투두리스트 ☑️ </h2> | ||
<input type="text" placeholder="할 일을 작성하세요" required maxlength="30"/> | ||
</form> | ||
</div> | ||
<div class="box"> | ||
<h2>📝 할 일 목록 📝</h2> | ||
<ul class="list" id="todo-list"></ul> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 공통적인 부분은 |
||
</div> | ||
<div class="box"> | ||
<h2>💙 완료 목록 💙</h2> | ||
<ul class="list" id="done-list"></ul> | ||
</div> | ||
</div> | ||
</body> | ||
<script src="script.js"></script> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
const todoForm = document.getElementById("todo-form"); | ||
const todoInput = todoForm.querySelector("input"); | ||
const todoList = document.getElementById("todo-list"); | ||
const doneList = document.getElementById("done-list"); | ||
|
||
todoForm.addEventListener("submit", submitTodo); | ||
|
||
function submitTodo(e) { | ||
e.preventDefault(); | ||
createTodo(todoInput.value); | ||
todoInput.value = ""; | ||
} | ||
|
||
/* | ||
코드 방식 어떤게 좋을까요.?.? | ||
createTodo() 처럼 변수를 생성하고 해당 변수에 대해 작업을 작성하는게 좋을지, | ||
completeTodo() 처럼 변수 생성을 한번에 하고 작업을 한번에 하는게 좋을지 | ||
궁금해서 올려요! | ||
*/ | ||
Comment on lines
+14
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이미 아시겠지만 코드에는 정답이 없습니다! 자기만의 기준을 명확하게 세우고 코드를 구성한다면 그게 바로 좋은 방법 아닐까요 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jhj2713 오오.. 사실 질문하면서도 많이 애매한 부분이라 소심하게 주석으로 질문했는데 이렇게 좋은 답변 주셔서 너무 감사합니다 💙 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저도 이 점 굉장히 궁금했는데 선영님이 고민하시고 효정님이 답변해주신 글 보니까 고민이 해결되었습니다! 앞으로도 좀 더 명확하고 좋은 코드를 위해 고민하겠습니다! |
||
|
||
function createTodo(content) { | ||
const todoSpan = document.createElement("span"); | ||
todoSpan.innerText = content; | ||
|
||
const completeBtn = document.createElement("button"); | ||
completeBtn.innerText = "✅"; | ||
completeBtn.addEventListener("click", completeTodo); | ||
|
||
const newTodoLi = document.createElement("li"); | ||
newTodoLi.append(todoSpan, completeBtn); | ||
|
||
todoList.append(newTodoLi); | ||
} | ||
|
||
function completeTodo(e) { | ||
const target = e.target.parentElement; | ||
|
||
const doneLi = document.createElement("li"); | ||
const doneSpan = document.createElement("span"); | ||
const doneBtn = document.createElement("button"); | ||
const returnBtn = document.createElement("button"); | ||
|
||
doneSpan.innerText = target.querySelector("span").innerText; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저는 span 태그가 아직 익숙하지 않아서 다른 방법을 사용했는데, 선영님처럼 span 을 사용하면 조금 더 깔끔하게 코드를 작성할 수 있어 좋은 것 같습니다! |
||
|
||
doneBtn.innerText = "❌"; | ||
doneBtn.addEventListener("click", deleteTodo); | ||
|
||
returnBtn.innerText = "🆙"; | ||
returnBtn.addEventListener("click", returnTodo); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저는 span을 클릭해서 todo 리스트로 옮기는 방식으로 했는데 returnBtn을 넣는게 사용자 입장에서는 더 명확한 기능일 것 같네요! 너무 좋은 방식 같습니다 🥰 |
||
doneLi.appendChild(doneSpan); | ||
doneLi.appendChild(doneBtn); | ||
doneLi.appendChild(returnBtn); | ||
seondal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
doneList.append(doneLi); | ||
|
||
target.remove(); | ||
} | ||
|
||
function returnTodo(e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 추가, 삭제하는 함수가 중복되는 부분이 없어 깔끔해 좋은 것 같습니다. e.target을 사용하여 깔끔하게 코드 작성할 수 있는 점 배우고 갑니다 ㅎㅎ 감사합니다 |
||
const value = e.target.parentElement.querySelector("span").innerText; | ||
createTodo(value); | ||
|
||
deleteTodo(e); | ||
} | ||
Comment on lines
+60
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
function deleteTodo(e) { | ||
e.target.parentElement.remove(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. deleteTodo 함수를 이렇게 깔끔하게 적는 방법도 있군요! 저는 고민을 많이해서 쓸데없는 코드도 많이 적었는데 ... 배워갑니다! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
@font-face { | ||
font-family: 'EarlyFontDiary'; | ||
src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_220508@1.0/EarlyFontDiary.woff2') format('woff2'); | ||
font-weight: normal; | ||
font-style: normal; | ||
} | ||
|
||
html, body { | ||
font-family: 'EarlyFontDiary'; | ||
height: 100%; | ||
display: flex; | ||
align-items : center; | ||
justify-content: center; | ||
flex-direction: column; | ||
padding: 20px; | ||
overflow: hidden; | ||
background-color: rgb(0, 70, 42); | ||
} | ||
|
||
.container { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
background-color: whitesmoke; | ||
width: 360px; | ||
padding: 20px; | ||
border-radius: 20px; | ||
} | ||
|
||
.box { | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
align-items: center; | ||
padding-bottom: 20px; | ||
border-bottom: 1px solid gray; | ||
} | ||
|
||
form { | ||
width: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
} | ||
|
||
input { | ||
box-sizing: border-box; | ||
padding: 10px; | ||
height: 50px; | ||
width: 250px; | ||
border: 1px solid lightgray; | ||
border-radius: 10px; | ||
box-shadow: none; | ||
} | ||
|
||
button { | ||
border: 0; | ||
background: none; | ||
cursor: pointer; | ||
} | ||
|
||
.list { | ||
display: flex; | ||
flex-direction: column; | ||
width: 80%; | ||
height: 200px; | ||
overflow: hidden auto; | ||
} | ||
|
||
#done-list { | ||
text-decoration: line-through; | ||
color: gray; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Semantic Tag에 대해 공부한 만큼 여기서도
div
말고 적절한 Semantic Tag를 사용해보는 것은 어떨까요~?