feat: added button disabled

This commit is contained in:
wonderlandpark 2021-03-28 13:00:02 +09:00
parent 8f153a0d36
commit 93c250b62f

View File

@ -6,10 +6,11 @@ const Button = ({
className,
children,
href,
disabled=false,
onClick,
}: ButtonProps): JSX.Element => {
return href ? (
<Link href={href}>
<Link href={!disabled && href}>
<a
className={`cursor-pointer rounded-md px-4 py-2 m-1 transition duration-300 ease select-none outline-none foucs:outline-none ${className ??
'bg-discord-blurple hover:opacity-80 dark:bg-very-black dark:hover:bg-discord-dark-hover text-white'}`}
@ -19,8 +20,8 @@ const Button = ({
</Link>
) : onClick ? (
<button
type={type}
onClick={onClick}
type={disabled ? 'button' : type}
onClick={disabled ? null : onClick}
className={`cursor-pointer rounded-md px-4 py-2 m-0.5 transition duration-300 ease select-none outline-none foucs:outline-none ${className ??
'bg-discord-blurple hover:opacity-80 dark:bg-very-black dark:hover:bg-discord-dark-hover text-white'}`}
>
@ -28,7 +29,7 @@ const Button = ({
</button>
) : (
<button
type={type}
type={disabled ? 'button' : type}
className={`cursor-pointer rounded-md px-4 py-2 m-0.5 transition duration-300 ease select-none outline-none foucs:outline-none ${className ??
'bg-discord-blurple hover:opacity-80 dark:bg-very-black dark:hover:bg-discord-dark-hover text-white'}`}
>
@ -42,6 +43,7 @@ interface ButtonProps {
className?: string
children: ReactNode
href?: string
disabled?: boolean
onClick?: () => void
}