ISSUE-032 - Adjusted my ReactRouter solution to drop the need for an interim path element. I am also now using WorkspacesRoute for more things, which I think is appropriate.
This commit is contained in:
1 parent
f9f7b739ee
commit
ae4a7e7818
5 files changed
+44
-42
No files matched your search
@@ -1,5 +1,4 @@
|
||||
import { useEffect } from "react";
|
||||
import { Route, Routes, useParams } from "react-router-dom";
|
||||
import { ReactNode, useEffect } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { Center } from "@bedrock-layout/center";
|
||||
import { Stack } from "@bedrock-layout/stack";
|
||||
@@ -14,16 +13,23 @@ import { WorkspaceControls } from "../WorkspaceControls";
|
||||
import { OverlayDisplay } from "../../OverlayTool";
|
||||
|
||||
import { workspaces } from "../../../domain/data/workspaces";
|
||||
import { WorkspaceId } from "../../../types/state";
|
||||
|
||||
export const Workspace = () => {
|
||||
type WorkspaceProps = {
|
||||
workspaceId: WorkspaceId,
|
||||
previewContent: ReactNode,
|
||||
prototypeControls: ReactNode,
|
||||
};
|
||||
export const Workspace = ({
|
||||
workspaceId,
|
||||
previewContent,
|
||||
prototypeControls,
|
||||
}: WorkspaceProps) => {
|
||||
const dispatch = useDispatch();
|
||||
const { "*": workspaceId } = useParams();
|
||||
const { animatedBG, workspaceProperties } = useSelector(workspaceSelector);
|
||||
const { currentWorkspaceId: overlayWorkspaceId } = useSelector(overlayToolSelector);
|
||||
|
||||
useEffect(() => {
|
||||
if (workspaceId == null) return;
|
||||
|
||||
// Update workspace store for ID.
|
||||
dispatch(updateWorkspace({
|
||||
workspaceId,
|
||||
@@ -39,8 +45,6 @@ export const Workspace = () => {
|
||||
}
|
||||
}, [workspaceId]);
|
||||
|
||||
if (workspaceId == null) return null;
|
||||
|
||||
return (
|
||||
<Stack
|
||||
gutter="lg"
|
||||
@@ -53,37 +57,15 @@ export const Workspace = () => {
|
||||
dimensions={workspaceProperties.previewWindowDimensions}
|
||||
animatedBG={animatedBG}
|
||||
>
|
||||
<PreviewContent />
|
||||
{previewContent}
|
||||
<OverlayDisplay
|
||||
containerDimensions={workspaceProperties.previewWindowDimensions}
|
||||
/>
|
||||
</PreviewWindow>
|
||||
<ControlsContainer>
|
||||
<WorkspaceControls />
|
||||
<PrototypeControls />
|
||||
{prototypeControls}
|
||||
</ControlsContainer>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
import { ChyronDriver } from "../../BroadcastGraphics/Chyrons/Driver";
|
||||
import { AngledFlagWorkSpace } from "../CustomWorkSpaces/AngledFlagWorkSpace";
|
||||
import { ChyronPrototypeControls } from "../PrototypingControls/ChyronPrototype";
|
||||
import { AngledFlagPrototypeControls } from "../PrototypingControls/AngledFlagPrototype";
|
||||
|
||||
const PreviewContent = () => (
|
||||
<Routes>
|
||||
<Route path="chyronDriver" element={<ChyronDriver />} />
|
||||
<Route path="angledFlag" element={<AngledFlagWorkSpace />} />
|
||||
<Route path="*" element={null} />
|
||||
</Routes>
|
||||
);
|
||||
|
||||
const PrototypeControls = () => (
|
||||
<Routes>
|
||||
<Route path="chyronDriver" element={<ChyronPrototypeControls />} />
|
||||
<Route path="angledFlag" element={<AngledFlagPrototypeControls />} />
|
||||
<Route path="*" element={null} />
|
||||
</Routes>
|
||||
);
|
||||
Reference in new issue
Block a user