File size: 4,161 Bytes
ea35075 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
import React, {useState} from 'react';
import FormControlLabel from '@mui/material/FormControlLabel';
import Checkbox from '@mui/material/Checkbox';
import {SketchPicker} from 'react-color';
import {Accordion, AccordionSummary, AccordionDetails} from '@mui/material';
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
import Box from '@mui/material/Box';
function CanvasSettingsPanel({setCanvasBgColor, setCanvasGround, setCanvasGrid, setCanvasAxis}) {
const [bgColorChecked, setBgColorChecked] = useState(false);
const [bgColor, setBgColor] = useState();
const [groundChecked, setGroundChecked] = useState(true);
const [axisChecked, setAxisChecked] = useState(true);
const [gridChecked, setGridChecked] = useState(true);
return (
<div>
<Box mb={1} mt={1}>
<Accordion>
<AccordionSummary expandIcon={<ExpandMoreIcon/>}>
Canvas
</AccordionSummary>
<AccordionDetails>
<FormControlLabel
control={
<Checkbox
checked={bgColorChecked}
onChange={(event) => {
setBgColorChecked(event.target.checked);
}}
color="primary"
/>
}
label={'Background Color'}
/>
{bgColorChecked && (
<SketchPicker
color={bgColor}
onChangeComplete={(color) => {
setBgColor(color);
setCanvasBgColor(color);
}}
disableAlpha={true}
/>
)}
<FormControlLabel
control={
<Checkbox
checked={groundChecked}
onChange={(event) => {
setGroundChecked(event.target.checked);
if (setCanvasGround) {
setCanvasGround(event.target.checked);
}
}}
color="primary"
/>
}
label='Ground'
/>
<FormControlLabel
control={
<Checkbox
checked={gridChecked}
onChange={(event) => {
setGridChecked(event.target.checked);
setCanvasGrid(event.target.checked)
}}
color="primary"
/>
}
label='Grid'
/>
<FormControlLabel
control={
<Checkbox
checked={axisChecked}
onChange={(event) => {
setAxisChecked(event.target.checked);
setCanvasAxis(event.target.checked)
}}
color="primary"
/>
}
label='Axis'
/>
</AccordionDetails>
</Accordion>
</Box>
</div>
);
}
export default CanvasSettingsPanel;
|