Skip to content

Commit

Permalink
Merge pull request #1237 from meetarora10/top-branch
Browse files Browse the repository at this point in the history
feat: Added a scroll to top button on the contributor page .
  • Loading branch information
apu52 authored Jul 27, 2024
2 parents c435cf0 + 23a10f0 commit 087b0dc
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion contributors.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
body {
font-family: Arial, sans-serif;
font-family: 'Poppins';
background-color: #f4f4f4;
color: #333;
display: flex;
Expand Down
55 changes: 55 additions & 0 deletions contributors.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,67 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contributors</title>
<link rel="stylesheet" href="contributors.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css"
integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<link href="https://cdn.jsdelivr.net/npm/[email protected]/fonts/remixicon.css" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">

<style>
html {
scroll-behavior: smooth;
}
.top-btn {
display: none;
width: 50px;
height: 50px;
position: fixed;
bottom: 10px;
right: 0px;
background-color: #ab45e7;
color: #fff;
padding: 2px;
border: none;
margin-right: 36px;
border-radius: 50%;
cursor: pointer;
}

.top-btn:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="container">
<h1 class="title">Contributors</h1>
<div id="contributors" class="contributors-grid"></div>
</div>
<button class="top-btn" id="goToTopBtn" onclick="goToTop()"><i class="fa-solid fa-chevron-up"
style="color: #ffffff;"></i></button>
<script>
// Get the button
var mybutton = document.getElementById("goToTopBtn");

// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function () {
scrollFunction();
};

function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}

// When the user clicks on the button, scroll to the top of the document
function goToTop() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
</script>
<script src="contributors.js"></script>
</body>
</html>

0 comments on commit 087b0dc

Please sign in to comment.