-
Notifications
You must be signed in to change notification settings - Fork 1
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
[Feature] 액션시트 컴포넌트 구현 #165
base: main
Are you sure you want to change the base?
Conversation
ab9e60c
to
d45ec4a
Compare
|
Size Change: +21.4 kB (+3.15%) Total Size: 702 kB
ℹ️ View Unchanged
|
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.
수고하셨어요~~
저도 children 의 타입을 강제할 수 있는 방법은 없나,, 찾아봤는데 언급 주신 이슈 처럼 아직 해결되진 않은 거 같더라구요.
대안책으로는..
컴파일 타임에서 children 타입을 지정하는 건 어려울 거 같지만 런타임에서는 children 을 순회하면서 특정 타입의 컴포넌트 인지 아닌 지 판단할 수 있지 않을까...🤔 라는 생각이 드네요.
Children.forEach(children, (child) => {
if (typeof child === 'Element' && child?.type === 'ActionSheetHeader') {
...
}
|
||
const dialogStyle = cva({ | ||
base: { | ||
width: 390, |
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.
text: string; | ||
subText: string; |
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.
p3;
text 와 subText 는 줄바꿈이 생길 걸 고려해서 ReactNode 로 받는 게 더 안정적일 거 같아요!
그리고 기본 h1 텍스트만 쓰이는 상황도 있을 거 같아서 sub 는 optional 로 받는 게 좋을 거 같습니당
+) style, className 은 defaultProps 를 확장하면 따로 정의하지 않아도 될 거 같습니다.
componentSubtitle: "액션시트 컴포넌트", | ||
a11y: { | ||
config: { | ||
rules: [{ id: "color-contrast", enabled: false }], | ||
}, | ||
}, |
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.
p3;
합성 컴포넌트 처럼 쓰인다는 description 이 들어가면 더욱 좋을 거 같은데 description property 를 활용해서 명시하면 어떨까요?
- ActionSheet.Header Footer Body 를 조합해서 쓸 수 있어요.
const ActionSheet = ({ | ||
isOpen, | ||
onClose, | ||
children, | ||
...rest | ||
}: ActionSheetProps) => { | ||
const dialogRef = useRef<HTMLDialogElement>(null); |
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.
p3
최상위 ActionSheetComponent 에는 ref 를 프로퍼티로 주입받을 수 있도록 열어도 좋을 거 같아요.
return ( | ||
isOpen && ( | ||
<ActionSheetContext.Provider value={{ onClose: handleClose }}> | ||
<dialog className={dialogStyle({ state })} ref={dialogRef} {...rest}> |
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.
p3;
외부에서 주입받은 className 은 기존의 className 과 합쳐져야 className 으로 만든 panda 스타일링이 잘 동작할 거 같아요! 관련 이슈 #186
position="fixed" | ||
top={0} | ||
width="100vw" | ||
zIndex={9998} |
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.
p4;
actiionsheet z Index 도 토큰으로 지정하면 좋을 거 같아요~
|
||
const handleClose = () => { | ||
setState("close"); | ||
setTimeout(onClose, 100); |
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.
p4;
100ms 는 상수로 분리해서 어떤 용도인지 나타내면 좋을 거 같아요!
🎉 변경 사항
액션시트 컴포넌트를 구현합니다.
🚩 관련 이슈
🙏 여기는 꼭 봐주세요!
문제상황
ReactElement
타입이면서, 원하는 컴포넌트의 타입을 제네릭으로 받으면prop
타입을 제한할 수 있으니children
의 형식과 타입을 제한할 수 있다고 생각했습니다.ReactElement
중에서도ActionSheetHeader
에서 정의한prop
을 받아야 만족하는 것으로 예상했습니다.ReactElement
로children
개수만 맞추면 타입체킹에서 걸리지 않았습니다…해결방법으로 알아봤던 것들
-> 결국 안된다는 것 같은데, 혹시 다른 아이디어가 있으시면 리뷰 부탁드립니다..