From 0b695506cfebd86099817c47ce4bd174beb252f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Thu, 18 Jul 2024 02:21:46 +0200 Subject: [PATCH] About page for tests --- packages/webui/src/routeTree.gen.ts | 24 ++++++++++++++++++++++-- packages/webui/src/routes/__root.tsx | 12 +++++++++++- packages/webui/src/routes/about.lazy.tsx | 13 +++++++++++++ 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 packages/webui/src/routes/about.lazy.tsx diff --git a/packages/webui/src/routeTree.gen.ts b/packages/webui/src/routeTree.gen.ts index e8428b4..0edc01b 100644 --- a/packages/webui/src/routeTree.gen.ts +++ b/packages/webui/src/routeTree.gen.ts @@ -16,10 +16,16 @@ import { Route as rootRoute } from './routes/__root' // Create Virtual Routes +const AboutLazyImport = createFileRoute('/about')() const IndexLazyImport = createFileRoute('/')() // Create/Update Routes +const AboutLazyRoute = AboutLazyImport.update({ + path: '/about', + getParentRoute: () => rootRoute, +} as any).lazy(() => import('./routes/about.lazy').then((d) => d.Route)) + const IndexLazyRoute = IndexLazyImport.update({ path: '/', getParentRoute: () => rootRoute, @@ -36,12 +42,22 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof IndexLazyImport parentRoute: typeof rootRoute } + '/about': { + id: '/about' + path: '/about' + fullPath: '/about' + preLoaderRoute: typeof AboutLazyImport + parentRoute: typeof rootRoute + } } } // Create and export the route tree -export const routeTree = rootRoute.addChildren({ IndexLazyRoute }) +export const routeTree = rootRoute.addChildren({ + IndexLazyRoute, + AboutLazyRoute, +}) /* prettier-ignore-end */ @@ -51,11 +67,15 @@ export const routeTree = rootRoute.addChildren({ IndexLazyRoute }) "__root__": { "filePath": "__root.tsx", "children": [ - "/" + "/", + "/about" ] }, "/": { "filePath": "index.lazy.tsx" + }, + "/about": { + "filePath": "about.lazy.tsx" } } } diff --git a/packages/webui/src/routes/__root.tsx b/packages/webui/src/routes/__root.tsx index 8a63141..9ffcb49 100644 --- a/packages/webui/src/routes/__root.tsx +++ b/packages/webui/src/routes/__root.tsx @@ -1,4 +1,4 @@ -import { Outlet, createRootRoute } from "@tanstack/react-router" +import { Link, Outlet, createRootRoute } from "@tanstack/react-router" import { Suspense, lazy } from "react" @@ -12,6 +12,16 @@ const TanStackRouterDevtools = process.env.NODE_ENV === "production" export function Root() { return <>
+
+ + Home + + + + About + +
+
diff --git a/packages/webui/src/routes/about.lazy.tsx b/packages/webui/src/routes/about.lazy.tsx new file mode 100644 index 0000000..1a122a2 --- /dev/null +++ b/packages/webui/src/routes/about.lazy.tsx @@ -0,0 +1,13 @@ +import { createLazyFileRoute } from "@tanstack/react-router" +import { observer } from "mobx-react-lite" + + +export const About = observer(() => { + + return <> +

About

+ + +}) + +export const Route = createLazyFileRoute("/about")({ component: About })