mirror of
https://github.com/vercel/commerce.git
synced 2025-07-05 20:51:21 +00:00
39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import classNames from 'classnames'
|
|
import React, { memo } from 'react'
|
|
import { ButonType, ButtonSize } from 'src/utils/constanst.utils'
|
|
import s from './ButtonCommon.module.scss'
|
|
|
|
interface Props {
|
|
children?: React.ReactNode,
|
|
type?: ButonType,
|
|
size?: ButtonSize,
|
|
icon?: any,
|
|
isIconSuffix?: boolean,
|
|
loading?: boolean,
|
|
disabled?: boolean,
|
|
onClick?: () => void,
|
|
}
|
|
|
|
const ButtonCommon = memo(({ type = ButonType.primary, size = ButtonSize.default,
|
|
icon, loading, disabled, isIconSuffix, children, onClick }: Props) => {
|
|
return (
|
|
<button className={classNames({
|
|
[s.buttonCommon]: true,
|
|
[s[type]]: !!type,
|
|
[s[size]]: !!size,
|
|
[s.loading]: loading,
|
|
[s.preserve]: isIconSuffix,
|
|
})}
|
|
disabled={disabled}
|
|
onClick={onClick}
|
|
>
|
|
{
|
|
icon && <span className={s.icon}>{icon}</span>
|
|
}
|
|
<span className={s.label}>{children}</span>
|
|
</button>
|
|
)
|
|
})
|
|
|
|
export default ButtonCommon
|