Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Feature/GitHub page #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"homepage": "http://ShehryarShoukat96.github.io/hangman/",
"name": "client",
"version": "0.1.0",
"private": true,
Expand All @@ -13,6 +14,7 @@
"@types/react-dom": "^16.9.8",
"@types/react-router-dom": "^5.1.5",
"@types/socket.io-client": "^1.4.33",
"gh-pages": "^3.1.0",
"node-sass": "^4.14.1",
"normalize.css": "^8.0.1",
"react": "^16.13.1",
Expand All @@ -27,7 +29,9 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
},
"eslintConfig": {
"extends": "react-app"
Expand Down
2 changes: 1 addition & 1 deletion client/src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ html, #root, .App {
body {
font-family: 'Lexend Zetta', sans-serif;
background-image: linear-gradient(270deg, rgba(0, 30, 41, 0.65), rgba(197, 0, 50, 0.56)),
url('/background.jpg'); /* Disclaimer: I do not own this image (Source: https://wallpaperaccess.com/cute-skull)*/
url('/hangman/background.jpg'); /* Disclaimer: I do not own this image (Source: https://wallpaperaccess.com/cute-skull)*/
background-repeat: no-repeat;
height: 100%;
@media (max-width: 480px) {
Expand Down
10 changes: 6 additions & 4 deletions client/src/components/hangman/game/game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import {
} from '@material-ui/core';

import {GameStyle} from './game.style';
import {getAlphabetMap, socket} from '../../../utils';
import {getAlphabetMap, getServerPrefix, socket} from '../../../utils';

const SERVER_PREFIX = getServerPrefix();

interface PropTypes {
classes: {
Expand Down Expand Up @@ -97,7 +99,7 @@ function Game({classes, match}: PropTypes) {
justify='center'
className={classes.main}>
<Grid item xs={12}>
<Link style={{textDecoration: 'none'}} to={'/'}>
<Link style={{textDecoration: 'none'}} to={`${SERVER_PREFIX}/`}>
<Button size={'large'} variant='outlined' className={classes.backButton}>
Go Back
</Button>
Expand All @@ -108,7 +110,7 @@ function Game({classes, match}: PropTypes) {
</Grid>
<Grid item xs={12} className={classes.word}>
<div className={classes.hangman}>
<img src={`/hangman-${tries}.png`} height={'180'} width={'150'} alt='Hangman not fount :('/>
<img src={`${SERVER_PREFIX}/hangman-${tries}.png`} height={'180'} width={'150'} alt='Hangman not fount :('/>
</div>
</Grid>
<Grid item xs={12} className={classes.word}>
Expand Down Expand Up @@ -142,7 +144,7 @@ function Game({classes, match}: PropTypes) {
<DialogActions className={classes.dialogActions}>
<Grid justify={'center'} container>
<Grid item md={7} xs={12}>
<Link style={{textDecoration: 'none'}} to={'/'}>
<Link style={{textDecoration: 'none'}} to={`${SERVER_PREFIX}/`}>
<Button size={'medium'}
variant='outlined'
className={classes.dialogActionsButtonDanger}>
Expand Down
6 changes: 4 additions & 2 deletions client/src/components/hangman/hangman.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ import {

import TitleScreen from "./title_screen";
import Game from "./game";
import {getServerPrefix} from "../../utils";

const SERVER_PREFIX = getServerPrefix();

function Hangman() {
return (
<Router>
<Switch>
<Route exact path="/game/:difficulty" component={Game} />
<Route exact path="/*">
<Route exact path={`${SERVER_PREFIX}/game/:difficulty`} component={Game} />
<Route exact path={`${SERVER_PREFIX}/*`}>
<TitleScreen/>
</Route>
</Switch>
Expand Down
14 changes: 9 additions & 5 deletions client/src/components/hangman/title_screen/title-screen.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import React from "react";
import {Button, Grid, withStyles} from "@material-ui/core";
import {TitleScreenStyle} from "./title-screen.style";
import {Link} from "react-router-dom";

import {TitleScreenStyle} from "./title-screen.style";
import {getServerPrefix} from "../../../utils";

const SERVER_PREFIX = getServerPrefix();

interface PropTypes {
classes: {
main: string,
Expand Down Expand Up @@ -32,22 +36,22 @@ function TitleScreen({classes}: PropTypes) {
<Grid item xs={12} className={classes.difficultyArea}>
<Grid container spacing={1} justify="center">
<Grid item sm={7} xs={10}>
<Link style={{textDecoration: 'none'}} to={'/game/easy'}>
<Link style={{textDecoration: 'none'}} to={`${SERVER_PREFIX}/game/easy`}>
<Button size={'large'} variant="outlined" className={classes.difficultyButton}>Easy</Button>
</Link>
</Grid>
<Grid item sm={7} xs={10}>
<Link style={{textDecoration: 'none'}} to={'/game/medium'}>
<Link style={{textDecoration: 'none'}} to={`${SERVER_PREFIX}/game/medium`}>
<Button size={'large'} variant="outlined" className={classes.difficultyButton}>Medium</Button>
</Link>
</Grid>
<Grid item sm={7} xs={10}>
<Link style={{textDecoration: 'none'}} to={'/game/hard'}>
<Link style={{textDecoration: 'none'}} to={`${SERVER_PREFIX}/game/hard`}>
<Button size={'large'} variant="outlined" className={classes.difficultyButton}>Hard</Button>
</Link>
</Grid>
<Grid item sm={7} xs={10}>
<Link style={{textDecoration: 'none'}} to={'/game/almost-impossible'}>
<Link style={{textDecoration: 'none'}} to={`${SERVER_PREFIX}/game/almost-impossible`}>
<Button size={'large'} variant="outlined" className={classes.difficultyButton}>Almost
Impossible</Button>
</Link>
Expand Down
3 changes: 3 additions & 0 deletions client/src/utils/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const getAlphabetMap = () => {
return alphabetMap;
};

const getServerPrefix =() => '/hangman';

export {
getAlphabetMap,
getServerPrefix,
}
5 changes: 3 additions & 2 deletions client/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import socket from './socket';
import {getAlphabetMap} from './common';
import {getAlphabetMap, getServerPrefix} from './common';

export {
socket,
getAlphabetMap
getAlphabetMap,
getServerPrefix
}
2 changes: 1 addition & 1 deletion client/src/utils/socket.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import socketIOClient from "socket.io-client";

const SOCKET_ENDPOINT = "http://localhost:3001";
const SOCKET_ENDPOINT = "https://hangman-server-1.herokuapp.com/";

const socket = socketIOClient(SOCKET_ENDPOINT);

Expand Down
75 changes: 71 additions & 4 deletions client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2346,7 +2346,7 @@ async-limiter@~1.0.0:
resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd"
integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==

async@^2.6.2:
async@^2.6.1, async@^2.6.2:
version "2.6.3"
resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff"
integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==
Expand Down Expand Up @@ -3268,7 +3268,7 @@ combined-stream@^1.0.6, combined-stream@~1.0.6:
dependencies:
delayed-stream "~1.0.0"

commander@^2.11.0, commander@^2.20.0:
commander@^2.11.0, commander@^2.18.0, commander@^2.20.0:
version "2.20.3"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
Expand Down Expand Up @@ -4200,6 +4200,11 @@ elliptic@^6.0.0, elliptic@^6.5.2:
minimalistic-assert "^1.0.0"
minimalistic-crypto-utils "^1.0.0"

email-addresses@^3.0.1:
version "3.1.0"
resolved "https://registry.yarnpkg.com/email-addresses/-/email-addresses-3.1.0.tgz#cabf7e085cbdb63008a70319a74e6136188812fb"
integrity sha512-k0/r7GrWVL32kZlGwfPNgB2Y/mMXVTq/decgLczm/j34whdaspNrZO8CnXPf1laaHxI6ptUlsnAxN+UAPw+fzg==

emoji-regex@^7.0.1, emoji-regex@^7.0.2:
version "7.0.3"
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156"
Expand Down Expand Up @@ -4849,6 +4854,28 @@ [email protected]:
resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd"
integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==

filename-reserved-regex@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/filename-reserved-regex/-/filename-reserved-regex-1.0.0.tgz#e61cf805f0de1c984567d0386dc5df50ee5af7e4"
integrity sha1-5hz4BfDeHJhFZ9A4bcXfUO5a9+Q=

filenamify-url@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/filenamify-url/-/filenamify-url-1.0.0.tgz#b32bd81319ef5863b73078bed50f46a4f7975f50"
integrity sha1-syvYExnvWGO3MHi+1Q9GpPeXX1A=
dependencies:
filenamify "^1.0.0"
humanize-url "^1.0.0"

filenamify@^1.0.0:
version "1.2.1"
resolved "https://registry.yarnpkg.com/filenamify/-/filenamify-1.2.1.tgz#a9f2ffd11c503bed300015029272378f1f1365a5"
integrity sha1-qfL/0RxQO+0wABUCknI3jx8TZaU=
dependencies:
filename-reserved-regex "^1.0.0"
strip-outer "^1.0.0"
trim-repeated "^1.0.0"

[email protected]:
version "6.0.1"
resolved "https://registry.yarnpkg.com/filesize/-/filesize-6.0.1.tgz#f850b509909c7c86f7e450ea19006c31c2ed3d2f"
Expand Down Expand Up @@ -4902,7 +4929,7 @@ find-cache-dir@^2.1.0:
make-dir "^2.0.0"
pkg-dir "^3.0.0"

find-cache-dir@^3.2.0:
find-cache-dir@^3.2.0, find-cache-dir@^3.3.1:
version "3.3.1"
resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-3.3.1.tgz#89b33fad4a4670daa94f855f7fbe31d6d84fe880"
integrity sha512-t2GDMt3oGC/v+BMwzmllWDuJF/xcDtE5j/fCGbqDD7OLuJkj0cfh1YSA5VKPvwMeLFLNDBkwOKZ2X85jGLVftQ==
Expand Down Expand Up @@ -5195,6 +5222,19 @@ getpass@^0.1.1:
dependencies:
assert-plus "^1.0.0"

gh-pages@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/gh-pages/-/gh-pages-3.1.0.tgz#ec3ed0f6a6e3fc3d888758fa018f08191c96bd55"
integrity sha512-3b1rly9kuf3/dXsT8+ZxP0UhNLOo1CItj+3e31yUVcaph/yDsJ9RzD7JOw5o5zpBTJVQLlJAASNkUfepi9fe2w==
dependencies:
async "^2.6.1"
commander "^2.18.0"
email-addresses "^3.0.1"
filenamify-url "^1.0.0"
find-cache-dir "^3.3.1"
fs-extra "^8.1.0"
globby "^6.1.0"

glob-parent@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae"
Expand Down Expand Up @@ -5620,6 +5660,14 @@ https-browserify@^1.0.0:
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73"
integrity sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=

humanize-url@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/humanize-url/-/humanize-url-1.0.1.tgz#f4ab99e0d288174ca4e1e50407c55fbae464efff"
integrity sha1-9KuZ4NKIF0yk4eUEB8VfuuRk7/8=
dependencies:
normalize-url "^1.0.0"
strip-url-auth "^1.0.0"

hyphenate-style-name@^1.0.3:
version "1.0.4"
resolved "https://registry.yarnpkg.com/hyphenate-style-name/-/hyphenate-style-name-1.0.4.tgz#691879af8e220aea5750e8827db4ef62a54e361d"
Expand Down Expand Up @@ -7725,7 +7773,7 @@ normalize-range@^0.1.2:
resolved "https://registry.yarnpkg.com/normalize-range/-/normalize-range-0.1.2.tgz#2d10c06bdfd312ea9777695a4d28439456b75942"
integrity sha1-LRDAa9/TEuqXd2laTShDlFa3WUI=

[email protected]:
[email protected], normalize-url@^1.0.0:
version "1.9.1"
resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-1.9.1.tgz#2cc0d66b31ea23036458436e3620d85954c66c3c"
integrity sha1-LMDWazHqIwNkWENuNiDYWVTGbDw=
Expand Down Expand Up @@ -10751,6 +10799,18 @@ strip-json-comments@^3.0.1:
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006"
integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==

strip-outer@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/strip-outer/-/strip-outer-1.0.1.tgz#b2fd2abf6604b9d1e6013057195df836b8a9d631"
integrity sha512-k55yxKHwaXnpYGsOzg4Vl8+tDrWylxDEpknGjhTiZB8dFRU5rTo9CAzeycivxV3s+zlTKwrs6WxMxR95n26kwg==
dependencies:
escape-string-regexp "^1.0.2"

strip-url-auth@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/strip-url-auth/-/strip-url-auth-1.0.1.tgz#22b0fa3a41385b33be3f331551bbb837fa0cd7ae"
integrity sha1-IrD6OkE4WzO+PzMVUbu4N/oM164=

[email protected]:
version "0.23.1"
resolved "https://registry.yarnpkg.com/style-loader/-/style-loader-0.23.1.tgz#cb9154606f3e771ab6c4ab637026a1049174d925"
Expand Down Expand Up @@ -11030,6 +11090,13 @@ trim-newlines@^1.0.0:
resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613"
integrity sha1-WIeWa7WCpFA6QetST301ARgVphM=

trim-repeated@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/trim-repeated/-/trim-repeated-1.0.0.tgz#e3646a2ea4e891312bf7eace6cfb05380bc01c21"
integrity sha1-42RqLqTokTEr9+rObPsFOAvAHCE=
dependencies:
escape-string-regexp "^1.0.2"

"true-case-path@^1.0.2":
version "1.0.3"
resolved "https://registry.yarnpkg.com/true-case-path/-/true-case-path-1.0.3.tgz#f813b5a8c86b40da59606722b144e3225799f47d"
Expand Down