Skip to content

Commit

Permalink
feat: adiciona modal de configurações, possibilidade de desativar som…
Browse files Browse the repository at this point in the history
… da roleta e mantém o rodapé fixo
  • Loading branch information
freitaschz committed Feb 3, 2024
1 parent 51a6efb commit ce9bf1b
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 47 deletions.
82 changes: 75 additions & 7 deletions assets/css/style.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;700&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap");

* {
margin: 0;
Expand All @@ -8,6 +8,9 @@

body {
font-family: "Poppins", sans-serif;
}

main {
padding: 30px;
}

Expand All @@ -17,25 +20,76 @@ body {
text-align: center;
}

.modal {
display: none;
justify-content: center;
align-items: center;
position: fixed;
z-index: 2;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.4);
}

.modalContent {
position: relative;
border-radius: 15px;
padding: 20px;
min-width: max-content;
width: 30%;
max-width: 100%;
background-color: #fff;
border: 1px solid #000;
}

.modalHeader {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
border-bottom: 1px solid #000;
margin-bottom: 20px;
}

.modalTitle {
font-size: 1.2rem;
font-weight: 600;
}

.modalBody {
width: 100%;
height: 100%;
}

.result {
display: block;
margin: auto;
background-color: #dee2e6;
width: max-content;
margin-top: 30px;
padding: 10px 100px;
min-width: max-content;
width: 30%;
padding: 10px 20px;
border-radius: 30px;
}

.result__text {
font-weight: 700;
font-size: 1.2rem;
text-align: center;
}

