Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a JS Counter #1181

Merged
merged 1 commit into from
Oct 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Contributors.html
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@
<a class="box-item" href="https://github.com/kapil706"><span>Kapil Chaudhary</span></a>
<a class="box-item" href="https://github.com/glbdhananjaya"><span>Bhashitha Dhananjaya</span></a>
<a class="box-item" href="https://github.com/sunankles"><span>Sunankles</span></a>

<a class="box-item" href="https://github.com/Ibb-uth"><span>Ibraheem Uthman</span></a>

<!-- Please maintain the alignment... -->

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
:root {
--mainWhite: #f5f5f5;
--mainGreen: #7fb800;
--mainBlue: #0d2c54;
--lightBlue: #00a6ed;
--mainBlack: #333333;
}
.max-height {
min-height: 100vh;
}
body {
background: url("../img/mainBcg.jpeg") center/cover fixed no-repeat;
color: var(--mainWhite);
}
.main-container {
border: 0.1rem solid var(--mainWhite);
box-shadow: 0 0.5rem 0.5rem rgba(0, 0, 0, 0.9);
border-radius: 0.2rem;
}
#counter {
color: var(--mainGreen);
font-size: 10rem;
color: var(--mainBlack);
}
.prevBtn,
.nextBtn {
box-shadow: 0 0.2rem 0.5rem rgba(0, 0, 0, 0.9);
background: var(--mainBlue);
color: var(--mainWhite);
}
.prevBtn:hover {
background: var(--lightBlue);
}
.nextBtn:hover {
background: var(--lightBlue);
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<!-- bootstrap css -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- main css -->
<link rel="stylesheet" href="css/main.css">
<!-- google fonts -->
<link href="https://fonts.googleapis.com/css?family=Courgette" rel="stylesheet">

<!-- font awesome -->
<script src="js/all.js"></script>
<title>Counter Project</title>
<style>
</style>
</head>

<body>


<div class="container">
<div class="row max-height align-items-center">
<div class="col-10 mx-auto col-md-6 text-center main-container p-5">
<h1 class="text-uppercase">counter</h1>
<h1 id="counter">0</h1>
<div class="btn-container d-flex justify-content-around flex-wrap">
<button class="btn counterBtn prevBtn text-uppercase m-2">lower count</button>
<button class="btn counterBtn nextBtn text-uppercase m-2">add count</button>
</div>
</div>
</div>
</div>



<!-- jquery -->
<script src="js/jquery-3.3.1.min.js"></script>
<!-- bootstrap js -->
<script src="js/bootstrap.bundle.min.js"></script>
<!-- script js -->
<script src="js/app.js"></script>
</body>

</html>
3,639 changes: 3,639 additions & 0 deletions Program's_Contributed_By_Contributors/HTML Designs/JS Counter/js/all.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
(function(){
const buttons = document.querySelectorAll('.counterBtn')
let count= 0


//Add event listeners and functionailty to each button
buttons.forEach(function(button){
button.addEventListener('click', function(){
if (button.classList.contains('prevBtn')){
count--
} else if (button.classList.contains('nextBtn')){
count++
}

//Select the counter text
const counter = document.querySelector('#counter')
counter.textContent = count

if (count < 0 ){
counter.style.color = 'red'
} else if (count > 0){
counter.style.color = 'green'
} else {
counter.style.color = '#333333'
}
})
})
})()

Large diffs are not rendered by default.

Large diffs are not rendered by default.