Skip to content

Commit

Permalink
completed sound board
Browse files Browse the repository at this point in the history
  • Loading branch information
tsr-kairi committed Jun 30, 2021
1 parent fe31137 commit d9fa82d
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Day 9 - Sound Board/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const sounds = ["applause", "boo", "gasp", "tada", "victory", "worng"];

sounds.forEach((sound) => {
const btn = document.createElement("button");
btn.classList.add("btn");

btn.innerText = sound;

btn.addEventListener("click", () => {
stopSongs();
document.getElementById("sound").play();
});

document.getElementById("buttons").appendChild(btn);
});

function stopSongs() {
sounds.forEach((sound) => {
const song = document.getElementById(sound);

song.pause();
song.currentTime = 0;
});
}
23 changes: 23 additions & 0 deletions Day 9 - Sound Board/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="./style.css" />
<title>Sound | Board</title>
</head>
<body>
<audio id="applause" src="./sounds/applause.mp3"></audio>
<audio id="boo" src="./sounds/boo.mp3"></audio>
<audio id="gasp" src="./sounds/gasp.mp3"></audio>
<audio id="tada" src="./sounds/tada.mp3"></audio>
<audio id="victory" src="./sounds/victory.mp3"></audio>
<audio id="wrong" src="./sounds/wrong.mp3"></audio>


<div id="buttons"></div>

<script src="./app.js"></script>
</body>
</html>
Binary file added Day 9 - Sound Board/sounds/applause.mp3
Binary file not shown.
Binary file added Day 9 - Sound Board/sounds/boo.mp3
Binary file not shown.
Binary file added Day 9 - Sound Board/sounds/gasp.mp3
Binary file not shown.
Binary file added Day 9 - Sound Board/sounds/tada.mp3
Binary file not shown.
Binary file added Day 9 - Sound Board/sounds/victory.mp3
Binary file not shown.
Binary file added Day 9 - Sound Board/sounds/wrong.mp3
Binary file not shown.
41 changes: 41 additions & 0 deletions Day 9 - Sound Board/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@import url("https://fonts.googleapis.com/css2?family=Poppins&family=Pattaya&display=swap");

*::after,
*::before {
box-sizing: border-box;
margin: 0;
padding: 0;
}

body {
background-color: rgb(161, 100, 223);
font-family: "Poppins", sans-serif;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
text-align: center;
height: 100vh;
overflow: hidden;
margin: 0;
}

.btn {
background-color: rebeccapurple;
border-radius: 5px;
border: none;
color: #fff;
margin: 1rem;
padding: 1.5rem 3rem;
font-size: 1.2rem;
font-family: inherit;
cursor: pointer;
}

.btn:hover {
opacity: 0.9;
}

.btn:focus {
outline: none;
}

0 comments on commit d9fa82d

Please sign in to comment.