ISSUE-017 - Overlay state is streamlined.

Total change to workspaces. Now an object instead of a list.
Utilizing workspace overlays list - prototype currently colors the mock item.
Reset overlay on workspace change.
Improved combined dragging/transition element behavior.
This commit is contained in:
Kyle Geib committed 2022-01-13 14:16:09 -05:00
1 parent a6a5eb7751
commit 861d702a27
11 files changed
+177 -150

No files matched your search

@@ -1,9 +1,13 @@
import { useEffect } from "react";
import { useParams } from "react-router-dom";
import { useSelector } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { Center } from "@bedrock-layout/center";
import { Stack } from "@bedrock-layout/stack";
import { workspaceSelector } from "../../../features/workspace/workspaceSelector";
import { setWorkspaceId } from "../../../features/workspace/workspaceSlice";
import { overlayToolSelector } from "../../../features/overlayTool/overlayToolSelector";
import { newWorkspace } from "../../../features/overlayTool/overlayToolSlice";
import { PreviewWindow, H2, ControlsContainer } from "./styles";
import { WorkspaceControls } from "./WorkspaceControls";
@@ -15,6 +19,24 @@ import { workspaceObject } from "../workspaces";
export const Workspace = () => {
const { workspaceId } = useParams();
const { animatedBG } = useSelector(workspaceSelector);
const { currentWorkspaceId: overlayWorkspaceId } = useSelector(overlayToolSelector);
const dispatch = useDispatch();
useEffect(() => {
if (workspaceId == null) return;
// Update workspace store for ID.
dispatch(setWorkspaceId(workspaceId));
// Switching Workspace means we need to init a newWorkspace for Overlay tool.
if (overlayWorkspaceId !== workspaceId) {
dispatch(newWorkspace({
overlayIds: workspaceObject[workspaceId].overlayIds,
workspaceId: workspaceId,
}));
}
}, [workspaceId]);
return (
<Stack
gutter="lg"
@@ -22,7 +44,7 @@ export const Workspace = () => {
maxWidth="80%"
centerChildren
>
<H2>{workspaceId ? workspaceObject[workspaceId] : "Unknown"}</H2>
<H2>{workspaceId ? workspaceObject[workspaceId].name : "Unknown"}</H2>
<PreviewWindow height={600} width={800} animatedBG={animatedBG}>
<MockupBlock
color="#415bad"
@@ -1,21 +1,31 @@
import _ from "lodash";
import { NavLink } from "react-router-dom";
import { WorkspaceListBox } from "./styles";
import { Stack } from "@bedrock-layout/stack";
import { NavLink } from "react-router-dom";
import { MenuItem } from "../../Common/MenuItem.styled";
import { workspaceList } from "../workspaces";
import { workspaceObject } from "../workspaces";
type WorkspaceListProps = {
headerOffset?: number,
};
export const WorkspaceList = ({ headerOffset }: WorkspaceListProps) => (
<WorkspaceListBox headerOffset={headerOffset}>
<Stack as="ul" gutter="md">
{workspaceList.map((workspace, i) => (
<WorkspaceListNavLink key={i} to={workspace.id} label={workspace.name} />
))}
</Stack>
</WorkspaceListBox>
);
export const WorkspaceList = ({ headerOffset }: WorkspaceListProps) => {
const workspaceList = _.keys(workspaceObject);
return (
<WorkspaceListBox headerOffset={headerOffset}>
<Stack as="ul" gutter="md">
{workspaceList.map((id, i) => (
<WorkspaceListNavLink
key={id}
to={id}
label={workspaceObject[id].name}
/>
))}
</Stack>
</WorkspaceListBox>
);
};
type WorkspaceListNavLinkProps = {
to: string,
@@ -13,7 +13,7 @@ import { LayoutGrid, LayoutGridItem } from "../Common/LayoutGrid.styled";
const WORKSPACE_LIST_WIDTH = 180;
export default function Workspaces() {
const { height } = useSelector(mainMenuDimensionsSelector);
const { height: mainMenuHeight } = useSelector(mainMenuDimensionsSelector);
const dispatch = useDispatch();
const [workspaceRef, {
height: workspaceHeight,
@@ -31,14 +31,14 @@ export default function Workspaces() {
return (
<LayoutGrid columns={[`${WORKSPACE_LIST_WIDTH}px`, 1]} rows={1}>
<LayoutGridItem column={1} row={1}>
<WorkspaceList headerOffset={height} />
<WorkspaceList headerOffset={mainMenuHeight} />
</LayoutGridItem>
<LayoutGridItem column={2} row={1}>
<FullScreenContainer
ref={workspaceRef}
minHeight={700}
minWidth={900}
heightCutoff={height}
heightCutoff={mainMenuHeight}
widthCutoff={WORKSPACE_LIST_WIDTH}
>
<Outlet />
+48 -47
View File
@@ -1,56 +1,57 @@
export const workspaceList = [
{
import { OverlayIds } from "../../types/state";
export type WorkspaceObject = {
[id: string]: {
name: string,
overlayIds: OverlayIds,
},
};
export const workspaceObject: WorkspaceObject = {
workspace1: {
name: "Workspace 1",
id: "workspace1",
overlayIds: ["red", "blue", "white"],
},
{
workspace2: {
name: "Workspace 2",
id: "workspace2",
overlayIds: ["green"],
},
{
workspace3: {
name: "Workspace 3",
id: "workspace3",
overlayIds: ["green"],
},
{
workspace4: {
name: "Workspace 4 has a longer name than the rest",
id: "workspace4",
overlayIds: ["green"],
},
{ name: "blah", id: "blah0" },
{ name: "blah", id: "blah1" },
{ name: "blah", id: "blah2" },
{ name: "blah", id: "blah3" },
{ name: "blah", id: "blah4" },
{ name: "blah", id: "blah5" },
{ name: "blah", id: "blah6" },
{ name: "blah", id: "blah7" },
{ name: "blah", id: "blah8" },
{ name: "blah", id: "blah9" },
{ name: "blah", id: "blah10" },
{ name: "blah", id: "blah11" },
{ name: "blah", id: "blah12" },
{ name: "blah", id: "blah13" },
{ name: "blah", id: "blah14" },
{ name: "blah", id: "blah15" },
{ name: "blah", id: "blah16" },
{ name: "blah", id: "blah17" },
{ name: "blah", id: "blah18" },
{ name: "blah", id: "blah19" },
{ name: "blah", id: "blah20" },
{ name: "blah", id: "blah21" },
{ name: "blah", id: "blah22" },
{ name: "blah", id: "blah23" },
{ name: "blah", id: "blah24" },
{ name: "blah", id: "blah25" },
{ name: "blah", id: "blah26" },
{ name: "blah", id: "blah27" },
{ name: "blah", id: "blah28" },
{ name: "blah", id: "blah29" },
];
blah0: { name: "blah", overlayIds: ["green"] },
blah1: { name: "blah", overlayIds: ["green"] },
blah2: { name: "blah", overlayIds: ["green"] },
blah3: { name: "blah", overlayIds: ["green"] },
blah4: { name: "blah", overlayIds: ["green"] },
blah5: { name: "blah", overlayIds: ["green"] },
blah6: { name: "blah", overlayIds: ["green"] },
blah7: { name: "blah", overlayIds: ["green"] },
blah8: { name: "blah", overlayIds: ["green"] },
blah9: { name: "blah", overlayIds: ["green"] },
blah10: { name: "blah", overlayIds: ["green"] },
blah11: { name: "blah", overlayIds: ["green"] },
blah12: { name: "blah", overlayIds: ["green"] },
blah13: { name: "blah", overlayIds: ["green"] },
blah14: { name: "blah", overlayIds: ["green"] },
blah15: { name: "blah", overlayIds: ["green"] },
blah16: { name: "blah", overlayIds: ["green"] },
blah17: { name: "blah", overlayIds: ["green"] },
blah18: { name: "blah", overlayIds: ["green"] },
blah19: { name: "blah", overlayIds: ["green"] },
blah20: { name: "blah", overlayIds: ["green"] },
blah21: { name: "blah", overlayIds: ["green"] },
blah22: { name: "blah", overlayIds: ["green"] },
blah23: { name: "blah", overlayIds: ["green"] },
blah24: { name: "blah", overlayIds: ["green"] },
blah25: { name: "blah", overlayIds: ["green"] },
blah26: { name: "blah", overlayIds: ["green"] },
blah27: { name: "blah", overlayIds: ["green"] },
blah28: { name: "blah", overlayIds: ["green"] },
blah29: { name: "blah", overlayIds: ["green"] },
};
export const workspaceObject = ((list: typeof workspaceList) => {
const obj: {[key: string]: string} = {};
list.forEach(item => {
obj[item.id] = item.name;
});
return obj;
})(workspaceList);