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

[2주차 기본 과제] 2. WEB 💛 TO DO MATE 🌈 없애보자!!!!! #5

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

yesongoget
Copy link
Contributor

✨ 구현 기능 명세

  • 기본 과제
    -### 하트 안의 숫자
  1. 미완료한 할일의 갯수를 계산하여 보여줍니다.✔
  2. 할 일 완료 클릭시 갯수가 줄어듭니다. ✔

✅ 카테고리별 할일 추가

  1. 카테고리별 할일 추가가 가능합니다. ✔
  2. 모달을 띄워 진행합니다 ✔

✅ 달력 / MY 버튼 클릭시 페이지 이동

  1. 달력 → href=”/”
  2. MY → href=”/mycategory”
  • 심화 과제
  • 생각 과제

🌼 PR Point


🥺 소요 시간, 어려웠던 점

  • 12h
  • js... 익숙해지고 싶어요

function countUnchecked() {
// 1. HTML 파일에서 checkbox 요소들을 선택
const allCheckboxes = [...checkboxes];
if (newTodoElem) {
allCheckboxes.push(newTodoElem.querySelector('input[type="checkbox"]'));
}
// 2. 체크되지 않은 요소들의 개수를 계산
const uncheckedCount = allCheckboxes
.filter((checkbox) => !checkbox.checked)
.length;

// 3. 계산된 개수를 표시
const countElement = document.getElementById('fri_count');
countElement.textContent = uncheckedCount;
};`

newTodoElem에 대해서도 allCheckboxes 목록에 추가하고 체크되지 않은 요소들의 개수를 계산하도록 했는데..
모달을 통해 새로 추가된 할 일 목록에 대해 생성되었을 때만 count에 적용이 되고, 이후 해당 할일 목록의 checkbox를 선택하는 이벤트에 대해서는 count에 적용이 안되더라구요 .. .ㅠ 놓친 부분이 있는 것 같은데.. 해결 방법을 알고 싶습니닷...


🌈 구현 결과물

webtodo.mp4

Comment on lines +7 to +9
{ id: 'check1', text: '웹팟 과제' },
{ id: 'check2', text: '1차 세미나 복습' },
{ id: 'check3', text: '리액트 서터디' },
Copy link

Choose a reason for hiding this comment

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

그 체크 된 요소 새로 추가 된 애랑 모든 요소에 나는 state: true 또는 false로 해서 상태값을 정해주고 그 상태값에 대해서 개수를 계산하도록 했고돈?! 모달을 추가할 요소에도 상태값이 포함된 상태로 하면 상태값 계산 함수를 만들어서 계속 재사용하면 되도라곡...!

Copy link

Choose a reason for hiding this comment

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

근데 요건 내 방법이공!! 다른 방법도 많고 내카.. 좀 더 찾아서 올려줄궤!!>><><

Choose a reason for hiding this comment

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

나도 일단 데이터에 Done으로 true 아님 false를 줘놨었어!! 그리고 전역으로 todonum이라는 변수 만든다음에 할일 리스트 만들때 한번 체크해서 할일값이 false인 애들 세서 개수 집어넣어놓은 다음에, 이후에 모든 state 건드는 함수들 안에다가 todonum++이나 -- 같이 넣어놔서 매번 전역으로 만들어놓은 todonum을 건드리고 다시 html에 띄워주도록 했어..! 이게 좋은 방법인지는 잘 모르겠다ㅠㅠ

Copy link

@Dangpy Dangpy left a comment

Choose a reason for hiding this comment

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

image
째고야!! 예혀나!!! 리팩토하면서 이동 하는 것도 해보면 좋을것같아이이잉 카테고리 페이지로 ><><><><

Copy link

@eastlaw80 eastlaw80 left a comment

Choose a reason for hiding this comment

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

정말,,,자스 쉽지 않다,,,어려운 과제 하느라 고생했어 예현이!!

Comment on lines +7 to +9
{ id: 'check1', text: '웹팟 과제' },
{ id: 'check2', text: '1차 세미나 복습' },
{ id: 'check3', text: '리액트 서터디' },

Choose a reason for hiding this comment

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

나도 일단 데이터에 Done으로 true 아님 false를 줘놨었어!! 그리고 전역으로 todonum이라는 변수 만든다음에 할일 리스트 만들때 한번 체크해서 할일값이 false인 애들 세서 개수 집어넣어놓은 다음에, 이후에 모든 state 건드는 함수들 안에다가 todonum++이나 -- 같이 넣어놔서 매번 전역으로 만들어놓은 todonum을 건드리고 다시 html에 띄워주도록 했어..! 이게 좋은 방법인지는 잘 모르겠다ㅠㅠ

Comment on lines +102 to +127
// 2. 체크되지 않은 요소들의 개수를 계산
const uncheckedCount = allCheckboxes
.filter((checkbox) => !checkbox.checked)
.length;

// 3. 계산된 개수를 표시
const countElement = document.getElementById('fri_count');
countElement.textContent = uncheckedCount;
};

checkboxes.forEach((checkbox) => {
checkbox.addEventListener('change', countUnchecked);
});


addBtns.forEach(addBtn => {
addBtn.addEventListener('click', () => {
// 모달 생성 및 표시
const modal = modalTemplate.cloneNode(true);
modal.classList.add('modal');
document.body.appendChild(modal);
// 모달 보이기
modal.style.display = 'block';
// submit 이벤트 등록
const form = modal.querySelector('form');

Choose a reason for hiding this comment

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

기능들마다 주석 잘 되어있어서 너무 읽기 좋다ㅎㅎ,,,

Copy link

@eastlaw80 eastlaw80 left a comment

Choose a reason for hiding this comment

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

정말,,,자스 쉽지 않다,,,어려운 과제 하느라 고생했어 예현이!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants