1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-24 22:14:18 +00:00
pds-2021-g2-nest/nest_frontend/components/base/Button.js

33 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-05-11 14:37:15 +00:00
import React from "react"
import Style from "./Button.module.css"
import classNames from "classnames"
2021-05-22 02:17:02 +00:00
import makeIcon from "../../utils/makeIcon"
/**
* A clickable button.
*
* @param children - The contents of the button.
* @param disabled - Whether the button is disabled or not.
* @param onClick - Function to call when the button is clicked. Won't be called if the button is disabled.
* @param className - Additional class(es) that should be added to the button.
* @param color - The color of the button. Either `Red`, `Grey`, `Green` or `Yellow`.
* @param icon - The FontAwesome IconDefinition of the icon that should be rendered in the button.
* @param props - Additional props to pass to the button.
* @returns {JSX.Element}
* @constructor
*/
export default function Button({ children, disabled, onClick, className, color, icon, ...props }) {
return (
<button
type={"button"}
className={classNames(Style.Button, Style[`Button${color}`], disabled ? null : "Clickable", className)}
onClick={disabled ? null : onClick}
disabled={disabled}
{...props}
>
2021-05-23 14:20:53 +00:00
{children} {makeIcon(icon, { className: Style.Icon })}
</button>
)
}