Skip to content

Commit

Permalink
completed incrementing counter
Browse files Browse the repository at this point in the history
  • Loading branch information
tsr-kairi committed Jul 2, 2021
1 parent 72baf52 commit 59f49c1
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Day 15 - Incrementing Counter/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const counters = document.querySelectorAll(".counter");

counters.forEach((counter) => {
counter.innerText = "0";

const upddateCounter = () => {
const target = +counter.getAttribute("data-target");
const c = +counter.innerText;

const increment = target / 200;

if (c < target) {
counter.innerText = `${Math.ceil(c + increment)}`;
setTimeout(upddateCounter, 1);
} else {
counter.innerText = target;
}
};

upddateCounter();
});
38 changes: 38 additions & 0 deletions Day 15 - Incrementing Counter/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!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="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<link rel="stylesheet" href="./style.css" />
<title>Incrementing | Counter</title>
</head>
<body>
<div class="counter-container">
<i class="fab fa-twitter fa-3x"></i>
<div class="counter" data-target="12000"></div>
<span>Twitter Followers</span>
</div>

<div class="counter-container">
<i class="fab fa-youtube fa-3x"></i>
<div class="counter" data-target="5000"></div>
<span>YouTube Subscribers</span>
</div>

<div class="counter-container">
<i class="fab fa-facebook fa-3x"></i>
<div class="counter" data-target="7500"></div>
<span>facebook Fans</span>
</div>

<script src="./app.js"></script>
</body>
</html>
44 changes: 44 additions & 0 deletions Day 15 - Incrementing Counter/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@import url("https://fonts.googleapis.com/css2?family=Roboto+Mono&display=swap");
*::after,
*::before {
box-sizing: border-box;
margin: 0;
padding: 0;
}

body {
background-color: #8e44ad;
color: #fff;
font-family: "Roboto Mono", sans-serif;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
}

.counter-container {
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
margin: 30px 50px;
}

.counter {
font-size: 60px;
margin-top: 10px;
}

@media (max-width: 580px) {
body {
flex-direction: column;
}
.counter-container {
margin: 20px 40px;
}
.counter {
font-size: 40px;
margin-top: 5px;
}
}

0 comments on commit 59f49c1

Please sign in to comment.