Merge pull request #1832 from bluewave-labs/feat/subheader-render-condition

feat: conditionally render subheader
This commit is contained in:
Alexander Holliday authored and GitHub committed 2025-02-26 13:39:23 -08:00
commit a1b8d0952a
2 files changed
+9

No files matched your search

+8
View File
@@ -8,6 +8,7 @@ import { Stack, Typography } from "@mui/material";
* @component * @component
* @example * @example
* *
* @param {boolean} props.shouldRender - Whether to render the subheader
* @param {string} props.direction - Direction of the subheader * @param {string} props.direction - Direction of the subheader
* @param {string} props.headerText - Header text * @param {string} props.headerText - Header text
* @param {number} props.headerLevel - Font characteristic of the header * @param {number} props.headerLevel - Font characteristic of the header
@@ -19,6 +20,7 @@ import { Stack, Typography } from "@mui/material";
*/ */
const SubHeader = ({ const SubHeader = ({
shouldRender = true,
direction = "row", direction = "row",
headerText, headerText,
headerLevel = 1, headerLevel = 1,
@@ -29,6 +31,11 @@ const SubHeader = ({
...props ...props
}) => { }) => {
const theme = useTheme(); const theme = useTheme();
if (!shouldRender) {
return null;
}
return ( return (
<Stack <Stack
direction={direction} direction={direction}
@@ -63,6 +70,7 @@ const SubHeader = ({
}; };
SubHeader.propTypes = { SubHeader.propTypes = {
shouldRender: PropTypes.bool,
direction: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), direction: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
headerText: PropTypes.string, headerText: PropTypes.string,
headerLevel: PropTypes.number, headerLevel: PropTypes.number,
@@ -246,6 +246,7 @@ const DistributedUptimeStatus = () => {
/> />
<SubHeader <SubHeader
shouldRender={statusPage?.subMonitors?.length > 0}
direction={{ s: "column", md: "row" }} direction={{ s: "column", md: "row" }}
headerText={t("distributedStatusServerMonitors")} headerText={t("distributedStatusServerMonitors")}
subHeaderText={t("distributedStatusServerMonitorsDescription")} subHeaderText={t("distributedStatusServerMonitorsDescription")}