Skip to content

Commit 55a4cc1

Browse files
committed
Demo site part 2
1 parent ea31dc5 commit 55a4cc1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1097
-210
lines changed

apps/react/demo/biome.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
33
"extends": ["@canonical/biome-config"],
44
"files": {
5-
"include": ["src", "*.json", "vite.config.ts"]
5+
"include": ["src", "*.json", "vite.config.ts"],
6+
"ignore": ["src/routeTree.gen.ts"]
67
}
78
}

apps/react/demo/package.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,24 @@
2020
"check:biome": "biome check",
2121
"check:biome:fix": "biome check --write",
2222
"check:ts": "tsc --noEmit",
23-
"storybook": "storybook dev -p 6010 --no-open --host 0.0.0.0"
23+
"storybook": "storybook dev -p 6011 --no-open --host 0.0.0.0"
2424
},
2525
"dependencies": {
2626
"@canonical/storybook-config": "^0.9.0-experimental.5",
2727
"@canonical/react-ssr": "^0.9.0-experimental.10",
2828
"@canonical/styles": "^0.9.0-experimental.9",
29+
"@tanstack/react-router": "^1.114.25",
2930
"react": "^19.0.0",
30-
"react-dom": "^19.0.0"
31+
"react-dom": "^19.0.0",
32+
"react-shadow": "^20.6.0"
3133
},
3234
"devDependencies": {
3335
"@biomejs/biome": "^1.9.4",
3436
"@canonical/biome-config": "^0.9.0-experimental.2",
3537
"@canonical/react-ds-core": "^0.9.0-experimental.11",
3638
"@canonical/typescript-config-react": "^0.9.0-experimental.2",
39+
"@tanstack/react-router-devtools": "^1.114.25",
40+
"@tanstack/router-plugin": "^1.114.25",
3741
"@chromatic-com/storybook": "^3.2.2",
3842
"@storybook/blocks": "^8.4.7",
3943
"@storybook/react": "^8.4.7",

apps/react/demo/src/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Routing tree generated by TanStack
2+
routeTree.gen.ts

apps/react/demo/src/Application.tsx

+12-50
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,18 @@
1-
import { Button, TooltipArea } from "@canonical/react-ds-core";
2-
import React, { Suspense, useState, lazy } from "react";
3-
import canonicalLogo from "./assets/canonical.svg";
4-
import reactLogo from "./assets/react.svg";
5-
import "./Application.css";
1+
import { RouterProvider, createRouter } from "@tanstack/react-router";
62

7-
const LazyButton = lazy(
8-
() =>
9-
new Promise((resolve) => {
10-
// @ts-ignore
11-
setTimeout(() => resolve(import("./LazyComponent.js")), 2000);
12-
}),
13-
);
3+
// Import the generated route tree
4+
import { routeTree } from "./routeTree.gen.js";
145

15-
function App() {
16-
const [count, setCount] = useState(0);
6+
const router = createRouter({ routeTree });
7+
8+
declare module "@tanstack/react-router" {
9+
interface Register {
10+
router: typeof router;
11+
}
12+
}
1713

18-
return (
19-
<>
20-
<div>
21-
<a
22-
href="https://canonical.com"
23-
target="_blank"
24-
referrerPolicy="no-referrer"
25-
rel="noreferrer"
26-
>
27-
<img src={canonicalLogo} className="logo" alt="Canonical logo" />
28-
</a>
29-
<a href="https://react.dev" target="_blank" rel="noreferrer">
30-
<img src={reactLogo} className="logo react" alt="React logo" />
31-
</a>
32-
</div>
33-
<h1>Canonical Design System</h1>
34-
<h2>React Vite template</h2>
35-
<Suspense fallback={"Loading..."}>
36-
<LazyButton />
37-
</Suspense>
38-
<div className="card">
39-
<TooltipArea
40-
preferredDirections={["right", "bottom"]}
41-
Message={`Increment count to ${count + 1}`}
42-
>
43-
<Button
44-
label={`Count: ${count}`}
45-
onClick={() => setCount((count) => count + 1)}
46-
/>
47-
</TooltipArea>
48-
<p>
49-
Edit <code>src/App.tsx</code> and save to test HMR
50-
</p>
51-
</div>
52-
</>
53-
);
14+
function App() {
15+
return <RouterProvider router={router} />;
5416
}
5517

5618
export default App;

apps/react/demo/src/ExampleComponent/ExampleComponent.stories.tsx

-58
This file was deleted.

apps/react/demo/src/ExampleComponent/ExampleComponent.tests.tsx

-17
This file was deleted.

apps/react/demo/src/ExampleComponent/ExampleComponent.tsx

-29
This file was deleted.

apps/react/demo/src/ExampleComponent/index.ts

-3
This file was deleted.

apps/react/demo/src/ExampleComponent/styles.css

-7
This file was deleted.

apps/react/demo/src/ExampleComponent/types.ts

-13
This file was deleted.

apps/react/demo/src/LazyComponent.tsx

-13
This file was deleted.

apps/react/demo/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from "./ExampleComponent/index.js";
1+
export * from "./ui/index.js";

apps/react/demo/src/routes/__root.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Outlet, createRootRoute } from "@tanstack/react-router";
2+
import { TanStackRouterDevtools } from "@tanstack/react-router-devtools";
3+
4+
export const Route = createRootRoute({
5+
component: () => (
6+
<>
7+
<Outlet />
8+
<TanStackRouterDevtools position={"top-right"} />
9+
</>
10+
),
11+
});

apps/react/demo/src/routes/about.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { createFileRoute } from "@tanstack/react-router";
2+
3+
export const Route = createFileRoute("/about")({
4+
component: RouteComponent,
5+
});
6+
7+
function RouteComponent() {
8+
return <div>Hello "/about"!</div>;
9+
}

apps/react/demo/src/routes/index.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { createFileRoute } from "@tanstack/react-router";
2+
import { Showcase } from "./showcase.js";
3+
4+
// For now, redirect all requests to the showcase
5+
export const Route = createFileRoute("/")({
6+
component: Showcase,
7+
});
8+
9+
function Index() {
10+
return <span>Home</span>;
11+
}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { createFileRoute } from "@tanstack/react-router";
2+
import { ShowcaseComponent } from "../ui/index.js";
3+
export const Route = createFileRoute("/showcase")({
4+
component: Showcase,
5+
});
6+
7+
export function Showcase() {
8+
return <ShowcaseComponent />;
9+
}

apps/react/demo/src/ssr/entry-client.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ import "../index.css";
33
import Application from "../Application.js";
44

55
hydrateRoot(document.getElementById("root") as HTMLElement, <Application />);
6-
7-
console.log("hydrated");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
import Component from "./Showcase.js";
3+
4+
const meta = {
5+
title: "Showcase",
6+
component: Component,
7+
} satisfies Meta<typeof Component>;
8+
9+
export default meta;
10+
11+
type Story = StoryObj<typeof meta>;
12+
13+
export const Default: Story = {
14+
args: {},
15+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import {
2+
ConfigProvider,
3+
ExampleControls,
4+
ExampleRenderer,
5+
SHOWCASE_EXAMPLES,
6+
} from "./index.js";
7+
8+
const Showcase = () => {
9+
return (
10+
<ConfigProvider examples={SHOWCASE_EXAMPLES}>
11+
<div>
12+
<ExampleRenderer />
13+
<ExampleControls
14+
style={{
15+
position: "fixed",
16+
left: 0,
17+
bottom: 0,
18+
}}
19+
/>
20+
</div>
21+
</ConfigProvider>
22+
);
23+
};
24+
25+
export default Showcase;

0 commit comments

Comments
 (0)