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
32 changes: 31 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 @@ -708,7 +719,26 @@ body.nav-active { overflow: hidden; }
opacity: 1;
pointer-events: all;
}

cart-icon{
display: flex;
gap: 10px;
cursor: pointer;
}
span#cart-count {
transform: translateY(8px);
}
i.fas.fa-shopping-cart {
transform: translateY(15px);
}
.cart-btn{
transform: translate(75rem,-13px);
}
button.cart-btn {
font-size: 2rem;
background-color: rgb(46, 41, 41);
color: rgb(182, 169, 169);
height: 0px;
}



Expand Down
74 changes: 74 additions & 0 deletions assets/js/script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,78 @@
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();
});
});
document.getElementsByClassName('cart-icon')[0].addEventListener('click',()=> {
// Open a new window
const newWindow = window.open('', '_blank', 'width=600,height=400');

// Add HTML content to the new window
newWindow.document.write(`
<html>
<head>
<title>Your Cart</title>
<link rel="stylesheet" href="./assets/css/style.css">

</head>
<body>
<h2>Your Cart</h2>
<li>
<div class="menu-card hover:card">

<figure class="card-banner img-holder" style="--width: 100; --height: 100;">
<img src="./assets/images/menu-1.png" width="100" height="100" loading="lazy" alt="Greek Salad"
class="img-cover">
</figure>

<div>

<div class="title-wrapper Menu1">
<h3 class="title-3">
<a href="#" class="card-title">Greek Salad</a>
</h3>

<span class="badge label-1">Seasonal</span>

<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>

</div>

</div>
</li>
</body>
</html>
`);

newWindow.document.body.appendChild(newDiv);
// Focus on the new window
newWindow.focus();
});
/**
* PRELOAD
*
Expand Down
32 changes: 24 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- 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">

<!--
- preload images
Expand Down Expand Up @@ -167,7 +168,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>

<div class="text-center">
Expand Down Expand Up @@ -210,7 +217,16 @@
</div>
</header>


<div id="cartNewWindow" class="NewWindow">
<div class="NewWindow-content">
<div class="NewWindow-header">
<span>Your Cart</span>
<span class="NewWindow-close" id="closeNewWindow">&times;</span>
</div>
<div id="cartItems"></div>
<div id="cartTotal" class="total-price"></div>
</div>
</div>

<main>
<article>
Expand Down Expand Up @@ -546,7 +562,7 @@ <h2 class="headline-1 section-title text-center">Delicious Menu</h2>

<div>

<div class="title-wrapper">
<div class="title-wrapper Menu1">
<h3 class="title-3">
<a href="#" class="card-title">Greek Salad</a>
</h3>
Expand All @@ -555,7 +571,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 +598,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 +625,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 +654,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 +681,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 +708,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