A Pen by antony wamunyu on CodePen.
Created
May 7, 2024 18:07
-
-
Save ToneyGi/86b064909f1d094cd2db937420532506 to your computer and use it in GitHub Desktop.
Recipe website
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
<header> | |
<div class="logo">Recipe Website</div> | |
<nav> | |
<ul> | |
<li><a href="#">Home</a></li> | |
<li><a href="#">Recipes</a></li> | |
<li><a href="#">About</a></li> | |
<!-- Add more navigation links as needed --> | |
</ul> | |
</nav> | |
</header> | |
<main> | |
<!-- Recipe Cards --> | |
<article class="recipe-card" data-title="Recipe Title 1" data-description="Description of the recipe 1" data-image="food1.jpg" data-meal-type="breakfast"> | |
<img src="https://i.postimg.cc/QxyQpSnJ/fef15534-b9f1-4981-b385-46cd20d49447.jpg" alt="Food 1"> | |
<h2>Breakfast</h2> | |
<p>Select your base—tortillas, rice noodles, or crusty bread—then cook your protein of choice—chorizo, grilled chicken, or tofu. Add a variety of veggies like bell peppers, spinach, or tomatoes, and season with herbs and spices such as basil, cilantro, or cumin. Finally, garnish and serve with fresh ingredients like avocado, feta cheese, or sesame seeds for a delightful breakfast dish with flavors from around the world</p> | |
<div class="actions"> | |
<button class="save-button">Save</button> | |
<button class="share-button">Share</button> | |
</div> | |
</article> | |
<article class="recipe-card" data-title="Recipe Title 2" data-description="Description of the recipe 2" data-image="food2.jpg" data-meal-type="lunch"> | |
<img src="https://i.postimg.cc/brKQjwnF/2d86b20b-d0e8-49c4-9cba-0d4d73066454.jpg" alt="Food 2"> | |
<h2>Lunch</h2> | |
<p>Create a diverse lunch with global influences. Choose a protein—shrimp, chicken, or lamb—and pair it with a base like pasta, rice, or greens. Add fresh veggies, herbs, and spices, and finish with a flavorful sauce. Present it beautifully to entice diners.</p> | |
<div class="actions"> | |
<button class="save-button">Save</button> | |
<button class="share-button">Share</button> | |
</div> | |
</article> | |
<article class="recipe-card" data-title="Recipe Title 3" data-description="Description of the recipe 3" data-image="food3.jpg" data-meal-type="dinner"> | |
<img src="https://i.postimg.cc/MGVRyShy/dd25c8d4-50ab-4cb2-beef-2181c6015d20.jpg" alt="Food 3"> | |
<h2>Dinner</h2> | |
<p>Prepare a diverse dinner featuring Italian, Mexican, Asian, or Mediterranean cuisine. Choose a main ingredient—beef, fish, tofu, or chicken—and pair it with pasta, rice, or veggies. Season with herbs, spices, and sauces for flavor, and present beautifully.</p> | |
<div class="actions"> | |
<button class="save-button">Save</button> | |
<button class="share-button">Share</button> | |
</div> | |
</article> | |
<!-- Add more recipe cards as needed --> | |
</main> | |
<footer> | |
<p>© 2024 Recipe Website. All rights reserved.</p> | |
<div class="social-media"> | |
<a href="#">Share on Facebook</a> | |
<a href="#">Share on X</a> | |
<a href="#">Share on Pinterest</a> | |
<a href="#">Share on Instagram</a> | |
<a href="#">Share on Tiktok</a> | |
<!-- Add more social media sharing links as needed --> | |
</div> | |
</footer> | |
<div class="meal-planner"> | |
<input type="text" id="search-bar" placeholder="Search for recipes..."> | |
<div id="filter-options"> | |
<label for="meal-type-filter">Filter by Meal Type:</label> | |
<select id="meal-type-filter"> | |
<option value="">All</option> | |
<option value="breakfast">Breakfast</option> | |
<option value="lunch">Lunch</option> | |
<option value="dinner">Dinner</option> | |
<!-- Add more meal types as needed --> | |
</select> | |
</div> | |
</div> | |
<div class="meal-plan"> | |
<!-- Display Generated Meal Plan --> | |
</div> | |
<script src="script.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Functionality for the meal planner tool | |
document.addEventListener('DOMContentLoaded', function() { | |
const daysOfWeek = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; | |
const mealPlan = {}; | |
// Generate meal planner interface | |
const mealPlanner = document.createElement('div'); | |
mealPlanner.classList.add('meal-planner'); | |
mealPlanner.innerHTML = ` | |
<h3>Meal Planner</h3> | |
<input type="text" id="search-bar" placeholder="Search for recipes..."> | |
<div id="filter-options"> | |
<label for="meal-type-filter">Filter by Meal Type:</label> | |
<select id="meal-type-filter"> | |
<option value="">All</option> | |
<option value="breakfast">Breakfast</option> | |
<option value="lunch">Lunch</option> | |
<option value="dinner">Dinner</option> | |
<!-- Add more meal types as needed --> | |
</select> | |
</div> | |
<button id="generate-meal-plan">Generate Meal Plan</button> | |
`; | |
document.body.appendChild(mealPlanner); | |
// Populate recipe options in dropdown menus | |
const recipeDropdowns = document.querySelectorAll('.day select'); | |
recipeDropdowns.forEach(dropdown => { | |
document.querySelectorAll('.recipe-card').forEach(recipeCard => { | |
const title = recipeCard.getAttribute('data-title'); | |
const option = document.createElement('option'); | |
option.value = title; | |
option.textContent = title; | |
dropdown.appendChild(option); | |
}); | |
}); | |
// Add event listener for generating meal plan | |
document.getElementById('generate-meal-plan').addEventListener('click', function() { | |
recipeDropdowns.forEach(dropdown => { | |
const day = dropdown.parentNode.querySelector('h4').textContent; | |
const recipeTitle = dropdown.value; | |
if (recipeTitle !== "") { | |
mealPlan[day] = recipeTitle; | |
} else { | |
delete mealPlan[day]; | |
} | |
}); | |
// Display generated meal plan | |
const mealPlanDisplay = document.querySelector('.meal-plan'); | |
mealPlanDisplay.innerHTML = ` | |
<h3>Generated Meal Plan</h3> | |
<ul> | |
${Object.keys(mealPlan).map(day => ` | |
<li><strong>${day}:</strong> ${mealPlan[day]}</li> | |
`).join('')} | |
</ul> | |
`; | |
}); | |
// Search functionality | |
document.getElementById('search-bar').addEventListener('input', function() { | |
const searchTerm = this.value.toLowerCase(); | |
const recipeCards = document.querySelectorAll('.recipe-card'); | |
recipeCards.forEach(card => { | |
const title = card.getAttribute('data-title').toLowerCase(); | |
const description = card.getAttribute('data-description').toLowerCase(); | |
if (title.includes(searchTerm) || description.includes(searchTerm)) { | |
card.style.display = 'block'; | |
} else { | |
card.style.display = 'none'; | |
} | |
}); | |
}); | |
// Filtering options | |
document.getElementById('meal-type-filter').addEventListener('change', function() { | |
const selectedMealType = this.value.toLowerCase(); | |
const recipeCards = document.querySelectorAll('.recipe-card'); | |
recipeCards.forEach(card => { | |
const mealType = card.getAttribute('data-meal-type').toLowerCase(); | |
if (selectedMealType === '' || mealType === selectedMealType) { | |
card.style.display = 'block'; | |
} else { | |
card.style.display = 'none'; | |
} | |
}); | |
}); | |
// Functionality for saving recipes to personalized collections | |
document.querySelectorAll('.save-button').forEach(button => { | |
button.addEventListener('click', () => { | |
const recipeCard = button.closest('.recipe-card'); | |
const title = recipeCard.getAttribute('data-title'); | |
const description = recipeCard.getAttribute('data-description'); | |
const image = recipeCard.getAttribute('data-image'); | |
// Here, you would implement code to save the recipe to personalized collections | |
// For demonstration purposes, let's log the recipe details | |
console.log(`Recipe "${title}" saved to personalized collections.`); | |
}); | |
}); | |
// Functionality for sharing recipes on social media platforms | |
document.querySelectorAll('.share-button').forEach(button => { | |
button.addEventListener('click', () => { | |
const recipeCard = button.closest('.recipe-card'); | |
const title = recipeCard.getAttribute('data-title'); | |
const description = recipeCard.getAttribute('data-description'); | |
const image = recipeCard.getAttribute('data-image'); | |
// Here, you would implement code to share the recipe on social media platforms | |
// For demonstration purposes, let's log the recipe details | |
console.log(`Recipe "${title}" shared on social media.`); | |
}); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Reset styles */ | |
body, h1, h2, p, ul, li { | |
margin: 0; | |
padding: 0; | |
} | |
/* Basic styles */ | |
body { | |
font-family: Arial, sans-serif; | |
} | |
header { | |
background-color: #0000FF; | |
color: #fff; | |
padding: 10px; | |
display: flex; | |
justify-content: space-between; | |
align-items: center; | |
} | |
nav ul { | |
list-style: none; | |
} | |
nav ul li { | |
display: inline; | |
margin-right: 20px; | |
} | |
nav ul li a { | |
text-decoration: none; | |
color: #fff; | |
} | |
main { | |
display: flex; | |
flex-wrap: wrap; | |
justify-content: space-around; | |
padding: 20px; | |
} | |
.recipe-card { | |
width: 300px; | |
margin-bottom: 20px; | |
} | |
.recipe-card img { | |
width: 100%; | |
height: auto; | |
} | |
.recipe-card h2 { | |
margin-top: 10px; | |
} | |
.recipe-card .actions { | |
margin-top: 10px; | |
} | |
footer { | |
background-color: #00FF00; | |
color: #fff; | |
padding: 10px; | |
text-align: center; | |
} | |
.social-media a { | |
color: #fff; | |
margin-right: 10px; | |
} | |
.meal-planner { | |
padding: 20px; | |
background-color: #A020F0; | |
text-align: center; | |
} | |
.meal-planner input[type="text"], | |
.meal-planner select { | |
margin-bottom: 10px; | |
padding: 8px; | |
font-size: 16px; | |
} | |
.meal-plan { | |
padding: 20px; | |
background-color: #f5f5f5; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Recipe Card