Skip to content

Commit

Permalink
Make the "Importing" button text more dynamic
Browse files Browse the repository at this point in the history
Now the text of the button cycles through little loading dots to
indicate that there is some thinking happening.

This was part of my original vision for this button, so finally we have
the import loading experience our users deserve.
  • Loading branch information
pcraig3 committed Dec 12, 2024
1 parent 2ca3512 commit 7336075
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve
### Changed

- Decompose instructions boxes that start with "Instructions for new nofo team"
- Made the import button more dynamic

### Fixed

- Loading gif also used on re-import page
- bug: since adding replace_links, replace_chars was not being applied

## [1.39.0] - 2023-12-04
Expand Down
8 changes: 8 additions & 0 deletions bloom_nofos/bloom_nofos/static/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,14 @@ details > summary > span:hover {
padding: 8px 0;
}

.nofo_import .submit-button {
width: 132px;
}

.nofo_import .submit-button.submit-button--loading {
text-align: left;
}

/* Edit page */

/* header widget for NOFO */
Expand Down
15 changes: 13 additions & 2 deletions bloom_nofos/bloom_nofos/templates/includes/loading_horse.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,21 @@
const loadingGif = form.querySelector(".loading-horse--container");

form.addEventListener("submit", function () {
// Disable the button and change its text
// Disable the button, change its text, add classname
button.disabled = true;
button.textContent = "Importing…";
button.textContent = "Importing";
button.classList.add("submit-button--loading");
button.setAttribute("aria-label", "Importing…");

let dotCount = 0; // Tracks the number of dots (0 to 3)

// Start an interval to cycle through the dots
intervalId = setInterval(() => {
dotCount = (dotCount + 1) % 4; // Cycle between 0, 1, 2, 3
button.textContent = `Importing${".".repeat(dotCount)}`;
}, 330);

// show the horse gif
setTimeout(() => {
loadingGif.classList.add("visible");
}, 50);
Expand Down

0 comments on commit 7336075

Please sign in to comment.