Skip to content
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
21 changes: 20 additions & 1 deletion assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,17 @@ body.nav-active { overflow: hidden; }
/*-----------------------------------*\
#HEADER
\*-----------------------------------*/
.cart-icon{
display: flex;
gap: 10px;
cursor: pointer;
}
span#cart-count {
transform: translateY(8px);
}
i.fas.fa-shopping-cart {
transform: translateY(15px);
}

.header .btn { display: none; }

Expand Down Expand Up @@ -989,12 +1000,20 @@ body.nav-active { overflow: hidden; }
.menu .section-title { margin-block-end: 40px; }

.menu .grid-list { margin-block-end: 50px; }

.cart-btn{
transform: translate(75rem,-13px);
}
.menu-card {
display: flex;
align-items: flex-start;
gap: 20px;
}
button.cart-btn {
font-size: 2rem;
background-color: rgb(46, 41, 41);
color: rgb(182, 169, 169);
height: 0px;
}

.hover\:card .card-banner { background-color: var(--gold-crayola); }

Expand Down
26 changes: 26 additions & 0 deletions assets/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,32 @@ window.addEventListener("load", function () {
});


const cartCountElement = document.getElementById('cart-count');
const cartButtons = document.querySelectorAll('.cart-btn');

let cart = {};

function updateCartCount() {
const itemCount = Object.keys(cart).length;
cartCountElement.textContent = itemCount;
}

cartButtons.forEach(button => {
button.addEventListener('click', () => {
const dishId = button.getAttribute('data-id');

if (cart[dishId]) {
delete cart[dishId];
button.textContent = 'Add to Cart';
} else {
cart[dishId] = true;
button.textContent = 'Remove from Cart';
}

updateCartCount();
});
});

/**
* add event listener on multiple elements
*/
Expand Down
21 changes: 15 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
- custom css link
-->
<link rel="stylesheet" href="./assets/css/style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
</head>

<!--
- preload images
Expand Down Expand Up @@ -167,6 +169,13 @@
<span class="span">Contact</span>
</a>
</li>
<li>
<div class="cart-icon">
<span id="cart-count">0</span>
<i class="fas fa-shopping-cart"></i>
</div>

</li>

</ul>

Expand Down Expand Up @@ -555,7 +564,7 @@ <h3 class="title-3">

<span class="span title-2">$25.50</span>
</div>

<button class="cart-btn" data-id="1">Add to Cart</button>
<p class="card-text label-1">
Tomatoes, green bell pepper, sliced cucumber onion, olives, and feta cheese.
</p>
Expand All @@ -582,7 +591,7 @@ <h3 class="title-3">

<span class="span title-2">$40.00</span>
</div>

<button class="cart-btn" data-id="2">Add to Cart</button>
<p class="card-text label-1">
Vegetables, cheeses, ground meats, tomato sauce, seasonings and spices
</p>
Expand All @@ -609,7 +618,7 @@ <h3 class="title-3">

<span class="span title-2">$10.00</span>
</div>

<button class="cart-btn" data-id="3">Add to Cart</button>
<p class="card-text label-1">
Butternut Squash, Olive Oil, Garlic, Thyme, Black Pepper
</p>
Expand Down Expand Up @@ -638,7 +647,7 @@ <h3 class="title-3">

<span class="span title-2">$39.00</span>
</div>

<button class="cart-btn" data-id="4">Add to Cart</button>
<p class="card-text label-1">
Vegetables, cheeses, ground meats, tomato sauce, seasonings and spices.
</p>
Expand All @@ -665,7 +674,7 @@ <h3 class="title-3">

<span class="span title-2">$25.00</span>
</div>

<button class="cart-btn" data-id="5">Add to Cart</button>
<p class="card-text label-1">
Avocados with crab meat, red onion, crab salad stuffed red bell pepper and green bell pepper.
</p>
Expand All @@ -692,7 +701,7 @@ <h3 class="title-3">

<span class="span title-2">$49.00</span>
</div>

<button class="cart-btn" data-id="6">Add to Cart</button>
<p class="card-text label-1">
Vegetables, cheeses, ground meats, tomato sauce, seasonings and spices
</p>
Expand Down