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

[SDR-422] FE : Button, Icon, Logo atom 추가합니다. #244

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from

Conversation

yongseongjeon
Copy link
Collaborator

@yongseongjeon yongseongjeon commented Dec 9, 2022

📝 구현 내용

  • Storybook 설치
  • Atom, Story 생성
    • <Button />
    • <Icon />
    • <Logo />
    • <Text />

🙇🏻‍♂️ 리뷰어에게 부탁합니다!

npm run storybook
  • <Text />, <Avatar />, <SpeechBuble />, <Card />, <Box />, <Switch /> 생성 예정입니다.

Comment on lines +15 to +16
size?: 'LARGE' | 'SMALL';
backgroundColor?: 'YELLOW' | 'BLUE';
Copy link
Member

Choose a reason for hiding this comment

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

enum COLOR = {
  YELLOW = 'YELLOW',
 BLUE = 'BLUE',
};

처럼 enum을 정의한 후 타입 정의할때는 enum을 활용하는게 좋을 것 같아요

// ex)
 type ButtonProps = {
  ...
  backgroundColor?: COLOR
}

Copy link
Member

Choose a reason for hiding this comment

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

size나 다른 부분도 마찬가지입니다.

type ButtonProps = {
size?: 'LARGE' | 'SMALL';
backgroundColor?: 'YELLOW' | 'BLUE';
children: React.ReactNode;
Copy link
Member

Choose a reason for hiding this comment

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

type ButtonProps = { } & JSX.IntrinsicElements['button']

형태를 활용하면 children이나 onClick등은 별도 타입선언을 안해도 될것같아요!

backgroundColor: 'YELLOW',
};

export const Small = Template.bind({});
Copy link
Member

Choose a reason for hiding this comment

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

Small이 디폴트라면 Default로 네이밍 하는것도 나쁘지 않아 보이는데 어떻게 생각하시나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

좋아요 ㅎㅎ


type IconProps = {
type: IconComponentsKeys;
color?: 'inherit' | 'action' | 'disabled' | 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning';
Copy link
Member

Choose a reason for hiding this comment

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

color..?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

아이콘이 전부 MUI로 구성되어 있어서 아이콘 컴포넌트 API와 동일하게 타입을 정해봤어요.
https://mui.com/material-ui/api/icon/#props

Comment on lines +39 to +41
if (!SelectedIcon) {
throw new Error(`${type} 컴포넌트를 찾을 수 없습니다. `);
}
Copy link
Member

Choose a reason for hiding this comment

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

type을 강제했는데 예외상황이 발생할 수 있나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ts 사용하기 전에 저렇게 예외처리 해놓았는데 이젠 그럴 필요가 없겠군요!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants