Skip to content

Commit

Permalink
Start using Tanstack Router for future pages (Games & AI)
Browse files Browse the repository at this point in the history
  • Loading branch information
illusionTBA committed Nov 1, 2024
1 parent 86f3c45 commit 914f095
Show file tree
Hide file tree
Showing 8 changed files with 805 additions and 166 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-select": "^2.1.2",
"@radix-ui/react-separator": "^1.1.0",
"@tanstack/react-router": "^1.78.0",
"@titaniumnetwork-dev/ultraviolet": "^3.2.7",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
Expand All @@ -38,6 +39,8 @@
},
"devDependencies": {
"@eslint/js": "^9.11.1",
"@tanstack/router-devtools": "^1.78.0",
"@tanstack/router-plugin": "^1.78.0",
"@types/node": "^22.7.4",
"@types/react": "^18.3.10",
"@types/react-dom": "^18.3.0",
Expand Down
500 changes: 498 additions & 2 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

29 changes: 23 additions & 6 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import App from './App.tsx'
import { RouterProvider, createRouter } from '@tanstack/react-router'
import './index.css'

createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>,
)
// Import the generated route tree
import { routeTree } from './routeTree.gen'

// Create a new router instance
const router = createRouter({ routeTree })

// Register the router instance for type safety
declare module '@tanstack/react-router' {
interface Register {
router: typeof router
}
}

const rootElement = document.getElementById('root')!
if (!rootElement.innerHTML) {
const root = createRoot(rootElement)
root.render(
<StrictMode>
<RouterProvider router={router} />
</StrictMode>,
)
}
93 changes: 93 additions & 0 deletions src/routeTree.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/* eslint-disable */

// @ts-nocheck

// noinspection JSUnusedGlobalSymbols

// This file was automatically generated by TanStack Router.
// You should NOT make any changes in this file as it will be overwritten.
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.

import { createFileRoute } from '@tanstack/react-router'

// Import Routes

import { Route as rootRoute } from './routes/__root'

// Create Virtual Routes

const IndexLazyImport = createFileRoute('/')()

// Create/Update Routes

const IndexLazyRoute = IndexLazyImport.update({
id: '/',
path: '/',
getParentRoute: () => rootRoute,
} as any).lazy(() => import('./routes/index.lazy').then((d) => d.Route))

// Populate the FileRoutesByPath interface

declare module '@tanstack/react-router' {
interface FileRoutesByPath {
'/': {
id: '/'
path: '/'
fullPath: '/'
preLoaderRoute: typeof IndexLazyImport
parentRoute: typeof rootRoute
}
}
}

// Create and export the route tree

export interface FileRoutesByFullPath {
'/': typeof IndexLazyRoute
}

export interface FileRoutesByTo {
'/': typeof IndexLazyRoute
}

export interface FileRoutesById {
__root__: typeof rootRoute
'/': typeof IndexLazyRoute
}

export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath
fullPaths: '/'
fileRoutesByTo: FileRoutesByTo
to: '/'
id: '__root__' | '/'
fileRoutesById: FileRoutesById
}

export interface RootRouteChildren {
IndexLazyRoute: typeof IndexLazyRoute
}

const rootRouteChildren: RootRouteChildren = {
IndexLazyRoute: IndexLazyRoute,
}

export const routeTree = rootRoute
._addFileChildren(rootRouteChildren)
._addFileTypes<FileRouteTypes>()

/* ROUTE_MANIFEST_START
{
"routes": {
"__root__": {
"filePath": "__root.tsx",
"children": [
"/"
]
},
"/": {
"filePath": "index.lazy.tsx"
}
}
}
ROUTE_MANIFEST_END */
20 changes: 20 additions & 0 deletions src/routes/__root.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { createRootRoute, Outlet } from '@tanstack/react-router'
import { TanStackRouterDevtools } from '@tanstack/router-devtools'

export const Route = createRootRoute({
component: () => (
<>
{/* <div className="p-2 flex gap-2">
<Link to="/" className="[&.active]:font-bold">
Home
</Link>{' '}
<Link to="/about" className="[&.active]:font-bold">
About
</Link>
</div>
<hr /> */}
<Outlet />
<TanStackRouterDevtools />
</>
),
})
Loading

0 comments on commit 914f095

Please sign in to comment.