Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
1️⃣ 어떤 작업을 했나요? (Summary)
2025-01-27.8.41.23.mov
dialog와 statebutton 컴포넌트를 제작하였습니다.
기존 코드에 영향을 미치는 변경사항
index.css
에 button 관련 코드 주석처리 해두었습니다./test
이 경로로 들어가면 확인 가능합니당기존 코드에 영향을 미치지 않는 변경사항
컴포넌트 사용 방법
일단 컴포넌트 전체 구조입니다! 추가된 부분만 썼어요
Dialog 컴포넌트 구현
Handy의 TextButton을 기반으로 한 리스트 형태의 다이얼로그 컴포넌트입니다. TextButton을 여러개 이어서 만들었어요.
만약 새로운 다이얼로그가 필요한 경우 options에 새로운 배열을 넣고 만들면 돼요!
이런 식으로 props를 넣어주면
이런 다이얼로그가 생겨요
GenericDialog 컴포넌트 구현
그럼 이건 무엇이냐 하면 Dialog를 버튼과 같이 쉽게 쓰기 위해 만든 래퍼 컴포넌트에요
래퍼라
children: React.ReactElement;
이 부분만 추가된 거 확인하면 될 것 같습니당버튼을 children로 받는 거라고 생각하면 돼요! 그래서 받은 버튼 + GenericDialog = 드롭다운 형태를 쉽게 만들도록 했어요
이런식으로 사용하면 됩니당 핸디에서 쓰는 BoxButton과 같이 버튼을 안에 넣어주면
이렇게 쓸 수 있어요
StateButton 컴포넌트 구현
위에서 설명한
GenericDialog
와 버튼을 합쳐두었어요!이거 세 개는 미리 만들어 두었어요
얘네는 만들어둔거라 이런식으로 사용하면 될 것 같아요
순서대로 이거 세 개 입니당
2️⃣ 알아두시면 좋아요!
3️⃣ 추후 작업
렌더 프롭 해결하기
다이얼로그 외부 클릭이랑 버튼 재 클릭시 다이얼로그가 닫히게 하기 위해서
cloneElement
를 썼는데요, 이걸 쓰지 말라고 하더라구요 암튼 그래서 이 부분 수정할건데 아마 전반적인 코드는 안바뀔 것 같아서 일단 pr 올리고 제롬이 저의 고봉밥 pr을 읽는 동안 수정해서 커밋하도록 하겠습니당그리고 쉽게 갖다 쓸 수 있게 생각하고 코드 짜긴 했는데 너무 어렵더라구여... 이 부분 이상하다 이 컴포넌트 도저히 못 쓰겠다 하는 건 바로 말해주세요 이해 안가는 부분도 말해주세요 바로 달려오겠음 자 여기까지 pr 읽어주셔서 감사합니다 ㅎ
4️⃣ 체크리스트 (Checklist)
main
브랜치의 최신 코드를pull
받았나요?