2024-12-18 13:44:48 -08:00
|
|
|
import { Box, Typography } from "@mui/material";
|
|
|
|
|
import { useTheme } from "@mui/material/styles";
|
2024-12-18 13:46:51 -08:00
|
|
|
import PropTypes from "prop-types";
|
2024-12-18 13:44:48 -08:00
|
|
|
|
2024-12-18 13:46:51 -08:00
|
|
|
/**
|
|
|
|
|
* StatBox Component
|
|
|
|
|
*
|
|
|
|
|
* A reusable component that displays a statistic with a heading and subheading
|
|
|
|
|
* in a styled box with a gradient background.
|
|
|
|
|
*
|
|
|
|
|
* @component
|
|
|
|
|
* @param {Object} props - The component props
|
|
|
|
|
* @param {string} props.heading - The primary heading/title of the statistic
|
|
|
|
|
* @param {string|React.ReactNode} props.subHeading - The value or description of the statistic
|
|
|
|
|
* @param {Object} [props.sx] - Additional custom styling to be applied to the box
|
|
|
|
|
*
|
|
|
|
|
* @example
|
|
|
|
|
* return (
|
|
|
|
|
* <StatBox
|
|
|
|
|
* heading="Total Users"
|
|
|
|
|
* subHeading="1,234"
|
|
|
|
|
* sx={{ width: 300 }}
|
|
|
|
|
* />
|
|
|
|
|
* )
|
|
|
|
|
*
|
|
|
|
|
* @returns {React.ReactElement} A styled box containing the statistic
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
const StatBox = ({ heading, subHeading, sx }) => {
|
2024-12-18 13:44:48 -08:00
|
|
|
const theme = useTheme();
|
|
|
|
|
return (
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
padding: `${theme.spacing(4)} ${theme.spacing(8)}`,
|
|
|
|
|
minWidth: 200,
|
|
|
|
|
width: 225,
|
|
|
|
|
border: 1,
|
|
|
|
|
borderStyle: "solid",
|
2025-01-08 21:41:59 -05:00
|
|
|
borderColor: theme.palette.primary.lowContrast,
|
2024-12-18 13:44:48 -08:00
|
|
|
borderRadius: 4,
|
|
|
|
|
backgroundColor: theme.palette.background.main,
|
|
|
|
|
background: `linear-gradient(340deg, ${theme.palette.background.accent} 20%, ${theme.palette.background.main} 45%)`,
|
|
|
|
|
"& h2": {
|
|
|
|
|
fontSize: 13,
|
|
|
|
|
fontWeight: 500,
|
2025-01-07 21:27:52 -05:00
|
|
|
color: theme.palette.primary.contrastText.secondary,
|
2024-12-18 13:44:48 -08:00
|
|
|
textTransform: "uppercase",
|
|
|
|
|
},
|
|
|
|
|
"& p": {
|
|
|
|
|
fontSize: 18,
|
2025-01-07 21:27:52 -05:00
|
|
|
color: theme.palette.primary.contrastText.main,
|
2024-12-18 13:44:48 -08:00
|
|
|
marginTop: theme.spacing(2),
|
|
|
|
|
"& span": {
|
2025-01-07 21:27:52 -05:00
|
|
|
color: theme.palette.primary.contrastText.tertiary,
|
2024-12-18 13:44:48 -08:00
|
|
|
marginLeft: theme.spacing(2),
|
|
|
|
|
fontSize: 15,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
...sx,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Typography component="h2">{heading}</Typography>
|
|
|
|
|
<Typography>{subHeading}</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2024-12-18 13:46:51 -08:00
|
|
|
StatBox.propTypes = {
|
|
|
|
|
heading: PropTypes.string.isRequired,
|
|
|
|
|
subHeading: PropTypes.node.isRequired,
|
|
|
|
|
sx: PropTypes.object,
|
|
|
|
|
};
|
|
|
|
|
|
2024-12-18 13:44:48 -08:00
|
|
|
export default StatBox;
|