ISSUE-017 - Improvements to a number of things.
* Moved FullScreenContainer in WorkspacesRoute to make scrolling much better. Seriously, 100% works better. * Simplified dimensions state actions to a shared one. * Abandoned the noisy and useless "AnimatedBG" type. * Added workspace dimensions state (I'll need this later to prevent off-screen dragging). * Placed OverlayDisplay component in PreviewWindow, where it makes more sense. I'll still allow it to roam around outside of it, though. * Renamed "menu" dimensions to "mainMenu". * Improved initNewOverlayItem action to support setting visible. * Correct handling of showing the OverlayItemContainer. * Simplified the initial position of a new OverlayItem to a simple initial value instead of setting it in the middle of provided dimensions. * Made PreviewWindow `position: relative` to allow absolute positioning of OverlayItem from it. * Added importHelpers to tsconfig because VSCode was complaining about it.
This commit is contained in:
1 parent
506491eed9
commit
61b60b9819
16 files changed
+113
-76
No files matched your search
@@ -2,7 +2,6 @@ import { useState } from "react";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import { PadBox } from "@bedrock-layout/padbox";
|
||||
|
||||
import { appDimensionsSelector } from "../../../features/pageDimensions/pageDimensionsSelector";
|
||||
import { overlayToolSelector } from "../../../features/overlayTool/overlayToolSelector";
|
||||
import {
|
||||
initNewOverlayItem,
|
||||
@@ -22,17 +21,15 @@ export function OverlayControl() {
|
||||
|
||||
|
||||
/* For prototyping use only */
|
||||
const { width: appWidth, height: appHeight } = useSelector(appDimensionsSelector);
|
||||
const [overlayId, setOverlayId] = useState("foo_1.00000");
|
||||
const { width, height } = useSelector(appDimensionsSelector);
|
||||
|
||||
const getRandomArbitrary = (min: number, max: number) =>
|
||||
Math.random() * (max - min) + min;
|
||||
|
||||
const posRandomizer = () => {
|
||||
dispatch(setPosition({
|
||||
x: Math.floor(getRandomArbitrary(50, width - 50)),
|
||||
y: Math.floor(getRandomArbitrary(50, height - 50)),
|
||||
x: Math.floor(getRandomArbitrary(-50, 850)),
|
||||
y: Math.floor(getRandomArbitrary(-50, 650)),
|
||||
}));
|
||||
};
|
||||
const idRandomizer = () => {
|
||||
@@ -48,10 +45,12 @@ export function OverlayControl() {
|
||||
if (currentOverlayItem == null) {
|
||||
dispatch(initNewOverlayItem({
|
||||
overlayId,
|
||||
appDimensions: { height: appHeight, width: appWidth },
|
||||
initialPosition: { x: 400, y: 300 },
|
||||
setVisible: true,
|
||||
}));
|
||||
} else {
|
||||
dispatch(setVisibility(value));
|
||||
}
|
||||
dispatch(setVisibility(value));
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -4,11 +4,17 @@ import { overlayToolSelector } from "../../../features/overlayTool/overlayToolSe
|
||||
import { OverlayItemContainer } from "./styles";
|
||||
|
||||
export function OverlayDisplay() {
|
||||
const { currentOverlayItem } = useSelector(overlayToolSelector);
|
||||
const { currentOverlayItem, visible } = useSelector(overlayToolSelector);
|
||||
|
||||
if (currentOverlayItem == null) return null;
|
||||
|
||||
const { id, position } = currentOverlayItem;
|
||||
|
||||
return (
|
||||
<OverlayItemContainer position={position}>
|
||||
<OverlayItemContainer
|
||||
position={position}
|
||||
visible={visible}
|
||||
>
|
||||
{id}
|
||||
<br />
|
||||
({position.x}px {position.y}px)
|
||||
|
||||
@@ -3,16 +3,21 @@ import { OverlayPosition } from "../../../types/state";
|
||||
|
||||
export type OverlayItemContainerProps = {
|
||||
position: OverlayPosition,
|
||||
visible: boolean,
|
||||
};
|
||||
export const OverlayItemContainer = styled.div.attrs<OverlayItemContainerProps>(({
|
||||
position: { x, y },
|
||||
visible,
|
||||
}) => ({
|
||||
style: {
|
||||
top: y,
|
||||
left: x,
|
||||
display: visible ? undefined : "none",
|
||||
},
|
||||
}))<OverlayItemContainerProps>`
|
||||
position: absolute;
|
||||
|
||||
/* Temporary. Overlay will be transparent and based on an image. */
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
background-color: white;
|
||||
|
||||
Reference in new issue
Block a user