TEAM-BEAT / BEAT-Client

https://beat-client.vercel.app/
5 stars 1 forks source link

[Feat/#35] Bottom Sheet 공통 컴포넌트 추가 #46

Closed sinji2102 closed 1 week ago

sinji2102 commented 1 week ago

📌 관련 이슈번호

🎟️ PR 유형

어떤 변경 사항이 있나요?

✅ Key Changes

📢 To Reviewers

먼저 사과의 말씀 전합니다. . . 바텀시트가 뭔가 생긴 게 자꾸만 재사용 될 것 같은데 다음에 재사용될 때는 저 형식이 아닌 것 같아 잘게 컴포넌트를 쪼개다 보니까 요상한 코드가 되었어요... 엉엉... 아기개발자가 컴포넌트 분리 욕심을 내면 어떻게 되는지를 보고 계십니다...

사용법

전체적인 폴더 구조

📦components ┗ 📂commons ┃ ┣ 📂bottomSheet ┃ ┃ ┣ 📂actionsBottomSheet ┃ ┃ ┃ ┣ 📂phoneNumber ┃ ┃ ┃ ┃ ┣ 📜PhoneNumber.tsx ┃ ┃ ┃ ┃ ┃ : 휴대폰 번호 및 복사 기능 컴포넌트( action 바텀 시트가 전화번호가 아닌 정보 전달이 있을 수 있어 생성)
┃ ┃ ┃ ┃ ┗ 📜PhoneNumberStyle.tsx ┃ ┃ ┃ ┣ 📜ActionBottomSheet.tsx ┃ ┃ ┃ : Action 바텀 시트. 큰 제목과 sub title 포함 ┃ ┃ ┃ ┗ 📜ActionBottomSheetStyle.tsx ┃ ┃ ┣ 📂viewBottomSheet ┃ ┃ ┃ ┣ 📜ViewBottomSheet.tsx ┃ ┃ ┃ : View 바텀 시트. 큰 제목 및 작은 제목 포함. ContextBox이 포함되어 있고 children으로 Context를 받아야 함 ┃ ┃ ┃ ┗ 📜ViewBottomSheetStyle.tsx ┃ ┃ ┣ 📜BottomSheet.tsx ┃ ┃ : 가장 틀이 되는 (가장 큰) 바텀 시트. 타이틀만 포함되며 ViewBottomSheet와 AcionBottomSheet에서 제목을 받음 ┃ ┃ ┗ 📜BottomSheetStyle.tsx ┃ ┗ 📂contextBox ┃ ┃ ┣ 📜Context.tsx ┃ ┃ : Context가 쓰이는 개수가 바텀 시트마다 달라서 따로 제작. ┃ ┃ ┣ 📜ContextBox.tsx ┃ ┃ : ContextBox마다 들어가는 내용도 다르고 크기도 달라 커스텀 할 수 있도록 제작. ┃ ┃ ┣ 📜ContextBoxStyle.tsx ┃ ┃ ┗ 📜ContextStyle.tsx

너무,, 복잡해서 간략하게 설명해 두었습니다,,,

View Bottom Sheet

image

const ViewBottomSheetTest = () => { const [isOpen, setIsOpen] = useState(false);

const handleSheetOpen = () => { setIsOpen(true); };

const handleSheetClose = () => { setIsOpen(false); };

return (

{isOpen && ( )}

); };

export default ViewBottomSheetTest;

const Test = styled.div` width: 37.5rem; height: 660.7rem;

background-color: white; `;


### Acton Bottom Sheet
![image](https://github.com/TEAM-BEAT/BEAT-Client/assets/66528589/038b5709-25e5-41bd-832d-3e5855c4dfa1)
- ActionBottomSheet도 전화번호가 아닌 다른 정보가 들어올 가능성이 있어 보여 컴포넌트를 분리해 두었습니다.
- viewBottomSheeet와 동일하게 ActionBottomSheet에 children으로 원하는 값을 넣어주면 됩니다! 이때 title과 subTitle이 들어갑니다
- 추후 혹은 코드리뷰 반영 시 title과 subTitle이 필수적으로 들어갈 필요 없도록 수정하겠습니다.
- viewBottomSheet와 ActionBottomSheet가 같은 ContextBox를사용하나 정렬이 달라 props로 원하는 정렬을 맞추도록 해두었습니다. 기본값은 flex-start입니다.

-  사용 예제

import styled from "styled-components"; import { useState } from "react"; import ActionBottomSheet from "@components/commons/bottomSheet/actionsBottomSheet/ActionBottomSheet"; import PhoneNumber from "@components/commons/bottomSheet/actionsBottomSheet/phoneNumber/PhoneNumber"; import Button from "@components/commons/button/Button"; import OuterLayout from "@components/commons/bottomSheet/OuterLayout";

const ActionBottomSheetTest = () => { const [isOpen, setIsOpen] = useState(false);

const handleSheetOpen = () => { setIsOpen(true); };

const handleSheetClose = () => { setIsOpen(false); };

return (

{isOpen && ( )}

); };

export default ActionBottomSheetTest;

const Test = styled.div` width: 37.5rem; height: 66.7rem;

background-color: white; `;



</br>

### 버튼 관련 중요!!
- 버튼을 넣어야 해서 보니까 children을 분리해야 할 것 같아서 ViewBottomSheet의 경우에는 Context 컴포넌트, ActionBottomSheet의 경우에는 PhoneNumber 컴포넌트를 제외하고는 박스 아래에 들어가도록 했습니다!
- 지금 생각해보니까 버튼만 밖에 들어가고 박스 안에는 어떤 게 들어갈지 모르니 ButtonLayout 컴포넌트를 분리하는 게 더 좋은 선택이었을 것 같은데... 현재 ButtonLayout 컴포넌트가 따로 존재하지 않아서 ButtonLayout 컴포넌트를 또 하나 생성하는 게 좋을지 다들 의견 남겨주세요... 엉엉 ㅠㅠ ButtonLayout 컴포넌트를 만드는 게 좋다고 판단되면 아마 사용하던 페이지에는 지장 없도록 ButtonLayout만 밖으로 넘긴다!! 로 할 예정이니 합숙할 때나 내일 오전에 수정하도록 하겠습니다!!

## 📸 스크린샷

### View Bottom Sheet
![image](https://github.com/TEAM-BEAT/BEAT-Client/assets/66528589/a8a5ef1c-a17e-4ff1-b193-5dc487ea5730)

### Action Bottom Sheet
![image](https://github.com/TEAM-BEAT/BEAT-Client/assets/66528589/edfad883-48f6-4146-9cff-3d9e1f41817d)
github-actions[bot] commented 1 week ago

PR 작성하느라 고생 많았어요!! 라벨 잘 지정되었는지 확인 한 번 해 주기 🫶

github-actions[bot] commented 1 week ago

🚀storybook: https://6687a84e56a8d673624b5d25-mpehhfrwph.chromatic.com/

github-actions[bot] commented 1 week ago

🚀storybook: https://6687a84e56a8d673624b5d25-fxuxrnmmog.chromatic.com/

github-actions[bot] commented 1 week ago

🚀storybook: https://6687a84e56a8d673624b5d25-chbueosgwx.chromatic.com/

github-actions[bot] commented 1 week ago

🚀storybook: https://6687a84e56a8d673624b5d25-scuzhjzxna.chromatic.com/

github-actions[bot] commented 1 week ago

🚀storybook: https://6687a84e56a8d673624b5d25-dzjhvyxpmr.chromatic.com/

sinji2102 commented 1 week ago

버튼 관련해서 코드 수정해서 PR도 수정했으니 다들 잘 읽어주기!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

github-actions[bot] commented 1 week ago

🚀storybook: https://6687a84e56a8d673624b5d25-zfpzmtpcks.chromatic.com/

github-actions[bot] commented 1 week ago

🚀storybook: https://6687a84e56a8d673624b5d25-yjquyvfkdn.chromatic.com/

github-actions[bot] commented 1 week ago

🚀storybook: https://6687a84e56a8d673624b5d25-clowbohiao.chromatic.com/

sonarcloud[bot] commented 1 week ago

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

github-actions[bot] commented 1 week ago

🚀storybook: https://6687a84e56a8d673624b5d25-debbponzky.chromatic.com/