freelawproject / courtlistener

A fully-searchable and accessible archive of court data including growing repositories of opinions, oral arguments, judges, judicial financial records, and federal filings.
https://www.courtlistener.com
Other
532 stars 147 forks source link

Add a spinner or progress marker of some kind to the search results #4384

Closed mlissner closed 6 days ago

mlissner commented 2 weeks ago

It'd be fun to do something fancy, but we probably don't have time to get it right.

Nevertheless, ideas include:

Probably we should just do the last thing, or maybe the last two things, but it'd be fun to do more.

Back in https://github.com/freelawproject/courtlistener/issues/4209#issuecomment-2285130213, we decided the spinner could wait until HTMX, but I agree that we should do it.

mlissner commented 2 weeks ago

Assigning to Eduardo, because he just did a spinner for the CSV feature, and because he has https://github.com/freelawproject/recap/issues/361 on his backlog as well. I guess he's our spinner guy.

ERosendo commented 1 week ago

I've been experimenting with different spinner options for our search interface, based on the ideas you provided.

As a first step, I've implemented the grayed-out button with spinners approach. Here are a few GIFs showcasing how this might look:

Search bar in the homepage template ![Screen Recording 2024-09-04 at 10 46 26 PM](https://github.com/user-attachments/assets/2aa57886-f1dc-41d8-b481-8a3b65592e7e)
Search button in the results page ![Screen Recording 2024-09-04 at 10 59 50 PM](https://github.com/user-attachments/assets/e399df56-867a-4f4e-8fa3-5021c4f8ab7f)
Search button in the sidebar filters template ![Screen Recording 2024-09-05 at 12 42 56 AM](https://github.com/user-attachments/assets/0412b163-98fe-4a60-a37d-63c34ed11469)

I also tried an option where the button remains active while the spinner is displayed. Here are GIFs demonstrating that:

Search bar in the homepage template ![Screen Recording 2024-09-05 at 1 08 52 AM](https://github.com/user-attachments/assets/07284f11-f2f0-4979-b792-71cfd5787df5)
Search button in the results page ![Screen Recording 2024-09-05 at 1 12 14 AM](https://github.com/user-attachments/assets/ecd8e0c5-56b1-4229-b915-ffd77e3eda71)
Search button in the sidebar filters template ![Screen Recording 2024-09-05 at 1 10 56 AM](https://github.com/user-attachments/assets/cda1c0ad-aee8-4b89-a2f6-9196417dec8a)

Additionally, I experimented with removing the search results and displaying a medium-sized spinner. Here's a GIF showcasing this option:

Screen Recording 2024-09-05 at 2 01 31 AM

mlissner commented 1 week ago

These look great, except for the one where the button doesn't get grayed out. I think that'd be a mistake, since it'd encourage people to click it a second time (and start things over). I assume you're using the disabled state for the button when you do this?

I think if we only did the spinner(s) that'd help folks a ton. I'm curious to see your HTMX progress bar solution next. What libraries are you looking at for that?

ERosendo commented 1 week ago

I assume you're using the disabled state for the button when you do this?

You're right! In #2331, we introduced a new HTMX extension called loading-states. This extension enhances user experience by controlling element behavior while a request is in flight. One key feature is the ability to disable specific HTML elements using the data-loading-disable attribute.

I'm curious to see your HTMX progress bar solution next. What libraries are you looking at for that?

I noticed GitHub is using Turbo's progress bar component and decided to adopt a similar approach for our application. Their progress bar is a simple <div> element with the class turbo-progress-bar (you can see the code for reference: code). and we can use HTMX events to achieve a similar effect without introducing additional dependencies. Here's the plan:

ERosendo commented 1 week ago

@mlissner Here's a visual experiment to show the progress bar in action. I slowed down the internet so you can see it working. I tried the regular blue one and then experimented with a red bar that matched the CL logo color.

Screen Recording 2024-09-05 at 4 05 22 PM


Screen Recording 2024-09-05 at 4 03 12 PM

Let me know what you think.

mlissner commented 1 week ago

That red looks pretty danged good. Should we be implementing the progress bar in a way that it can easily be used by other htmx features?

ERosendo commented 1 week ago

Should we be implementing the progress bar in a way that it can easily be used by other htmx features?

Absolutely! The goal is to create a reusable JavaScript module that encapsulates both the logic and styling of the progress bar. This will allow us to seamlessly integrate progress bars into our HTMX requests, similar to how the loading-states extension works, enhancing the user experience.