-
Notifications
You must be signed in to change notification settings - Fork 0
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] 버튼 공통 컴포넌트 수정 #59
Conversation
CI가 실패한 것 같습니다. 확인 부탁해용 |
ci가 실패했는데, 지운 active 속성을 사용해서 그런 것 같아요! 확인부탁드립니당 |
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.
천재만재 썬뎃 고생하셨습니다아~!~ 몇가지 코멘트 남겼으니 확인부탁드려용
export const buttonLayout = ({ disabled, size, radius, fontSize }: ButtonLayoutProps) => css` | ||
display: flex; | ||
justify-content: center; | ||
width: ${size === 'small' ? '6.9rem' : size === 'medium' ? '12rem' : '32rem'}; |
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.
L5 - 참고 의견
4px 단위로 수정하면 좋을 것 같아요!
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.
와우 ! 저희가 4px 기준으로 맞추기로 했는데 6.9 .. ? 도대체 무엇 ? 수면 이슈로 인하여 그런 듯 .. 당장 6.8로 수정하도록 하겠습니다 꼼꼼한 마루 짱 ! 👏
frontend/src/styles/Theme.ts
Outdated
}, | ||
placeholder: { | ||
fontSize: '1.2rem', | ||
fontWeight: '500', |
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.
L4 - 변경 제안
기본 폰트 weight는 400 이라서 강조하는 의도가 아니라면 font-weight를 400으로 수정해도 괜찮을 것 같아요!
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.
좋아요우 바로 반영하겠습니다 😊
|
||
font-weight: bold; | ||
font-size: 2rem; | ||
border-radius: 2.4rem; | ||
font-size: ${fontSize === 'small' |
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.
L4 - 변경 제안
삼항 연산자가 많아서 조금 헷갈리는 것 같아요! 그래서 mapper 방식을 사용해봐도 좋을 것 같아요!
const getSize = (size) => {
if (size === 'medium'){
return css`
font-size: Theme.typography.headline2.fontSize;
border-raduis: Theme.borderRadius.radius20;
`
}
...
}
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.
안 그래도 저도 .. 마음에 무지하게 걸려서 리팩토링을 바로 해버렸답니다 . 확인부탁드려요 ! ✨
onClick, | ||
disabled = false, | ||
size = 'large', | ||
radius = 'none', |
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.
L4 - 변경 제안
raddius에 none 이라는 타입은 어떻게 쓰이느 건가요?? 속성 없이 안적으면 적용 안되는 걸로 하는 건 어떨까요?
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.
default로 그러면 0을 달아줘야 해서 그것마저 같은 형식으로 관리해서 통일감을 줄까 하는 생각이었는데, 꼭 필요한 것은 아니라고 생각합니다 반영 하겠숨니다👏
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.
공통 스타일 로직 분리하느라 수고 많았어요~~~
@@ -16,7 +16,7 @@ const GameResult = () => { | |||
<div css={gameResultTitleWrapper}> | |||
<h1 css={gameResultTitle}>게임 결과</h1> | |||
</div> | |||
<Button text="확인" active={true} onClick={goToHome} /> | |||
<Button text="확인" onClick={goToHome} /> |
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.
L5 - 참고 의견
active 옵션을 지웠는데 그럼 button의 색은 어떤식으로 구분하는 게 좋다고 생각하시나요?
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.
버튼이 button의 disabled는 default가 false이니 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.
오 저도 잘 수정된 것 같아요! 그냥 버튼인데 active: true를 설정해줘야 되는게 어색하더라구요 굿굿
@@ -39,7 +39,7 @@ const SelectContainer = () => { | |||
handleSelectOption={handleSelectOption} | |||
/> | |||
</section> | |||
<Button text="선택" active={Boolean(selectedId)} onClick={goToRoundResult} /> | |||
<Button text="선택" disabled={Boolean(selectedId)} onClick={goToRoundResult} /> |
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.
L5 - 참고 의견
active에 따라 색을 구분하다가 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.
버튼의 색상은 기본적으로 peanut400 이고 disabled 속성이 true인 경우는 peanut300 으로 설정했습니다. 추가로 다른 버튼 색상으로 정의하고 싶은 경우는 style 속성을 통해 backgroundColor: black
이런 식으로 커스텀할 수 있습니다 👏
slogan: { | ||
fontSize: '2.8rem', | ||
fontWeight: 'bold', | ||
}, |
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.
L5 - 참고 의견
slogan은 주로 어디에 사용하실 생각이신가요?
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.
저희 피그마에 정의된 타이포그래피를 기준으로 Theme에 디자인 토큰을 정의했습니다. slogan 같은 경우 처음 메인 화면에서 서비스 이름을 띄워줄 때 사용할 것 같아요 !
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> { | ||
text: string; | ||
onClick: () => void; | ||
disabled?: boolean; | ||
style?: React.CSSProperties; | ||
size?: 'small' | 'medium' | 'large'; | ||
radius?: 'none' | 'small' | 'medium' | 'large'; | ||
fontSize?: 'small' | 'medium' | 'large'; | ||
} |
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.
L5 - 참고 의견
이제 더 다양하게 커스텀이 가능하겠네요!
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.
어떻게 하면 자주 쓰는 버튼들을 정의해서 사용할 수 있을까 고민해보았습니다 사용해 보면서 필요하다면 더 수정해 보아요 ~! 🚀✨
|
||
background-color: ${active ? Theme.color.peanut400 : Theme.color.peanut300}; | ||
const getSizeStyles = (size: 'small' | 'medium' | 'large' | undefined) => { |
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.
L4 - 변경 제안
or undefiend 보다 size를 size?로 바꾸면 더 간결해질 것 같습니다!
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 getFontSize = (fontSize: 'small' | 'medium' | 'large' | undefined) => { | ||
switch (fontSize) { | ||
case 'small': | ||
return Theme.typography.caption.fontSize; | ||
case 'medium': | ||
return Theme.typography.headline2.fontSize; | ||
case 'large': | ||
default: | ||
return Theme.typography.headline1.fontSize; | ||
} | ||
}; |
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.
L4 - 변경 제안
getFontSize 같은 함수는 Button에 국한되지 않고 여러 곳에서 사용할 수 있으니까 공통 로직으로 만들면 더 좋을 것 같습니다.
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.
오오 정말 좋은 의견이네요! 다른 로직에서도 충분히 사용이 가능하겠군요. 반영해 보겠습니다 👏
@@ -16,7 +16,7 @@ const GameResult = () => { | |||
<div css={gameResultTitleWrapper}> | |||
<h1 css={gameResultTitle}>게임 결과</h1> | |||
</div> | |||
<Button text="확인" active={true} onClick={goToHome} /> | |||
<Button text="확인" onClick={goToHome} /> |
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.
오 저도 잘 수정된 것 같아요! 그냥 버튼인데 active: true를 설정해줘야 되는게 어색하더라구요 굿굿
Issue Number
#49
As-Is
공통 버튼 컴포넌트의 재사용성 한계
To-Be
Check List
Test Screenshot
스토리북으로 확인해보시면 옵션에 따른 버튼의 변화를 바로 확인하실 수 있습니다 ^.^
(Optional) Additional Description
스토리북때문에 지금 통과가 안 되는 것 같아요 🥲