Skip to content

Commit

Permalink
refa: unify route structure (#62)
Browse files Browse the repository at this point in the history
* cleanup index/app

* moved index route, yay

* migrate state management

* move compound components

* make demo link typesafe

* remove old stuff

* add smoketest

* move smoketest
  • Loading branch information
sebald authored Jun 5, 2024
1 parent 5bc5297 commit 608dc80
Show file tree
Hide file tree
Showing 54 changed files with 249 additions and 4,181 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ coverage
*.njsproj
*.sln
*.sw?

# tanstack/router
**/routeTree.gen.ts
src/route-tree.ts
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@testing-library/jest-dom": "6.4.5",
"@testing-library/react": "^15.0.6",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.1",
"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.0",
"@types/react-test-renderer": "^18.3.0",
Expand Down
61 changes: 32 additions & 29 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { StrictMode } from 'react';
import { QueryClientProvider, QueryClient } from '@tanstack/react-query';
import { createRouter, RouterProvider } from '@tanstack/react-router';

import { MarigoldProvider } from '@marigold/components';
import theme from '@marigold/theme-core';

import { routeTree } from './route-tree';

// Router
// ---------------
const router = createRouter({ routeTree });

declare module '@tanstack/react-router' {
interface Register {
router: typeof router;
}
}

// Query
// ---------------
const queryClient = new QueryClient();

// App
// ---------------
export const App = () => (
<StrictMode>
<QueryClientProvider client={queryClient}>
<MarigoldProvider theme={theme}>
<RouterProvider router={router} />
</MarigoldProvider>
</QueryClientProvider>
</StrictMode>
);
9 changes: 0 additions & 9 deletions src/components/App.test.tsx

This file was deleted.

11 changes: 0 additions & 11 deletions src/components/App.tsx

This file was deleted.

16 changes: 7 additions & 9 deletions src/components/DemoLink.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import { Link } from '@tanstack/react-router';
import { ExternalLink } from '@marigold/icons';
import { ReactNode } from 'react';
import type { ComponentProps, ReactNode } from 'react';

const DemoLink = ({
destination,
children,
}: {
destination: string;
children: ReactNode;
}) => {
export interface DemoLinkProps extends ComponentProps<typeof Link> {
children?: ReactNode;
}

const DemoLink = ({ children, ...props }: DemoLinkProps) => {
return (
<div className="w-fit">
<Link
{...props}
target="_blank"
to={destination}
search=""
className="flex-1 cursor-pointer rounded-md border-2 border-solid bg-white p-2 align-baseline font-black text-gray-800 hover:bg-gray-300"
>
Expand Down
18 changes: 18 additions & 0 deletions src/components/Devtools.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { Suspense, lazy } from 'react';

const TanStackRouterDevtools =
process.env.NODE_ENV === 'production'
? () => null
: lazy(() =>
import('@tanstack/router-devtools').then(res => ({
default: res.TanStackRouterDevtools,
}))
);

export const Devtools = () => (
<Suspense>
<TanStackRouterDevtools />
<ReactQueryDevtools />
</Suspense>
);
26 changes: 0 additions & 26 deletions src/components/Header.test.tsx

This file was deleted.

9 changes: 0 additions & 9 deletions src/components/Logo.test.tsx

This file was deleted.

23 changes: 0 additions & 23 deletions src/components/Preview.tsx

This file was deleted.

Loading

0 comments on commit 608dc80

Please sign in to comment.