Skip to content

Commit

Permalink
✨Add Visitor Counter feature done ! #694 #717 (#810)
Browse files Browse the repository at this point in the history
Hello, PR
Done - #717


## Checklist
<!-- [X] - put a cross/X inside [] to check the box -->
- [x] I have gone through the [contributing
guide](https://github.com/Anjaliavv51/Retro)
- [x] I have updated my branch and synced it with project `main` branch
before making this PR
- [x] I have performed a self-review of my code
- [x] I have tested the changes thoroughly before submitting this pull
request.
- [x] I have provided relevant issue numbers, screenshots, and videos
after making the changes.
- [x] I have commented my code, particularly in hard-to-understand
areas.
  • Loading branch information
Anjaliavv51 authored Jan 8, 2025
2 parents 2dd81c0 + 352e8e7 commit b7c2db8
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 0 deletions.
20 changes: 20 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1362,4 +1362,24 @@ <h4 style="font-family: var(--ff-philosopher);color: hsl(203, 30%, 26%);">Follow
<script>
document.getElementById("copyright").textContent = new Date().getFullYear();
</script>


<br /><br />

<link rel="stylesheet" href="visi.css">

<!-- ############### Footer ############### -->
<div class="visitor-counter">

<div>Visitor</div>
<div class="website-counter"></div>

</div>

<script src="path/to/visitorCounter.js"></script>
<script src="./assets/css/visitors.css"></script>

<script src="visi.js"></script>


</html>
104 changes: 104 additions & 0 deletions visi.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
.visitor-counter {

position: fixed;
bottom: 20px; /* Distance from the bottom */
right: 90px; /* Distance from the right */
z-index: 9999; /* Ensure it appears above other content */
background-color: rgb(255 214 206); /* Slightly opaque background for better visibility */
height: 60px;
width: 100px;
color: #333; /* Darker text for better contrast */
font-weight: 700;
font-size: 18px;
text-align: center;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
border-radius: 12px; /* Softer corners */
backdrop-filter: blur(10px); /* Increased blur for a modern touch */
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15), /* Slightly more pronounced shadow */
0 2px 4px rgba(0, 0, 0, 0.1);
z-index: 1000;
transition: all 0.3s ease; /* Smooth transition for hover effect */

}

.visitor-counter:hover {

transform: scale(1.05); /* Slightly enlarge on hover */
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2); /* Enhance shadow on hover */

}

.visitor-counter div:first-child {

margin-bottom: -5px;
font-size: 14px; /* Adjusted for clarity */
letter-spacing: 1px; /* Increased spacing for readability */

}

.website-counter {

font-size: 24px;
font-family: 'Arial', sans-serif; /* Consistent font family */

}

@media screen and (max-width: 768px) {

.visitor-counter {

height: 100px;
width: 100px;
font-size: 16px;

}

.website-counter {

font-size: 20px;

}

}

@media screen and (max-width: 480px) {

.visitor-counter {

height: 80px;
width: 80px;
font-size: 14px;

}

.website-counter {

font-size: 18px;

}

}

.dark-mode .visitor-counter div {

color: #f0f0f0; /* Lighter text for dark mode */

}

.dark-mode .visitor-counter .website-counter {

color: #f0f0f0; /* Lighter color for consistency */

}

.dark-mode .visitor-counter {

background-color: rgba(0, 0, 0, 0.7); /* Darker background for dark mode */
box-shadow: 0 6px 12px rgba(255, 255, 255, 0.1),
0 2px 4px rgba(255, 255, 255, 0.05);

}

31 changes: 31 additions & 0 deletions visi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Function to get the count from localStorage or initialize it
function getVisitorCount() {

return localStorage.getItem('visitorCount') || 0;

}


// Function to increment and save the count
function incrementVisitorCount() {

let count = parseInt(getVisitorCount()) + 1;
localStorage.setItem('visitorCount', count);

return count;
}


// Function to display the count
function displayVisitorCount() {

const counterElement = document.querySelector('.website-counter');
const count = incrementVisitorCount();
counterElement.textContent = count;

}

// Call the display function when the page loads
document.addEventListener('DOMContentLoaded', displayVisitorCount);


0 comments on commit b7c2db8

Please sign in to comment.