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

versions: Improve the loading indicator #10740

Merged
merged 1 commit into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions app/styles/crate/versions.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
display: block;
margin-bottom: var(--space-s);
}

&:global(.is-empty) {
visibility: hidden;
}
}
.list {
list-style: none;
Expand All @@ -25,9 +29,13 @@
> * + * {
margin-top: var(--space-2xs);
}

&:global(.is-empty) {
min-height: calc(2 * var(--space-s) + var(--space-xl));
}
}

.load-more {
.load-more, .loading {
--shadow: 0 1px 3px light-dark(hsla(51, 90%, 42%, .35), #232321);

/* TODO: move to shared */
Expand All @@ -36,13 +44,18 @@
border: 0;
padding: 0 var(--space-m);

button {
:not(:global(.is-empty)) + & button {
border-radius: var(--space-3xs);
box-shadow: var(--shadow);
cursor: pointer;
position: relative;
}

:global(.is-empty) + & button {
background-color: transparent;
position: relative;
}

.loading-spinner {
display: inline-flex;
align-items: center;
Expand Down
22 changes: 15 additions & 7 deletions app/templates/crate/versions.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<CrateHeader @crate={{this.crate}} />

<div local-class="results-meta">
<span local-class="page-description" data-test-page-description>
<span local-class="page-description"
class="{{if (and this.loadMoreTask.isRunning (not this.sortedVersions)) 'is-empty'}}"
data-test-page-description
>
<strong>{{ this.sortedVersions.length }}</strong> of <strong>{{ this.crate.num_versions }}</strong>
<strong>{{ this.crate.name }}</strong> versions since
{{date-format this.crate.created_at 'PPP'}}
Expand All @@ -16,22 +19,27 @@
</div>
</div>

<ul local-class="list">
<ul local-class="list" class="{{unless this.sortedVersions 'is-empty'}}">
{{#each this.sortedVersions as |version|}}
<li>
<VersionList::Row @version={{version}} local-class="row" data-test-version={{version.num}} />
</li>
{{/each}}
</ul>
{{#if this.next_page}}
{{#if this.loadMoreTask.isRunning}}
Copy link
Member

Choose a reason for hiding this comment

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

should we also hide the .page-description element above while this.loadMoreTask.isRunning && this.sortedVersions.count === 0?

Copy link
Contributor Author

@eth3lbert eth3lbert Mar 4, 2025

Choose a reason for hiding this comment

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

So, this is regarding the initial load (like the 'is-empty' check mentioned above)? I presume this could be achieved via

style="{{unless this.sortedVersions 'visibility:hidden'}}"

(which could also be implemented using a CSS class and style).

I don't really have a preference on this, but I think the reasoning behind it is to make it more noticeable that it's still loading and is an initial load. So, I'm okay with this.

I'm also wondering if we should prevent the page loading progress (the yellow one at the top) from completing until the first versions have finished loading.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should we also hide the .page-description element above while this.loadMoreTask.isRunning && this.sortedVersions.count === 0?

done!

<div local-class="loading">
<button type="button" data-test-id="loading" disabled={{this.loadMoreTask.isRunning}}
{{on "click" (perform this.loadMoreTask)}}
>
Loading...<LoadingSpinner local-class="loading-spinner" />
</button>
</div>
{{else if this.next_page}}
<div local-class="load-more">
<button type="button" data-test-id="load-more" disabled={{this.loadMoreTask.isRunning}}
{{on "click" (perform this.loadMoreTask)}}
>
Load More
{{#if this.loadMoreTask.isRunning}}
<LoadingSpinner local-class="loading-spinner" />
{{/if}}
</button>
</div>
{{/if}}
{{/if}}
Loading