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

Feat/11/modal component #22

Merged
merged 15 commits into from
Jul 8, 2024

Conversation

donghunee
Copy link
Collaborator

Modal Component


🏄🏼‍♂️‍ Summary (요약)

  • Modal Component 생성

🫨 Describe your Change (변경사항)

  • Modal Component 생성
  • Modal Portal 적용
  • useModal hook 생성

🧐 Issue number and link (참고)

2024-07-07.10.44.00.mov
  • 많은 피드백 부탁드립니다:)

📚 Reference (참조)

@donghunee donghunee added the 🚀 feature New feature or request label Jul 7, 2024
@donghunee donghunee added this to the v1.0.0 milestone Jul 7, 2024
@donghunee donghunee self-assigned this Jul 7, 2024
@donghunee donghunee added the 🚧 still working 수정 중입니다. 아직 리뷰하지 말아주세요! label Jul 7, 2024
@donghunee donghunee removed the 🚧 still working 수정 중입니다. 아직 리뷰하지 말아주세요! label Jul 7, 2024
Copy link
Member

@leeminhee119 leeminhee119 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 !!
오호 몰랐는데 React DOM에서 createPortal API를 제공하고 있군요...!! 📝

Comment on lines 17 to 19
<Modal onClose={close} isModalOpen={isOpen}>
<div>냠냠</div>
</Modal>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<Modal onClose={close} isModalOpen={isOpen}>
<div>냠냠</div>
</Modal>
{isOpen &&
<Modal onClose={close}>
<div>냠냠</div>
</Modal>
}

요렇게 하고 Modal 안에서 스크롤 방지하는 로직을 useModal 훅으로 옮기면 isModalOpen props가 없어져도 될 것 같아요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

prop로 넘기는 것보다 더 깔끔한 것 같아요~!! 감사합니다:)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

isOpen을 계속 써야하는 번거로움이 있을 것 같아서 코드를 개선해봤습니다~!!

Comment on lines 14 to 16
useEffect(() => {
document.body.style.overflow = isModalOpen ? "hidden" : "auto";
}, [isModalOpen]);
Copy link
Member

Choose a reason for hiding this comment

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

이 내용을 useModal 훅 안에서 isModalOpen 대신 isOpen으로 대체해서 옮기면 어떨까요 ??

@donghunee donghunee added the 🚧 still working 수정 중입니다. 아직 리뷰하지 말아주세요! label Jul 7, 2024
@donghunee donghunee requested a review from sean2337 July 7, 2024 17:29
@donghunee donghunee removed the 🚧 still working 수정 중입니다. 아직 리뷰하지 말아주세요! label Jul 8, 2024
export type ModalType = {
isOpen: boolean;
title: string;
content: JSX.Element | string;
Copy link
Member

Choose a reason for hiding this comment

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

문자열이랑 컴포넌트도 넘길 수 있군요 ✨

isOpen: boolean;
title: string;
content: JSX.Element | string;
callBack?: () => any;
Copy link
Member

Choose a reason for hiding this comment

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

callBack을 any 로 정의하신 이유가 궁금합니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

void로 해야하는걸 실수 했네요 수정해놓겠습니다:)

return () => {
document.removeEventListener("mousedown", listener);
};
}, [close, modalRef]);
Copy link
Member

Choose a reason for hiding this comment

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

modalRef를 의존성 배열에 넣지 않으면 동작하지 않는 코드인가요?! 궁금해요!🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

아이고 체크를 못했네요.. close랑 modalRef 둘다 넣지 않아도 됩니다:)

@klmhyeonwoo
Copy link
Member

너무너무 고생하셨습니다 🏄🏼‍♂️

@klmhyeonwoo klmhyeonwoo mentioned this pull request Jul 8, 2024
14 tasks
@donghunee donghunee merged commit bba70bb into depromeet:develop Jul 8, 2024
1 check passed
@donghunee donghunee deleted the feat/11/modal-component branch July 8, 2024 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants