Skip to content
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

Add sorting functionality to category pages #596

Merged
merged 6 commits into from
Jan 28, 2025
Merged

Add sorting functionality to category pages #596

merged 6 commits into from
Jan 28, 2025

Conversation

17cupsofcoffee
Copy link
Collaborator

This PR adds a dropdown to category pages, allowing the crates to be sorted in various ways:

firefox_2025-01-25_19-26-26.mp4

I originally intended to use a pre-made library for this, but all the ones I could find either:

  • were way too huge/complex
  • only worked with tables
  • only worked with JS frameworks like React

Since we're already using jQuery for other parts of the site, I decided to just take the old school approach and write some JS myself. It seems fairly snappy on desktop, though I need to give it a try on mobile too.


I also found while working on this that Semantic UI's .cards class (which is used to create the columns on the homepage/game categories) is an absolute nightmare - it uses negative margins for everything, which breaks the layout in strange ways if you try to put any other UI near it 🙃

To get around this, I ended up replacing it with a new .card-grid class, which uses CSS Grid to create the columns. This feature is supported in 97% of browsers at this point.


I would appreciate feedback on the UI, and whether there are other sort options that should be available!

I did originally have the option to sort by license, but the license info is a little too inconsistent for that to work (e.g. some repos have MIT and Apache, some have Apache and MIT).

The way that Semantic UI does columns for the cards is a massive pain to override (it uses negative margins for everything), and this was making the menu glitch out on mobile. CSS grid is supported by every major browser now, so there's no reason not to use it.
This seems more in line with how UI is laid out on other sites I've seen.
@17cupsofcoffee
Copy link
Collaborator Author

I made a few more tweaks to the UI on desktop and mobile:

image
image

I think at this point, this is ready to be merged - I will wait a bit longer to see if there's any feedback first.

@17cupsofcoffee 17cupsofcoffee merged commit 9f60c5d into master Jan 28, 2025
4 checks passed
@17cupsofcoffee 17cupsofcoffee deleted the sorting branch January 28, 2025 18:03
@17cupsofcoffee 17cupsofcoffee mentioned this pull request Jan 28, 2025
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.

1 participant