Skip to content

Commit 2bdfcd9

Browse files
committed
feat: created example routes
1 parent ce329e2 commit 2bdfcd9

File tree

5 files changed

+149
-11
lines changed

5 files changed

+149
-11
lines changed

src/pages/about.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Link } from "react-router";
2+
3+
export default function About() {
4+
return (
5+
<div className="min-h-screen p-8">
6+
<div className="mx-auto max-w-4xl">
7+
<h1 className="mb-4 text-4xl font-bold">About Page</h1>
8+
<p className="mb-6 text-gray-600">This is the about page demonstrating static routing.</p>
9+
<p className="mb-4">Route: /about</p>
10+
<Link to="/" className="text-blue-600 hover:underline">
11+
← Back to Home
12+
</Link>
13+
</div>
14+
</div>
15+
);
16+
}

src/pages/index.tsx

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Button } from "@/components";
2+
import { Link } from "react-router";
23

34
interface Props extends React.ComponentProps<"div"> {}
45

@@ -10,18 +11,36 @@ const Home = ({ ...rest }: Props) => {
1011
};
1112
return (
1213
<div className="grid min-h-screen place-items-center bg-gray-900 text-white" {...rest}>
13-
<div>
14-
<span className="mx-3 text-2xl">Count: {count}</span>
15-
<Button variant={"secondary"} onClick={handleIncrement}>
16-
Increase
17-
</Button>
14+
<div className="space-y-8 text-center">
15+
<div>
16+
<span className="mx-3 text-2xl">Count: {count}</span>
17+
<Button variant={"secondary"} onClick={handleIncrement}>
18+
Increase
19+
</Button>
20+
</div>
21+
22+
<nav className="space-x-4">
23+
<Link to="/about" className="text-blue-400 hover:underline">
24+
About
25+
</Link>
26+
<Link to="/users" className="text-blue-400 hover:underline">
27+
Users
28+
</Link>
29+
<Link to="/users/profile" className="text-blue-400 hover:underline">
30+
Profile
31+
</Link>
32+
<Link to="/users/123" className="text-blue-400 hover:underline">
33+
User #123
34+
</Link>
35+
</nav>
36+
37+
<p className="text-center text-xl">
38+
React-TS Starter with Vite By Md Kawsar Islam Yeasin
39+
<a href="https://github.com/yeasin2002" className="mx-2 underline" target="_blank">
40+
(yeasin2002)
41+
</a>
42+
</p>
1843
</div>
19-
<p className="text-center text-xl">
20-
React-TS Starter with Vite By Md Kawsar Islam Yeasin
21-
<a href="https://github.com/yeasin2002" className="mx-2 underline" target="_blank">
22-
(yeasin2002)
23-
</a>
24-
</p>
2544
</div>
2645
);
2746
};

src/pages/users/[id].tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Link, useParams } from "react-router";
2+
3+
export default function UserDetail() {
4+
const { id } = useParams<{ id: string }>();
5+
6+
return (
7+
<div className="min-h-screen p-8">
8+
<div className="mx-auto max-w-4xl">
9+
<h1 className="mb-4 text-4xl font-bold">User Details</h1>
10+
<p className="mb-6 text-gray-600">Route: /users/:id (dynamic route)</p>
11+
12+
<div className="mb-8 rounded border p-6">
13+
<p className="mb-2 text-lg">
14+
<span className="font-semibold">User ID:</span> {id}
15+
</p>
16+
<p className="text-gray-600">
17+
This is a dynamic route that matches /users/1, /users/2, etc.
18+
</p>
19+
</div>
20+
21+
<div className="space-x-4">
22+
<Link to="/users" className="text-blue-600 hover:underline">
23+
← Back to Users
24+
</Link>
25+
<Link to="/" className="text-blue-600 hover:underline">
26+
Home
27+
</Link>
28+
</div>
29+
</div>
30+
</div>
31+
);
32+
}

src/pages/users/index.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Link } from "react-router";
2+
3+
const users = [
4+
{ id: 1, name: "Alice Johnson" },
5+
{ id: 2, name: "Bob Smith" },
6+
{ id: 3, name: "Charlie Brown" },
7+
];
8+
9+
export default function Users() {
10+
return (
11+
<div className="min-h-screen p-8">
12+
<div className="mx-auto max-w-4xl">
13+
<h1 className="mb-4 text-4xl font-bold">Users List</h1>
14+
<p className="mb-6 text-gray-600">Route: /users</p>
15+
16+
<div className="mb-8 space-y-4">
17+
{users.map((user) => (
18+
<div key={user.id} className="rounded border p-4 hover:bg-gray-50">
19+
<Link to={`/users/${user.id}`} className="font-medium text-blue-600 hover:underline">
20+
{user.name}
21+
</Link>
22+
</div>
23+
))}
24+
</div>
25+
26+
<div className="space-x-4">
27+
<Link to="/users/profile" className="text-blue-600 hover:underline">
28+
View Profile
29+
</Link>
30+
<Link to="/" className="text-blue-600 hover:underline">
31+
← Back to Home
32+
</Link>
33+
</div>
34+
</div>
35+
</div>
36+
);
37+
}

src/pages/users/profile.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { Link } from "react-router";
2+
3+
export default function UserProfile() {
4+
return (
5+
<div className="min-h-screen p-8">
6+
<div className="mx-auto max-w-4xl">
7+
<h1 className="mb-4 text-4xl font-bold">User Profile</h1>
8+
<p className="mb-6 text-gray-600">Route: /users/profile</p>
9+
10+
<div className="mb-8 rounded border p-6">
11+
<h2 className="mb-4 text-xl font-semibold">Profile Information</h2>
12+
<div className="space-y-2">
13+
<p>
14+
<span className="font-semibold">Name:</span> Current User
15+
</p>
16+
<p>
17+
<span className="font-semibold">Email:</span> user@example.com
18+
</p>
19+
<p className="mt-4 text-sm text-gray-600">This is a static nested route under /users</p>
20+
</div>
21+
</div>
22+
23+
<div className="space-x-4">
24+
<Link to="/users" className="text-blue-600 hover:underline">
25+
← Back to Users
26+
</Link>
27+
<Link to="/" className="text-blue-600 hover:underline">
28+
Home
29+
</Link>
30+
</div>
31+
</div>
32+
</div>
33+
);
34+
}

0 commit comments

Comments
 (0)