Skip to content

Commit

Permalink
MNG-88_StartButtonActivation (#12)
Browse files Browse the repository at this point in the history
* Add keyup to input

* Add activateStart.ts

* Uncomment html

* Add class to activate/disable start button

* Add activateStartButton function

* Change class name to button-enabled
  • Loading branch information
mariusz-sm authored Feb 7, 2021
1 parent 2d25dbd commit b8f5490
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 239 deletions.
2 changes: 2 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<div id="start-game-border">
<div id="start-game-bg1">
<div id="start-game-bg2">
<div id="start-game-button">
<div id="start-game-button" class="button-disabled">
Start
</div>
</div>
Expand Down
7 changes: 7 additions & 0 deletions src/activateStart.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const activateStart = (name1Input: HTMLInputElement, name2Input: HTMLInputElement, startButton: HTMLDivElement) => {
if (name1Input.value.length > 0 && name2Input.value.length > 0) {
startButton.className = 'button-enabled'
} else {
startButton.className = 'button-disabled'
}
}
15 changes: 15 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { showModal, hideModal } from "./modalPopUpFunctions";
import { activateStart } from './activateStart';

const renderStartingPage = (appDiv: HTMLDivElement) => {
const startingPage = document.querySelector(
Expand All @@ -24,11 +25,25 @@ const createHowToPlayButton = () => {
});
hideModal(infoModal);
};
const activateStartButton = () => {
const player1NameInput = document.querySelector('#enter-player1-name') as HTMLInputElement;
const player2NameInput = document.querySelector('#enter-player2-name') as HTMLInputElement;
const startButton = document.querySelector("#start-game-button") as HTMLDivElement;
player1NameInput.addEventListener("keyup", () => {
activateStart(player1NameInput, player2NameInput, startButton)
})
player2NameInput.addEventListener("keyup", () => {
activateStart(player1NameInput, player2NameInput, startButton)
})
};

const renderApp = () => {
const app = document.querySelector("#app") as HTMLDivElement;
renderStartingPage(app);
renderHowToPlayModal(app);
activateStartButton();
createHowToPlayButton();

};

setTimeout(renderApp, 2000);
16 changes: 11 additions & 5 deletions styles/SASS/_start-view.scss
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,28 @@
#start-game-button {
@include centerpokeball;
@include boxshadow;
background-color: $color-primary;
width: 110px;
height: 110px;
text-align: center;
font-family: 'Pokemon Solid';
font-size: 1em;
color: $color-primary;
padding-top: 15%;

&:hover {
background-color: $color-bg;
color: $color-text;

@include dropshadow
}

}

.button-enabled {
background-color: $color-bg;
color: $color-text;
}

.button-disabled {
background-color: $color-primary;
color: $color-primary;
}
}
}
}
Expand Down
Loading

0 comments on commit b8f5490

Please sign in to comment.