-
Notifications
You must be signed in to change notification settings - Fork 4
feat(ui): Bottom Sheet #284
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
base: main
Are you sure you want to change the base?
Conversation
|
|
00cb433 to
3001a40
Compare
3001a40 to
8c82c1c
Compare
constantly-dev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨습니다! 코드 깔끔한 것 같아요!
질문드리고 싶은 점이 구현하신 것처럼 제어/비제어의 경우를 모두 고려해 구현하신 이유가 사용 방법에 대한 선택을 더 많이 주기 위함인가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const context = useContext(BottomSheetContext); | ||
|
|
||
| if (context === null) { | ||
| throw new Error('this hook muse be used within a BottomSheetProvider'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
사소하지만 muse -> must 오타인 것 같습니다!
| export function BottomSheetTrigger({ children }: HTMLAttributes<HTMLButtonElement>) { | ||
| const { open, onOpenChange } = useBottomSheetContext(); | ||
|
|
||
| const handleOpenChange = () => { | ||
| onOpenChange(!open); | ||
| }; | ||
|
|
||
| return <div onClick={handleOpenChange}>{children}</div>; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trigger가 button의 역할을 하지 않는 경우 때문에 div로 두신 걸까요??
| return ( | ||
| open && ( | ||
| <div className={overlayStyle}> | ||
| {title && ( | ||
| <div className={titleWrapperStyle}> | ||
| {backIcon && <IconChevronLeft onClick={() => onOpenChange(false)} className={iconStyle} />} | ||
| <p className={titleTextStyle}>{title}</p> | ||
| </div> | ||
| )} | ||
| {children} | ||
| </div> | ||
| ) | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
물론 open이 숫자 0이나 빈 문자열이 될 가능성이 없는 boolean이라 예상하지 못한 경우는 없어서 괜찮은데,
컴포넌트 조건부 렌더링(boolean)에서
- 현재처럼 &&를 사용 (
BottomSheetContent의 return 값이JSX.Element | false) - early return으로 null 반환 (
BottomSheetContent의 return 값이JSX.Element | null)
이 두개 중 어떤걸 선호하시나요?
| const uncontrolled = _open === undefined; | ||
|
|
||
| const open = uncontrolled ? internalOpenValue : _open; | ||
| const handleOpenChange = (value: boolean) => { | ||
| if (uncontrolled) { | ||
| if (value) { | ||
| internalOpen(); | ||
| } else { | ||
| internalClose(); | ||
| } | ||
| } else { | ||
| onOpenChange?.(value); | ||
| } | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
물론 지금도 좋지만 uncontrolled가 boolean 값을 가지니 일반적인 is- prefix를 써서 isControlled로 사용하고 조건을 반대로 해도 가독성이 좋을 것 같습니다.
| const meta: Meta = { | ||
| title: 'Components/BottomSheet', | ||
| tags: ['autodocs'], | ||
| }; | ||
| export default meta; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.


변경사항
바텀싯 컴포넌트를 구현하였습니다.
링크
시급한 정도
🏃♂️ 보통 : 최대한 빠르게 리뷰 부탁드립니다.
기타 사항
커밋 보시면서 리뷰해주시면 더 편하실 거에요