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

77 lines
1.6 KiB
TypeScript
Raw Normal View History

2026-02-20 18:13:39 +00:00
import { BaseBox } from ".";
2026-01-25 16:31:54 +00:00
import Stack from "@mui/material/Stack";
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
2026-02-28 16:16:14 +00:00
import { LAYOUT } from "@/Utils/Theme/constants";
2026-01-25 16:31:54 +00:00
import type { ResponsiveStyleValue } from "@mui/system";
import { useTheme } from "@mui/material/styles";
type BaseChartProps = React.PropsWithChildren<{
icon?: React.ReactNode;
2026-01-25 16:31:54 +00:00
title: string;
2026-09-01 11:23:03 -07:00
rightTitle?: string;
2026-01-25 16:31:54 +00:00
width?: number | string;
maxWidth?: number | string;
flexBasis?: number | string;
2026-01-25 16:31:54 +00:00
padding?: number | string | ResponsiveStyleValue<number | string>;
2026-07-29 11:45:49 -07:00
onClick?: () => void;
2026-01-25 16:31:54 +00:00
}>;
export const BaseChart = ({
children,
title,
2026-09-01 11:23:03 -07:00
rightTitle,
2026-01-25 16:31:54 +00:00
width = "100%",
maxWidth = "100%",
flexBasis = "0%",
2026-01-25 16:31:54 +00:00
padding,
2026-07-29 11:45:49 -07:00
onClick,
2026-01-25 16:31:54 +00:00
}: BaseChartProps) => {
const theme = useTheme();
return (
<BaseBox
2026-07-29 11:45:49 -07:00
onClick={onClick}
2026-01-25 16:31:54 +00:00
sx={{
2026-02-28 16:16:14 +00:00
padding: padding ?? theme.spacing(LAYOUT.MD),
2026-01-25 16:31:54 +00:00
display: "flex",
flex: 1,
flexBasis,
2026-01-25 16:31:54 +00:00
width: width,
maxWidth: maxWidth,
2026-07-29 11:45:49 -07:00
...(onClick && {
cursor: "pointer",
"& .recharts-wrapper": { cursor: "pointer !important" },
}),
2026-01-25 16:31:54 +00:00
}}
>
<Stack
2026-02-28 16:16:14 +00:00
gap={theme.spacing(LAYOUT.MD)}
2026-01-25 16:31:54 +00:00
flex={1}
>
2026-09-01 11:23:03 -07:00
<Stack
direction="row"
justifyContent={"space-between"}
2026-01-25 16:31:54 +00:00
>
2026-09-01 11:23:03 -07:00
<Typography
variant="eyebrow"
color="text.secondary"
sx={{ overflowWrap: "anywhere" }}
>
{title}
</Typography>
{rightTitle && (
<Typography
variant="eyebrow"
color="text.secondary"
sx={{ overflowWrap: "anywhere" }}
>
{rightTitle}
</Typography>
)}
</Stack>
2026-01-25 16:31:54 +00:00
<Box flex={1}>{children}</Box>
</Stack>
</BaseBox>
);
};