From cd49788cd9bfcaf47431a606797dd6123877f4f4 Mon Sep 17 00:00:00 2001 From: Kagura Date: Sun, 17 Nov 2024 14:53:34 +0800 Subject: [PATCH] + Map Size change --- package.json | 1 + src/App.js | 28 +++++++++++++++++++++++++++- src/index.js | 5 ++++- yarn.lock | 20 ++++++++++++++++++++ 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4b2d99f..d642472 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "react-scripts": "^5.0.0" }, "devDependencies": { + "react-router-dom": "^6.28.0", "tailwindcss": "^3.4.15" }, "browserslist": { diff --git a/src/App.js b/src/App.js index 761b701..fa82e62 100644 --- a/src/App.js +++ b/src/App.js @@ -1,4 +1,5 @@ import { useState } from "react"; +import { useLocation } from 'react-router-dom'; function Square({ row, column, value, clickHandler }) { let buttonClass = "" @@ -38,7 +39,7 @@ function SquareRow({ rowId, rows, clickHandler }) { return <>{items}; } -export default function Map({ mapSize }) { +function Map({ mapSize }) { // Config Here const ticTacToeMaxMapSize = 6 @@ -166,3 +167,28 @@ export default function Map({ mapSize }) { ); } + +export default function Game(){ + const location = useLocation(); + const params = new URLSearchParams(location.search); + const useSize = params.get('mapSize'); + let realSize = parseInt(useSize) + if (realSize == NaN || realSize < 3 || realSize > 20){ + realSize = 3 + } + return( + <> + + +
+
+ + +
+
+ + ) +} \ No newline at end of file diff --git a/src/index.js b/src/index.js index 59b7f4e..6a1ee66 100644 --- a/src/index.js +++ b/src/index.js @@ -3,10 +3,13 @@ import { createRoot } from "react-dom/client"; import "./styles.css"; import App from "./App"; +import { BrowserRouter } from "react-router-dom"; const root = createRoot(document.getElementById("root")); root.render( - + + + ); \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index dee0b2e..d6dc6cb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1590,6 +1590,11 @@ schema-utils "^4.2.0" source-map "^0.7.3" +"@remix-run/router@1.21.0": + version "1.21.0" + resolved "https://registry.yarnpkg.com/@remix-run/router/-/router-1.21.0.tgz#c65ae4262bdcfe415dbd4f64ec87676e4a56e2b5" + integrity sha512-xfSkCAchbdG5PnbrKqFWwia4Bi61nH+wm8wLEqfHDyp7Y3dZzgqS2itV8i4gAq9pC2HsTpwyBC6Ds8VHZ96JlA== + "@rollup/plugin-babel@^5.2.0": version "5.3.1" resolved "https://registry.yarnpkg.com/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz#04bc0608f4aa4b2e4b1aebf284344d0f68fda283" @@ -7605,6 +7610,21 @@ react-refresh@^0.11.0: resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.11.0.tgz#77198b944733f0f1f1a90e791de4541f9f074046" integrity sha512-F27qZr8uUqwhWZboondsPx8tnC3Ct3SxZA3V5WyEvujRyyNv0VYPhoBg1gZ8/MV5tubQp76Trw8lTv9hzRBa+A== +react-router-dom@^6.28.0: + version "6.28.0" + resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-6.28.0.tgz#f73ebb3490e59ac9f299377062ad1d10a9f579e6" + integrity sha512-kQ7Unsl5YdyOltsPGl31zOjLrDv+m2VcIEcIHqYYD3Lp0UppLjrzcfJqDJwXxFw3TH/yvapbnUvPlAj7Kx5nbg== + dependencies: + "@remix-run/router" "1.21.0" + react-router "6.28.0" + +react-router@6.28.0: + version "6.28.0" + resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.28.0.tgz#29247c86d7ba901d7e5a13aa79a96723c3e59d0d" + integrity sha512-HrYdIFqdrnhDw0PqG/AKjAqEqM7AvxCz0DQ4h2W8k6nqmc5uRBYDag0SBxx9iYz5G8gnuNVLzUe13wl9eAsXXg== + dependencies: + "@remix-run/router" "1.21.0" + react-scripts@^5.0.0: version "5.0.1" resolved "https://registry.yarnpkg.com/react-scripts/-/react-scripts-5.0.1.tgz#6285dbd65a8ba6e49ca8d651ce30645a6d980003"