Skip to content

Commit

Permalink
completed hover board
Browse files Browse the repository at this point in the history
  • Loading branch information
tsr-kairi committed Jul 11, 2021
1 parent 33e1b8a commit bc84950
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Day 36 - Hoverboard/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const container = document.getElementById("container");
const colors = ["#e74c3c", "#8e44ad", "#3498db", "#e67e22", "#2ecc71"];
const SQUARES = 500;

for (let i = 0; i < SQUARES; i++) {
const square = document.createElement("div");
square.classList.add("square");

square.addEventListener("mouseover", () => setColor(square));

square.addEventListener("mouseout", () => removeColor(square));

container.appendChild(square);
}

function setColor(element) {
const color = getRandomColor();
element.style.background = color;
element.style.boxShadow = `0 0 2px ${color}, 0 0 10px ${color}`;
}

function removeColor(element) {
element.style.background = "#1d1d1d";
element.style.boxShadow = "0 0 2px #000";
}

function getRandomColor() {
return colors[Math.floor(Math.random() * colors.length)];
}
15 changes: 15 additions & 0 deletions Day 36 - Hoverboard/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!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>Hover | board</title>
</head>
<body>
<div class="container" id="container"></div>

<script src="./app.js"></script>
</body>
</html>
37 changes: 37 additions & 0 deletions Day 36 - Hoverboard/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
*::after,
*::before {
box-sizing: border-box;
margin: 0;
padding: 0;
}

body {
background-color: #111;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
overflow: hidden;
margin: 0;
}

.container {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
max-width: 400px;
}

.square {
background-color: #1d1d1d;
box-shadow: 0 0 2px #000;
height: 16px;
width: 16px;
margin: 2px;
transition: 1s ease;
}

.square:hover {
text-decoration: 0s;
}

0 comments on commit bc84950

Please sign in to comment.