Skip to content
Snippets Groups Projects
Commit d49fe64f authored by Aggarwal Himanshu's avatar Aggarwal Himanshu
Browse files

Add a way to disable button

parent fc6445a6
No related branches found
No related tags found
2 merge requests!17Merge develop into main,!12Filter Enhancements
...@@ -13,11 +13,13 @@ import classNames from "classnames"; ...@@ -13,11 +13,13 @@ import classNames from "classnames";
* </Button> * </Button>
* ) * )
*/ */
function Button({ children, className, onClick, type }) { function Button({ children, className, onClick, type, disabled }) {
return ( return (
<button <button
className={classNames("py-2 px-5 rounded-xl", className)} className={classNames("py-2 px-5 rounded-xl", className, {
onClick={onClick} "brightness-50 cursor-default": disabled,
})}
onClick={disabled ? undefined : onClick}
type={type ? type : "button"} type={type ? type : "button"}
> >
{children} {children}
...@@ -38,6 +40,18 @@ Button.propTypes = { ...@@ -38,6 +40,18 @@ Button.propTypes = {
* The function to run when button is pressed * The function to run when button is pressed
*/ */
onClick: PropTypes.func, onClick: PropTypes.func,
/**
* The type of button
*/
type: PropTypes.string,
/**
* Whether the button is disabled
*/
disabled: PropTypes.bool,
};
Button.defaultProps = {
type: "button",
}; };
export default Button; export default Button;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment