From ca7bf5f9488c5475e850582bd68d83ac2d40cb8b Mon Sep 17 00:00:00 2001 From: cowboykipnugget <524877@vistacollege.nl> Date: Wed, 12 Feb 2025 13:50:09 +0100 Subject: [PATCH] Merge branch 'main' of https://github.com/Alvin-Zilverstand/Schoolkantine --- website/index.html | 26 +++++----- website/script.js | 119 +++++++++++++++++++++------------------------ website/style.css | 83 +++++++++++++++---------------- 3 files changed, 108 insertions(+), 120 deletions(-) diff --git a/website/index.html b/website/index.html index 12a1be9..0754067 100644 --- a/website/index.html +++ b/website/index.html @@ -13,15 +13,19 @@ + + +
+
@@ -45,9 +49,9 @@

Totaal: €0.00

- + diff --git a/website/script.js b/website/script.js index b0822dc..58a8d0e 100644 --- a/website/script.js +++ b/website/script.js @@ -1,74 +1,65 @@ -// Functie om de details van een geselecteerd item weer te geven -function showItemDetails(item) { - var title = ""; - var imageSrc = ""; - var description = ""; - var price = 0; +// Functie om de productcategorie te tonen +function showCategory(category) { + const productDisplay = document.getElementById('product-display'); + productDisplay.innerHTML = ''; // Maak het display leeg voordat we nieuwe items toevoegen - // Afhankelijk van het geselecteerde item, pas de details aan - if (item === 'Broodjes') { - title = "Broodje Gezond"; - imageSrc = "media/broodje-gezond.jpg"; - description = "Op dit broodje zit kaas, veldsla, komkommer, tomaat, ei, ham en/of kip en bufkes saus."; - price = 3.50; - } else if (item === 'drinks') { - title = "Spa Water"; - imageSrc = "media/spa.webp"; - description = "Koude verfrissende water."; - price = 1.00; - } else if (item === 'Snacks') { - title = "Frikandel"; - imageSrc = "media/frikandel.jpg"; - description = "Een frikandel, dat wil je wel!"; - price = 2.00; - } else if (item === 'deserts') { - title = "Ijsjes"; - imageSrc = "media/ijs.png"; - description = "Een lekker ijsje met vele smaken, zoals aardbei, vanille, chocolade, mint, bosbes en nog veel meer (alleen in de zomer!)."; - price = 1.50; - } else if (item === 'Deals') { - title = "Deals"; - imageSrc = "media/deals.jpg"; - description = "Onze beste deals met de beste prijzen!"; - price = 10.00; - } else if (item === 'Soepen') { - title = "Soepen"; - imageSrc = "media/soep.jpg"; - description = "Soep van de dag! (Allergieën? Meld het bij ons!)"; - price = 2.50; - } else if (item === 'Salades') { - title = "Salades"; - imageSrc = "media/salade.jpg"; - description = "Een heerlijke salade met verse groenten en een dressing naar keuze."; - price = 3.00; - } else if (item === 'Placeholder2') { - title = "Placeholder 2"; - imageSrc = ""; - description = "Beschrijving voor Placeholder 2."; - price = 0; + let items = []; + + // Afhankelijk van de gekozen categorie, voeg je de juiste producten toe + if (category === 'Broodjes') { + items = [ + { title: "Broodje Gezond", imageSrc: "media/broodje-gezond.jpg", price: 3.50 }, + { title: "Broodje Kaas", imageSrc: "media/broodje-kaas.jpg", price: 3.00 }, + ]; + } else if (category === 'drinks') { + items = [ + { title: "Spa Water", imageSrc: "media/spa.webp", price: 1.00 }, + { title: "Cola", imageSrc: "media/cola.jpg", price: 1.50 }, + ]; + } else if (category === 'Snacks') { + items = [ + { title: "Frikandel", imageSrc: "media/frikandel.jpg", price: 2.00 }, + { title: "Bitterballen", imageSrc: "media/bitterballen.jpg", price: 2.50 }, + ]; } - // Update de inhoud van het modaal venster - document.getElementById("modal-title").innerText = title; - document.getElementById("modal-image").src = imageSrc; - document.getElementById("modal-description").innerText = description; - document.getElementById("modal-price").innerText = `Prijs: €${price.toFixed(2)}`; - document.getElementById("add-to-cart").onclick = function() { - addToCart({ title, price }); + // Voeg de items toe aan de weergave + items.forEach(item => { + const productBox = document.createElement('div'); + productBox.classList.add('product-box'); + productBox.onclick = () => showItemDetails(item); + + productBox.innerHTML = ` + ${item.title} +

${item.title}

+

€${item.price.toFixed(2)}

