This commit is contained in:
hamid zarghami
2024-12-24 09:00:36 +03:30
parent 6cb43e42b2
commit 7bded16958
9 changed files with 253 additions and 6 deletions
+32
View File
@@ -0,0 +1,32 @@
import { ButtonHTMLAttributes, FC, memo, ReactNode } from 'react'
import ReactLoading from 'react-loading'
import { XOR } from '../helpers/types'
import { clx } from '../helpers/utils'
type Props = {
className?: string;
isLoading?: boolean,
} & ButtonHTMLAttributes<HTMLButtonElement> &
XOR<{ children: ReactNode }, { label: string, isLoading?: boolean }>;
const Button: FC<Props> = memo((props: Props) => {
const buttonClass = clx(
'flex rounded-xl items-center justify-center text-center h-12 text-sm bg-primary text-white w-full',
props.disabled && 'cursor-not-allowed opacity-60',
props.className
);
return (
<button {...props} className={`${buttonClass} ${props.className}`} >
{
props.isLoading ?
<ReactLoading type='spin' color={'white'} width={20} height={20} />
:
props.label || props.children
}
</button>
)
})
export default Button