2021-08-12 05:45:38 +00:00
|
|
|
import React from "react";
|
2019-09-21 01:52:38 +00:00
|
|
|
import styled from "styled-components";
|
2021-06-17 13:26:54 +00:00
|
|
|
import {
|
|
|
|
|
CONTAINER_GRID_PADDING,
|
|
|
|
|
GridDefaults,
|
|
|
|
|
} from "constants/WidgetConstants";
|
|
|
|
|
const GRID_POINT_SIZE = 1;
|
2020-03-27 09:02:11 +00:00
|
|
|
const WrappedDragLayer = styled.div<{
|
|
|
|
|
columnWidth: number;
|
|
|
|
|
rowHeight: number;
|
2021-04-23 05:43:13 +00:00
|
|
|
noPad: boolean;
|
2020-03-27 09:02:11 +00:00
|
|
|
}>`
|
2019-09-21 01:52:38 +00:00
|
|
|
position: absolute;
|
|
|
|
|
pointer-events: none;
|
2021-06-17 13:26:54 +00:00
|
|
|
left: ${(props) =>
|
|
|
|
|
props.noPad ? "0" : `${CONTAINER_GRID_PADDING - GRID_POINT_SIZE}px;`};
|
|
|
|
|
top: ${(props) =>
|
|
|
|
|
props.noPad ? "0" : `${CONTAINER_GRID_PADDING - GRID_POINT_SIZE}px;`};
|
2021-04-23 05:43:13 +00:00
|
|
|
height: ${(props) =>
|
2021-06-17 13:26:54 +00:00
|
|
|
props.noPad
|
|
|
|
|
? `100%`
|
|
|
|
|
: `calc(100% - ${(CONTAINER_GRID_PADDING - GRID_POINT_SIZE) * 2}px)`};
|
2021-04-23 05:43:13 +00:00
|
|
|
width: ${(props) =>
|
2021-06-17 13:26:54 +00:00
|
|
|
props.noPad
|
|
|
|
|
? `100%`
|
|
|
|
|
: `calc(100% - ${(CONTAINER_GRID_PADDING - GRID_POINT_SIZE) * 2}px)`};
|
2020-03-06 09:33:20 +00:00
|
|
|
|
|
|
|
|
background-image: radial-gradient(
|
2021-06-17 13:26:54 +00:00
|
|
|
circle at ${GRID_POINT_SIZE}px ${GRID_POINT_SIZE}px,
|
|
|
|
|
${(props) => props.theme.colors.grid} ${GRID_POINT_SIZE}px,
|
2020-03-06 09:33:20 +00:00
|
|
|
transparent 0
|
|
|
|
|
);
|
2021-06-17 13:26:54 +00:00
|
|
|
background-size: ${(props) =>
|
|
|
|
|
props.columnWidth - GRID_POINT_SIZE / GridDefaults.DEFAULT_GRID_COLUMNS}px
|
2021-08-12 05:45:38 +00:00
|
|
|
${(props) => props.rowHeight}px;
|
2019-09-21 01:52:38 +00:00
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
type DragLayerProps = {
|
2019-09-25 17:24:23 +00:00
|
|
|
parentRowHeight: number;
|
|
|
|
|
parentColumnWidth: number;
|
2021-04-23 05:43:13 +00:00
|
|
|
noPad: boolean;
|
2019-09-21 01:52:38 +00:00
|
|
|
};
|
|
|
|
|
|
2021-04-28 10:28:39 +00:00
|
|
|
function DragLayerComponent(props: DragLayerProps) {
|
2019-09-21 01:52:38 +00:00
|
|
|
return (
|
2020-03-06 09:33:20 +00:00
|
|
|
<WrappedDragLayer
|
|
|
|
|
columnWidth={props.parentColumnWidth}
|
2021-04-23 05:43:13 +00:00
|
|
|
noPad={props.noPad}
|
2021-04-28 10:28:39 +00:00
|
|
|
rowHeight={props.parentRowHeight}
|
2021-08-12 05:45:38 +00:00
|
|
|
/>
|
2019-09-21 01:52:38 +00:00
|
|
|
);
|
2021-04-28 10:28:39 +00:00
|
|
|
}
|
2019-09-21 01:52:38 +00:00
|
|
|
export default DragLayerComponent;
|