Files
Checkmate/client/src/Components/v2/design-elements/StatusBox.tsx
T

152 lines
3.0 KiB
TypeScript
Raw Normal View History

2026-01-23 23:54:58 +00:00
import Stack from "@mui/material/Stack";
import Typography from "@mui/material/Typography";
import Box from "@mui/material/Box";
import { BaseBox } from "@/Components/v2/design-elements";
import Background from "@/assets/Images/background-grid.svg?react";
import { useTranslation } from "react-i18next";
2026-01-27 23:05:00 +00:00
import type { SxProps } from "@mui/material";
2026-01-23 23:54:58 +00:00
import { useTheme } from "@mui/material/styles";
2026-01-27 23:05:00 +00:00
type StatusBoxProps = React.PropsWithChildren<{
children: React.ReactNode;
sx?: SxProps;
}>;
2026-01-23 23:54:58 +00:00
2026-01-27 23:05:00 +00:00
export const BGBox = ({ children, sx }: StatusBoxProps) => {
2026-01-23 23:54:58 +00:00
const theme = useTheme();
return (
<BaseBox
sx={{
overflow: "hidden",
position: "relative",
flex: 1,
padding: theme.spacing(4),
2026-01-27 23:05:00 +00:00
...sx,
2026-01-23 23:54:58 +00:00
}}
>
<Box
position="absolute"
top="-10%"
left="5%"
>
<Background />
</Box>
{children}
</BaseBox>
);
};
const StatusBox = ({
label,
n,
color,
2026-01-27 23:05:00 +00:00
sx,
2026-01-23 23:54:58 +00:00
}: {
label: string;
n: number;
color: string | undefined;
2026-01-27 23:05:00 +00:00
sx?: SxProps;
2026-01-23 23:54:58 +00:00
}) => {
const theme = useTheme();
return (
2026-01-27 23:05:00 +00:00
<BGBox sx={sx}>
2026-01-23 23:54:58 +00:00
<Stack spacing={theme.spacing(4)}>
<Typography
variant={"h2"}
textTransform="uppercase"
color={theme.palette.text.secondary}
>
{label}
</Typography>
<Typography
variant="h1"
color={color}
>
{n}
</Typography>
</Stack>
</BGBox>
);
};
export const UpStatusBox = ({ n }: { n: number }) => {
const theme = useTheme();
const { t } = useTranslation();
return (
<StatusBox
label={t("pages.common.monitors.status.up")}
n={n}
color={theme.palette.success.light}
/>
);
};
export const DownStatusBox = ({ n }: { n: number }) => {
const theme = useTheme();
const { t } = useTranslation();
return (
<StatusBox
label={t("pages.common.monitors.status.down")}
n={n}
color={theme.palette.error.light}
/>
);
};
export const PausedStatusBox = ({ n }: { n: number }) => {
const theme = useTheme();
const { t } = useTranslation();
return (
<StatusBox
label={t("pages.common.monitors.status.paused")}
n={n}
color={theme.palette.warning.light}
/>
);
};
2026-01-27 22:24:16 +00:00
export const TotalChecksBox = ({ n }: { n: number }) => {
const theme = useTheme();
const { t } = useTranslation();
return (
<StatusBox
label={t("pages.common.monitors.status.total")}
n={n}
color={theme.palette.primary.light}
/>
);
};
export const DownChecksBox = ({ n }: { n: number }) => {
const theme = useTheme();
const { t } = useTranslation();
return (
<StatusBox
label={t("pages.common.monitors.status.down")}
n={n}
color={theme.palette.error.light}
/>
);
};
2026-01-28 17:59:11 +00:00
export const UpChecksBox = ({ n }: { n: number }) => {
const theme = useTheme();
const { t } = useTranslation();
return (
<StatusBox
label={t("pages.common.monitors.status.up")}
n={n}
color={theme.palette.success.light}
/>
);
};
2026-01-23 23:54:58 +00:00
export const InitializingStatusBox = ({ n }: { n: number }) => {
const theme = useTheme();
const { t } = useTranslation();
return (
<StatusBox
label={t("pages.common.monitors.status.initializing")}
n={n}
color={theme.palette.warning.light}
/>
);
};