Skip to content

Conversation

@suji8073
Copy link
Member

Motivation 🤔

  • 기존에는 Bottom Sheet가 올라온 상태에서는 댓글 입력 영역 컴포넌트가 보이지 않았음
  • 변경된 가이드에서는 Bottom Sheet가 올라온 상태일 때, 댓글 입력 영역 컴포넌트가 보여야 함
    • 보임과 동시에 Bottom Sheet가 움직임에 따라 댓글 입력 영역 컴포넌트가 동적으로 움직여야 함
image

Key Changes 🔑

[BottomSheet]

  • BottomSheet의 움직임에 따라 DOM에서 직접 height를 계산해 동적으로 업데이트
    • ref를 통해 height 값을 얻을 수는 있지만, 드래그 중이거나 애니메이션 중일 때는 정확한 height를 제공하지 않음
    • 따라서 DOM에서 --rsbs-overlay-h, --rsbs-overlay-translate-y 값을 직접 읽어 계산하는 방식으로 변경
  • 계산된 height 값을 기반으로 댓글 입력 영역의 상위 컴포넌트에 bottom 스타일을 적용해 위치를 동적으로 조정
  • react-spring-bottom-sheet의 custom은 꽤 제한적
    • 라이브러리 사용 없이 컴포넌트를 직접 만들면 꽤 간단한 코드 구현이 가능할지도?!

[Storybook]

  • Storybook 전용 global.css를 분리해 별도로 관리
    • BottomSheet는 --layout-max-w 변수로 너비가 설정되는데, 이 값이 기본 global.css에서는 480px로 지정됨
    • Storybook에서는 fullScreen 파라미터로 인해 댓글 입력 영역은 100%로 출력되지만, BottomSheet는 여전히 480px로 제한되는 문제 발생
    • 이를 해결하기 위해 Storybook에서만 --layout-max-w 값을 100%로 관리되도록 설정

Attachment 📷

  • storybook 참고 ~ ✅

- layout-max-w CSS 변수를 100% 로 정의
- BottomSheet 내 header와 children을 각각 BottomSheetHeader와 BottomSheetContent로 분리
- observerRef(MutationObserver)를 통해 BottomSheet 높이 변화 감지
- FloatingInput이 BottomSheet 위에 정확히 위치되도록 대응
- CommentInput, UploadBtn, ImageOpen view를 TextFieldBottom 컴포넌트로 분리
- BottomSheet의 height를 기반으로 상위 컴포넌트의 bottom 스타일을 동적으로 조정
- 업로드 버튼 클릭 시 텍스트/이미지 존재 여부에 따라 분기 처리하여 업로드 로직 수행
@suji8073 suji8073 added ✨ Feature 기능 개발 🔨 Refactor 코드 리팩토링 labels Mar 24, 2025
@suji8073 suji8073 self-assigned this Mar 24, 2025
@github-actions
Copy link

setShowGallery: (value: boolean) => void;
}) => {
const openNativeGallery = () => {
document.getElementById('fileInput')?.click();
Copy link
Contributor

Choose a reason for hiding this comment

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

ref 가 아닌 직접 돔을 참조한 이유가 있을까용??

Copy link
Member Author

Choose a reason for hiding this comment

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

아녀! 그렇진 않지만 id로 참조하는 것보단 ref가 더 정확할 것 같아 수정 완료했습니닷 !!

- BottomSheetHeader 내 image 타입 string[]으로 제한
- input을 통한 카메라 앨범 접근 시 dom id 접근이 아닌 Ref로 접근하도록 수정
@github-actions
Copy link

@suji8073 suji8073 merged commit 8ac62a6 into develop Mar 30, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ Feature 기능 개발 🔨 Refactor 코드 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants