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

190 lines
4.1 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";
2026-02-20 18:13:39 +00:00
import { BaseBox } from "@/Components/design-elements";
2026-01-23 23:54:58 +00:00
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={{
2026-02-12 23:31:37 +00:00
backgroundColor: theme.palette.background.default,
2026-01-23 23:54:58 +00:00
overflow: "hidden",
position: "relative",
flex: 1,
padding: theme.spacing(6),
2026-01-27 23:05:00 +00:00
...sx,
2026-01-23 23:54:58 +00:00
}}
>
<Box
position="absolute"
2026-02-12 23:31:37 +00:00
top={0}
left={0}
right={0}
bottom={0}
sx={{
pointerEvents: "none",
backgroundImage: `
linear-gradient(${theme.palette.divider} 1px, transparent 1px),
linear-gradient(90deg, ${theme.palette.divider} 1px, transparent 1px)
`,
backgroundSize: "24px 24px",
maskImage:
"linear-gradient(135deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 30%, rgba(0,0,0,0.4) 100%)",
WebkitMaskImage:
"linear-gradient(135deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 30%, rgba(0,0,0,0.4) 100%)",
}}
/>
2026-01-23 23:54:58 +00:00
{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
textTransform="uppercase"
color={theme.palette.text.secondary}
sx={{
fontSize: 11,
fontWeight: 500,
letterSpacing: "0.08em",
}}
2026-01-23 23:54:58 +00:00
>
{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-02-11 20:11:22 +00:00
export const MaintenanceStatusBox = ({ n }: { n: number }) => {
const theme = useTheme();
const { t } = useTranslation();
return (
<StatusBox
label={t("pages.common.monitors.status.maintenance")}
n={n}
color={theme.palette.warning.light}
/>
);
};
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}
/>
);
};
2026-02-14 22:57:27 +00:00
export const BreachedStatusBox = ({ n }: { n: number }) => {
const theme = useTheme();
const { t } = useTranslation();
return (
<StatusBox
label={t("pages.common.monitors.status.breached")}
n={n}
color={theme.palette.warning.main}
/>
);
};
2026-02-11 20:11:22 +00:00
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}
/>
);
};