diff --git a/package-lock.json b/package-lock.json index d4acebb..69f74e7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,8 @@ "dependencies": { "react": "^18.0.0", "react-dom": "^18.0.0", - "react-scripts": "^5.0.0" + "react-scripts": "^5.0.0", + "react-switch": "^7.0.0" }, "devDependencies": {} }, @@ -14072,6 +14073,18 @@ } } }, + "node_modules/react-switch": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/react-switch/-/react-switch-7.0.0.tgz", + "integrity": "sha512-KkDeW+cozZXI6knDPyUt3KBN1rmhoVYgAdCJqAh7st7tk8YE6N0iR89zjCWO8T8dUTeJGTR0KU+5CHCRMRffiA==", + "dependencies": { + "prop-types": "^15.7.2" + }, + "peerDependencies": { + "react": "^15.3.0 || ^16.0.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^15.3.0 || ^16.0.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/read-cache": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", @@ -15953,16 +15966,16 @@ } }, "node_modules/typescript": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", - "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=14.17" + "node": ">=4.2.0" } }, "node_modules/unbox-primitive": { diff --git a/package.json b/package.json index 2c033c3..a686f46 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,10 @@ "dependencies": { "react": "^18.0.0", "react-dom": "^18.0.0", - "react-scripts": "^5.0.0" + "react-scripts": "^5.0.0", + "react-switch": "^7.0.0" }, "main": "/index.js", - "devDependencies": {}, "name": "vy6j3f", "description": null, "version": "0.0.0", diff --git a/src/App.js b/src/App.js index d1b7ac9..0ffbb3f 100644 --- a/src/App.js +++ b/src/App.js @@ -1,4 +1,6 @@ import { useState } from "react"; +import ReactSwitch from "react-switch"; + function Square({ value, onSquareClick }) { return ( @@ -57,6 +59,11 @@ export default function Game() { const [currentMove, setCurrentMove] = useState(0); const xIsNext = currentMove % 2 === 0; const currentSquares = history[currentMove]; + const [theme, setTheme] = useState("dark"); + + const toggleTheme = () => { + setTheme((curr) => (curr === "light" ? "dark" : "light")); + }; function handlePlay(nextSquares) { const nextHistory = [...history.slice(0, currentMove + 1), nextSquares]; @@ -85,7 +92,9 @@ export default function Game() { }); return ( -