.bingoHub {
.bingo {
display: flex;
justify-content: center;
align-items: center;
}

.bingoHub {
display: flex;
justify-content: start;
align-items: center;
overflow-y: auto;
gap: 50px;
margin: 30px 0;
}
Expand Down Expand Up @@ -98,7 +152,9 @@ body {
display: flex;
justify-content: center;
align-items: center;
gap: 24px;
flex-wrap: wrap;
gap: 16px;
margin: 30px 0;
}

.inputSelect {
Expand Down Expand Up @@ -135,7 +191,9 @@ body {
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
gap: 24px;
margin-bottom: 10px;
}

.btn--lightGray {
Expand All @@ -151,6 +209,10 @@ body {
color: #fff;
}

.btn--inv {
background: none;
}

.letterBg--redBg {
background-color: #dc3545;
}
Expand All @@ -173,8 +235,14 @@ body {

footer {
display: flex;
position: sticky;
z-index: 1;
bottom: 0;
justify-content: center;
align-items: center;
flex-direction: column;
margin-top: 30px;
padding: 20px 0;
background-color: #fff;
border-top: 1px solid #000;
width: 100%;
}
16 changes: 16 additions & 0 deletions assets/js/modal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const btnOpenConfigModal = document.querySelector("#openConfigModal");
const btnCloseConfigModal = document.querySelector("#closeConfigModal");
const configModal = document.querySelector("#configModal");

function openConfigModal() {
configModal.style.display = "flex";
document.body.style.overflow = "hidden";
}

function closeConfigModal() {
configModal.style.display = "none";
document.body.style.overflow = "auto";
}

btnOpenConfigModal.addEventListener("click", openConfigModal);
btnCloseConfigModal.addEventListener("click", closeConfigModal);
21 changes: 18 additions & 3 deletions assets/js/script.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import "./modal.js";

const inputSelectGamemode = document.querySelector("#selectGamemode");
const resetButton = document.querySelector("#resetBtn");
const drawButton = document.querySelector("#drawBtn");
const gamemodeNumber = document.querySelector("#gamemodeNumber");
const drawVoice = document.querySelector("#voiceDraw");
const drawVoice = document.querySelector("#drawVoice");
const roulleteAudio = document.querySelector("#roulleteAudio");
const numbersHub = document.querySelectorAll(".numbersHub");
const resultText = document.querySelector("#resultText");

Expand All @@ -19,6 +22,7 @@ const rouletteAudio = new Audio("assets/audio/somRoleta.wav");
let maxNumberOfBalls = null;
let listOfDrawnNumbers = [];
let activateBallReading = true;
let activateRouletteAudio = true;

const gamemodes = {
75: 75,
Expand Down Expand Up @@ -62,8 +66,7 @@ function drawNumber() {
drawButton.disabled = true;
const numbers = document.querySelectorAll(".numberBg");
if (listOfDrawnNumbers.length < maxNumberOfBalls) {
rouletteAudio.play();
rouletteAudio.onended = () => {
const onEndCallback = () => {
let number = null;
do {
number = Math.floor(Math.random() * maxNumberOfBalls) + 1;
Expand All @@ -77,6 +80,12 @@ function drawNumber() {
drawButton.disabled =
listOfDrawnNumbers.length === maxNumberOfBalls;
};
if (activateRouletteAudio) {
rouletteAudio.onended = onEndCallback;
rouletteAudio.play();
return;
}
onEndCallback();
return;
}
alert("Não existem mais números para serem sorteados!");
Expand All @@ -96,18 +105,24 @@ function checkBallReading() {
activateBallReading = drawVoice.checked;
}

function checkRouletteAudio() {
activateRouletteAudio = roulleteAudio.checked;
}

function resetBingo() {
drawButton.disabled = true;
listOfDrawnNumbers = [];
for (const hub of numbersHub) {
hub.innerHTML = "";
}
checkBallReading();
checkRouletteAudio();
getGamemode();
drawButton.disabled = false;
}

resetButton.addEventListener("click", resetBingo);
drawButton.addEventListener("click", drawNumber);
drawVoice.addEventListener("change", checkBallReading);
roulleteAudio.addEventListener("change", checkRouletteAudio);
resetBingo();
100 changes: 63 additions & 37 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,61 +33,87 @@ <h2 class="mainSubtitle">Sorteador de Bingo</h2>
<option value="100">100 bolas</option>
</select>
</div>
<div>
<label for="voiceDraw">Sorteio com voz:</label>
<input
type="checkbox"
name="voiceDraw"
id="voiceDraw"
checked
/>
<button class="btn btn--black" id="openConfigModal" aria-label="Abrir configurações">
<i class="bi bi-gear" role="img" aria-label="Ícone de configurações"></i> Configurações
</button>
<div class="modal" id="configModal">
<div class="modalContent">
<div class="modalHeader">
<p class="modalTitle">Configurações</p>
<button class="btn btn__large btn--inv" id="closeConfigModal" aria-label="Fechar configurações">
<i class="bi bi-x-lg" role="img" aria-label="Ícone de fechar"></i>
</button>
</div>
<div class="modalBody">
<div>
<label for="roulleteAudio">Som de roleta:</label>
<input
type="checkbox"
name="roulleteAudio"
id="roulleteAudio"
checked
/>
</div>
<div>
<label for="drawVoice">Ler números com voz:</label>
<input
type="checkbox"
name="drawVoice"
id="drawVoice"
checked
/>
</div>
</div>
</div>
</div>
</div>
<div class="result">
<p class="result__text" id="resultText">INICIE O SORTEIO</p>
</div>
<div class="bingoHub">
<div class="letterHub">
<div class="letterBg letterBg--redBg">
<p class="bingoLetter">B</p>
<div class="bingo">
<div class="bingoHub">
<div class="letterHub">
<div class="letterBg letterBg--redBg">
<p class="bingoLetter">B</p>
</div>
<div class="numbersHub"></div>
</div>
<div class="numbersHub"></div>
</div>
<div class="letterHub">
<div class="letterBg letterBg--orangeBg">
<p class="bingoLetter">I</p>
<div class="letterHub">
<div class="letterBg letterBg--orangeBg">
<p class="bingoLetter">I</p>
</div>
<div class="numbersHub"></div>
</div>
<div class="numbersHub"></div>
</div>
<div class="letterHub">
<div class="letterBg letterBg--greenBg">
<p class="bingoLetter">N</p>
<div class="letterHub">
<div class="letterBg letterBg--greenBg">
<p class="bingoLetter">N</p>
</div>
<div class="numbersHub"></div>
</div>
<div class="numbersHub"></div>
</div>
<div class="letterHub">
<div class="letterBg letterBg--blueBg">
<p class="bingoLetter">G</p>
<div class="letterHub">
<div class="letterBg letterBg--blueBg">
<p class="bingoLetter">G</p>
</div>
<div class="numbersHub"></div>
</div>
<div class="numbersHub"></div>
</div>
<div class="letterHub">
<div class="letterBg letterBg--purpleBg">
<p class="bingoLetter">O</p>
<div class="letterHub">
<div class="letterBg letterBg--purpleBg">
<p class="bingoLetter">O</p>
</div>
<div class="numbersHub"></div>
</div>
<div class="numbersHub"></div>
</div>
</div>
</main>
<footer>
<div class="groupBtnsPlayBingo">
<button class="btn btn__large btn--black" id="drawBtn">
<i class="bi bi-dice-5"></i>Sortear
<i class="bi bi-dice-5" role="img" aria-label="Ícone de um dado"></i>Sortear
</button>
<button class="btn btn__large btn--gray" id="resetBtn">
<i class="bi bi-arrow-counterclockwise"></i>Reiniciar
<i class="bi bi-arrow-counterclockwise" role="img" aria-label="Ícone de reinício"></i>Reiniciar
</button>
</div>
</main>
<footer>
<p class="footerText">
Feito com ❤️ por
<a href="https://github.com/thiagofqs" target="_blank"
Expand Down

0 comments on commit ce9bf1b

Please sign in to comment.