Skip to content

Conversation

@AgnesSj01
Copy link

No description provided.

@JennieDalgren JennieDalgren self-assigned this Oct 23, 2025
Copy link

@JennieDalgren JennieDalgren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find your netlify link anywhere?

const sortPopSelect = document.getElementById("sortPop");
const searchInput = document.getElementById("search");

const renderStars = (num) => "⭐".repeat(num);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +12 to +13
const CACHE_KEY = "recipesCache"; // localStorage key
const CACHE_TIME = 6 * 60 * 60 * 1000; // 6 hours in ms

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Comment on lines +81 to +89
const query = searchQuery.trim().toLowerCase();
if (query) {
list = list.filter((r) => {
const inTitle = (r.title || "").toLowerCase().includes(query);
const inIngredients = (r.ingredients || []).some((i) =>
(i || "").toLowerCase().includes(query)
);
return inTitle || inIngredients;
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +118 to +120
if (list.length === 0) {
cardsEl.innerHTML = `<p>No recipes found. Try another filter</p>`;
return;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great empty state

// Get the diet type (vegan, vegetarian, etc.)
const dietText = r.diet;
// Convert popularity score into stars
const popularText = renderStars(r.popularity);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clever

Comment on lines +136 to +137
const ingHtml = r.ingredients.map((i) => `<li>${i}</li>`).join(""); //Här görs igridienslistan om från array till html

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stick to english ;)

Comment on lines +174 to +185
<article class="recipe">
<img src="${r.img}" alt="${r.title}" />
<h3 class="title">${r.title}</h3>
<div class="meta">
<p><strong>Cuisine:</strong> <span class="cuisine">${cuisineText}</span></p>
<p><strong>Diet:</strong> <span>${dietText}</span></p>
<p><strong>Popularity:</strong>${popularText}</p>
<p><strong>Time:</strong> <span>${timeText}</span></p>
</div>
<h4>Ingredients</h4>
<ul>${ingHtml}</ul>
</article>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be thorough with indentation of html even inside of js

cardsEl.innerHTML = renderSingleResult(recipe);

// Reveal the "Show all" button so the user can restore the list
showAllButton.style.display = "inline-block";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⭐ nice ux

Comment on lines +235 to +240
const saved = JSON.parse(cached);
const tooOld = Date.now() - saved.timestamp > CACHE_TIME;

// Use cached recipes and render immediately
if (!tooOld) {
cardsEl.innerHTML = "<p>Showing recipes from cache</p>";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! very good use of a timed cache

Comment on lines +271 to +284
switch (error.message) {
case "401":
message = "<p>Invalid or missing API key (401).</p>";
break;
case "402":
case "429":
message = `
<p>You have reached your daily API quota or are rate-limited (402/429).</p>
<p>Try again tomorrow, reduce requests, or use cached data.</p>
`;
break;
default:
message =
"<p>Could not fetch recipes right now. Please try again later.</p>";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice set up of error msgs

@JennieDalgren
Copy link

never mind, I just saw that I reviewed your other PR already! :D
Remember, you don't need to open PR more than once. It will update if you update. And multiple persons can feedback on it.

@AgnesSj01
Copy link
Author

AgnesSj01 commented Oct 24, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants