Files
Checkmate/client/src/Components/v1/Subheader/index.jsx
T

83 lines
2.0 KiB
React
Raw Normal View History

import PropTypes from "prop-types";
import { useTheme } from "@emotion/react";
2025-02-26 11:41:36 -08:00
import { Stack, Typography } from "@mui/material";
/**
*
* @component
* @example
*
2025-02-26 13:38:25 -08:00
* @param {boolean} props.shouldRender - Whether to render the subheader
2025-02-26 11:41:36 -08:00
* @param {string} props.direction - Direction of the subheader
* @param {string} props.headerText - Header text
* @param {number} props.headerLevel - Font characteristic of the header
* @param {string} props.subHeaderText - Subheader text
* @param {number} props.subHeaderLevel - Font characteristic of the subheader
2025-02-24 14:33:25 -08:00
* @param {string} props.alignItems - Align items
* @param {node} props.children - Children
* @returns {JSX.Element} The rendered component
*/
2025-02-23 17:47:02 -08:00
const SubHeader = ({
2025-02-26 13:38:25 -08:00
shouldRender = true,
2025-02-26 11:41:36 -08:00
direction = "row",
2025-02-23 17:47:02 -08:00
headerText,
headerLevel = 1,
subHeaderText,
subHeaderLevel = 1,
2025-02-24 14:33:25 -08:00
alignItems = "center",
children,
2025-02-26 11:41:36 -08:00
...props
2025-02-23 17:47:02 -08:00
}) => {
const theme = useTheme();
2025-02-26 13:38:25 -08:00
if (!shouldRender) {
return null;
}
return (
2025-02-23 17:47:02 -08:00
<Stack
2025-02-26 11:41:36 -08:00
direction={direction}
2025-02-24 14:33:25 -08:00
alignItems={alignItems}
justifyContent="space-between"
2025-02-26 11:41:36 -08:00
{...props}
2025-02-23 17:47:02 -08:00
>
<Stack direction={"column"}>
<Typography
component={`h${headerLevel}`}
variant={`h${headerLevel}`}
mb={theme.spacing(1)}
>
<Typography
component="span"
fontSize="inherit"
color={theme.palette.primary.contrastTextTertiary}
>
{headerText}
</Typography>
</Typography>
<Typography
variant={`body${subHeaderLevel}`}
color={theme.palette.primary.contrastTextTertiary}
>
{subHeaderText}
</Typography>
</Stack>
2025-02-24 14:33:25 -08:00
{children}
</Stack>
);
};
SubHeader.propTypes = {
2025-02-26 13:38:25 -08:00
shouldRender: PropTypes.bool,
2025-02-26 11:41:36 -08:00
direction: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
2025-02-23 17:47:02 -08:00
headerText: PropTypes.string,
headerLevel: PropTypes.number,
subHeaderText: PropTypes.string,
subHeaderLevel: PropTypes.number,
2025-02-26 11:41:36 -08:00
alignItems: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
2025-02-24 14:33:25 -08:00
children: PropTypes.node,
};
export default SubHeader;