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
@@ -8,6 +8,7 @@ import { workspaceSelector } from "../../../features/workspace/workspaceSelector
|
||||
import { PreviewWindow, H2, ControlsContainer } from "./styles";
|
||||
import { WorkspaceControls } from "./WorkspaceControls";
|
||||
import { MockupBlock } from "../../Common/MockupBlock.styled";
|
||||
import { OverlayDisplay } from "../../OverlayTool";
|
||||
|
||||
import { workspaceObject } from "../workspaces";
|
||||
|
||||
@@ -28,6 +29,7 @@ export const Workspace = () => {
|
||||
height="300px"
|
||||
width="400px"
|
||||
>Preview Item</MockupBlock>
|
||||
<OverlayDisplay />
|
||||
</PreviewWindow>
|
||||
<ControlsContainer>
|
||||
<WorkspaceControls />
|
||||
|
||||
@@ -3,7 +3,6 @@ import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
import { workspaceSelector } from "../../../features/workspace/workspaceSelector";
|
||||
import { setAnimatedBG } from "../../../features/workspace/workspaceSlice";
|
||||
import { AnimatedBG } from "../../../types/state";
|
||||
|
||||
import { Toggle } from "../../Common/Inputs/Toggle";
|
||||
import { OverlayControl } from "../../OverlayTool";
|
||||
@@ -17,7 +16,7 @@ export const WorkspaceControls = () => {
|
||||
<Toggle
|
||||
label="Animate BG"
|
||||
toggled={animatedBG}
|
||||
onToggle={(value: AnimatedBG) => {
|
||||
onToggle={(value: boolean) => {
|
||||
dispatch(setAnimatedBG(value));
|
||||
}} />
|
||||
<OverlayControl />
|
||||
|
||||
@@ -16,6 +16,7 @@ export type PreviewWindowProps = {
|
||||
export const PreviewWindow = styled(PadBox).attrs(() => ({
|
||||
padding: "lg",
|
||||
}))<PreviewWindowProps>`
|
||||
position: relative;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
@@ -1,27 +1,49 @@
|
||||
import { useSelector } from "react-redux";
|
||||
import { useEffect } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { Outlet } from "react-router-dom";
|
||||
|
||||
import { menuDimensionsSelector } from "../../features/pageDimensions/pageDimensionsSelector";
|
||||
import { mainMenuDimensionsSelector } from "../../features/pageDimensions/pageDimensionsSelector";
|
||||
import { useDimensions } from "../../utils/hooks";
|
||||
import { setDimensions } from "../../features/pageDimensions/pageDimensionsSlice";
|
||||
|
||||
import { FullScreenContainer } from "../Common/FullScreenContainer.styled";
|
||||
import { WorkspaceList } from "./WorkspaceList";
|
||||
import { LayoutGrid, LayoutGridItem } from "../Common/LayoutGrid.styled";
|
||||
import { OverlayDisplay } from "../OverlayTool";
|
||||
|
||||
const WORKSPACE_LIST_WIDTH = 180;
|
||||
|
||||
export default function Workspaces() {
|
||||
const { height } = useSelector(menuDimensionsSelector);
|
||||
const { height } = useSelector(mainMenuDimensionsSelector);
|
||||
const dispatch = useDispatch();
|
||||
const [workspaceRef, {
|
||||
height: workspaceHeight,
|
||||
width: workspaceWidth,
|
||||
}] = useDimensions<HTMLDivElement>();
|
||||
|
||||
// Set Workspace dimensions.
|
||||
useEffect(() => {
|
||||
dispatch(setDimensions({
|
||||
name: "workspace",
|
||||
dimensions: { height: workspaceHeight, width: workspaceWidth },
|
||||
}));
|
||||
}, [workspaceHeight, workspaceWidth]);
|
||||
|
||||
return (
|
||||
<FullScreenContainer minHeight={700} minWidth={900} heightCutoff={height}>
|
||||
<LayoutGrid columns={["180px", 1]} rows={1}>
|
||||
<LayoutGridItem column={1} row={1}>
|
||||
<WorkspaceList headerOffset={height} />
|
||||
</LayoutGridItem>
|
||||
<LayoutGridItem column={2} row={1}>
|
||||
<LayoutGrid columns={[`${WORKSPACE_LIST_WIDTH}px`, 1]} rows={1}>
|
||||
<LayoutGridItem column={1} row={1}>
|
||||
<WorkspaceList headerOffset={height} />
|
||||
</LayoutGridItem>
|
||||
<LayoutGridItem column={2} row={1}>
|
||||
<FullScreenContainer
|
||||
ref={workspaceRef}
|
||||
minHeight={700}
|
||||
minWidth={900}
|
||||
heightCutoff={height}
|
||||
widthCutoff={WORKSPACE_LIST_WIDTH}
|
||||
>
|
||||
<Outlet />
|
||||
<OverlayDisplay />
|
||||
</LayoutGridItem>
|
||||
</LayoutGrid>
|
||||
</FullScreenContainer>
|
||||
</FullScreenContainer>
|
||||
</LayoutGridItem>
|
||||
</LayoutGrid>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user