diff --git a/client/src/hooks/useWorkspace.tsx b/client/src/hooks/useWorkspace.tsx index 835f48fd..8002e40c 100644 --- a/client/src/hooks/useWorkspace.tsx +++ b/client/src/hooks/useWorkspace.tsx @@ -19,6 +19,7 @@ type Workspace = { layers: Layers; }; + export function useWorkspace() { const notify = useSnackbar(); const [layers, setLayers] = useLayers(); diff --git a/client/src/pages/RecipesPage.tsx b/client/src/pages/RecipesPage.tsx new file mode 100644 index 00000000..c3f11cd6 --- /dev/null +++ b/client/src/pages/RecipesPage.tsx @@ -0,0 +1,96 @@ +import { WorkspacesOutlined } from "@mui/icons-material"; +import { + Box, + List, + ListItemButton, + ListItemIcon, + ListItemText, + Typography as Type +} from "@mui/material"; +import { Flex } from "components/generic/Flex"; +import { Scroll } from "components/generic/Scrollbars"; +import { useViewTreeContext } from "components/inspector/ViewTree"; +import { useWorkspace } from "hooks/useWorkspace"; +import { startCase, values } from "lodash"; +import { Page } from "pages/Page"; +import { ReactNode } from "react"; + + +const paths = (import.meta.glob("/public/recipes/*.workspace", { as: "url" })); +const files = await Promise.all(values(paths).map(f => f())) + +function stripExtension(path:string) { + return path.split(".")[0]; +} + +function basename(path: string) { + return path.split('/').pop()!; +} + +export function RecipesPage() { + const { controls, onChange, state } = useViewTreeContext(); + const { load } = useWorkspace(); + + async function open(path:string){ + try { + const response = await fetch(path); + + if (!response.ok) { + throw new Error('Network response was not ok'); + } + + const blob = await response.blob(); + const filename = basename(path); + const file = new File([blob], filename, { type: blob.type }); + + load(file) + + } catch (error) { + console.error('There was a problem with the fetch operation:', error); + } + } + + function renderSection(label: ReactNode, content: ReactNode) { + return ( + + + {label} + + {content} + + ); + } + + return ( + + + + + + + Recipes + {renderSection( + "Recipes", + <> + + {files.map(( path , i) => ( + open(path)}> + + + + + + ))} + + + )} + + + + + {controls} + + ); +} + + diff --git a/client/src/pages/index.tsx b/client/src/pages/index.tsx index ad70b674..99097abc 100644 --- a/client/src/pages/index.tsx +++ b/client/src/pages/index.tsx @@ -7,6 +7,7 @@ import { SettingsOutlined, SortOutlined as StepsIcon, ViewInArOutlined, + WorkspacesOutlined, } from "@mui/icons-material"; import { Dictionary } from "lodash"; import { ReactNode } from "react"; @@ -18,6 +19,8 @@ import { SettingsPage } from "./SettingsPage"; import { StepsPage } from "./StepsPage"; import { TreePage } from "./TreePage"; import { ViewportPage } from "./ViewportPage"; +import { RecipesPage } from "./RecipesPage"; + export type PageMeta = { id: string; @@ -75,4 +78,10 @@ export const pages: Dictionary = { icon: , content: AboutPage, }, + recipes: { + id: "recipes", + name: "Recipes", + icon: , + content: RecipesPage, + }, }; diff --git a/client/src/public/recipes/astar-jps-small-maze.workspace b/client/src/public/recipes/astar-jps-small-maze.workspace new file mode 100644 index 00000000..ed940cb1 Binary files /dev/null and b/client/src/public/recipes/astar-jps-small-maze.workspace differ diff --git a/client/src/public/recipes/aurora-polyanya.workspace b/client/src/public/recipes/aurora-polyanya.workspace new file mode 100644 index 00000000..d01fb4ac Binary files /dev/null and b/client/src/public/recipes/aurora-polyanya.workspace differ diff --git a/client/src/public/recipes/dynamic-starcraft.workspace b/client/src/public/recipes/dynamic-starcraft.workspace new file mode 100644 index 00000000..ffd615f9 Binary files /dev/null and b/client/src/public/recipes/dynamic-starcraft.workspace differ diff --git a/client/src/public/recipes/frozen-sea-astar.workspace b/client/src/public/recipes/frozen-sea-astar.workspace new file mode 100644 index 00000000..359d685c Binary files /dev/null and b/client/src/public/recipes/frozen-sea-astar.workspace differ diff --git a/client/src/public/recipes/jps-vs-jps-prune2.workspace b/client/src/public/recipes/jps-vs-jps-prune2.workspace new file mode 100644 index 00000000..702c7dac Binary files /dev/null and b/client/src/public/recipes/jps-vs-jps-prune2.workspace differ diff --git a/client/src/public/recipes/lacam-random-32-32-20.workspace b/client/src/public/recipes/lacam-random-32-32-20.workspace new file mode 100644 index 00000000..198036b1 Binary files /dev/null and b/client/src/public/recipes/lacam-random-32-32-20.workspace differ diff --git a/client/src/public/recipes/mapf-large.workspace b/client/src/public/recipes/mapf-large.workspace new file mode 100644 index 00000000..7810b0f4 Binary files /dev/null and b/client/src/public/recipes/mapf-large.workspace differ diff --git a/client/src/public/recipes/mapf-sortation.workspace b/client/src/public/recipes/mapf-sortation.workspace new file mode 100644 index 00000000..e4f794e5 Binary files /dev/null and b/client/src/public/recipes/mapf-sortation.workspace differ diff --git a/client/src/public/recipes/melbourne-routing.workspace b/client/src/public/recipes/melbourne-routing.workspace new file mode 100644 index 00000000..2544ce2d Binary files /dev/null and b/client/src/public/recipes/melbourne-routing.workspace differ diff --git a/client/src/public/recipes/new-york-astar.workspace b/client/src/public/recipes/new-york-astar.workspace new file mode 100644 index 00000000..67052645 Binary files /dev/null and b/client/src/public/recipes/new-york-astar.workspace differ diff --git a/client/src/public/recipes/nine-tile.workspace b/client/src/public/recipes/nine-tile.workspace new file mode 100644 index 00000000..8e850ed5 Binary files /dev/null and b/client/src/public/recipes/nine-tile.workspace differ diff --git a/client/src/public/recipes/rayscan-arena2.workspace b/client/src/public/recipes/rayscan-arena2.workspace new file mode 100644 index 00000000..11f38e35 Binary files /dev/null and b/client/src/public/recipes/rayscan-arena2.workspace differ