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
29 changes: 29 additions & 0 deletions submissions/Healthy Food/data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const foods = [
"Apple",
"Avocado",
"Banana",
"Blueberries",
"Broccoli",
"Carrot",
"Chia seeds",
"Garlic",
"Green tea",
"Kale",
"Lentils",
"Oats",
"Quinoa",
"Salmon",
"Spinach",
"Sweet Potato",
"Tomato",
"Walnuts",
"Yogurt"
];

const tips = [
"Drink more water throughout the day.",
"Eat a rainbow of vegetables daily.",
"Replace soda with green tea.",
"Snack on nuts instead of chips.",
"Add seeds like chia and flax to your diet."
];
14 changes: 14 additions & 0 deletions submissions/Healthy Food/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"manifest_version": 3,
"name": "Healthy Food",
"description": "Explore healthy food options and daily wellness tips.",
"version": "1.0",
"action": {
"default_popup": "popup.html",
"default_icon": "icon.png"
},
"permissions": ["storage"],
"icons": {
"128": "icon.png"
}
}
44 changes: 44 additions & 0 deletions submissions/Healthy Food/popup.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
body {
width: 300px;
font-family: sans-serif;
padding: 10px;
background: #f4fff4;
}

h1 {
font-size: 18px;
margin-bottom: 10px;
}

#daily-tip {
font-style: italic;
margin-bottom: 10px;
}

input {
width: 100%;
padding: 5px;
margin-bottom: 10px;
}

ul {
list-style: none;
padding: 0;
max-height: 300px;
overflow-y: auto;
}

li {
padding: 5px;
background: #ffffff;
border: 1px solid #ccc;
margin-bottom: 5px;
cursor: pointer;
display: flex;
justify-content: space-between;
align-items: center;
}

li.fav {
background: #e0ffe0;
}
15 changes: 15 additions & 0 deletions submissions/Healthy Food/popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>Healthy Food</title>
<link rel="stylesheet" href="popup.css" />
</head>
<body>
<h1>Healthy Food</h1>
<p id="daily-tip"></p>
<input type="text" id="search" placeholder="Search food..." />
<ul id="food-list"></ul>
</body>
<script src="data.js"></script>
<script src="popup.js"></script>
</html>
51 changes: 51 additions & 0 deletions submissions/Healthy Food/popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
function getRandomTip() {
return tips[Math.floor(Math.random() * tips.length)];
}

function loadFavorites() {
return JSON.parse(localStorage.getItem("favorites") || "[]");
}

function saveFavorites(favs) {
localStorage.setItem("favorites", JSON.stringify(favs));
}

function renderFoodList(filter = "") {
const list = document.getElementById("food-list");
list.innerHTML = "";
const favs = loadFavorites();

foods
.filter(f => f.toLowerCase().includes(filter.toLowerCase()))
.forEach(food => {
const li = document.createElement("li");
li.textContent = food;
if (favs.includes(food)) li.classList.add("fav");

const btn = document.createElement("button");
btn.textContent = favs.includes(food) ? "★" : "☆";
btn.onclick = (e) => {
e.stopPropagation();
const newFavs = favs.includes(food)
? favs.filter(f => f !== food)
: [...favs, food];
saveFavorites(newFavs);
renderFoodList(document.getElementById("search").value);
};

li.appendChild(btn);
li.onclick = () => {
window.open(`https://www.google.com/search?q=${encodeURIComponent(food)}+nutrition`, '_blank');
};

list.appendChild(li);
});
}

document.addEventListener("DOMContentLoaded", () => {
document.getElementById("daily-tip").textContent = getRandomTip();
document.getElementById("search").addEventListener("input", (e) => {
renderFoodList(e.target.value);
});
renderFoodList();
});