frontPanel/src/ui_kit/CustomCheckbox.tsx

64 lines
1.6 KiB
TypeScript
Raw Normal View History

2022-12-26 10:00:03 +00:00
import { FormControlLabel, Checkbox, useTheme, Box } from "@mui/material";
interface Props {
label: string;
handleChange?: () => void;
2022-12-26 10:00:03 +00:00
}
export default function CustomCheckbox({ label, handleChange }: Props) {
2022-12-26 10:00:03 +00:00
const theme = useTheme();
return (
<FormControlLabel
control={
<Checkbox
2022-12-26 10:00:03 +00:00
icon={<Icon />}
checkedIcon={<CheckedIcon />}
onChange={handleChange}
2022-12-26 10:00:03 +00:00
/>}
label={label}
sx={{
color: theme.palette.grey2.main,
ml: "-9px",
userSelect: "none",
}}
2022-12-26 10:00:03 +00:00
/>
);
}
function Icon() {
const theme = useTheme();
return (
<Box sx={{
height: "26px",
width: "26px",
borderRadius: "8px",
backgroundColor: theme.palette.background.default,
border: `1px solid ${theme.palette.grey2.main}`,
}} />
);
}
function CheckedIcon() {
const theme = useTheme();
return (
<Box sx={{
height: "26px",
width: "26px",
borderRadius: "8px",
display: "flex",
justifyContent: "center",
alignItems: "center",
backgroundColor: theme.palette.brightPurple.main,
2022-12-26 10:00:03 +00:00
border: `1px solid ${theme.palette.grey2.main}`,
}}>
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 18" fill="none">
<path d="M2 9L10 16.5L22.5 1.5" stroke='#ffffff' strokeWidth="4" strokeLinecap="round" />
2022-12-26 10:00:03 +00:00
</svg>
</Box>
);
}