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

updated the scroll to top button #185

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
40 changes: 35 additions & 5 deletions account.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap"
rel="stylesheet" />
<link href="https://unpkg.com/[email protected]/dist/aos.css" rel="stylesheet" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
<script src="https://kit.fontawesome.com/f390425e8d.js" crossorigin="anonymous"></script>
Expand All @@ -20,6 +21,9 @@
</head>

<body>
<div id="progress">
<span id="progress-value">&#x1F815;</span>
</div>

<div class="container">
<div class="navbar">
Expand Down Expand Up @@ -110,13 +114,17 @@ <h3>Follow Us</h3>
<div class="socialbtns" align="center">
<ul>
<li>
<a href="#" class="fa fa-lg fa-facebook"></a>Facebook</li><br>
<a href="#" class="fa fa-lg fa-facebook"></a>Facebook
</li><br>
<li>
<a href="#" class="fa fa-lg fa-twitter"></a>Twitter</li><br>
<a href="#" class="fa fa-lg fa-twitter"></a>Twitter
</li><br>
<li>
<a href="#" class="fa fa-lg fa-instagram"></a>Instagram</li><br>
<a href="#" class="fa fa-lg fa-instagram"></a>Instagram
</li><br>
<li>
<a href="#" class="fa fa-lg fa-youtube"></a>Youtube</li><br>
<a href="#" class="fa fa-lg fa-youtube"></a>Youtube
</li><br>
</ul>
</div>
</div>
Expand Down Expand Up @@ -172,6 +180,28 @@ <h3>Follow Us</h3>
MenuItems.classList.toggle("active")
cartImage.classList.toggle("bgm-change")
})


let calcScrollValue = () => {
let scrollProgress = document.getElementById("progress");
let progressValue = document.getElementById("progress-value");
let pos = document.documentElement.scrollTop;
let calcHeight = document.documentElement.scrollHeight - document.documentElement.clientHeight;
let scrollValue = Math.round((pos * 100) / calcHeight);

if (pos > 100) {
scrollProgress.style.display = "grid";
}
else {
scrollProgress.style.display = "none";
}
scrollProgress.addEventListener("click", () => {
document.documentElement.scrollTop = 0;
})
scrollProgress.style.background = `conic-gradient(#ff523b ${scrollValue}%, #000 ${scrollValue}%)`;
// console.log(scrollValue);
}
window.onscroll = calcScrollValue;
</script>
<script src="https://unpkg.com/[email protected]/dist/aos.js"></script>
<script>
Expand Down
39 changes: 34 additions & 5 deletions allproducts.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap"
rel="stylesheet" />
<link href="https://unpkg.com/[email protected]/dist/aos.css" rel="stylesheet" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
<script src="https://kit.fontawesome.com/f390425e8d.js" crossorigin="anonymous"></script>
Expand All @@ -21,6 +22,9 @@
</head>

<body>
<div id="progress">
<span id="progress-value">&#x1F815;</span>
</div>

<div class="container">
<div class="navbar">
Expand Down Expand Up @@ -269,13 +273,17 @@ <h3>Follow Us</h3>
<div class="socialbtns" align="center">
<ul>
<li>
<a href="#" class="fa fa-lg fa-facebook"></a> Facebook</li><br>
<a href="#" class="fa fa-lg fa-facebook"></a> Facebook
</li><br>
<li>
<a href="#" class="fa fa-lg fa-twitter"></a> Twitter</li><br>
<a href="#" class="fa fa-lg fa-twitter"></a> Twitter
</li><br>
<li>
<a href="#" class="fa fa-lg fa-instagram"></a> Instagram</li><br>
<a href="#" class="fa fa-lg fa-instagram"></a> Instagram
</li><br>
<li>
<a href="#" class="fa fa-lg fa-youtube"></a> Youtube</li><br>
<a href="#" class="fa fa-lg fa-youtube"></a> Youtube
</li><br>
</ul>
</div>
</div>
Expand Down Expand Up @@ -311,6 +319,27 @@ <h3>Follow Us</h3>
MenuItems.classList.toggle("active")
cartImage.classList.toggle("bgm-change")
})

