Open History to see the last commit
1/// <reference types="vite/client" />
2import { ReactQueryDevtools } from '@tanstack/react-query-devtools/production'
3import {
4 HeadContent,
5 Link,
6 Outlet,
7 Scripts,
8 createRootRouteWithContext,
9 useRouterState,
10} from '@tanstack/react-router'
11import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
12import * as React from 'react'
13import { Toaster } from 'react-hot-toast'
14import type { QueryClient } from '@tanstack/react-query'
15import { DefaultCatchBoundary } from '~/components/DefaultCatchBoundary'
16import { IconLink } from '~/components/IconLink'
17import { NotFound } from '~/components/NotFound'
18import appCss from '~/styles/app.css?url'
19import { seo } from '~/utils/seo'
20import { Loader } from '~/components/Loader'
21β
22export const Route = createRootRouteWithContext<{
23 queryClient: QueryClient
24}>()({
25 head: () => ({
26 meta: [
27 {
28 charSet: 'utf-8',
29 },
30 {
31 name: 'viewport',
32 content: 'width=device-width, initial-scale=1',
33 },
34 ...seo({
35 title:
36 'TanStack Start | Type-Safe, Client-First, Full-Stack React Framework',
37 description: `TanStack Start is a type-safe, client-first, full-stack React framework. `,
38 }),
39 ],
40 links: [
41 { rel: 'stylesheet', href: appCss },
42 {
43 rel: 'apple-touch-icon',
44 sizes: '180x180',
45 href: '/apple-touch-icon.png',
46 },
47 {
48 rel: 'icon',
49 type: 'image/png',
50 sizes: '32x32',
51 href: '/favicon-32x32.png',
52 },
53 {
54 rel: 'icon',
55 type: 'image/png',
56 sizes: '16x16',
57 href: '/favicon-16x16.png',
58 },
59 { rel: 'manifest', href: '/site.webmanifest', color: '#fffff' },
60 { rel: 'icon', href: '/favicon.ico' },
61 ],
62 }),
63 errorComponent: (props) => {
64 return (
65 <RootDocument>
66 <DefaultCatchBoundary {...props} />
67 </RootDocument>
68 )
69 },
70 notFoundComponent: () => <NotFound />,
71 component: RootComponent,
72})
73β
74function RootComponent() {
75 return (
76 <RootDocument>
77 <Outlet />
78 </RootDocument>
79 )
80}
81β
82function RootDocument({ children }: { children: React.ReactNode }) {
83 return (
84 <html>
85 <head>
86 <HeadContent />
87 </head>
88 <body>
89 <div className="h-screen flex flex-col min-h-0">
90 <div className="bg-slate-900 border-b border-slate-800 flex items-center justify-between py-4 px-8 box-border">
91 <div className="flex items-center gap-4">
92 <div>
93 <Link to="/" className="block leading-tight">
94 <div className="font-black text-2xl text-white">Trellaux</div>
95 <div className="text-slate-500">a TanStack Demo</div>
96 </Link>
97 </div>
98 <LoadingIndicator />
99 </div>
100 <div className="flex items-center gap-6">
101 {/* <label
102 htmlFor="countries"
103 className="block text-sm font-medium text-gray-900 dark:text-white"
104 >
105 Delay
106 </label>
107 <select
108 className="border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
109 onChange={(event) => {
110 // setExtraDelay(Number(event.currentTarget.value))
111 }}
112 defaultValue="0"
113 >
114 <option value="0">None</option>
115 <option value="100">100</option>
116 <option value="500">500</option>
117 <option value="2000">2000</option>
118 </select> */}
119 <IconLink
120 href="https://github.com/TanStack/router/tree/main/examples/react/start-trellaux"
121 label="Source"
122 icon="/github-mark-white.png"
123 />
124 <IconLink
125 href="https://tanstack.com"
126 icon="/tanstack.png"
127 label="TanStack"
128 />
129 </div>
130 </div>
131β
132 <div className="grow min-h-0 h-full flex flex-col">
133 {children}
134 <Toaster />
135 </div>
136 </div>
137 <ReactQueryDevtools />
138 <TanStackRouterDevtools position="bottom-right" />
139 <Scripts />
140 </body>
141 </html>
142 )
143}
144β
145function LoadingIndicator() {
146 const isLoading = useRouterState({ select: (s) => s.isLoading })
147 return (
148 <div
149 className={`h-12 transition-all duration-300 ${
150 isLoading ? `opacity-100 delay-300` : `opacity-0 delay-0`
151 }`}
152 >
153 <Loader />
154 </div>
155 )
156}