Skip to content

Commit 2d695b2

Browse files
committed
Init Twodoku
0 parents  commit 2d695b2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+30964
-0
lines changed

ClientApp/.gitignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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*

ClientApp/.vscode/settings.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"javascript.updateImportsOnFileMove.enabled": "always",
3+
"javascript.preferences.importModuleSpecifier": "non-relative"
4+
}

ClientApp/craco.config.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
style: {
3+
postcss: {
4+
plugins: [require("tailwindcss"), require("autoprefixer")],
5+
},
6+
},
7+
};

ClientApp/jsconfig.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": "src"
4+
},
5+
"include": ["src"]
6+
}

ClientApp/package-lock.json

+15,748
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ClientApp/package.json

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"name": "twodoku",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"@craco/craco": "^6.1.1",
7+
"@testing-library/jest-dom": "^5.11.4",
8+
"@testing-library/react": "^11.1.0",
9+
"@testing-library/user-event": "^12.1.10",
10+
"classnames": "^2.3.1",
11+
"concurrently": "^6.0.2",
12+
"lodash": "^4.17.21",
13+
"moment": "^2.29.1",
14+
"react": "^17.0.2",
15+
"react-dom": "^17.0.2",
16+
"react-router-dom": "^5.2.0",
17+
"react-scripts": "4.0.3",
18+
"semantic-ui-css": "^2.4.1",
19+
"semantic-ui-react": "^2.0.3",
20+
"socket.io-client": "^4.0.1",
21+
"uuid": "^8.3.2",
22+
"web-vitals": "^1.0.1"
23+
},
24+
"scripts": {
25+
"start": "craco start",
26+
"build": "craco build",
27+
"test": "craco test",
28+
"server-start": "concurrently \"node ../Server/src/index.js\" \"yarn start\"",
29+
"eject": "react-scripts eject"
30+
},
31+
"eslintConfig": {
32+
"extends": [
33+
"react-app",
34+
"react-app/jest"
35+
]
36+
},
37+
"browserslist": {
38+
"production": [
39+
">0.2%",
40+
"not dead",
41+
"not op_mini all"
42+
],
43+
"development": [
44+
"last 1 chrome version",
45+
"last 1 firefox version",
46+
"last 1 safari version"
47+
]
48+
},
49+
"devDependencies": {
50+
"@tailwindcss/postcss7-compat": "^2.1.0",
51+
"autoprefixer": "^9.8.6",
52+
"postcss": "^7.0.35",
53+
"tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.1.0"
54+
}
55+
}

ClientApp/prettierrc.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"trailingComma": "es5",
3+
"tabWidth": 4,
4+
"semi": true,
5+
"singleQuote": true
6+
}

ClientApp/public/favicon.ico

15 KB
Binary file not shown.

ClientApp/public/index.html

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8" />
6+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1" />
8+
<meta name="theme-color" content="#000000" />
9+
<meta name="description" content="Web site created using create-react-app" />
10+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
11+
<!--
12+
manifest.json provides metadata used when your web app is installed on a
13+
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
14+
-->
15+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
16+
<!--
17+
Notice the use of %PUBLIC_URL% in the tags above.
18+
It will be replaced with the URL of the `public` folder during the build.
19+
Only files inside the `public` folder can be referenced from the HTML.
20+
21+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
22+
work correctly both with client-side routing and a non-root public URL.
23+
Learn how to configure a non-root public URL by running `npm run build`.
24+
-->
25+
<title>Twodoku</title>
26+
</head>
27+
28+
<body>
29+
<noscript>You need to enable JavaScript to run this app.</noscript>
30+
<div id="root"></div>
31+
<!--
32+
This HTML file is a template.
33+
If you open it directly in the browser, you will see an empty page.
34+
35+
You can add webfonts, meta tags, or analytics to this file.
36+
The build step will place the bundled scripts into the <body> tag.
37+
38+
To begin the development, run `npm start` or `yarn start`.
39+
To create a production bundle, use `npm run build` or `yarn build`.
40+
-->
41+
</body>
42+
43+
</html>

ClientApp/public/logo192.png

5.22 KB
Loading

ClientApp/public/logo512.png

9.44 KB
Loading

ClientApp/public/manifest.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"short_name": "React App",
3+
"name": "Create React App Sample",
4+
"icons": [
5+
{
6+
"src": "favicon.ico",
7+
"sizes": "64x64 32x32 24x24 16x16",
8+
"type": "image/x-icon"
9+
},
10+
{
11+
"src": "logo192.png",
12+
"type": "image/png",
13+
"sizes": "192x192"
14+
},
15+
{
16+
"src": "logo512.png",
17+
"type": "image/png",
18+
"sizes": "512x512"
19+
}
20+
],
21+
"start_url": ".",
22+
"display": "standalone",
23+
"theme_color": "#000000",
24+
"background_color": "#ffffff"
25+
}

ClientApp/public/robots.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# https://www.robotstxt.org/robotstxt.html
2+
User-agent: *
3+
Disallow:
Loading
14.6 KB
Loading
20.6 KB
Loading

