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

MNG-88_StartButtonActivation #12

Merged
merged 7 commits into from
Feb 7, 2021
Merged
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
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';
mariusz-sm marked this conversation as resolved.
Show resolved Hide resolved

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