2023-06-26 10:07:12 +00:00
|
|
|
"use client";
|
|
|
|
|
|
2023-02-13 13:46:56 +00:00
|
|
|
import { FC } from "react";
|
2023-05-25 12:37:14 +00:00
|
|
|
import Image from "next/legacy/image";
|
2023-02-13 13:46:56 +00:00
|
|
|
import { Card, Grid } from "@mui/material";
|
2023-08-25 07:11:33 +00:00
|
|
|
import horizontalBar from "../images/horizontal-bar.svg";
|
|
|
|
|
import horizontalBarStacked from "../images/horizontal-bar-stacked.svg";
|
|
|
|
|
import verticalBar from "../images/vertical-bar.svg";
|
|
|
|
|
import verticalBarStacked from "../images/vertical-bar-stacked.svg";
|
|
|
|
|
import pieDonut from "../images/pie-donut.svg";
|
|
|
|
|
import line from "../images/line.svg";
|
|
|
|
|
import lineStacked from "../images/line-stacked.svg";
|
|
|
|
|
import dataTable from "../images/data-table.svg";
|
|
|
|
|
import metric from "../images/metric.svg";
|
|
|
|
|
import tagCloud from "../images/tag-cloud.svg";
|
2024-03-20 17:51:21 +01:00
|
|
|
import { useLeafcutterContext } from "./LeafcutterProvider";
|
2023-02-13 13:46:56 +00:00
|
|
|
|
|
|
|
|
interface VisualizationSelectCardProps {
|
|
|
|
|
visualizationType: string;
|
|
|
|
|
title: string;
|
|
|
|
|
enabled: boolean;
|
|
|
|
|
selected: boolean;
|
|
|
|
|
toggleSelected: any;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const VisualizationSelectCard: FC<VisualizationSelectCardProps> = ({
|
|
|
|
|
visualizationType,
|
|
|
|
|
title,
|
|
|
|
|
enabled,
|
|
|
|
|
selected,
|
|
|
|
|
toggleSelected,
|
|
|
|
|
}) => {
|
|
|
|
|
const {
|
|
|
|
|
typography: { small },
|
|
|
|
|
colors: {
|
|
|
|
|
white,
|
|
|
|
|
leafcutterElectricBlue,
|
|
|
|
|
leafcutterLightBlue,
|
|
|
|
|
cdrLinkOrange,
|
|
|
|
|
},
|
2024-03-20 17:51:21 +01:00
|
|
|
} = useLeafcutterContext();
|
2023-05-24 20:27:57 +00:00
|
|
|
const images: any = {
|
2023-02-13 13:46:56 +00:00
|
|
|
horizontalBar,
|
|
|
|
|
horizontalBarStacked,
|
|
|
|
|
verticalBar,
|
|
|
|
|
verticalBarStacked,
|
|
|
|
|
line,
|
|
|
|
|
lineStacked,
|
|
|
|
|
pieDonut,
|
|
|
|
|
dataTable,
|
|
|
|
|
metric,
|
|
|
|
|
tagCloud,
|
|
|
|
|
unknown: line,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let backgroundColor = leafcutterElectricBlue;
|
|
|
|
|
if (!enabled) {
|
|
|
|
|
backgroundColor = leafcutterLightBlue;
|
|
|
|
|
} else if (selected) {
|
|
|
|
|
backgroundColor = cdrLinkOrange;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Card
|
|
|
|
|
sx={{
|
|
|
|
|
height: "100px",
|
|
|
|
|
backgroundColor,
|
|
|
|
|
borderRadius: "10px",
|
|
|
|
|
padding: "10px",
|
|
|
|
|
opacity: enabled ? 1 : 0.5,
|
|
|
|
|
cursor: enabled ? "pointer" : "default",
|
|
|
|
|
"&:hover": {
|
|
|
|
|
backgroundColor: enabled ? cdrLinkOrange : white,
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
elevation={enabled ? 2 : 0}
|
|
|
|
|
onClick={() => toggleSelected(visualizationType)}
|
|
|
|
|
>
|
|
|
|
|
<Grid
|
|
|
|
|
direction="column"
|
|
|
|
|
container
|
|
|
|
|
justifyContent="space-around"
|
|
|
|
|
alignContent="center"
|
|
|
|
|
alignItems="center"
|
|
|
|
|
wrap="nowrap"
|
|
|
|
|
sx={{ height: "100%" }}
|
|
|
|
|
spacing={0}
|
|
|
|
|
>
|
|
|
|
|
<Grid
|
|
|
|
|
item
|
|
|
|
|
sx={{
|
|
|
|
|
...small,
|
|
|
|
|
textAlign: "center",
|
|
|
|
|
color: enabled ? white : leafcutterElectricBlue,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{title}
|
|
|
|
|
</Grid>
|
|
|
|
|
<Grid item>
|
|
|
|
|
<Image
|
|
|
|
|
src={images[visualizationType]}
|
|
|
|
|
alt=""
|
|
|
|
|
width={35}
|
|
|
|
|
height={35}
|
|
|
|
|
/>
|
|
|
|
|
</Grid>
|
|
|
|
|
</Grid>
|
|
|
|
|
</Card>
|
|
|
|
|
);
|
|
|
|
|
};
|