From af302ec7788e07b427ad252d4d941c67630831f8 Mon Sep 17 00:00:00 2001 From: DavidS12321 Date: Sat, 3 Feb 2024 02:56:25 -0800 Subject: [PATCH] dietary --- filter.js | 5 ++++- index.html | 38 +++++++++++++++++++++++++------------- styles.css | 2 +- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/filter.js b/filter.js index 3799d7f..e0f5a10 100644 --- a/filter.js +++ b/filter.js @@ -37,6 +37,7 @@ function applyFilters() { // Get selected values from checkboxes const selectedMeals = getSelectedValues('meal'); const selectedCuisines = getSelectedValues('cuisine'); + const selectedDietaryRestrictions = getSelectedValues('restrictions'); // New line // Get all place boxes const placeBoxes = document.querySelectorAll('.place-box'); @@ -48,16 +49,18 @@ function applyFilters() { placeBoxes.forEach(function (placeBox) { const placeMeal = placeBox.getAttribute('data-meal'); const placeCuisine = placeBox.getAttribute('data-cuisine').split(' '); // Split into an array + const placeDietaryRestrictions = placeBox.getAttribute('data-restrictions').split(' '); // New line const isMealMatch = selectedMeals.length === 0 || selectedMeals.some(meal => placeMeal.includes(meal)); const isCuisineMatch = selectedCuisines.length === 0 || selectedCuisines.every(cuisine => placeCuisine.includes(cuisine)); + const isDietaryRestrictionsMatch = selectedDietaryRestrictions.length === 0 || selectedDietaryRestrictions.every(dr => placeDietaryRestrictions.includes(dr)); // New line // Add search functionality const placeName = placeBox.querySelector('h3').innerText.toLowerCase(); const isSearchMatch = placeName.includes(searchQuery); // Show/hide place box based on filters and search query - placeBox.style.display = isMealMatch && isCuisineMatch && isSearchMatch ? 'block' : 'none'; + placeBox.style.display = isMealMatch && isCuisineMatch && isDietaryRestrictionsMatch && isSearchMatch ? 'block' : 'none'; // Updated line }); } diff --git a/index.html b/index.html index 9762b33..2ce07f2 100644 --- a/index.html +++ b/index.html @@ -64,80 +64,92 @@

Cuisine

+ + +

Dietary Restrictions

+ + +
-
+
Restaurant 1

Starbucks

A cozy place offering a variety of delicious meals. Perfect for a quick bite or a leisurely meal.

Learn More
-
+
Restaurant 2

Subway

Healthy and fresh options for those looking for nutritious meals. Salads, smoothies, and more!

Learn More
-
+
Restaurant 3

Panda Express

Healthy and fresh options for those looking for nutritious meals. Salads, smoothies, and more!

Learn More
-
+
Restaurant 4

QDoba

Healthy and fresh options for those looking for nutritious meals. Salads, smoothies, and more!

Learn More
-
+
Restaurant 5

Hibachi-San

Learn More
-
+
Restaurant 6

Carl's Junior

Healthy and fresh options for those looking for nutritious meals. Salads, smoothies, and more!

Learn More
-
+
Restaurant 7

Round Table

Healthy and fresh options for those looking for nutritious meals. Salads, smoothies, and more!

Learn More
-
+
Restaurant 8

Poly Fresh Market

Healthy and fresh options for those looking for nutritious meals. Salads, smoothies, and more!

Learn More
-
+
Restaurant 9

BRIC Break

A cozy place offering a variety of delicious meals. Perfect for a quick bite or a leisurely meal.

Learn More
-
+
Restaurant 10

Vista Market

Healthy and fresh options for those looking for nutritious meals. Salads, smoothies, and more!

Learn More
-
+
Restaurant 11

Saddles

Saddles Cafe is dedicated to providing an exquisite selection of specialty coffee and tea beverages, complemented by an @@ -145,14 +157,14 @@

Saddles

Learn More
-
+
Restaurant 12

Centerpointe

Healthy and fresh options for those looking for nutritious meals. Salads, smoothies, and more!

Learn More
-
+
Restaurant 13

FitBites

Experience a unique culinary journey at Fitbites, where we bring together a delightful blend of diverse cuisines.

diff --git a/styles.css b/styles.css index 0b7cc38..97c2d35 100644 --- a/styles.css +++ b/styles.css @@ -131,7 +131,7 @@ nav a:hover { display: flex; flex-wrap: wrap; /* Allow wrapping to the next line when there's not enough space */ margin-left: 350px; - margin-top: -400px; + margin-top: -550px; } .search-container {