11import HighlightOffIcon from "@mui/icons-material/HighlightOff" ;
2- import { Button } from "@mui/material" ;
32import 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" ;
84
9- type ContentsType = "basic" | "local" ;
5+ type ContentIdType = "basic" | "local" ;
106
117export 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