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
@@ -46,9 +46,9 @@ export function SlotSelector({
|
|||||||
const transitions = useTransition(index, {
|
const transitions = useTransition(index, {
|
||||||
ref: transRef,
|
ref: transRef,
|
||||||
keys: null,
|
keys: null,
|
||||||
from: { opacity: 0, transform: "translate3d(0, 100%, 0" },
|
from: { opacity: 0, transform: "translate3d(0, 100%, 0)" },
|
||||||
enter: { opacity: 1, transform: "translate3d(0, 0%, 0" },
|
enter: { opacity: 1, transform: "translate3d(0, 0%, 0)" },
|
||||||
leave: { opacity: 0, transform: "translate3d(0, -100%, 0" },
|
leave: { opacity: 0, transform: "translate3d(0, -100%, 0)" },
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { useEffect } from "react";
|
import { ReactNode, useEffect } from "react";
|
||||||
import { Route, Routes, useParams } from "react-router-dom";
|
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { Center } from "@bedrock-layout/center";
|
import { Center } from "@bedrock-layout/center";
|
||||||
import { Stack } from "@bedrock-layout/stack";
|
import { Stack } from "@bedrock-layout/stack";
|
||||||
@@ -14,16 +13,23 @@ import { WorkspaceControls } from "../WorkspaceControls";
|
|||||||
import { OverlayDisplay } from "../../OverlayTool";
|
import { OverlayDisplay } from "../../OverlayTool";
|
||||||
|
|
||||||
import { workspaces } from "../../../domain/data/workspaces";
|
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 dispatch = useDispatch();
|
||||||
const { "*": workspaceId } = useParams();
|
|
||||||
const { animatedBG, workspaceProperties } = useSelector(workspaceSelector);
|
const { animatedBG, workspaceProperties } = useSelector(workspaceSelector);
|
||||||
const { currentWorkspaceId: overlayWorkspaceId } = useSelector(overlayToolSelector);
|
const { currentWorkspaceId: overlayWorkspaceId } = useSelector(overlayToolSelector);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (workspaceId == null) return;
|
|
||||||
|
|
||||||
// Update workspace store for ID.
|
// Update workspace store for ID.
|
||||||
dispatch(updateWorkspace({
|
dispatch(updateWorkspace({
|
||||||
workspaceId,
|
workspaceId,
|
||||||
@@ -39,8 +45,6 @@ export const Workspace = () => {
|
|||||||
}
|
}
|
||||||
}, [workspaceId]);
|
}, [workspaceId]);
|
||||||
|
|
||||||
if (workspaceId == null) return null;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
gutter="lg"
|
gutter="lg"
|
||||||
@@ -53,37 +57,15 @@ export const Workspace = () => {
|
|||||||
dimensions={workspaceProperties.previewWindowDimensions}
|
dimensions={workspaceProperties.previewWindowDimensions}
|
||||||
animatedBG={animatedBG}
|
animatedBG={animatedBG}
|
||||||
>
|
>
|
||||||
<PreviewContent />
|
{previewContent}
|
||||||
<OverlayDisplay
|
<OverlayDisplay
|
||||||
containerDimensions={workspaceProperties.previewWindowDimensions}
|
containerDimensions={workspaceProperties.previewWindowDimensions}
|
||||||
/>
|
/>
|
||||||
</PreviewWindow>
|
</PreviewWindow>
|
||||||
<ControlsContainer>
|
<ControlsContainer>
|
||||||
<WorkspaceControls />
|
<WorkspaceControls />
|
||||||
<PrototypeControls />
|
{prototypeControls}
|
||||||
</ControlsContainer>
|
</ControlsContainer>
|
||||||
</Stack>
|
</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>
|
|
||||||
);
|
|
||||||
@@ -18,7 +18,7 @@ export const WorkspaceList = ({ headerOffset }: WorkspaceListProps) => {
|
|||||||
{workspaceList.map((id) => (
|
{workspaceList.map((id) => (
|
||||||
<WorkspaceListNavLink
|
<WorkspaceListNavLink
|
||||||
key={id}
|
key={id}
|
||||||
to={`s/${id}`}
|
to={id}
|
||||||
label={workspaces[id].name}
|
label={workspaces[id].name}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { Outlet } from "react-router-dom";
|
import { Route, Routes } from "react-router-dom";
|
||||||
import useMeasure from "react-use-measure";
|
import useMeasure from "react-use-measure";
|
||||||
|
|
||||||
import { mainMenuDimensionsSelector } from "../../features/pageDimensions/pageDimensionsSelector";
|
import { mainMenuDimensionsSelector } from "../../features/pageDimensions/pageDimensionsSelector";
|
||||||
@@ -10,6 +10,12 @@ import { FullScreenContainer } from "../Common/FullScreenContainer.styled";
|
|||||||
import { WorkspaceList } from "./WorkspaceList";
|
import { WorkspaceList } from "./WorkspaceList";
|
||||||
import { LayoutGrid, LayoutGridItem } from "../Common/LayoutGrid.styled";
|
import { LayoutGrid, LayoutGridItem } from "../Common/LayoutGrid.styled";
|
||||||
|
|
||||||
|
import { Workspace } from "./Workspace";
|
||||||
|
import { ChyronDriver } from "../BroadcastGraphics/Chyrons/Driver";
|
||||||
|
import { ChyronPrototypeControls } from "./PrototypingControls/ChyronPrototype";
|
||||||
|
import { AngledFlagWorkSpace } from "./CustomWorkSpaces/AngledFlagWorkSpace";
|
||||||
|
import { AngledFlagPrototypeControls } from "./PrototypingControls/AngledFlagPrototype";
|
||||||
|
|
||||||
const WORKSPACE_LIST_WIDTH = 180;
|
const WORKSPACE_LIST_WIDTH = 180;
|
||||||
|
|
||||||
export default function Workspaces() {
|
export default function Workspaces() {
|
||||||
@@ -41,7 +47,24 @@ export default function Workspaces() {
|
|||||||
heightCutoff={mainMenuHeight}
|
heightCutoff={mainMenuHeight}
|
||||||
widthCutoff={WORKSPACE_LIST_WIDTH}
|
widthCutoff={WORKSPACE_LIST_WIDTH}
|
||||||
>
|
>
|
||||||
<Outlet />
|
<Routes>
|
||||||
|
<Route index element={<h1>Workspaces Home</h1>} />
|
||||||
|
<Route path="chyronDriver" element={
|
||||||
|
<Workspace
|
||||||
|
workspaceId="chyronDriver"
|
||||||
|
previewContent={<ChyronDriver />}
|
||||||
|
prototypeControls={<ChyronPrototypeControls />}
|
||||||
|
/>
|
||||||
|
} />
|
||||||
|
<Route path="angledFlag" element={
|
||||||
|
<Workspace
|
||||||
|
workspaceId="angledFlag"
|
||||||
|
previewContent={<AngledFlagWorkSpace />}
|
||||||
|
prototypeControls={<AngledFlagPrototypeControls />}
|
||||||
|
/>
|
||||||
|
} />
|
||||||
|
<Route path="*" element={<h1>Unknown Workspace</h1>} />
|
||||||
|
</Routes>
|
||||||
</FullScreenContainer>
|
</FullScreenContainer>
|
||||||
</LayoutGridItem>
|
</LayoutGridItem>
|
||||||
</LayoutGrid>
|
</LayoutGrid>
|
||||||
|
|||||||
+1
-4
@@ -26,10 +26,7 @@ ReactDOM.render(
|
|||||||
<Route path="/" element={<App />}>
|
<Route path="/" element={<App />}>
|
||||||
<Route index element={<h1>Home</h1>} />
|
<Route index element={<h1>Home</h1>} />
|
||||||
<Route path="broadcast" element={<Broadcast />} />
|
<Route path="broadcast" element={<Broadcast />} />
|
||||||
<Route path="workspaces" element={<Workspaces />}>
|
<Route path="workspaces/*" element={<Workspaces />} />
|
||||||
<Route index element={<h1>Workspaces Home</h1>} />
|
|
||||||
<Route path="s/*" element={<Workspace />} />
|
|
||||||
</Route>
|
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="*" element={<h1>Page Not Found</h1>} />
|
<Route path="*" element={<h1>Page Not Found</h1>} />
|
||||||
</Routes>
|
</Routes>
|
||||||
|
|||||||
Reference in new issue
Block a user