Skip to content

First PR for this project #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open

First PR for this project #17

wants to merge 28 commits into from

Conversation

govargas
Copy link

Hi Christina! This PR implements the Recipe Library I did for this assignment. The project dynamically fetches recipe data from Spoonacular’s /recipes/random endpoint and displays recipe cards with filtering, sorting, random selection, infinite scrolling, and caching.

I implemented—I think—all of the requirements and some stretch goals; I describe these and more in detail in the README file.

If it looks like a lot of code, well, I’m still working to understand everything I did!
I also wish I implemented the search function, but that would have been too much for my brain to grasp right now. Maybe later in the week.

index.html Outdated

Choose a reason for hiding this comment

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

Super cool that you created your own dropdown! And html looks neat and makes sense.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you!

*, *::before, *::after {
box-sizing: border-box;
}

Choose a reason for hiding this comment

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

I'm curious why you used *::before and *::after? (no feedback just genuinely interested)

Copy link
Author

@govargas govargas Mar 18, 2025

Choose a reason for hiding this comment

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

It comes from CSS I used in the previous business project. The design looked off without it, and I learned it was good practice for potential pseudo-elements, so I kept it. Removing it in this project distorts the recipe card’s alignment, placement, and borders on both mobile and desktop. Seems like a quick fix tho, so I am eager to learn alternative methods to address these issues.

.menu-icon.open span:nth-child(3) {
transform: translateY(-9px) rotate(45deg);
}

Choose a reason for hiding this comment

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

This is a really cool implementation of the nav hamburger menu!

Copy link
Author

Choose a reason for hiding this comment

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

Glad you like it. I took Technigo's nav hamburger icon as inspiration and used on the first project, the business site. Then used that as a template for this one :)

Choose a reason for hiding this comment

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

Some cool CSS and the file looks organised and I found it easy to read :)

Choose a reason for hiding this comment

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

So I think that not everything needs to be inside the document.addEventListener("DOMContentLoaded") function. It might be a bit more readable if you find a way to break some functions out of there and use DOMContentLoaded when its needed. Unless there is a specific reason that I'm missing.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks. I will definitely look into that!


// --- Loading State ---
recipesContainer.innerHTML = "<p>Loading recipes...</p>";

Choose a reason for hiding this comment

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

This is an interesting way of doing this, adding this before the recipes are fetched, its a cool and simple solution in my opinion!

Copy link
Author

Choose a reason for hiding this comment

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

Thank you!

Copy link

@christina-baldwin christina-baldwin left a comment

Choose a reason for hiding this comment

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

I've added a few comments within the code with more specifics. I think this is well made and organised and all the requirements and stretch goals are implemented so great job!

@govargas
Copy link
Author

Thanks for your thoughtful comments and feedback, Christina!

@HIPPIEKICK HIPPIEKICK self-assigned this Mar 27, 2025
Copy link
Contributor

@HIPPIEKICK HIPPIEKICK left a comment

Choose a reason for hiding this comment

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

I really like what you did with the filters and sorting options, great idea to make it less cluttered! However, I found a little bug when opening the Sort by drop down. When hovering Newest and Rating, it jumps around because of the added border. A solution is to always have a transparent border to start with (and then just change the color on hover). This way we avoid the growing width and the jumping.

Another bug I found is that your Random button doesn’t work if some filters are selected. It’s fine if you want to connect the random recipe with your filters, but make sure to display something useful if you can’t find a matching recipe.

And a third bug:
When choosing Vegetarian and Mediterranean I get like 10 identical recipes. I think it might be a bug with the infinite scrolling?

Don’t forget that we should always default to const. You can always change to let if you bump into errors. Apart from that, your JavaScript looks good and you’ve chosen descriptive function/variable names.

Some things to fix in order to be approved, but with allt this said I think you should be proud of all you have accomplished ⭐

@govargas
Copy link
Author

Hi Matilda, thanks for the feedback!
I made the following changes based on your request:

Border “jumping around” issue dropdown menu buttons:
I added a default transparent border to the sort buttons as suggested, and extended it to all dropdown buttons since I noticed the jumping effect there as well.

Random button bug when some filters are selected:
I added a check to see if there are any matching recipes in the filtered list. When filtering leaves no matches for the current localStorage (cached for 1 hour on the user’s browser), the app now displays a message: “No matching recipe found for the selected filters. Please reset the filters, select different options or try refreshing the page in a while” instead of trying to pick a random recipe from an empty array.

Duplicate recipe bug when applying filters + infinite scrolling:
I added a deduplication step in the JS when fetching new recipes during infinite scrolling to avoid duplicate entries when filters like Vegetarian and Mediterranean are applied.

const as default:
I updated variable declarations to use const by default unless reassignment was needed. Might have missed some, but I think I changed the crucial ones.

Please let me know if you find this works better or if there’s anything else I need to work on in order to get approved. Thank you!

@govargas govargas requested a review from HIPPIEKICK March 28, 2025 14:21
Copy link
Contributor

@HIPPIEKICK HIPPIEKICK left a comment

Choose a reason for hiding this comment

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

Amazing work sorting this out ⭐ Thanks for documenting your changes so well too 😊

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.

3 participants