Allow deselection of all widgets. Allow resize from over the resize marker dot.
This commit is contained in:
parent
5c492970ed
commit
d6a5b62861
|
|
@ -8,6 +8,7 @@ import WidgetFactory from "../utils/WidgetFactory";
|
||||||
import { widgetOperationParams, noCollision } from "../utils/WidgetPropsUtils";
|
import { widgetOperationParams, noCollision } from "../utils/WidgetPropsUtils";
|
||||||
import DragLayerComponent from "./DragLayerComponent";
|
import DragLayerComponent from "./DragLayerComponent";
|
||||||
import { WidgetFunctionsContext } from "../pages/Editor";
|
import { WidgetFunctionsContext } from "../pages/Editor";
|
||||||
|
import { FocusContext } from "../pages/Editor/Canvas";
|
||||||
|
|
||||||
type DropTargetComponentProps = ContainerProps & {
|
type DropTargetComponentProps = ContainerProps & {
|
||||||
updateWidget?: Function;
|
updateWidget?: Function;
|
||||||
|
|
@ -29,6 +30,8 @@ export const DropTargetComponent = (props: DropTargetComponentProps) => {
|
||||||
const [dropTargetOffset, setDropTargetOffset] = useState({ x: 0, y: 0 });
|
const [dropTargetOffset, setDropTargetOffset] = useState({ x: 0, y: 0 });
|
||||||
const { updateWidget } = useContext(WidgetFunctionsContext);
|
const { updateWidget } = useContext(WidgetFunctionsContext);
|
||||||
const occupiedSpaces = useContext(OccupiedSpaceContext);
|
const occupiedSpaces = useContext(OccupiedSpaceContext);
|
||||||
|
const { setFocus } = useContext(FocusContext);
|
||||||
|
|
||||||
// Make this component a drop target
|
// Make this component a drop target
|
||||||
const [{ isOver, isExactlyOver }, drop] = useDrop({
|
const [{ isOver, isExactlyOver }, drop] = useDrop({
|
||||||
accept: Object.values(WidgetFactory.getWidgetTypes()),
|
accept: Object.values(WidgetFactory.getWidgetTypes()),
|
||||||
|
|
@ -87,8 +90,15 @@ export const DropTargetComponent = (props: DropTargetComponentProps) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleFocus = () => {
|
||||||
|
if (props.isRoot) {
|
||||||
|
setFocus && setFocus(props.widgetId);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
onClick={handleFocus}
|
||||||
ref={drop}
|
ref={drop}
|
||||||
style={{
|
style={{
|
||||||
position: "relative",
|
position: "relative",
|
||||||
|
|
|
||||||
|
|
@ -26,23 +26,28 @@ const handleStyles: {
|
||||||
top: {
|
top: {
|
||||||
height: "30px",
|
height: "30px",
|
||||||
top: "-15px",
|
top: "-15px",
|
||||||
|
zIndex: 1,
|
||||||
},
|
},
|
||||||
bottom: {
|
bottom: {
|
||||||
height: "30px",
|
height: "30px",
|
||||||
bottom: "-15px",
|
bottom: "-15px",
|
||||||
|
zIndex: 1,
|
||||||
},
|
},
|
||||||
left: {
|
left: {
|
||||||
width: "30px",
|
width: "30px",
|
||||||
left: "-15px",
|
left: "-15px",
|
||||||
|
zIndex: 1,
|
||||||
},
|
},
|
||||||
right: {
|
right: {
|
||||||
width: "30px",
|
width: "30px",
|
||||||
right: "-15px",
|
right: "-15px",
|
||||||
|
zIndex: 1,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const ResizableContainer = styled(Rnd)`
|
const ResizableContainer = styled(Rnd)`
|
||||||
position: relative;
|
position: relative;
|
||||||
|
opacity: 0.99;
|
||||||
&:after,
|
&:after,
|
||||||
&:before {
|
&:before {
|
||||||
content: "";
|
content: "";
|
||||||
|
|
@ -55,11 +60,13 @@ const ResizableContainer = styled(Rnd)`
|
||||||
&:after {
|
&:after {
|
||||||
right: -${props => props.theme.spaces[1]}px;
|
right: -${props => props.theme.spaces[1]}px;
|
||||||
top: calc(50% - ${props => props.theme.spaces[1]}px);
|
top: calc(50% - ${props => props.theme.spaces[1]}px);
|
||||||
|
z-index: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:before {
|
&:before {
|
||||||
left: calc(50% - ${props => props.theme.spaces[1]}px);
|
left: calc(50% - ${props => props.theme.spaces[1]}px);
|
||||||
bottom: -${props => props.theme.spaces[1]}px;
|
bottom: -${props => props.theme.spaces[1]}px;
|
||||||
|
z-index: 1;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
@ -169,6 +176,7 @@ export const ResizableComponent = (props: ResizableComponentProps) => {
|
||||||
resizeGrid={[props.parentColumnSpace, props.parentRowSpace]}
|
resizeGrid={[props.parentColumnSpace, props.parentRowSpace]}
|
||||||
bounds={bounds}
|
bounds={bounds}
|
||||||
resizeHandleStyles={handleStyles}
|
resizeHandleStyles={handleStyles}
|
||||||
|
resizeHandleWrapperClass="top-of-stacking-context"
|
||||||
enableResizing={{
|
enableResizing={{
|
||||||
top: true && !isDragging && isFocused === props.widgetId,
|
top: true && !isDragging && isFocused === props.widgetId,
|
||||||
right: true && !isDragging && isFocused === props.widgetId,
|
right: true && !isDragging && isFocused === props.widgetId,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user