Merge pull request #1845 from Owaiseimdad/StatusBarResolutionStyling
Added a new HOC in status bar in order to make sure it works on both …
This commit is contained in:
1 file changed
+50
-14
@@ -3,6 +3,45 @@ import { Box, Stack, Tooltip, Typography } from "@mui/material";
|
|||||||
import { formatDateWithTz } from "../../../Utils/timeUtils";
|
import { formatDateWithTz } from "../../../Utils/timeUtils";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A customizable Bar component that renders a colored bar with optional children.
|
||||||
|
* @component
|
||||||
|
*
|
||||||
|
* @param {string} width The width of the bar (e.g., "100px").
|
||||||
|
* @param {string} height The height of the bar (e.g., "50px").
|
||||||
|
* @param {string} backgroundColor The background color of the bar (e.g., "#FF5733").
|
||||||
|
* @param {string} [borderRadius] Optional border radius for the bar (e.g., "8px").
|
||||||
|
* @param {node} children The content to be rendered inside the bar.
|
||||||
|
* @returns {JSX.Element} The Bar component.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const Bar = ({ width, height, backgroundColor, borderRadius, children }) => {
|
||||||
|
const theme = useTheme();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
position="relative"
|
||||||
|
width={width}
|
||||||
|
height={height}
|
||||||
|
backgroundColor={backgroundColor}
|
||||||
|
sx={{
|
||||||
|
borderRadius: borderRadius || theme.spacing(1.5),
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
Bar.propTypes = {
|
||||||
|
width: PropTypes.string.isRequired,
|
||||||
|
height: PropTypes.string.isRequired,
|
||||||
|
backgroundColor: PropTypes.string.isRequired,
|
||||||
|
borderRadius: PropTypes.string,
|
||||||
|
children: PropTypes.node,
|
||||||
|
};
|
||||||
|
|
||||||
/* TODO add prop validation and jsdocs */
|
/* TODO add prop validation and jsdocs */
|
||||||
const StatusPageBarChart = ({ checks = [] }) => {
|
const StatusPageBarChart = ({ checks = [] }) => {
|
||||||
@@ -10,6 +49,11 @@ const StatusPageBarChart = ({ checks = [] }) => {
|
|||||||
const [animate, setAnimate] = useState(false);
|
const [animate, setAnimate] = useState(false);
|
||||||
const uiTimezone = useSelector((state) => state.ui.timezone);
|
const uiTimezone = useSelector((state) => state.ui.timezone);
|
||||||
|
|
||||||
|
const barWidth = {
|
||||||
|
xs: "calc(60% / 25)",
|
||||||
|
xl: "calc(40% / 25)",
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setAnimate(true);
|
setAnimate(true);
|
||||||
}, []);
|
}, []);
|
||||||
@@ -41,15 +85,11 @@ const StatusPageBarChart = ({ checks = [] }) => {
|
|||||||
/* TODO what is the purpose of this box? */
|
/* TODO what is the purpose of this box? */
|
||||||
// CAIO_REVIEW the purpose of this box is to make sure there are always at least 25 bars
|
// CAIO_REVIEW the purpose of this box is to make sure there are always at least 25 bars
|
||||||
// even if there are less than 25 checks
|
// even if there are less than 25 checks
|
||||||
<Box
|
<Bar
|
||||||
key={`${check}-${index}`}
|
key={`${check}-${index}`}
|
||||||
position="relative"
|
width={barWidth}
|
||||||
width="calc(30vw / 25)"
|
|
||||||
height="100%"
|
height="100%"
|
||||||
backgroundColor={theme.palette.primary.lowContrast}
|
backgroundColor={theme.palette.primary.lowContrast}
|
||||||
sx={{
|
|
||||||
borderRadius: theme.spacing(1.5),
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
@@ -140,14 +180,10 @@ const StatusPageBarChart = ({ checks = [] }) => {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Box
|
<Bar
|
||||||
position="relative"
|
width={barWidth}
|
||||||
width="calc(30vw / 25)"
|
|
||||||
height="100%"
|
height="100%"
|
||||||
backgroundColor={theme.palette.primary.lowContrast} // CAIO_REVIEW
|
backgroundColor={theme.palette.primary.lowContrast}
|
||||||
sx={{
|
|
||||||
borderRadius: theme.spacing(1.5),
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Box
|
<Box
|
||||||
position="absolute"
|
position="absolute"
|
||||||
@@ -164,7 +200,7 @@ const StatusPageBarChart = ({ checks = [] }) => {
|
|||||||
transition: "height 600ms cubic-bezier(0.4, 0, 0.2, 1)",
|
transition: "height 600ms cubic-bezier(0.4, 0, 0.2, 1)",
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Bar>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in new issue
Block a user