Skip to content

Conversation

@KingNono1030
Copy link
Contributor

@KingNono1030 KingNono1030 commented Nov 18, 2024

📌 PR 템플릿

🏷️ PR 타입 (PR Type)

아래 해당 사항에 체크해 주세요.

  • 🐛 버그 수정 (Bugfix)
  • ✨ 기능 개발 (Feature)
  • 🎨 코드 스타일 변경 (Code style update) - 포매팅, 로컬 변수 등
  • ♻️ 리팩토링 (Refactoring) - 기능 변화 없음, API 변경 없음
  • 🛠️ 빌드 관련 변경 (Build related changes)
  • 📝 문서 내용 변경 (Documentation)
  • 🔄 기타 (Other) - 설명 작성

📝 요약 (Summary)

PR의 목적과 간단한 설명을 적어주세요.

드롭다운 메뉴 또는 설렉트 컴포넌트의 재료가 되는 아토믹한 드롭다운의 개발


🔍 상세 내용 (Describe your changes)

변경 사항을 구체적으로 작성해 주세요.

  • 기본 드롭다운 스타일링
  • 드롭다운 스토리 추가
  • 드롭다운 이용 -> 헤더 유저 메뉴
    • 공통 컴포넌트 하이라이트, 아바타 일부 수정
  • 스토리 추가

🔗 관련 이슈 또는 링크 (Issue Number or Link)

이슈 번호나 관련 링크가 있다면 추가해 주세요.


✅ 체크리스트 (Checklist)

PR 작성 시 아래 사항들을 점검해 주세요.

  • 빌드가 성공적으로 되었나요?
  • 코드에 주석을 추가했나요?
  • 모든 테스트가 통과했나요?
  • 관련 문서가 업데이트되었나요?

📸 스크린샷 (선택 사항)

변경 사항이 UI와 관련이 있다면 스크린샷을 추가해 주세요.

2024-11-21.01.27.05.mov

image

  • 드롭다운 바깥을 누르면 드롭다운이 닫힙니다.

📝 기타 사항

PR과 관련된 기타 사항이 있다면 적어주세요.

@KingNono1030 KingNono1030 self-assigned this Nov 18, 2024
@KingNono1030 KingNono1030 linked an issue Nov 18, 2024 that may be closed by this pull request
5 tasks
@KingNono1030 KingNono1030 marked this pull request as ready for review November 20, 2024 16:38
@KingNono1030 KingNono1030 requested a review from yongb2n November 20, 2024 16:38
@yellowjang
Copy link
Contributor

혹시 프로필 눌렀을 때, 드롭다운 열리면서 프로필이 살짝 밀리는 건 스토리북 환경에서만 그런건가요 ??

Copy link
Contributor

@yellowjang yellowjang left a comment

Choose a reason for hiding this comment

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

작업량이 엄청나시네요 ...
윤호님 코드는 주석이 없어도 흐름대로 코드가 깔끔하게 잘 작성되어 있어서 가독성이 정말 뛰어난 것 같아요... 많이 배웁니다 ㅜㅜ

}, [])

return (
<DropdownContext.Provider value={{ isOpen, toggle, close }}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Dropdown value에 상태를 넣어주는거군요..!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

맞아요 드롭다운 안에서는 context api 로 상태를 관리하고 있어요

}

interface MenuProps extends BaseProps {
position?: 'dropup' | 'dropdown'
Copy link
Contributor

Choose a reason for hiding this comment

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

오 dropup/dropdown 으로 구분해서 position prop 나누어주는 거 좋은 것 같아요

Comment on lines +89 to +96
const Menu = ({
children,
className = '',
position = 'dropdown',
alignment = 'left',
}: MenuProps): JSX.Element | null => {
const { isOpen } = useDropdownContext()
if (!isOpen) return null
Copy link
Contributor

Choose a reason for hiding this comment

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

이런 식으로 prop 넘겨주는 게 많다보면 사용할 때 복잡할 거라고 생각했었는데 오히려 어떤 것들을 지정해줘야 되는지 명확해서 좋은 것 같네용

Copy link
Contributor Author

Choose a reason for hiding this comment

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

저도 바깥에서 classNames 를 내리느냐 vs 미리 props 를 연결해주느냐
관련해서 많은 고민을 했는데, 드롭다운을 쓰는 동료 개발자 입장에서는
처음부터 className을 임의로 주기에는 복잡도가 높은 것 같아서, 어느 정도 반복되는 패턴이 있으면 props 로 넘기고
예외가 있다면 바깥에서 추가로 스타일링을 입히는 방식으로 굳혔어요 ㅎㅎ

Comment on lines +128 to +131
const handleClick = (e: React.MouseEvent<HTMLElement>) => {
if (typeof onClick === 'function') {
onClick(e)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

혹시 typeof onClick 가 function 일 경우에 onClick 이벤트가 발생하도록
처리하신 이유가 있으신가요 ??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

onClick 이 옵셔널 프롭스인데, onClick 이 undefined 일 때 호출을 하면 타입 에러가 발생해서,
onClick 을 받은 경우에만 호출하도록 타입 가드를 설정해줬어요

Copy link
Contributor

Choose a reason for hiding this comment

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

아!! 그런 거였군요 ㅎㅎ 설명 감사합니다 :)

@KingNono1030
Copy link
Contributor Author

혹시 프로필 눌렀을 때, 드롭다운 열리면서 프로필이 살짝 밀리는 건 스토리북 환경에서만 그런건가요 ??

네 맞아요 저게 layout centered 라서, 자동으로 중간에 맞추려고 해서 그런데,
absolute 라서 트리거만 노말 플로우고, 메뉴 부분은 기존 돔 레이아웃에 관계 없어요

@KingNono1030
Copy link
Contributor Author

작업량이 엄청나시네요 ... 윤호님 코드는 주석이 없어도 흐름대로 코드가 깔끔하게 잘 작성되어 있어서 가독성이 정말 뛰어난 것 같아요... 많이 배웁니다 ㅜㅜ

제가 듣고 싶은 최고의 찬사네요 ㅎㅎ 감사합니다
근데 우리가 컴포넌트 기반의 개발을 해서 더욱이 두드러지는 것 같아요 :)

@KingNono1030 KingNono1030 merged commit be6443b into dev Nov 22, 2024
3 of 4 checks passed
@KingNono1030 KingNono1030 deleted the feat/common-component-dropdown branch November 25, 2024 05:16
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.

[FEATURE] [공통 컴포넌트] Dropdown

3 participants