Files
Checkmate/client/src/Pages/Uptime/Monitors/Components/StatusBoxes/statusBox.jsx
T

107 lines
2.5 KiB
React
Raw Normal View History

2025-01-24 13:09:05 -08:00
import PropTypes from "prop-types";
import { useTheme } from "@emotion/react";
import { Box, Stack, Typography } from "@mui/material";
import Arrow from "../../../../../assets/icons/top-right-arrow.svg?react";
import Background from "../../../../../assets/Images/background-grid.svg?react";
import ClockSnooze from "../../../../../assets/icons/clock-snooze.svg?react";
2025-05-30 15:03:32 -07:00
const StatusBox = ({ title, value, status }) => {
2025-01-24 13:09:05 -08:00
const theme = useTheme();
let sharedStyles = {
position: "absolute",
right: 8,
opacity: 0.5,
"& svg path": { stroke: theme.palette.primary.contrastTextTertiary },
};
let color;
let icon;
2025-05-30 15:03:32 -07:00
if (status === "up") {
2025-01-24 13:09:05 -08:00
color = theme.palette.success.lowContrast;
icon = (
2025-07-02 12:51:27 +05:30
<Box sx={{ ...sharedStyles, top: theme.spacing(4) }}>
2025-01-24 13:09:05 -08:00
<Arrow />
</Box>
);
2025-05-30 15:03:32 -07:00
} else if (status === "down") {
2025-01-24 13:09:05 -08:00
color = theme.palette.error.lowContrast;
icon = (
2025-07-02 12:51:27 +05:30
<Box sx={{ ...sharedStyles, transform: "rotate(180deg)", top: theme.spacing(2) }}>
2025-01-24 13:09:05 -08:00
<Arrow />
</Box>
);
2025-05-30 15:03:32 -07:00
} else if (status === "paused") {
2025-01-24 13:09:05 -08:00
color = theme.palette.warning.lowContrast;
icon = (
2025-07-02 12:51:27 +05:30
<Box sx={{ ...sharedStyles, top: theme.spacing(6), right: theme.spacing(6) }}>
2025-01-24 13:09:05 -08:00
<ClockSnooze />
</Box>
);
}
return (
<Box
position="relative"
flex={1}
border={1}
backgroundColor={theme.palette.primary.main}
borderColor={theme.palette.primary.lowContrast}
borderRadius={theme.shape.borderRadius}
p={theme.spacing(8)}
overflow="hidden"
>
<Box
position="absolute"
top="-10%"
left="5%"
>
<Background />
</Box>
<Stack direction="column">
<Stack
direction="row"
alignItems="center"
mb={theme.spacing(8)}
>
<Typography
variant={"h2"}
textTransform="uppercase"
color={theme.palette.primary.contrastTextTertiary}
>
{title}
</Typography>
{icon}
</Stack>
<Stack
direction="row"
alignItems="flex-start"
2025-07-02 12:51:27 +05:30
fontSize={theme.typography.h1.fontSize}
2025-01-24 13:09:05 -08:00
fontWeight={600}
color={color}
2025-07-02 12:51:27 +05:30
gap={theme.spacing(1)}
2025-01-24 13:09:05 -08:00
>
{value}
<Typography
2025-07-02 12:51:27 +05:30
fontSize={theme.typography.label.fontSize}
2025-01-24 13:09:05 -08:00
fontWeight={300}
color={theme.palette.primary.contrastTextSecondary}
sx={{
opacity: 0.3,
}}
>
#
</Typography>
</Stack>
</Stack>
</Box>
);
};
StatusBox.propTypes = {
2025-05-30 15:03:32 -07:00
title: PropTypes.string,
2025-01-24 13:09:05 -08:00
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
2025-05-30 15:03:32 -07:00
status: PropTypes.string,
2025-01-24 13:09:05 -08:00
};
export default StatusBox;