mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-01-21 00:59:44 -06:00
Added jsdocs and proptypes
This commit is contained in:
@@ -24,6 +24,9 @@ const icons = {
|
||||
* @param {'info' | 'error' | 'warning'} props.variant - The type of alert.
|
||||
* @param {string} [props.title] - The title of the alert.
|
||||
* @param {string} [props.body] - The body text of the alert.
|
||||
* @param {boolean} [props.isToast] - Indicates if the alert is used as a toast notification.
|
||||
* @param {boolean} [props.hasIcon] - Whether to display an icon in the alert.
|
||||
* @param {function} props.onClick - Toast dismiss function.
|
||||
* @returns {JSX.Element}
|
||||
*/
|
||||
|
||||
@@ -105,6 +108,16 @@ Alert.propTypes = {
|
||||
variant: PropTypes.oneOf(["info", "error", "warning"]).isRequired,
|
||||
title: PropTypes.string,
|
||||
body: PropTypes.string,
|
||||
isToast: PropTypes.bool,
|
||||
hasIcon: PropTypes.bool,
|
||||
onClick: function (props, propName, componentName) {
|
||||
if (props.isToast && !props[propName]) {
|
||||
return new Error(
|
||||
`Prop '${propName}' is required when 'isToast' is true in '${componentName}'.`
|
||||
);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
};
|
||||
|
||||
export default Alert;
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
import PropTypes from "prop-types";
|
||||
import { toast } from "react-toastify";
|
||||
import Alert from "../Components/Alert";
|
||||
|
||||
/**
|
||||
* @param {object} props
|
||||
* @param {'info' | 'error' | 'warning'} - The variant of the alert (e.g., "info", "error").
|
||||
* @param {string} props.title - The title of the alert.
|
||||
* @param {string} props.body - The body/content of the alert.
|
||||
* @param {boolean} props.hasIcon - Whether the alert should include an icon.
|
||||
* @param {object} [props.config] - Additional configuration props for the toast.
|
||||
*/
|
||||
|
||||
export const createToast = ({ variant, title, body, hasIcon, config = {} }) => {
|
||||
const toastConfig = {
|
||||
position: "bottom-right",
|
||||
@@ -24,3 +34,11 @@ export const createToast = ({ variant, title, body, hasIcon, config = {} }) => {
|
||||
toastConfig
|
||||
);
|
||||
};
|
||||
|
||||
createToast.propTypes = {
|
||||
variant: PropTypes.oneOf(["info", "error", "warning"]).isRequired,
|
||||
title: PropTypes.string,
|
||||
body: PropTypes.string,
|
||||
hasIcon: PropTypes.bool,
|
||||
config: PropTypes.object,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user