diff --git a/Css-files/style.css b/Css-files/style.css index 38bbf36a..ef5ba090 100644 --- a/Css-files/style.css +++ b/Css-files/style.css @@ -5,31 +5,31 @@ :root { - --primary-bg-color: #33333e; + --primary-bg-color: #33333e; --primary-text-color: #333335; - --secondary-bg-color: #f2f2f2; - --accent-color: #9e5c48; - --navbar-bg-color: #f2f2f2; + --secondary-bg-color: #f2f2f2; + --accent-color: #e59a83; + --navbar-bg-color: #f2f2f2; --navbar-hover-color: #e5e5e5; - --card-bg-color: #ffffff; + --card-bg-color: #ffffff; --card-hover-color: #f5f5f5; - --footer-bg-color: #f2f2f2; + --footer-bg-color: #f2f2f2; --footer-hover-color: #e5e5e5; } -.dark-theme{ +.dark-theme { - --primary-bg-color: #212123; + --primary-bg-color: #212123; --primary-text-color: #ffffff; - --secondary-bg-color: #333335; - --accent-color: #9e5c48; - --navbar-bg-color: #333335; + --secondary-bg-color: #333335; + --accent-color: #9e5c48; + --navbar-bg-color: #333335; --navbar-hover-color: #474749; - --card-bg-color: #2c2c2e; + --card-bg-color: #2c2c2e; --card-hover-color: #373739; - --footer-bg-color: #28282a; + --footer-bg-color: #28282a; --footer-hover-color: #333335; } @@ -845,13 +845,16 @@ textarea { padding: 100px; } } -::-webkit-scrollbar{ - width:20px; + +::-webkit-scrollbar { + width: 20px; } -::-webkit-scrollbar-track{ + +::-webkit-scrollbar-track { background: red; } -::-webkit-scrollbar-thumb{ + +::-webkit-scrollbar-thumb { border-radius: 12px; background-color: yellow; } \ No newline at end of file diff --git a/Html-files/MenuAPI.js b/Html-files/MenuAPI.js index a2dc40b9..06c5956e 100644 --- a/Html-files/MenuAPI.js +++ b/Html-files/MenuAPI.js @@ -1,72 +1,73 @@ const menuContainer = document.querySelector(".menu-container"); let categories = [ - "beef", - "breakfast", - "chicken", - "dessert", - "lamb", - "miscellaneous", - "pasta", - "pork", - "seafood", - "side", - "starter", - "vegan", - "vegetarian", - "goat", + "beef", + "breakfast", + "chicken", + "dessert", + "lamb", + "miscellaneous", + "pasta", + "pork", + "seafood", + "side", + "starter", + "vegan", + "vegetarian", + "goat", ]; //Function to render the navigation and tabs pane function renderPillsAndTabs() { - let pillsDiv = document.getElementById("v-pills-tab"); - let tabsDiv = document.getElementById("pills-tabContent"); - if (categories.length == 0) - menuContainer.innerHTML = `MENU WILL BE UPDATED SOON`; + let pillsDiv = document.getElementById("v-pills-tab"); + let tabsDiv = document.getElementById("pills-tabContent"); + if (categories.length == 0) + menuContainer.innerHTML = `MENU WILL BE UPDATED SOON`; - let firstCuisine = categories[0]; - pillsDiv.innerHTML += ``; - tabsDiv.innerHTML += `
`; - for (let i = 1; i < categories.length; i++) { - pillsDiv.innerHTML += ``; - tabsDiv.innerHTML += `
`; - } + } } renderPillsAndTabs(); // Function to get meals by category async function getMealsByCategory(category) { - const url = `https://www.themealdb.com/api/json/v1/1/filter.php?c=${category}`; - const response = await fetch(url); - const data = await response.json(); - return data.meals || []; + const url = `https://www.themealdb.com/api/json/v1/1/filter.php?c=${category}`; + const response = await fetch(url); + const data = await response.json(); + return data.meals || []; } // Function to log image source and name of the dish for a given category async function getMealDataByCategory(category) { - try { - const meals = await getMealsByCategory(category); - return meals.map((meal) => ({ - name: meal.strMeal, - imgSrc: meal.strMealThumb, - id: meal.idMeal - })); - } catch (error) { - console.error("Error fetching meals:", error); - return []; - } + try { + const meals = await getMealsByCategory(category); + return meals.map((meal) => ({ + name: meal.strMeal, + imgSrc: meal.strMealThumb, + id: meal.idMeal, + })); + } catch (error) { + console.error("Error fetching meals:", error); + return []; + } } // // Function to render meal details function renderMeals(mealData) { - return mealData.map((mealDetails) => ` + return mealData.map( + (mealDetails) => `
@@ -89,159 +90,183 @@ function renderMeals(mealData) {
` - )//.join(""); // Join the array into a single string + ); //.join(""); // Join the array into a single string } async function clickHandler(curpage, category) { - const mealData = await getMealDataByCategory(category); - const renderedMeals = renderMeals(mealData); - const mealsToBeDisplayed = renderedMeals.slice((curpage - 1) * 6, curpage * 6); - paneToBeRendered = document.getElementById(`v-pills-${category}`); - paneToBeRendered.innerHTML = `
` + mealsToBeDisplayed.join("") + `
` + createPagination(curpage, renderedMeals, category); + const mealData = await getMealDataByCategory(category); + const renderedMeals = renderMeals(mealData); + const mealsToBeDisplayed = renderedMeals.slice( + (curpage - 1) * 6, + curpage * 6 + ); + paneToBeRendered = document.getElementById(`v-pills-${category}`); + paneToBeRendered.innerHTML = + `
` + + mealsToBeDisplayed.join("") + + `
` + + createPagination(curpage, renderedMeals, category); } function createPagination(curpage, renderedMeals, category) { - let n = renderedMeals.length, totalPages = Math.ceil(n / 6); - let navcontent = ``; + return navcontent; } async function RenderPage() { - for (category of categories) { - const mealData = await getMealDataByCategory(category); - const renderedMeals = renderMeals(mealData); - const mealsToBeDisplayed = renderedMeals.slice(0, 6); - const paneToBeRendered = document.getElementById(`v-pills-${category}`); - paneToBeRendered.innerHTML = `
` + mealsToBeDisplayed.join("") + `
` + createPagination(1, renderedMeals, category); - createPagination(1, renderedMeals, paneToBeRendered); - } + for (category of categories) { + const mealData = await getMealDataByCategory(category); + const renderedMeals = renderMeals(mealData); + const mealsToBeDisplayed = renderedMeals.slice(0, 6); + const paneToBeRendered = document.getElementById(`v-pills-${category}`); + paneToBeRendered.innerHTML = + `
` + + mealsToBeDisplayed.join("") + + `
` + + createPagination(1, renderedMeals, category); + createPagination(1, renderedMeals, paneToBeRendered); + } } RenderPage(); - - // Function to get cart items from local storage function getCartItems() { - const cartItems = localStorage.getItem("cartItems"); - return cartItems ? JSON.parse(cartItems) : []; + const cartItems = localStorage.getItem("cartItems"); + return cartItems ? JSON.parse(cartItems) : []; } // Function to set cart items to local storage function setCartItems(cartItems) { - localStorage.setItem("cartItems", JSON.stringify(cartItems)); + localStorage.setItem("cartItems", JSON.stringify(cartItems)); } // Function to handle add to cart button click function cartBtn() { - menuContainer.addEventListener("click", (event) => { - const clickedElement = event.target; - if (clickedElement.classList.contains("add-to-cart-button")) { - const productName = clickedElement.dataset.productName; - const productImgSource = clickedElement.dataset.productImgsource; - const productPrice = clickedElement.dataset.productPrice; - - // Get the current cart items - const cartItems = getCartItems(); - - // Check if the item is already in the cart - const existingCartItem = cartItems.find( - (item) => item.name === productName - ); - - if (existingCartItem) { - // If the item is already in the cart, increase the quantity - existingCartItem.quantity += 1; - } else { - // If the item is not in the cart, add it with quantity 1 - cartItems.push({ - name: productName, - imgSrc: productImgSource, - quantity: 1, - price: productPrice, - }); - } - // console.log(cartItems); - - // Save the updated cart items to local storage - setCartItems(cartItems); - } - }); + menuContainer.addEventListener("click", (event) => { + const clickedElement = event.target; + if (clickedElement.classList.contains("add-to-cart-button")) { + const productName = clickedElement.dataset.productName; + const productImgSource = clickedElement.dataset.productImgsource; + const productPrice = clickedElement.dataset.productPrice; + + // Get the current cart items + const cartItems = getCartItems(); + + // Check if the item is already in the cart + const existingCartItem = cartItems.find( + (item) => item.name === productName + ); + + if (existingCartItem) { + // If the item is already in the cart, increase the quantity + existingCartItem.quantity += 1; + } else { + // If the item is not in the cart, add it with quantity 1 + cartItems.push({ + name: productName, + imgSrc: productImgSource, + quantity: 1, + price: productPrice, + }); + } + // console.log(cartItems); + + // Save the updated cart items to local storage + setCartItems(cartItems); + } + }); } cartBtn(); function filterMenu() { - const priceFilter = document.getElementById('filter-price').value; - - const menuItems = document.querySelectorAll('.menu-items .item'); - - menuItems.forEach(item => { - const itemName = item.querySelector('h3').innerText; - const itemPrice = parseFloat(item.querySelector('p').innerText.replace('$', '')); - let priceMatch = false; - - switch (priceFilter) { - case 'all': - priceMatch = true; - break; - case '0-5': - priceMatch = itemPrice >= 0 && itemPrice <= 5; - break; - case '5-10': - priceMatch = itemPrice > 5 && itemPrice <= 10; - break; - case '10-15': - priceMatch = itemPrice > 10 && itemPrice <= 15; - break; - case '15-20': - priceMatch = itemPrice > 15 && itemPrice <= 20; - break; - } - - if (priceMatch) { - item.style.display = ''; - } else { - item.style.display = 'none'; - } - }); -} + const priceFilter = document.getElementById("filter-price").value; + + const menuItems = document.querySelectorAll(".menu-items .item"); + menuItems.forEach((item) => { + const itemName = item.querySelector("h3").innerText; + const itemPrice = parseFloat( + item.querySelector("p").innerText.replace("$", "") + ); + let priceMatch = false; + + switch (priceFilter) { + case "all": + priceMatch = true; + break; + case "0-5": + priceMatch = itemPrice >= 0 && itemPrice <= 5; + break; + case "5-10": + priceMatch = itemPrice > 5 && itemPrice <= 10; + break; + case "10-15": + priceMatch = itemPrice > 10 && itemPrice <= 15; + break; + case "15-20": + priceMatch = itemPrice > 15 && itemPrice <= 20; + break; + } + + if (priceMatch) { + item.style.display = ""; + } else { + item.style.display = "none"; + } + }); +} diff --git a/index.html b/index.html index 33f4495f..e268376e 100644 --- a/index.html +++ b/index.html @@ -425,6 +425,44 @@

Laren Green

+ +