-
Notifications
You must be signed in to change notification settings - Fork 6
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
refactor: 누적 혼잡도 시각화 컴포넌트의 재사용성을 높인다 #232
Conversation
- 리액트 컴파운드 패턴을 사용하는 컴포넌트
- useSyncExternalStore 사용시 독립적인 컴포넌트들이 상태 공유를 하는 문제가 있어 Context api를 사용하는 방식으로 수정함.
🚀storybook: https://storybook.carffe.in/ |
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.
굉장한 방법을 활용했군요. 굿샷
🚀storybook: https://storybook.carffe.in/ |
🚀storybook: https://storybook.carffe.in/ |
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 rowAlignGraphCss = css` | ||
align-items: flex-end; | ||
`; |
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.
FlexBox 속성에 end 있어요~
return ( | ||
<FlexBox | ||
tag="li" | ||
nowrap={true} |
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.
nowrap={true} | |
nowrap |
True면 True를 넘겨주지 않아도 됩니다!
${({ align, ratio }) => | ||
align === 'column' | ||
? ` | ||
width: ${ratio === -1 ? '26rem' : `calc(26rem * ${ratio} / 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.
리팩터링 할 때 상수화도 진행해야겠다
import { GraphContext, type GraphProps } from '.'; | ||
|
||
interface BarContainerProps extends GraphProps { | ||
renderBar: (hour: number, ratio: number) => JSX.Element; |
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.
여기선 ReactNode가 아니라 JSX.Element 쓰고 있군요🤔 컨벤션이 필요해보입니다
return ( | ||
<FlexBox | ||
direction={align} | ||
nowrap={true} |
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.
위에서 말한 거 여기도 적용해주세요~
return ( | ||
<Button | ||
size="sm" | ||
outlined={true} |
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 { selectedDay, setSelectedDay } = useContext(GraphContext); | ||
|
||
const handleSelectDay = (day: string) => { | ||
if (isEnglishDays(day)) setSelectedDay(day); |
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.
확장성/명확성을 위해서 여기 중괄호로 감쌀까요?!
- 나중에 eslint 설정도 해놓겠습니다
<Graph.DayMenus | ||
statistics={statistics} | ||
menus={menus} | ||
renderMenuSelectButton={(menu: 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.
Menu EnglishDays/KoreanDays 배열 중 하나 맞나요?? 타입이 string[], 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.
확장성을 고려해서 타입을 지정하지 않고 string[]로 두었습니다
🚀storybook: https://storybook.carffe.in/ |
🚀storybook: https://storybook.carffe.in/ |
🚀storybook: https://storybook.carffe.in/ |
🚀storybook: https://storybook.carffe.in/ |
🚀storybook: https://storybook.carffe.in/ |
📄 Summary
🕰️ Actual Time of Completion
🙋🏻 More
TODO
close #230