├── .editorconfig
├── .gitignore
├── .husky
├── .gitignore
└── pre-commit
├── .prettierrc.json
├── LICENSE
├── README.md
├── docs
└── demo.gif
├── package-lock.json
├── package.json
├── public
├── assets
│ └── img
│ │ └── github.svg
├── favicon.ico
├── icon-128x128.png
├── icon-144x144.png
├── icon-152x152.png
├── icon-192x192.png
├── icon-384x384.png
├── icon-512x512.png
├── icon-72x72.png
├── icon-96x96.png
├── index.html
├── manifest.json
└── robots.txt
├── src
├── components
│ ├── App
│ │ ├── index.tsx
│ │ └── style.module.css
│ ├── Field
│ │ ├── index.tsx
│ │ └── style.module.css
│ ├── Game
│ │ ├── index.tsx
│ │ └── style.module.css
│ ├── Panel
│ │ ├── index.tsx
│ │ └── style.module.css
│ ├── Settings
│ │ ├── index.tsx
│ │ └── style.module.css
│ └── Statistics
│ │ ├── index.tsx
│ │ └── style.module.css
├── hooks
│ ├── useGame.ts
│ ├── useGameController.ts
│ ├── useInterval.ts
│ └── useSettings.ts
├── index.tsx
├── react-app-env.d.ts
├── styles
│ ├── colors.css
│ ├── main.css
│ └── vendor
│ │ └── reset.css
├── types.ts
└── utils
│ └── helpers.ts
└── tsconfig.json
/.editorconfig:
--------------------------------------------------------------------------------
1 | # editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | charset = utf-8
9 | trim_trailing_whitespace = true
10 | insert_final_newline = true
11 |
12 | [*.md]
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
25 | # misc
26 | *.pem
27 |
28 | # local env files
29 | .env
30 |
31 | # vercel
32 | .vercel
33 |
34 | # Logs
35 | logs
36 | *.log
37 |
38 | # Runtime data
39 | pids
40 | *.pid
41 | *.seed
42 | *.pid.lock
43 |
44 | # Directory for instrumented libs generated by jscoverage/JSCover
45 | lib-cov
46 |
47 | # Coverage directory used by tools like istanbul
48 | coverage
49 |
50 | # nyc test coverage
51 | .nyc_output
52 |
53 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
54 | .grunt
55 |
56 | # Bower dependency directory (https://bower.io/)
57 | bower_components
58 |
59 | # node-waf configuration
60 | .lock-wscript
61 |
62 | # Compiled binary addons (https://nodejs.org/api/addons.html)
63 | build/Release
64 |
65 | # Dependency directories
66 | node_modules/
67 | jspm_packages/
68 |
69 | # TypeScript v1 declaration files
70 | typings/
71 |
72 | # Optional npm cache directory
73 | .npm
74 |
75 | # Optional eslint cache
76 | .eslintcache
77 |
78 | # Optional REPL history
79 | .node_repl_history
80 |
81 | # Output of 'npm pack'
82 | *.tgz
83 |
84 | # Yarn Integrity file
85 | .yarn-integrity
86 |
87 | # JetBrains IDEs
88 | .idea
89 |
--------------------------------------------------------------------------------
/.husky/.gitignore:
--------------------------------------------------------------------------------
1 | _
2 |
--------------------------------------------------------------------------------
/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . "$(dirname "$0")/_/husky.sh"
3 |
4 | npx lint-staged
5 |
--------------------------------------------------------------------------------
/.prettierrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 120,
3 | "singleQuote": true,
4 | "trailingComma": "all",
5 | "jsxBracketSameLine": true,
6 | "bracketSpacing": false,
7 | "tabWidth": 2,
8 | "semi": true
9 | }
10 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Igor Sebelev
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Minesweeper React Typescript Game
2 |
3 | Legendary game written in React with Hooks and Typescript
4 |
5 | 
6 |
7 | ## Demo
8 | See demo [here](https://minesweeper-react-typescript.vercel.app/)
9 |
10 | ## How to play
11 | - Mines are scattered throughout a board, which is divided into fields.
12 | - Fields have three states: uncovered, covered and flagged.
13 | - A covered field is blank and clickable, while an uncovered field is exposed.
14 | - Flagged fields indicate a potential mine location. The number of flags is equal to the number of bombs on the board.
15 | - A left click uncovers a field. If you uncover a mined field, the game ends.
16 | - Otherwise, the uncovered field displays either a number, indicating the number of mines diagonally and/or adjacent to it, or an empty field, and all adjacent non-mined fields will automatically be uncovered.
17 | - Right-clicking on a field will flag it, causing a flag to appear on it. Flagged fields are still considered covered, and you can't click on them to uncover them. They must first be unflagged with an additional right-click.
18 | - The first click in any game will never be a mine.
19 | - To win the game, you must uncover all non-mine fields, at which point, the timer is stopped.
20 | - Flagging all the mined fields is not required.
21 |
22 | ## What’s Inside?
23 | - Project based on [create-react-app with TypeScript](https://create-react-app.dev/docs/adding-typescript/)
24 | - `tsconfig.json` is in strict mode
25 | - No implicit and explicit `any`, only static types, only hardcore :)
26 | - Written entirely with hooks
27 | - Loops optimizations and components memoization for preventing unnecessary renders
28 | - Formatted with Prettier
29 | - Precommit Husky hooks and lint-staged
30 |
31 | ## Available Scripts
32 |
33 | In the project directory, you can run:
34 |
35 | ### `npm start`
36 |
37 | Runs the app in the development mode.\
38 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
39 |
40 | The page will reload if you make edits.\
41 | You will also see any lint errors in the console.
42 |
43 | ### `npm test`
44 |
45 | Launches the test runner in the interactive watch mode.\
46 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
47 |
48 | ### `npm run build`
49 |
50 | Builds the app for production to the `build` folder.\
51 | It correctly bundles React in production mode and optimizes the build for the best performance.
52 |
53 | The build is minified and the filenames include the hashes.\
54 | Your app is ready to be deployed!
55 |
56 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
57 |
58 | ### `npm run eject`
59 |
60 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
61 |
62 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
63 |
64 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
65 |
66 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
67 |
68 | ## Maintainers
69 | [Igor Sebelev](https://github.com/adlite)
70 |
71 | ## License
72 | MIT
73 |
--------------------------------------------------------------------------------
/docs/demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adlite/minesweeper-react-typescript/1bc4d02416f2f13a489ace21ab2e1cc185baf487/docs/demo.gif
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "minesweeper-react-typescript",
3 | "version": "1.1.2",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^5.14.1",
7 | "@testing-library/react": "^11.2.7",
8 | "@testing-library/user-event": "^12.8.3",
9 | "@types/jest": "^26.0.24",
10 | "@types/node": "^12.20.25",
11 | "@types/react": "^17.0.21",
12 | "@types/react-dom": "^17.0.9",
13 | "classnames": "^2.3.1",
14 | "react": "^17.0.2",
15 | "react-dom": "^17.0.2",
16 | "react-scripts": "4.0.3",
17 | "typescript": "^4.4.3",
18 | "web-vitals": "^1.1.2"
19 | },
20 | "scripts": {
21 | "app:start": "react-scripts start",
22 | "app:build": "react-scripts build",
23 | "app:test": "react-scripts test",
24 | "app:eject": "react-scripts eject",
25 | "prettier:inspect": "prettier --check \"./**/*.{js,jsx,ts,tsx,json,css}\" --ignore-path .gitignore",
26 | "prettier:fix": "prettier --write \"./**/*.{js,jsx,ts,tsx,json,css}\" --ignore-path .gitignore",
27 | "eslint:inspect": "eslint \"./**/*.{js,jsx,ts,tsx}\" --ignore-path .gitignore .",
28 | "eslint:fix": "npm run eslint:inspect -- --fix",
29 | "linters:fix": "npm-run-all -p prettier:fix eslint:fix",
30 | "prepare": "husky install"
31 | },
32 | "eslintConfig": {
33 | "extends": [
34 | "react-app",
35 | "react-app/jest"
36 | ]
37 | },
38 | "browserslist": {
39 | "production": [
40 | ">0.2%",
41 | "not dead",
42 | "not op_mini all"
43 | ],
44 | "development": [
45 | "last 1 chrome version",
46 | "last 1 firefox version",
47 | "last 1 safari version"
48 | ]
49 | },
50 | "devDependencies": {
51 | "husky": "^7.0.2",
52 | "lint-staged": "^11.1.2",
53 | "npm-run-all": "^4.1.5",
54 | "prettier": "^2.4.1"
55 | },
56 | "lint-staged": {
57 | "*.{js,jsx,ts,tsx,json,css}": "prettier --write --ignore-path .gitignore",
58 | "*.{js,jsx,ts,tsx}": "eslint --ignore-path .gitignore --fix"
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/public/assets/img/github.svg:
--------------------------------------------------------------------------------
1 |
2 |
8 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adlite/minesweeper-react-typescript/1bc4d02416f2f13a489ace21ab2e1cc185baf487/public/favicon.ico
--------------------------------------------------------------------------------
/public/icon-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adlite/minesweeper-react-typescript/1bc4d02416f2f13a489ace21ab2e1cc185baf487/public/icon-128x128.png
--------------------------------------------------------------------------------
/public/icon-144x144.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adlite/minesweeper-react-typescript/1bc4d02416f2f13a489ace21ab2e1cc185baf487/public/icon-144x144.png
--------------------------------------------------------------------------------
/public/icon-152x152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adlite/minesweeper-react-typescript/1bc4d02416f2f13a489ace21ab2e1cc185baf487/public/icon-152x152.png
--------------------------------------------------------------------------------
/public/icon-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adlite/minesweeper-react-typescript/1bc4d02416f2f13a489ace21ab2e1cc185baf487/public/icon-192x192.png
--------------------------------------------------------------------------------
/public/icon-384x384.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adlite/minesweeper-react-typescript/1bc4d02416f2f13a489ace21ab2e1cc185baf487/public/icon-384x384.png
--------------------------------------------------------------------------------
/public/icon-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adlite/minesweeper-react-typescript/1bc4d02416f2f13a489ace21ab2e1cc185baf487/public/icon-512x512.png
--------------------------------------------------------------------------------
/public/icon-72x72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adlite/minesweeper-react-typescript/1bc4d02416f2f13a489ace21ab2e1cc185baf487/public/icon-72x72.png
--------------------------------------------------------------------------------
/public/icon-96x96.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adlite/minesweeper-react-typescript/1bc4d02416f2f13a489ace21ab2e1cc185baf487/public/icon-96x96.png
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |