Skip to content

Commit 622cc8a

Browse files
committed
temp
1 parent a89bf9f commit 622cc8a

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

apps/web/src/App.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import Start from "./pages/Start/Start";
66
import Tutorial from "./pages/Tutorial/Tutorial";
77
import "./App.css";
88
import { Route, BrowserRouter as Router, Routes } from "react-router-dom";
9+
import BasicRules from "./pages/Tutorial/BasicRules";
10+
import LocalRules from "./pages/Tutorial/LocalRules";
911

1012
export type PlayerInfo = {
1113
rank: number | null;
@@ -34,7 +36,11 @@ function App() {
3436
<Router>
3537
<Routes>
3638
<Route path="/" element={<Start setPlayerInfo={setPlayerInfo} />} />
37-
<Route path="/tutorial" element={<Tutorial />} />
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>
3844
<Route
3945
path="/play"
4046
element={

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

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
import HighlightOffIcon from "@mui/icons-material/HighlightOff";
2-
import { Button } from "@mui/material";
32
import IconButton from "@mui/material/IconButton";
4-
import { useState } from "react";
5-
import { useNavigate } from "react-router-dom";
6-
import BasicRules from "./BasicRules";
7-
import LocalRules from "./LocalRules";
3+
import { Link, Outlet, useNavigate, useParams } from "react-router-dom";
84

9-
type ContentsType = "basic" | "local";
5+
type ContentIdType = "basic" | "local";
106

117
export default function Tutorial() {
12-
const [currentContent, setCurrentContent] = useState<ContentsType>("basic");
138
const navigate = useNavigate();
14-
const contents: ContentsType[] = ["basic", "local"];
9+
const { contentId } = useParams<{ contentId: ContentIdType }>();
10+
const contents: ContentIdType[] = ["basic", "local"];
1511

1612
return (
1713
<div className="flex flex-col items-center bg-white rounded-[1rem] absolute h-[80vh] w-[80vw] left-[10%] top-[10%] pt-4 pl-4">
@@ -31,22 +27,25 @@ export default function Tutorial() {
3127
<div className="grid size-full gap-[3%] h-[90%] overflow-auto pt-4">
3228
<div className="col-start-1 col-end-2 flex w-50 flex-col border-r border-gray-300 px-5 h-full">
3329
{contents.map((content) => (
34-
<Button
30+
<Link
3531
key={content}
36-
sx={{
37-
marginBottom: "10%",
38-
}}
39-
variant={currentContent === content ? "contained" : "outlined"}
40-
onClick={() => setCurrentContent(content)}
32+
to={`/tutorial/${content}`}
33+
className={`
34+
mb-[10%] px-4 py-2 rounded border transition-colors duration-200
35+
${
36+
contentId === content
37+
? "bg-blue-500 text-white border-blue-500"
38+
: "bg-transparent text-blue-500 border-blue-500 hover:bg-blue-50"
39+
}
40+
`}
4141
>
4242
{content === "basic" ? "基本ルール" : "ローカルルール"}
43-
</Button>
43+
</Link>
4444
))}
4545
</div>
4646

4747
<div className="col-start-2 col-end-3 text-left">
48-
{currentContent === "basic" && <BasicRules />}
49-
{currentContent === "local" && <LocalRules />}
48+
<Outlet />
5049
</div>
5150
</div>
5251
</div>

0 commit comments

Comments
 (0)