Files
Checkmate/Client/src/Components/Button/index.jsx
T

49 lines
1.1 KiB
React
Raw Normal View History

2024-05-06 12:24:03 -07:00
import { Button as MuiButton } from "@mui/material";
import PropTypes from "prop-types";
const levelConfig = {
primary: {
variant: "contained",
color: "primary",
},
secondary: {
variant: "outlined",
color: "secondary",
},
tertiary: {
variant: "text",
color: "tertiary",
},
error: {
variant: "contained",
color: "error",
},
};
/**
2024-05-07 14:30:00 -07:00
* @param {Object} props
* @param {'primary' | 'secondary' | 'tertiary' | 'error'} props.level - The level of the button
* @param {string} props.label - The label of the button
* @param {boolean} [props.disabled] - Whether the button is disabled
* @returns {JSX.Element}
* @example
* // Render an error button
* <Button level="error" label="Error" disabled />
2024-05-06 12:24:03 -07:00
*/
const Button = ({ level, label, disabled }) => {
2024-05-06 12:24:03 -07:00
const { variant, color } = levelConfig[level];
return (
<MuiButton variant={variant} color={color} disabled={disabled}>
{label}
2024-05-06 12:24:03 -07:00
</MuiButton>
);
};
Button.propTypes = {
level: PropTypes.string.isRequired,
label: PropTypes.string.isRequired,
2024-05-06 12:24:03 -07:00
disabled: PropTypes.bool,
};
export default Button;