-
Notifications
You must be signed in to change notification settings - Fork 11
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주차] 김류원 미션 제출합니다. #10
base: master
Are you sure you want to change the base?
Changes from 1 commit
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 |
---|---|---|
@@ -1 +1,82 @@ | ||
//😍CEOS 20기 프론트엔드 파이팅😍 | ||
const addBtn = document.querySelector('.addBtn'); | ||
const TodoInput = document.querySelector('.TodoInput'); | ||
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. 여기서도 |
||
const todoList = document.querySelector('.todoList'); | ||
const todoForm = document.querySelector('.writeTodoForm'); | ||
const todoIcon = document.querySelector('.todoForm img'); | ||
|
||
|
||
function addTodo(e) { | ||
e.preventDefault(); | ||
|
||
const Todo = TodoInput.value.trim(); | ||
|
||
if (Todo) { | ||
createTodoElement(Todo); | ||
TodoInput.value = ''; | ||
} else { | ||
alert('To Do를 입력하세요'); | ||
} | ||
} | ||
|
||
todoForm.addEventListener('submit', addTodo); | ||
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 createTodoElement(Todo) { | ||
const listItem = document.createElement('li'); | ||
|
||
// 완료 토글 아이콘 | ||
const toggleIcon = document.createElement('img'); | ||
toggleIcon.src = './icon/notCheck.svg'; | ||
toggleIcon.alt = 'Toggle unComplete'; | ||
toggleIcon.classList.add('toggle-icon'); | ||
|
||
toggleIcon.addEventListener('click', () => { | ||
listItem.classList.toggle('completed'); | ||
todoText.classList.toggle('completed-text'); | ||
if (listItem.classList.contains('completed')) { | ||
toggleIcon.src = './icon/checkComplete.svg'; | ||
toggleIcon.alt = 'Toggle Complete'; | ||
} else { | ||
toggleIcon.src = './icon/notCheck.svg'; | ||
toggleIcon.alt = 'Toggle unComplete'; | ||
} | ||
}); | ||
|
||
// 투두 텍스트 | ||
const todoText = document.createElement('span'); | ||
todoText.textContent = Todo; | ||
|
||
// 삭제 버튼 | ||
const deleteBtn = document.createElement('button'); | ||
deleteBtn.textContent = '삭제'; | ||
deleteBtn.classList.add('delete-btn'); | ||
deleteBtn.addEventListener('click', () => { | ||
todoList.removeChild(listItem); | ||
}); | ||
|
||
// HTML 구조에 맞게 요소 추가 | ||
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. 다혜님이 말씀해주신것처럼, appendchild 메서드로 요소를 하나씩 추가하는 것보다 한번에 추가하는 방법을 사용하는게 최적화 측면에서도 좋아보여요! 가빈께 남긴 코드리뷰중에, 리플로우와 리페인팅에 대한 설명을 참고해보시면 좋을 것 같아요! |
||
listItem.appendChild(toggleIcon); | ||
listItem.appendChild(todoText); | ||
listItem.appendChild(deleteBtn); | ||
Comment on lines
+94
to
+96
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. 혹시 |
||
todoList.appendChild(listItem); | ||
} | ||
|
||
|
||
// 날짜 표시 함수 | ||
function formatDateKorean(date) { | ||
const days = ['일요일', '월요일', '화요일', '수요일', '목요일', '금요일', '토요일']; | ||
const months = ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월']; | ||
Comment on lines
+102
to
+103
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. 이렇게 상수를 선언해 주신 점 좋습니다👍 |
||
|
||
const month = months[date.getMonth()]; | ||
const day = date.getDate(); | ||
const dayOfWeek = days[date.getDay()]; | ||
|
||
return `${month} ${day}일 ${dayOfWeek}`; | ||
} | ||
Comment on lines
+101
to
+110
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.
|
||
|
||
// 페이지 로드 시 오늘 날짜 표시 | ||
document.addEventListener('DOMContentLoaded', () => { | ||
const todayDateElement = document.getElementById('todayDate'); | ||
const today = new Date(); | ||
todayDateElement.textContent = formatDateKorean(today); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,44 @@ | ||
/* 본인의 디자인 감각을 최대한 발휘해주세요! */ | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
} | ||
|
||
li { | ||
list-style: none; | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
/**/ | ||
|
||
.todoContainer { | ||
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. 류원님의 투투리스트에서 항목이 height을 초과하는 경우에, 컨테이너 밖으로 삐져나오게 되는 것 같아요. 이때 css의 overflow 속성을 사용하면, 컨텐츠가 컨테이너를 초과할 때 어떻게 처리할지 설정해줄 수 있을 것 같아요!! |
||
background-color: #f1f3ff;} | ||
header{ | ||
padding-left: 45px; | ||
|
||
} | ||
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. |
||
|
||
|
||
.completed-text { | ||
text-decoration: line-through; | ||
color: #888; | ||
} | ||
|
||
.toggle-icon, .delete-icon { | ||
width: 20px; | ||
height: 20px; | ||
cursor: pointer; | ||
} | ||
|
||
.toggle-icon { | ||
margin-right: 10px; | ||
} | ||
|
||
.delete-icon { | ||
margin-left: auto; | ||
} | ||
|
||
span { | ||
flex-grow: 1; | ||
} |
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.
WriteForm
이나TodoInput
,check_icon
에서 네이밍 컨벤션이 다른 부분이 보이는데, 혹시 의도하신걸까요?!