-
Notifications
You must be signed in to change notification settings - Fork 3
/
SelectionRectangle.jsx
51 lines (47 loc) · 1.04 KB
/
SelectionRectangle.jsx
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
import * as React from "react";
import { Box, alpha } from "@mui/material";
import PropTypes from "prop-types";
/**
* Rectangle that is drawn when the user is selecting a region of the canvas.
*/
export default function SelectionRectangle({
height = 0,
width = 0,
left = 0,
top = 0
}) {
return (
<Box
sx={theme => ({
backgroundColor: theme => alpha(theme.palette.primary.light, 0.1),
cursor: "crosshair",
height: `${height}px`,
left,
outline: `1px solid ${theme.palette.primary.main}`,
position: "absolute",
top,
width: `${width}px`
})}
/>
);
}
SelectionRectangle.propTypes = {
/**
* Height of the selection rectangle
*/
height: PropTypes.number,
/**
* Left position of the selection rectangle
* relative to the canvas
*/
left: PropTypes.number,
/**
* Top position of the selection rectangle
* relative to the canvas
*/
top: PropTypes.number,
/**
* Width of the selection rectangle
*/
width: PropTypes.number
};