-
Notifications
You must be signed in to change notification settings - Fork 4
[feat] 버튼 컴포넌트 생성 #25
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
Conversation
✅ Deploy Preview for thejulge1 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
jeonghwanJay
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.
수고하셨습니다 !!
src/components/Button.tsx
Outdated
| @@ -0,0 +1,61 @@ | |||
| import React from "react"; | |||
|
|
|||
| type ButtonVariant = "primary" | "white" | "disabled"; | |||
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.
disabled는 버튼의 상태를 나타내는 속성으로 봐도 좋을 것 같습니다 !
그래서 속성값으로 넣어도 좋을 것 같아요 !
export type ButtonVariant = 'primary' | 'white';
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
variant?: ButtonVariant;
textSize?: Record<ButtonTextSize, string>;
fullWidth?: boolean;
disabled?: boolean; // disabled 속성 분리
}
cozy-ito
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.
고생 많으셨습니다! 👍
src/components/Button.tsx
Outdated
| if (variant === "primary") { | ||
| variantClass = | ||
| "bg-[#EA3C12] text-white hover:bg-[#ca3f2a] active:bg-[#aa3523]"; | ||
| } else if (variant === "white") { | ||
| variantClass = | ||
| "bg-white text-[#EA3C12] border border-[#EA3C12] hover:bg-[#fff5f3] active:bg-[#ffe5e0]"; | ||
| } else if (variant === "disabled") { | ||
| variantClass = "bg-gray-40 text-white cursor-not-allowed"; | ||
| } |
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.
variantClass의 조건부 스타일 적용도
textSizeClassMap처럼 별도로 분리하시지 않으신 이유가 있을까요? 🤔
분리하면 반복적인 If 구문을 제거할 수 있을 것 같아요! 😆
| if (variant === "primary") { | |
| variantClass = | |
| "bg-[#EA3C12] text-white hover:bg-[#ca3f2a] active:bg-[#aa3523]"; | |
| } else if (variant === "white") { | |
| variantClass = | |
| "bg-white text-[#EA3C12] border border-[#EA3C12] hover:bg-[#fff5f3] active:bg-[#ffe5e0]"; | |
| } else if (variant === "disabled") { | |
| variantClass = "bg-gray-40 text-white cursor-not-allowed"; | |
| } | |
| const variantClassMap: Record<ButtonVariant, string> = { | |
| primary: "bg-[#EA3C12] text-white hover:bg-[#ca3f2a] active:bg-[#aa3523]", | |
| white: | |
| "bg-white text-[#EA3C12] border border-[#EA3C12] hover:bg-[#fff5f3] active:bg-[#ffe5e0]", | |
| disabled: "bg-gray-400 text-white cursor-not-allowed", | |
| }; |
...
const finalClassName = [
...
variantClassMap[variant]
...
] ...
#️⃣연관된 이슈
📝 PR 유형
📝작업 내용
스크린샷 (선택)
💬리뷰 요구사항(선택)