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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

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.
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