-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: 기존 Button 컴포넌트를 LinkedButton 컴포넌트로 리팩터링후 공용 버튼 컴포넌트를 새로 만듬
- Loading branch information
Showing
12 changed files
with
171 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,8 @@ | ||
import { style, styleVariants } from '@vanilla-extract/css'; | ||
import { flexCenter } from '@/styles/common/flex.css'; | ||
import { | ||
commonColorThemeVars, | ||
userColorThemeVars, | ||
} from '@/styles/theme/index.css'; | ||
import { style } from '@vanilla-extract/css'; | ||
|
||
export const buttonStyle = style([ | ||
flexCenter, | ||
{ | ||
gap: '0.625rem', | ||
export const buttonStyle = style({ | ||
transition: 'opacity 0.2s ease-in-out', | ||
':hover': { | ||
opacity: 0.8, | ||
}, | ||
]); | ||
|
||
const MHOVER = { | ||
backgroundColor: 'rgba(255, 255, 255, 0.8)', | ||
}; | ||
|
||
const MPRESS = { | ||
transition: 'none', | ||
backgroundColor: commonColorThemeVars.token['gray-scale-00'], | ||
boxShadow: '0px 3px 2px 0px rgba(0, 0, 0, 0.12) inset', | ||
}; | ||
|
||
const LHOVER = { | ||
border: '1.5px solid', | ||
borderColor: commonColorThemeVars.token['gray-scale-01'], | ||
color: commonColorThemeVars.token['gray-scale-01'], | ||
opacity: 0.8, | ||
}; | ||
|
||
const LPRESS = { | ||
transition: 'none', | ||
borderColor: commonColorThemeVars.token['gray-scale-00'], | ||
color: commonColorThemeVars.token['gray-scale-00'], | ||
opacity: 1, | ||
backgroundColor: 'rgba(255, 255, 255, 0.08)', | ||
}; | ||
|
||
export const buttonVariants = styleVariants({ | ||
M: [ | ||
buttonStyle, | ||
{ | ||
display: 'inline-flex', | ||
padding: '0.625rem 0.75rem', | ||
borderRadius: '0.5rem', | ||
backgroundColor: commonColorThemeVars.token['gray-scale-00'], | ||
color: userColorThemeVars.token['tertiary'], | ||
':hover': MHOVER, | ||
':active': MPRESS, | ||
}, | ||
], | ||
L: [ | ||
buttonStyle, | ||
{ | ||
padding: '0.625rem', | ||
backgroundColor: 'transparent', | ||
border: '1px solid', | ||
borderColor: commonColorThemeVars.token['gray-scale-00'], | ||
borderRadius: '0.25rem', | ||
color: commonColorThemeVars.token['gray-scale-00'], | ||
':hover': LHOVER, | ||
':active': LPRESS, | ||
}, | ||
], | ||
}); | ||
|
||
export const buttonStatusVariants = styleVariants({ | ||
MHOVER, | ||
MPRESS, | ||
LHOVER, | ||
LPRESS, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { style, styleVariants } from '@vanilla-extract/css'; | ||
import { flexCenter } from '@/styles/common/flex.css'; | ||
import { | ||
commonColorThemeVars, | ||
userColorThemeVars, | ||
} from '@/styles/theme/index.css'; | ||
|
||
export const buttonStyle = style([ | ||
flexCenter, | ||
{ | ||
gap: '0.625rem', | ||
}, | ||
]); | ||
|
||
const MHOVER = { | ||
backgroundColor: 'rgba(255, 255, 255, 0.8)', | ||
}; | ||
|
||
const MPRESS = { | ||
transition: 'none', | ||
backgroundColor: commonColorThemeVars.token['gray-scale-00'], | ||
boxShadow: '0px 3px 2px 0px rgba(0, 0, 0, 0.12) inset', | ||
}; | ||
|
||
const LHOVER = { | ||
border: '1.5px solid', | ||
borderColor: commonColorThemeVars.token['gray-scale-01'], | ||
color: commonColorThemeVars.token['gray-scale-01'], | ||
opacity: 0.8, | ||
}; | ||
|
||
const LPRESS = { | ||
transition: 'none', | ||
borderColor: commonColorThemeVars.token['gray-scale-00'], | ||
color: commonColorThemeVars.token['gray-scale-00'], | ||
opacity: 1, | ||
backgroundColor: 'rgba(255, 255, 255, 0.08)', | ||
}; | ||
|
||
export const buttonVariants = styleVariants({ | ||
M: [ | ||
buttonStyle, | ||
{ | ||
display: 'inline-flex', | ||
padding: '0.625rem 0.75rem', | ||
borderRadius: '0.5rem', | ||
backgroundColor: commonColorThemeVars.token['gray-scale-00'], | ||
color: userColorThemeVars.token['tertiary'], | ||
':hover': MHOVER, | ||
':active': MPRESS, | ||
}, | ||
], | ||
L: [ | ||
buttonStyle, | ||
{ | ||
padding: '0.625rem', | ||
backgroundColor: 'transparent', | ||
border: '1px solid', | ||
borderColor: commonColorThemeVars.token['gray-scale-00'], | ||
borderRadius: '0.25rem', | ||
color: commonColorThemeVars.token['gray-scale-00'], | ||
':hover': LHOVER, | ||
':active': LPRESS, | ||
}, | ||
], | ||
}); | ||
|
||
export const buttonStatusVariants = styleVariants({ | ||
MHOVER, | ||
MPRESS, | ||
LHOVER, | ||
LPRESS, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import classNames from 'classnames'; | ||
import { PropsWithChildren } from 'react'; | ||
import { fontVariants } from '@/styles/common/font.css'; | ||
import Button from '../Button/Button'; | ||
import { getSpecificButtonStatus } from '../Button/helper/getSepcificButtonStatus'; | ||
import { buttonVariants } from './LinkedButton.css'; | ||
|
||
interface Props { | ||
className?: string; | ||
size: 'M' | 'L'; | ||
href?: string; | ||
status?: 'DEFAULT' | 'HOVER' | 'PRESS'; | ||
width?: string; | ||
style?: React.CSSProperties; | ||
onClick?: React.MouseEventHandler<HTMLButtonElement>; | ||
} | ||
|
||
const LinkedButton = ({ | ||
className, | ||
children, | ||
href, | ||
size, | ||
status = 'DEFAULT', | ||
width, | ||
style, | ||
onClick, | ||
}: PropsWithChildren<Props>) => { | ||
return ( | ||
<Button | ||
as="a" | ||
type="button" | ||
href={href || ''} | ||
className={classNames( | ||
className, | ||
buttonVariants[size], | ||
fontVariants[ | ||
size === 'M' ? 'paragraph-m-medium' : 'paragraph-s-regular' | ||
], | ||
getSpecificButtonStatus?.(size, status), | ||
)} | ||
onClick={onClick} | ||
style={{ ...style, width }} | ||
> | ||
{children} | ||
</Button> | ||
); | ||
}; | ||
|
||
export default LinkedButton; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.