-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev/fe' of https://github.com/woowacourse-teams/2024-co…
…de-zap into refactor/templates_api
- Loading branch information
Showing
23 changed files
with
324 additions
and
312 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,15 @@ | ||
import React from 'react'; | ||
import { buttonStyle, stylesBySize, stylesByType, textTypeStyle } from './style'; | ||
import { ButtonHTMLAttributes } from 'react'; | ||
import * as S from './style'; | ||
|
||
interface Props { | ||
children: React.ReactNode; | ||
onClick?: (e?: React.MouseEvent<HTMLButtonElement>) => void; | ||
type?: 'default' | 'outlined' | 'text'; | ||
size?: 'small' | 'medium'; | ||
width?: string | number; | ||
disabled?: boolean; | ||
export interface Props extends ButtonHTMLAttributes<HTMLButtonElement> { | ||
variant: 'contained' | 'outlined' | 'text'; | ||
size: 'small' | 'medium' | 'filled'; | ||
} | ||
|
||
const Button = ({ children, onClick, type = 'default', size = 'medium', width, disabled = false }: Props) => ( | ||
<button | ||
css={[buttonStyle, stylesByType[type], stylesBySize[size], type === 'text' ? textTypeStyle : width && { width }]} | ||
disabled={disabled} | ||
onClick={onClick} | ||
> | ||
const Button = ({ children, onClick, variant, size, ...rest }: Props) => ( | ||
<S.Button variant={variant} size={size} onClick={onClick} {...rest}> | ||
{children} | ||
</button> | ||
</S.Button> | ||
); | ||
|
||
export default Button; |
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,66 +1,81 @@ | ||
import { css } from '@emotion/react'; | ||
import styled from '@emotion/styled'; | ||
import type { Props } from './Button'; | ||
|
||
export const buttonStyle = css({ | ||
cursor: 'pointer', | ||
borderRadius: '8px', | ||
textAlign: 'center', | ||
padding: '0.8rem 1.6rem', | ||
display: 'flex', | ||
alignItems: 'center', | ||
gap: '0.8rem', | ||
const variants = { | ||
contained: css` | ||
color: rgb(52 60 72 / 100%); | ||
background: rgb(255 211 105 / 100%); | ||
`, | ||
outlined: css` | ||
color: rgb(255 211 105 / 100%); | ||
background: none; | ||
border: 0.1rem solid rgb(255 211 105 / 100%); | ||
`, | ||
text: css` | ||
display: inline-block; | ||
'&:not(:disabled):focus': { | ||
outline: 'none', | ||
}, | ||
width: fit-content; | ||
height: fit-content; | ||
padding: 0; | ||
'&:not(:disabled):hover': { | ||
opacity: 0.8, | ||
}, | ||
color: rgb(255 211 105 / 100%); | ||
'&:not(:disabled):active': { | ||
opacity: 0.6, | ||
}, | ||
|
||
'&:disabled': { | ||
cursor: 'default', | ||
opacity: 0.6, | ||
}, | ||
}); | ||
|
||
export const stylesByType = { | ||
default: css({ | ||
background: 'rgb(255 211 105 / 100%)', | ||
color: 'rgb(52 60 72 / 100%)', | ||
}), | ||
outlined: css({ | ||
background: 'none', | ||
border: '0.1rem solid rgb(255 211 105 / 100%)', | ||
color: 'rgb(255 211 105 / 100%)', | ||
}), | ||
text: css({ | ||
background: 'none', | ||
color: 'rgb(255 211 105 / 100%)', | ||
}), | ||
background: none; | ||
border: none; | ||
`, | ||
}; | ||
|
||
export const stylesBySize = { | ||
small: css({ | ||
height: '3rem', | ||
fontWeight: 700, | ||
fontSize: '1.4rem', | ||
}), | ||
medium: css({ | ||
height: '4rem', | ||
fontWeight: 700, | ||
fontSize: '1.8rem', | ||
}), | ||
const sizes = { | ||
small: css` | ||
height: 3rem; | ||
font-size: 1.4rem; | ||
font-weight: 700; | ||
`, | ||
medium: css` | ||
height: 4rem; | ||
font-size: 1.8rem; | ||
font-weight: 700; | ||
`, | ||
filled: css` | ||
width: 100%; | ||
height: 4rem; | ||
font-size: 1.8rem; | ||
font-weight: 700%; | ||
`, | ||
}; | ||
|
||
export const textTypeStyle = css({ | ||
padding: '0', | ||
background: 'none', | ||
border: 'none', | ||
width: 'fit-content', | ||
height: 'fit-content', | ||
display: 'inline-block', | ||
}); | ||
export const Button = styled.button<Props>` | ||
cursor: pointer; | ||
display: flex; | ||
gap: 0.8rem; | ||
align-items: center; | ||
justify-content: center; | ||
padding: 0.8rem 1.6rem; | ||
text-align: center; | ||
border-radius: 8px; | ||
${({ size }) => sizes[size]}; | ||
${({ variant }) => variants[variant]}; | ||
&:disabled { | ||
cursor: default; | ||
opacity: 0.6; | ||
} | ||
&:not(:disabled):focus { | ||
outline: none; | ||
} | ||
&:not(:disabled):hover { | ||
opacity: 0.8; | ||
} | ||
&:not(:disabled):active { | ||
opacity: 0.6; | ||
} | ||
`; |
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
Oops, something went wrong.