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, {
|
||||
ref: transRef,
|
||||
keys: null,
|
||||
from: { opacity: 0, transform: "translate3d(0, 100%, 0" },
|
||||
enter: { opacity: 1, transform: "translate3d(0, 0%, 0" },
|
||||
leave: { opacity: 0, transform: "translate3d(0, -100%, 0" },
|
||||
from: { opacity: 0, transform: "translate3d(0, 100%, 0)" },
|
||||
enter: { opacity: 1, transform: "translate3d(0, 0%, 0)" },
|
||||
leave: { opacity: 0, transform: "translate3d(0, -100%, 0)" },
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
@@ -18,7 +18,7 @@ export const WorkspaceList = ({ headerOffset }: WorkspaceListProps) => {
|
||||
{workspaceList.map((id) => (
|
||||
<WorkspaceListNavLink
|
||||
key={id}
|
||||
to={`s/${id}`}
|
||||
to={id}
|
||||
label={workspaces[id].name}
|
||||
/>
|
||||
))}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useEffect } from "react";
|
||||
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 { mainMenuDimensionsSelector } from "../../features/pageDimensions/pageDimensionsSelector";
|
||||
@@ -10,6 +10,12 @@ import { FullScreenContainer } from "../Common/FullScreenContainer.styled";
|
||||
import { WorkspaceList } from "./WorkspaceList";
|
||||
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;
|
||||
|
||||
export default function Workspaces() {
|
||||
@@ -41,7 +47,24 @@ export default function Workspaces() {
|
||||
heightCutoff={mainMenuHeight}
|
||||
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>
|
||||
</LayoutGridItem>
|
||||
</LayoutGrid>
|
||||
|
||||
Reference in new issue
Block a user