ClientApp/src/components/App.js

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import React, { useState } from 'react';
2+
import classnames from 'classnames';
3+
import { Container, Menu } from 'semantic-ui-react';
4+
import { BrowserRouter as Router, Switch, Route, Link } from 'react-router-dom';
5+
import Introduction from './Home/Home';
6+
import ROUTES from 'constants/routes';
7+
import Twodoku from './Sudoku/Twodoku';
8+
9+
const TabsMetadata = [{ label: 'Home', route: ROUTES.HOME }];
10+
const tabStyles = 'font-sans text-2xl font-light';
11+
const activeTabStyles = 'font-sans text-3xl font-normal';
12+
const App = () => {
13+
const [activeTab, setActiveTab] = useState(ROUTES.HOME);
14+
const handleItemClick = (e, { name }) => setActiveTab(name);
15+
16+
return (
17+
<Router>
18+
<Container>
19+
<Menu pointing secondary>
20+
{TabsMetadata.map(({ label, route }, idx) => (
21+
<Link to={`/${route}`} key={`tab_${idx}`}>
22+
<Menu.Item
23+
name={route}
24+
active={activeTab === route}
25+
onClick={handleItemClick}
26+
>
27+
<span
28+
className={classnames(tabStyles, {
29+
[activeTabStyles]: activeTab === route,
30+
})}
31+
>
32+
{label}
33+
</span>
34+
</Menu.Item>
35+
</Link>
36+
))}
37+
</Menu>
38+
39+
<Switch>
40+
<Route path={`/${ROUTES.GAME}/:gameId`}>
41+
<Twodoku />
42+
</Route>
43+
<Route path="/" exact>
44+
<Introduction />
45+
</Route>
46+
</Switch>
47+
</Container>
48+
</Router>
49+
);
50+
};
51+
52+
export default App;

ClientApp/src/components/App.test.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { render, screen } from "@testing-library/react";
2+
import App from "./App";
3+
4+
test("renders learn react link", () => {
5+
render(<App />);
6+
const linkElement = screen.getByText(/learn react/i);
7+
expect(linkElement).toBeInTheDocument();
8+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from 'react';
2+
import { Dimmer, Loader } from 'semantic-ui-react';
3+
4+
const LoadingOverlay = ({ text, size }) => {
5+
return (
6+
<Dimmer active inverted>
7+
<Loader size={size} inverted>
8+
{text}
9+
</Loader>
10+
</Dimmer>
11+
);
12+
};
13+
LoadingOverlay.defaultProps = {
14+
text: 'Loading',
15+
size: 'medium',
16+
};
17+
export default LoadingOverlay;

ClientApp/src/components/Home/Home.js

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import React, { useState } from 'react';
2+
import {
3+
Button,
4+
Card,
5+
Container,
6+
Divider,
7+
Image,
8+
Message,
9+
} from 'semantic-ui-react';
10+
import SudokuBaseEx from 'assets/sudoku_example.jpg';
11+
import SudokuSolutionEx from 'assets/sudoku_example_1.jpg';
12+
import InvitationPopup from './InvitationPopup';
13+
import { v4 as uuidv4 } from 'uuid';
14+
import { useHistory } from 'react-router';
15+
import { useUserContext } from 'contexts/WithUserProfile';
16+
17+
const Introduction = () => {
18+
const [showModal, setShowModal] = useState(false);
19+
const history = useHistory();
20+
const [, , setUserName] = useUserContext();
21+
const sessionID = uuidv4();
22+
const initiateGame = (userId) => {
23+
setUserName(userId);
24+
history.push(`start/${sessionID}`);
25+
};
26+
return (
27+
<Container>
28+
<Message size="big">
29+
<Message.Header>
30+
<div className="flex justify-between">
31+
<span className="text-3xl">Rules of Twodoku</span>
32+
<Button primary size="large" onClick={() => setShowModal(true)}>
33+
Start Game
34+
</Button>
35+
</div>
36+
</Message.Header>
37+
<Divider />
38+
<p>
39+
It's like Sudoku, but two people work together to solve a single
40+
puzzle!
41+
</p>
42+
<p>
43+
Sudoku is a number puzzle game played using 81 squares laid out on a
44+
9×9 grid. The grid is further broken down into 9 3×3 boxes. When you
45+
start a sudoku puzzle, some of the numbers will have already been
46+
placed. All you have to do is fill in the missing numbers by following
47+
some simple rules:
48+
</p>
49+
<div className="pl-20">
50+
<ol className="list-decimal">
51+
<li>
52+
Every box must contain each number 1-9. The boxes are 3×3 grids
53+
and their outlines are marked with thicker line.
54+
</li>
55+
<li>Every row must contain each number 1-9</li>
56+
<li>Every column must contain each number 1-9</li>
57+
</ol>
58+
</div>
59+
60+
<p>
61+
Each sudoku board has only one solution, which means that each square
62+
has only one possible correct number. This allows you to use logic to
63+
find the correct number to place in each square. You can find the
64+
correct number to write either by eliminating every other number as a
65+
possibility or by eliminating that number as a possibility in that
66+
square’s shared row, column, or box.
67+
</p>
68+
<p>When you start a puzzle, it will look like something this:</p>
69+
<Card centered>
70+
<Image src={SudokuBaseEx} />
71+
<Card.Content>
72+
<Card.Description className="text-center">
73+
Some of the squares have values, your job is to fill in the blank
74+
squares.
75+
</Card.Description>
76+
</Card.Content>
77+
</Card>
78+
79+
<p>When solved, the puzzle will look like this:</p>
80+
<Card centered>
81+
<Image src={SudokuSolutionEx} />
82+
<Card.Content>
83+
<Card.Description className="text-center">
84+
Notice how every row, column, and box contains every number 1-9.
85+
</Card.Description>
86+
</Card.Content>
87+
</Card>
88+
<p>
89+
Sudoku instructions were written by{' '}
90+
<a href="http://www.sudokubeginner.com/rules-of-sudoku/">
91+
sudokubeginner.com
92+
</a>
93+
</p>
94+
</Message>
95+
<InvitationPopup
96+
open={showModal}
97+
onClose={() => setShowModal(false)}
98+
onStart={initiateGame}
99+
uuid={sessionID}
100+
/>
101+
</Container>
102+
);
103+
};
104+
export default Introduction;

0 commit comments

Comments
 (0)