|
|
@ -1,17 +1,11 @@ |
|
|
|
import { |
|
|
|
import { Button as MUIButton, SxProps, Theme } from '@mui/material'; |
|
|
|
Button as MUIButton, |
|
|
|
import { FC, useMemo } from 'react'; |
|
|
|
ButtonProps as MUIButtonProps, |
|
|
|
|
|
|
|
} from '@mui/material'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { BLACK, GREY, TEXT } from '../lib/consts/DEFAULT_THEME'; |
|
|
|
import { BLACK, GREY, TEXT } from '../lib/consts/DEFAULT_THEME'; |
|
|
|
|
|
|
|
|
|
|
|
type ContainedButtonProps = MUIButtonProps; |
|
|
|
const ContainedButton: FC<ContainedButtonProps> = ({ sx, ...restProps }) => { |
|
|
|
|
|
|
|
const combinedSx = useMemo<SxProps<Theme>>( |
|
|
|
const ContainedButton = ( |
|
|
|
() => ({ |
|
|
|
containedButtonProps: ContainedButtonProps, |
|
|
|
|
|
|
|
): JSX.Element => { |
|
|
|
|
|
|
|
const { children, sx } = containedButtonProps; |
|
|
|
|
|
|
|
const combinedSx: ContainedButtonProps['sx'] = { |
|
|
|
|
|
|
|
backgroundColor: TEXT, |
|
|
|
backgroundColor: TEXT, |
|
|
|
color: BLACK, |
|
|
|
color: BLACK, |
|
|
|
textTransform: 'none', |
|
|
|
textTransform: 'none', |
|
|
@ -21,21 +15,19 @@ const ContainedButton = ( |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
...sx, |
|
|
|
...sx, |
|
|
|
}; |
|
|
|
}), |
|
|
|
|
|
|
|
[sx], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<MUIButton |
|
|
|
<MUIButton |
|
|
|
{...{ |
|
|
|
{...{ |
|
|
|
variant: 'contained', |
|
|
|
variant: 'contained', |
|
|
|
...containedButtonProps, |
|
|
|
...restProps, |
|
|
|
sx: combinedSx, |
|
|
|
sx: combinedSx, |
|
|
|
}} |
|
|
|
}} |
|
|
|
> |
|
|
|
/> |
|
|
|
{children} |
|
|
|
|
|
|
|
</MUIButton> |
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
export type { ContainedButtonProps }; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default ContainedButton; |
|
|
|
export default ContainedButton; |
|
|
|