let calcScrollValue = () => {
let scrollProgress = document.getElementById("progress");
let progressValue = document.getElementById("progress-value");
let pos = document.documentElement.scrollTop;
let calcHeight = document.documentElement.scrollHeight - document.documentElement.clientHeight;
let scrollValue = Math.round((pos * 100) / calcHeight);

if (pos > 100) {
scrollProgress.style.display = "grid";
}
else {
scrollProgress.style.display = "none";
}
scrollProgress.addEventListener("click", () => {
document.documentElement.scrollTop = 0;
})
scrollProgress.style.background = `conic-gradient(#ff523b ${scrollValue}%, #000 ${scrollValue}%)`;
// console.log(scrollValue);
}
window.onscroll = calcScrollValue;
</script>
<script src="https://unpkg.com/[email protected]/dist/aos.js"></script>
<script>
Expand Down
50 changes: 38 additions & 12 deletions cart.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@
<link rel="stylesheet" href="style.css" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap"
rel="stylesheet" />
<link href="https://unpkg.com/[email protected]/dist/aos.css" rel="stylesheet" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
<link rel="icon" type="image/x-icon" href="images/logo-white.png" />
</head>

<body>

<div id="progress">
<span id="progress-value">&#x1F815;</span>
</div>
<div class="container">
<div class="navbar">
<div class="logo">
Expand Down Expand Up @@ -142,9 +147,9 @@ <h3>Follow Us</h3>
retrievedUser.cart[idNumber].productQuantity = element
.value; //updates the productQuantity of item in the cart array using the input element's value
let updatedCart = {
cart: retrievedUser.cart
} //saving the new cart array to a new variable in the format how cart items are saved
// console.log(updatedCart)
cart: retrievedUser.cart
} //saving the new cart array to a new variable in the format how cart items are saved
// console.log(updatedCart)
localStorage.setItem("user", JSON.stringify(updatedCart)) //updating the localStorage cart items
renderItemsAndCosts();
}
Expand Down Expand Up @@ -180,10 +185,10 @@ <h3>Follow Us</h3>
document.getElementById(
"subtotal-section"
).innerHTML = `<table><tr><td>Subtotal</td><td>Rs. ${subTotal}</td></tr><tr><td>GST</td><td>Rs. ${Number(
(subTotal / 7.78).toFixed(2)
)}</td></tr><tr><td>Total</td><td>Rs. ${Number(
(subTotal + subTotal / 7.78).toFixed(2)
)}</td></tr></table>`;
(subTotal / 7.78).toFixed(2)
)}</td></tr><tr><td>Total</td><td>Rs. ${Number(
(subTotal + subTotal / 7.78).toFixed(2)
)}</td></tr></table>`;
}
renderItemsAndCosts(); //rendering the cart items and the costs initially
// to remove the row of item
Expand All @@ -192,9 +197,9 @@ <h3>Follow Us</h3>
retrievedUser.cart.splice(idNumber,
1); //removing the item from the cart array, whose 'remove' button is clicked
let updatedCart = {
cart: retrievedUser.cart
} //saving the new cart array to a new variable in the format how cart items are saved
// console.log(updatedCart)
cart: retrievedUser.cart
} //saving the new cart array to a new variable in the format how cart items are saved
// console.log(updatedCart)
localStorage.setItem("user", JSON.stringify(updatedCart)) //updating the localStorage cart items
renderItemsAndCosts();
showToast();
Expand All @@ -214,7 +219,7 @@ <h3>Follow Us</h3>
let toast = document.getElementById("toast");
toast.className = "showToast";

setTimeout(function() {
setTimeout(function () {
toast.className = toast.className.replace("showToast", "");
}, 3000);
}
Expand All @@ -237,6 +242,27 @@ <h3>Follow Us</h3>
}
}
checkForItemsInCart();

let calcScrollValue = () => {
let scrollProgress = document.getElementById("progress");
let progressValue = document.getElementById("progress-value");
let pos = document.documentElement.scrollTop;
let calcHeight = document.documentElement.scrollHeight - document.documentElement.clientHeight;
let scrollValue = Math.round((pos * 100) / calcHeight);

if (pos > 100) {
scrollProgress.style.display = "grid";
}
else {
scrollProgress.style.display = "none";
}
scrollProgress.addEventListener("click", () => {
document.documentElement.scrollTop = 0;
})
scrollProgress.style.background = `conic-gradient(#ff523b ${scrollValue}%, #000 ${scrollValue}%)`;
// console.log(scrollValue);
}
window.onscroll = calcScrollValue;
</script>
</body>

Expand Down
Loading