2021-04-10 12:21:02 -07:00
|
|
|
import { FunctionComponent } from 'react'
|
|
|
|
|
|
|
|
interface ButtonProps {
|
|
|
|
onClick?: (x?) => void
|
|
|
|
disabled?: boolean
|
|
|
|
className?: string
|
2021-04-10 14:12:15 -07:00
|
|
|
grow?: boolean
|
2021-04-10 12:21:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
const Button: FunctionComponent<ButtonProps> = ({
|
|
|
|
children,
|
|
|
|
onClick,
|
|
|
|
disabled = false,
|
|
|
|
className,
|
2021-04-10 14:12:15 -07:00
|
|
|
grow = false,
|
2021-04-10 12:21:02 -07:00
|
|
|
...props
|
|
|
|
}) => {
|
|
|
|
if (disabled) {
|
|
|
|
return (
|
|
|
|
<button
|
2021-04-12 09:49:02 -07:00
|
|
|
className={`px-8 py-2 border border-th-fgd-4 bg-th-bkg-2
|
|
|
|
rounded-md focus:outline-none
|
|
|
|
${grow && `flex-grow`}
|
|
|
|
${disabled && `cursor-not-allowed text-th-fgd-4`},
|
|
|
|
`}
|
2021-04-10 12:21:02 -07:00
|
|
|
disabled={disabled}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</button>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<button
|
|
|
|
onClick={onClick}
|
2021-04-12 09:49:02 -07:00
|
|
|
className={`px-8 py-2 border border-mango-dark-lighter bg-mango-dark-light
|
|
|
|
focus:outline-none
|
|
|
|
${
|
|
|
|
disabled
|
|
|
|
? `cursor-not-allowed text-mango-med`
|
|
|
|
: `active:border-mango-yellow text-mango-yellow hover:bg-mango-dark-lighter`
|
|
|
|
}
|
|
|
|
${className}`}
|
2021-04-10 12:21:02 -07:00
|
|
|
{...props}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</button>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Button
|