2024-05-24 18:32:40 +03:30
|
|
|
import "./check.css";
|
2024-07-15 20:14:32 -04:00
|
|
|
import PropTypes from "prop-types";
|
|
|
|
|
import CheckGrey from "../../assets/icons/check.svg?react";
|
|
|
|
|
import { Stack, Typography } from "@mui/material";
|
|
|
|
|
import { useTheme } from "@emotion/react";
|
2024-05-24 18:32:40 +03:30
|
|
|
|
2024-05-24 22:17:12 +03:30
|
|
|
/**
|
|
|
|
|
* `Check` is a functional React component that displays a check icon and a label.
|
|
|
|
|
*
|
|
|
|
|
* @component
|
|
|
|
|
* @param {Object} props - The properties that define the `Check` component.
|
|
|
|
|
* @param {string} props.text - The text to be displayed as the label next to the check icon.
|
2024-07-15 20:14:32 -04:00
|
|
|
* @param {'info' | 'error' | 'success'} [props.variant='info'] - The variant of the check component, affecting its styling.
|
2024-05-24 22:17:12 +03:30
|
|
|
*
|
|
|
|
|
* @example
|
|
|
|
|
* // To use this component, import it and use it in your JSX like this:
|
|
|
|
|
* <Check text="Your Text Here" />
|
|
|
|
|
*
|
|
|
|
|
* @returns {React.Element} The `Check` component with a check icon and a label, defined by the `text` prop.
|
|
|
|
|
*/
|
2024-07-15 20:14:32 -04:00
|
|
|
const Check = ({ text, variant = "info" }) => {
|
|
|
|
|
const theme = useTheme();
|
2024-05-24 18:32:40 +03:30
|
|
|
return (
|
2024-07-15 20:14:32 -04:00
|
|
|
<Stack
|
|
|
|
|
direction="row"
|
|
|
|
|
gap={theme.gap.small}
|
|
|
|
|
className={`check${
|
|
|
|
|
variant === "error"
|
|
|
|
|
? " check-error"
|
|
|
|
|
: variant === "success"
|
|
|
|
|
? " check-success"
|
|
|
|
|
: " check-info"
|
|
|
|
|
}`}
|
|
|
|
|
alignItems="center"
|
|
|
|
|
>
|
|
|
|
|
<CheckGrey alt="form checks" />
|
|
|
|
|
<Typography component="span">{text}</Typography>
|
|
|
|
|
</Stack>
|
2024-05-24 18:32:40 +03:30
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2024-07-15 20:14:32 -04:00
|
|
|
Check.propTypes = {
|
|
|
|
|
text: PropTypes.string.isRequired,
|
|
|
|
|
variant: PropTypes.oneOf(["info", "error", "success"]),
|
|
|
|
|
};
|
|
|
|
|
|
2024-05-24 18:32:40 +03:30
|
|
|
export default Check;
|