Skip to content

Commit 4eac889

Browse files
committed
routing for tutorial
1 parent 622cc8a commit 4eac889

File tree

7 files changed

+59
-43
lines changed

7 files changed

+59
-43
lines changed

apps/web/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"preview": "vite preview"
1111
},
1212
"dependencies": {
13-
"shared": "workspace:*",
1413
"@emotion/react": "^11.13.3",
1514
"@emotion/styled": "^11.13.0",
1615
"@mui/base": "^5.0.0-beta.58",
@@ -21,7 +20,9 @@
2120
"react-dom": "^19.1.1",
2221
"react-icons": "^5.3.0",
2322
"react-markdown": "^9.0.1",
24-
"react-router-dom": "^6.26.2"
23+
"react-router": "^7.8.2",
24+
"react-router-dom": "^7.8.2",
25+
"shared": "workspace:*"
2526
},
2627
"devDependencies": {
2728
"@eslint/js": "^9.33.0",

apps/web/src/App.tsx

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { useState } from "react";
2+
import { Route, Routes } from "react-router";
23
import NotFound from "./pages/NotFound/NotFound";
34
import GameInterface from "./pages/Play/GameInterface";
45
import Result from "./pages/Result/Result";
56
import Start from "./pages/Start/Start";
6-
import Tutorial from "./pages/Tutorial/Tutorial";
7-
import "./App.css";
8-
import { Route, BrowserRouter as Router, Routes } from "react-router-dom";
97
import BasicRules from "./pages/Tutorial/BasicRules";
108
import LocalRules from "./pages/Tutorial/LocalRules";
9+
import Tutorial from "./pages/Tutorial/Tutorial";
10+
import "./App.css";
1111

1212
export type PlayerInfo = {
1313
rank: number | null;
@@ -33,27 +33,25 @@ function App() {
3333
fontFamily: "YuMincho, Hiragino Mincho ProN, serif",
3434
}}
3535
>
36-
<Router>
37-
<Routes>
38-
<Route path="/" element={<Start setPlayerInfo={setPlayerInfo} />} />
39-
<Route path="/tutorial" element={<Tutorial />}>
40-
<Route index element={<BasicRules />} />
41-
<Route path="basic" element={<BasicRules />} />
42-
<Route path="local" element={<LocalRules />} />
43-
</Route>
44-
<Route
45-
path="/play"
46-
element={
47-
<GameInterface
48-
playerInfo={playerInfo}
49-
setPlayerInfo={setPlayerInfo}
50-
/>
51-
}
52-
/>
53-
<Route path="/result" element={<Result playerInfo={playerInfo} />} />
54-
<Route path="*" element={<NotFound />} />
55-
</Routes>
56-
</Router>
36+
<Routes>
37+
<Route index element={<Start setPlayerInfo={setPlayerInfo} />} />
38+
<Route path="tutorial" element={<Tutorial />}>
39+
<Route index element={<BasicRules />} />
40+
<Route path="basic" element={<BasicRules />} />
41+
<Route path="local" element={<LocalRules />} />
42+
</Route>
43+
<Route
44+
path="play"
45+
element={
46+
<GameInterface
47+
playerInfo={playerInfo}
48+
setPlayerInfo={setPlayerInfo}
49+
/>
50+
}
51+
/>
52+
<Route path="result" element={<Result playerInfo={playerInfo} />} />
53+
<Route path="*" element={<NotFound />} />
54+
</Routes>
5755
</div>
5856
);
5957
}

apps/web/src/index.css

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ a {
2222
color: #646cff;
2323
text-decoration: inherit;
2424
}
25+
2526
a:hover {
2627
color: #535bf2;
2728
}
@@ -54,9 +55,11 @@ button {
5455
cursor: pointer;
5556
transition: border-color 0.25s;
5657
}
58+
5759
button:hover {
5860
border-color: #646cff;
5961
}
62+
6063
button:focus,
6164
button:focus-visible {
6265
outline: 4px auto -webkit-focus-ring-color;
@@ -68,10 +71,8 @@ button:focus-visible {
6871
color: #213547;
6972
background-color: #ffffff;
7073
}
74+
7175
a:hover {
7276
color: #747bff;
7377
}
74-
button {
75-
background-color: #f9f9f9;
76-
}
7778
}

apps/web/src/main.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
import { StrictMode } from "react";
22
import { createRoot } from "react-dom/client";
3+
import { BrowserRouter } from "react-router";
34
import App from "./App.tsx";
45
import "./index.css";
56

6-
createRoot(document.getElementById("root"))?.render(
7-
<StrictMode>
8-
<App />
9-
</StrictMode>,
10-
);
7+
const rootElement = document.getElementById("root");
8+
9+
if (rootElement) {
10+
const root = createRoot(rootElement);
11+
12+
root.render(
13+
<StrictMode>
14+
<BrowserRouter>
15+
<App />
16+
</BrowserRouter>
17+
</StrictMode>,
18+
);
19+
}

apps/web/src/pages/Start/Start.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ export default function Start(props: StartProps) {
6868

6969
<button
7070
onClick={handleUserNameSubmit}
71-
className="w-115 h-17.5 bg-[#fd903c] text-white text-xl rounded-md my-3.5"
71+
className="w-115 h-17.5 bg-black text-white text-xl rounded-md my-3.5"
7272
type="button"
7373
>
7474
プレイ
7575
</button>
7676
<div className="flex gap-5">
7777
<button
7878
onClick={() => navigate("/tutorial")}
79-
className="w-55 bg-[#85a4ba] text-white rounded-md"
79+
className="w-55 bg-black text-white rounded-md"
8080
type="button"
8181
>
8282
遊び方
@@ -90,7 +90,7 @@ export default function Start(props: StartProps) {
9090
});
9191
navigate("/result");
9292
}}
93-
className="w-55 bg-[#85a4ba] text-white rounded-md"
93+
className="w-55 bg-black text-white rounded-md"
9494
type="button"
9595
>
9696
ランキング

apps/web/src/pages/Tutorial/Tutorial.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import HighlightOffIcon from "@mui/icons-material/HighlightOff";
22
import IconButton from "@mui/material/IconButton";
3-
import { Link, Outlet, useNavigate, useParams } from "react-router-dom";
3+
import { Link, Outlet, useNavigate, useParams } from "react-router";
44

55
type ContentIdType = "basic" | "local";
66

bun.lock

Lines changed: 12 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)