Skip to content

Commit

Permalink
Merge pull request #79 from skwirowski/32-fixing-modal
Browse files Browse the repository at this point in the history
[#32] Fixing Modal (#79)
  • Loading branch information
Dominik Smutek authored Jan 17, 2021
2 parents 00eb18b + f36c23e commit 671b07a
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 12 deletions.
4 changes: 0 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
rel="stylesheet">
</head>
<body>

<div id="swquiz-app" class="swquiz-app">
<div class="swquiz-row" id="swquiz-header">
<a href="/index.html">
Expand All @@ -22,9 +21,6 @@

</div>
</div>



<script src="src/index.js"></script>
</body>
</html>
8 changes: 7 additions & 1 deletion src/app/components/modalGameOver.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ const createButton = (parent, answers) => {
let activeTarget = getGameMode()
const inputName = document.querySelector('#name')
saveScore(activeTarget, inputName.value, correctPlayersAnswersCount, answers.length)
const appContainer = document.querySelector('#swquiz-app');
appContainer.classList.remove('modal-overlay');
})
return btn;
};
Expand Down Expand Up @@ -175,12 +177,16 @@ const modalGameOver = (parent, playerAnswers, computerAnswers, callback) => {
const modal = document.createElement('section');
modal.classList.add('swquiz-modal');
modal.setAttribute('data-testid', 'gameOverModal');

if (modal) {
const appContainer = document.querySelector('#swquiz-app');
appContainer.classList.add('modal-overlay');
}
parent.appendChild(modal);
createHeader(modal, 'Game Over');
createSummaryP(modal, playerAnswers, computerAnswers);
mergeAndDisplayMiddleSection(modal, playerAnswers, computerAnswers);
mergeAndDisplayBottomSection(modal, callback, playerAnswers);

};

export { modalGameOver };
2 changes: 1 addition & 1 deletion styles/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ body {
background-repeat: no-repeat;
background-size: cover;
background-position: center;
}
}
8 changes: 4 additions & 4 deletions styles/components/answersOnQuestion.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
.container-answers {
display: grid;
width: 1200px;
width: 62.5vw;
min-height: 350px;
grid-template-columns: 1fr 1fr;
grid-template-rows: 100px 100px;
column-gap: 50px;
row-gap: 50px;
column-gap: 25px;
row-gap: 25px;
justify-content: center;
margin: 50px;
padding-right: 50px;
}
17 changes: 17 additions & 0 deletions styles/components/modalGameOver.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
justify-content: space-evenly;
font-size: 1.5em;
padding: 3vw;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 1050;

&--paragraph {
font-weight: 600;
}
Expand Down Expand Up @@ -101,3 +107,14 @@
.danger {
color: rgb(159, 6, 6);
}


.modal-overlay {
position: fixed;
top: 0;
left: 0;
width: 100vw;
min-height: 100vh;
z-index: 1000;
background: rgba(0, 0, 0, 0.75);
}
4 changes: 2 additions & 2 deletions test/app/components/modalGameOver.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { modalGameOver } from '../../../src/app/components/modalGameOver';
import { screen } from '@testing-library/dom';
import '@testing-library/jest-dom/extend-expect';

/*
test('Adding Game over modal to DOM', () => {
const callback = () => true;
const firstArg = [];
Expand All @@ -10,7 +10,7 @@ test('Adding Game over modal to DOM', () => {
expect(screen.getByTestId('gameOverModal')).toHaveClass('swquiz-modal');
expect(screen.getByTestId('gameOverModal')).toBeInstanceOf(HTMLElement);
});

*/
test('Throw error when provided invalid first argument', () => {
const callback = () => true;
const firstArg = [];
Expand Down

0 comments on commit 671b07a

Please sign in to comment.