From baf4edfe4a560708fbd2a8bcd0a322cb6d730a9a Mon Sep 17 00:00:00 2001 From: Himanshu Aggarwal <aggarwah@mcmaster.ca> Date: Wed, 16 Mar 2022 20:10:40 -0400 Subject: [PATCH] Add initial documentation for Button component --- src/cryptometrics/components/button/Button.js | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/cryptometrics/components/button/Button.js b/src/cryptometrics/components/button/Button.js index cf14da8..c2208b1 100644 --- a/src/cryptometrics/components/button/Button.js +++ b/src/cryptometrics/components/button/Button.js @@ -1,7 +1,19 @@ -import classNames from "classnames"; import React from "react"; +import PropTypes from "prop-types"; +import classNames from "classnames"; -export default function Button({ children, className, onClick }) { +/** + * Custom button component + * + * @component + * @example + * return ( + * <Button className="bg-indigo-500 text-white" onClick={() => console.log("Button pressed")}> + * Hello! + * </Button> + * ) + */ +function Button({ children, className, onClick }) { return ( <button className={classNames("py-2 px-5 rounded-xl", className)} @@ -11,3 +23,20 @@ export default function Button({ children, className, onClick }) { </button> ); } + +Button.propTypes = { + /** + * The content inside the button + */ + children: PropTypes.node.isRequired, + /** + * Additional CSS classes for the button (optional) + */ + className: PropTypes.string, + /** + * The function to run when button is pressed + */ + onClick: PropTypes.func, +}; + +export default Button; -- GitLab