+ `; + + productDisplay.appendChild(productBox); + }); +} + +// Functie om de details van een item weer te geven in het modaal +function showItemDetails(item) { + const modalTitle = document.getElementById('modal-title'); + const modalImage = document.getElementById('modal-image'); + const modalDescription = document.getElementById('modal-description'); + const modalPrice = document.getElementById('modal-price'); + const addToCartButton = document.getElementById('add-to-cart'); + + modalTitle.innerText = item.title; + modalImage.src = item.imageSrc; + modalDescription.innerText = `Beschrijving van ${item.title}`; + modalPrice.innerText = `Prijs: €${item.price.toFixed(2)}`; + + addToCartButton.onclick = function() { + addToCart({ title: item.title, price: item.price }); }; - // Zet het modaal venster zichtbaar - document.getElementById("modal").style.display = "block"; + document.getElementById('modal').style.display = 'block'; } // Functie om het modaal venster te sluiten function closeModal() { - document.getElementById("modal").style.display = "none"; -} - -// Zorg ervoor dat het modaal venster sluit wanneer er buiten het venster wordt geklikt -window.onclick = function(event) { - if (event.target == document.getElementById("modal")) { - closeModal(); - } + document.getElementById('modal').style.display = 'none'; } diff --git a/website/style.css b/website/style.css index 99299ef..6850755 100644 --- a/website/style.css +++ b/website/style.css @@ -3,8 +3,8 @@ body { font-family: Arial, sans-serif; margin: 0; display: flex; - justify-content: space-between; /* Ensure the body content is spaced between */ - background-color: #f2c14e; /* Set the background color to yellow */ + justify-content: space-between; + background-color: #f2c14e; } /* Linkerkant menu */ @@ -14,22 +14,15 @@ body { padding: 20px; height: 100vh; overflow-y: auto; - order: 1; /* Ensure the menu is on the left */ -} - -.menu-list h2 { - color: #d32f2f; - font-size: 2em; - margin-bottom: 20px; } .menu-item { background-color: #fff; - padding: 20px; /* Increase padding for larger buttons */ + padding: 20px; margin: 10px 0; border-radius: 8px; cursor: pointer; - font-size: 1.5em; /* Increase font size for larger buttons */ + font-size: 1.5em; transition: all 0.3s ease; } @@ -38,12 +31,13 @@ body { box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); } -/* Productweergave in mooie hokjes */ +/* Productweergave in een grid */ .product-display { width: 70%; display: flex; flex-wrap: wrap; padding: 20px; + justify-content: space-around; } .product-box { @@ -54,26 +48,20 @@ body { box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); text-align: center; cursor: pointer; + transition: all 0.3s ease; } -.menu-detail img { - width: 70%; - max-width: 300px; - max-height: 400px; - margin-bottom: 20px; +.product-box:hover { + transform: scale(1.05); } -.menu-detail h2 { - color: #d32f2f; - margin: 10px 0; +.product-box img { + width: 100%; + max-height: 150px; + object-fit: cover; } -.menu-item:hover { - background-color: #f59e42; - box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); -} - -/* Modaal venster (pop-up) */ +/* Modaal venster */ .modal { display: none; position: fixed; @@ -83,25 +71,24 @@ body { width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); - overflow: auto; /* Allow scrolling within the modal */ } .modal-content { background-color: white; - margin: 5% auto; /* Reduce margin to fit more content */ + margin: 5% auto; padding: 20px; border-radius: 8px; - width: 80%; /* Increase width to fit more content */ - max-width: 600px; /* Set a maximum width */ + width: 80%; + max-width: 600px; text-align: center; - max-height: 90vh; /* Ensure the modal content fits within the viewport height */ - overflow-y: auto; /* Allow vertical scrolling within the modal */ + max-height: 90vh; + overflow-y: auto; } .modal img { width: 100%; - max-width: 300px; /* Ensure the image fits within the modal */ - height: auto; /* Maintain aspect ratio */ + max-width: 300px; + height: auto; margin: 20px 0; } @@ -114,6 +101,23 @@ body { cursor: pointer; } +/* Winkelmandje */ +.cart { + width: 25%; + padding: 20px; + background-color: #fff; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); +} + +.cart ul { + list-style-type: none; + padding: 0; +} + +.cart li { + margin-bottom: 10px; +} + #add-to-cart { background-color: #4CAF50; color: white; @@ -121,19 +125,8 @@ body { padding: 10px 20px; cursor: pointer; border-radius: 5px; - margin-top: 20px; } #add-to-cart:hover { background-color: #45a049; } - -/* Footer */ -footer { - text-align: center; - padding: 20px; - background-color: #f2c14e; - position: fixed; - bottom: 0; - width: 100%; -}