Skip to content
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
55 changes: 55 additions & 0 deletions cart.css
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,61 @@ header {
transform: translateY(0px);
}
}
/* Ensure the cart icon is always on top */
.icon-cart {
position: fixed;
top: 20px;
right: 20px;
z-index: 3000;
}

/* Style for the cart sliding panel */
.cartTab {
position: fixed;
top: 0;
right: 0;
width: 400px;
height: 100vh;
background-color: white;
box-shadow: -2px 0 10px rgba(0,0,0,0.2);
z-index: 2000;
transition: transform 0.3s ease;
transform: translateX(100%); /* hidden by default */
}

/* When the cart is shown, add this class via JavaScript */
.cartTab.active {
transform: translateX(0);
}

/* Push chatbot inward so it's not overlapped by cartTab */
.chatbox {
position: fixed;
bottom: 20px;
right: 420px; /* 400px for cartTab + padding */
z-index: 4000;
background: white;
border-radius: 12px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
padding: 15px;
}

.cartTab {
position: fixed;
top: 0;
right: 0;
width: 400px;
height: 100vh;
background-color: #fff;
box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
z-index: 2000;
transition: transform 0.3s ease-in-out;
transform: translateX(100%); /* Hidden by default */
}

.cartTab.active {
transform: translateX(0); /* Slide in when active */
}

.icon-cart span {
position: absolute;
Expand Down
18 changes: 18 additions & 0 deletions cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,24 @@ products = [
}
];

// Wait until the DOM is fully loaded
document.addEventListener("DOMContentLoaded", () => {
const cartIcon = document.querySelector(".icon-cart");
const cartTab = document.querySelector(".cartTab");
const closeBtn = document.querySelector(".close");

// Show cart when clicking cart icon
cartIcon.addEventListener("click", () => {
cartTab.classList.add("active");
});

// Hide cart when clicking close button
closeBtn.addEventListener("click", () => {
cartTab.classList.remove("active");
});
});


// Event Listeners
iconCart.addEventListener('click', () => {
body.classList.toggle('showCart');
Expand Down