-
Notifications
You must be signed in to change notification settings - Fork 3
/
ResizeHandle.jsx
55 lines (51 loc) · 1.16 KB
/
ResizeHandle.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
52
53
54
55
import * as React from "react";
import { Box, SvgIcon } from "@mui/material";
import PropTypes from "prop-types";
import useResize from "./useResize";
/**
* Diagonal resize handle for the bottom right corner of a box.
*/
export default function ResizeHandle({ onResize, canvasSize }) {
const onMouseDown = useResize(onResize, canvasSize);
return (
<Box
sx={{
bottom: 0,
cursor: "nwse-resize",
height: 15,
position: "absolute",
right: 0,
width: 15
}}
onMouseDown={onMouseDown}
>
<SvgIcon
sx={{
bottom: 2,
height: 8,
opacity: 0.7,
position: "absolute",
right: 2,
width: 8
}}
viewBox="0 0 6 6"
color="action"
>
<path d="M 6 6 L 0 6 L 0 4.2 L 4 4.2 L 4.2 4.2 L 4.2 0 L 6 0 L 6 6 L 6 6 Z" />
</SvgIcon>
</Box>
);
}
ResizeHandle.propTypes = {
/**
* Size of the canvas
*/
canvasSize: PropTypes.shape({
height: PropTypes.number,
width: PropTypes.number
}),
/**
* Callback function that is called when the resize handle is dragged
*/
onResize: PropTypes.func
};