Skip to content

Commit

Permalink
Merge pull request #20 from edumudu/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
edumudu authored Jul 13, 2020
2 parents 9ed8d96 + ed26da3 commit b4b67e7
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 10 deletions.
1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"html-webpack-plugin": "^3.2.0",
"socket.io-client": "^2.3.0",
"style-loader": "^0.23.1",
"svg-inline-loader": "^0.8.2",
"webpack": "^4.29.3",
"webpack-cli": "^3.2.3",
"webpack-dev-server": "^3.1.14"
Expand Down
14 changes: 14 additions & 0 deletions client/src/assets/svgs/loader.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion client/src/js/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ class Modal {
this.hide();
}

show() {
show(bg = 'rgba(0,0,0,0.7)') {
this.#visible = true;
this.#overlay.style.display = 'flex';
this.#overlay.style.backgroundColor = bg
}

hide() {
Expand Down
14 changes: 9 additions & 5 deletions client/src/js/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import '../scss/app.scss';
import loaderSvg from '../assets/svgs/loader.svg';
import '@fortawesome/fontawesome-free/js/all';
import Board from './Game/Board';
import Modal from './Modal';
Expand All @@ -13,23 +14,25 @@ let room;

menu.setAction('<i class="fas fa-play"></i>', () => {
socket.emit('room');
menu.setTitle('Waiting for other player')
menu.setTitle('Waiting for other player');
menu.setContent(loaderSvg);
menu.disableAction(0);
});
menu.show();

menu.show('black');

modal.setAction('<i class="fas fa-undo-alt"></i>', () => {
socket.emit('room', room);
modal.hide();
menu.show();
menu.show('black');
game.destroy();
}, 'success', 'Rematch');

modal.setAction('<i class="fas fa-play"></i>', () => {
socket.emit('player-left');
socket.emit('room');
modal.hide();
menu.show();
menu.show('black');
game.destroy();
}, '', 'New game');

Expand All @@ -38,13 +41,14 @@ socket.on('start-game', (board, playerRoom) => {
game = new Board(el, board, socket.id);
game.setPlayerTurn(board.playerOfTheTime);
menu.hide();
menu.setContent('');

socket.on('enemy-left', () => {
game.destroy();
modal.hide();
menu.setTitle('Enemy left the room');
menu.enableAction(0);
menu.show();
menu.show('black');
})

socket.on('check', ids => {
Expand Down
19 changes: 19 additions & 0 deletions client/src/scss/geral.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ body {
font-family: 'Nunito', sans-serif;
color: #ebebeb;
background-color: $bg-color;

display: grid;
grid-template-rows: $game_info_height auto;
}

a {
Expand All @@ -25,6 +28,22 @@ a {
justify-content: center;
perspective: 1000px;
padding: 30px 30px 0;
height: calc(100vh - #{$game_info_height});
overflow-y: auto;

// For mozila
scrollbar-width: thin;
scrollbar-color: rgba(255, 255, 255, 0.5) transparent;

&::-webkit-scrollbar {
background-color: transparent;
width: 3px;
}

&::-webkit-scrollbar-thumb {
border-radius: 5px;
background-color: rgba(255, 255, 255, 0.5);
}
}

.card {
Expand Down
3 changes: 1 addition & 2 deletions client/src/scss/modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
align-items: center;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.7);

.modal {
padding: 20px 30px;
Expand All @@ -18,7 +17,7 @@

.title {
color: #fff;
font-size: 4rem;
font-size: clamp(2rem, 10vw, 4rem);
text-align: center;
}

Expand Down
5 changes: 4 additions & 1 deletion client/src/scss/scoreboard.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#game-info {
position: relative;
z-index: 1;
display: flex;
justify-content: space-between;
align-items: center;
padding: 30px 80px 0;
padding: 30px 80px 30px;
box-shadow: 0 0 4px #fff;

#restart-button {
display: none;
Expand Down
4 changes: 3 additions & 1 deletion client/src/scss/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ $card-bg: #0b0b0b;
$green: #1ddf16;
$success: #00b894;
$danger: #d63031;
$info: #3498db;
$info: #3498db;

$game_info_height: 134px;
5 changes: 5 additions & 0 deletions client/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ module.exports = {
test: /\.(wav|mp3)$/,
use: ['file-loader']
},
{
exclude: /node_modules/,
test: /\.svg$/,
loader: 'svg-inline-loader'
}
]
},
output: {
Expand Down

0 comments on commit b4b67e7

Please sign in to comment.