Skip to content
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주차] 오대균 미션 제출합니다. #1

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
13 changes: 9 additions & 4 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ addBtn.addEventListener('click', handleClickAddBtn);
const utc = Date.now();
const timeOff = new Date().getTimezoneOffset() * 60000;
const today = new Date(utc - timeOff).toISOString().split('T')[0];
document.querySelector('.dateInput').setAttribute('min', today);
const dateInputs = document
.querySelectorAll('.dateInput')
.forEach((dateInput) => {
dateInput.setAttribute('min', today);
});
Comment on lines +29 to +33

Choose a reason for hiding this comment

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

시작일 설정에 대한 제한도 걸어두신거 좋은 아이디어 인것 같아요! foreach 함수를 자유롭게 사용하시는 것 같아요 저도 배워야겠어요!


// 시작일 설정에 change event handler 등록
const fromDate = document.querySelector('.from');
Expand Down Expand Up @@ -153,7 +157,7 @@ function handleClickAddBtn() {
const fromDate = document.querySelector('.from');
const toDate = document.querySelector('.to');

if (!content.value || !fromDate.value || !toDate.value) return;
if (!content.value) return;

Choose a reason for hiding this comment

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

이 부분은 저도 리뷰를 받아서 알게 된 부분인데, input 입력시 스페이스바를 눌렀을때도 리스트에 추가되는데, trim()을 통해 공백을 제거하시면 빈 스페이스바 todo 를 방지할수 있다고 합니다!

Copy link
Author

Choose a reason for hiding this comment

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

아 그렇네요!! 고려하지 못한 디테일이었는데 덕분에 알게되었습니다 감사합니다~~

newTodo.idx = nextIdx++;
newTodo.content = content.value;
priorities.forEach((priority) => {
Expand All @@ -162,8 +166,8 @@ function handleClickAddBtn() {
return;
}
});
newTodo.fromDate = new Date(fromDate.value);
newTodo.toDate = new Date(toDate.value);
newTodo.fromDate = fromDate.value ? new Date(fromDate.value) : new Date();
newTodo.toDate = toDate.value ? new Date(toDate.value) : new Date();
Comment on lines +182 to +183

Choose a reason for hiding this comment

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

삼항 연산자를 통해 날짜를 등록하지 않았을 떄의 예외처리 까지 하신 것이 인상깊네요!

newTodo.isDone = false;

Choose a reason for hiding this comment

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

isDone으로 todo랑 done 구분하는 방법도 직관적이고 좋은 것 같네요~!


pushTodo(newTodo);
Expand All @@ -183,5 +187,6 @@ function handleChangeFromDate(e) {
let timeOff = new Date().getTimezoneOffset() * 60000;
let today = new Date(utc - timeOff).toISOString().split('T')[0];
document.querySelector('.to').setAttribute('min', today);
document.querySelector('.to').setAttribute('value', e.currentTarget.value);
}
}