Skip to content
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

Merged
merged 13 commits into from
Jul 31, 2023

Conversation

kyw0716
Copy link
Member

@kyw0716 kyw0716 commented Jul 29, 2023

📄 Summary

  • 재사용성을 높이기 위해 리액트 컴파운드 패턴을 적용해 컴포넌트를 설계한다.
    • 상단 메뉴 선택 부분, 하단 그래프 부분을 분리한다.
    • 메뉴 선택, 그래프 컴포넌트에 render props를 사용해 렌더링 할 하위 컴포넌트를 지정할 수 있도록 구성한다.

🕰️ Actual Time of Completion

4시간

🙋🏻 More

TODO

  • 현재 align을 기준으로 분기처리 되어있는 스타일들을 독립적인 컴포넌트로 구성하도록 코드를 리팩터링 한다.
  • 다른 디자인도 추가될 수 있도록 추가 확장성을 고민해본다.

close #230

- 리액트 컴파운드 패턴을 사용하는 컴포넌트
- useSyncExternalStore 사용시 독립적인 컴포넌트들이 상태 공유를 하는 문제가 있어 Context api를 사용하는 방식으로 수정함.
@kyw0716 kyw0716 added 🛠️ 리팩터링 개선사항입니다 FE 프론트엔드 관련 이슈입니다 labels Jul 29, 2023
@kyw0716 kyw0716 self-assigned this Jul 29, 2023
@github-actions
Copy link

🚀storybook: https://storybook.carffe.in/

Copy link
Member

@gabrielyoon7 gabrielyoon7 left a comment

Choose a reason for hiding this comment

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

굉장한 방법을 활용했군요. 굿샷

@github-actions
Copy link

🚀storybook: https://storybook.carffe.in/

@github-actions
Copy link

🚀storybook: https://storybook.carffe.in/

Copy link
Collaborator

@feb-dain feb-dain left a comment

Choose a reason for hiding this comment

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

굿굿 리뷰 확인해주세요~

Comment on lines 23 to 25
const rowAlignGraphCss = css`
align-items: flex-end;
`;
Copy link
Collaborator

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}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
nowrap={true}
nowrap

True면 True를 넘겨주지 않아도 됩니다!

${({ align, ratio }) =>
align === 'column'
? `
width: ${ratio === -1 ? '26rem' : `calc(26rem * ${ratio} / 100)`};
Copy link
Collaborator

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;
Copy link
Collaborator

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}
Copy link
Collaborator

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}
Copy link
Collaborator

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);
Copy link
Collaborator

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) => (
Copy link
Collaborator

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 으로 되어 있는 것 같은데 이유가 뭔가요?😮

Copy link
Member Author

Choose a reason for hiding this comment

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

확장성을 고려해서 타입을 지정하지 않고 string[]로 두었습니다

@github-actions
Copy link

🚀storybook: https://storybook.carffe.in/

@github-actions
Copy link

🚀storybook: https://storybook.carffe.in/

@github-actions
Copy link

🚀storybook: https://storybook.carffe.in/

@github-actions
Copy link

🚀storybook: https://storybook.carffe.in/

@github-actions
Copy link

🚀storybook: https://storybook.carffe.in/

@kyw0716 kyw0716 merged commit c1dfa95 into develop Jul 31, 2023
2 checks passed
@kyw0716 kyw0716 deleted the feat/230 branch July 31, 2023 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FE 프론트엔드 관련 이슈입니다 🛠️ 리팩터링 개선사항입니다
Projects
None yet
Development

Successfully merging this pull request may close these issues.

누적 혼잡도 시각화 컴포넌트의 재사용성을 높인다
3 participants