Skip to content

Commit

Permalink
Add a loading spinner to our main nav; fixes #378
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Aug 2, 2019
1 parent ccf3d6c commit 61cd4b8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/assets/javascripts/nav_spinners.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// add a spinner to our navlinks when turbolinks:click is triggered
$(document).on('turbolinks:click', function(event){
var $target = $(event.target);

if ($target.is('#mainnav .nav-link')) {
$target.append('<div class="flex-center nav-spinner"><div class="spinner-border text-primary" role="status"><span class="sr-only">Loading...</span></div></div>');
}
});

// remove the spinner after the new page loads (or is being written to the cache)
$(document).on('turbolinks:load turbolinks:before-cache', function(){
$('#mainnav .nav-spinner').remove();
});
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
@import 'modules/icons';
@import 'modules/checkouts';
@import 'modules/requests';
@import 'modules/nav_spinner';
5 changes: 5 additions & 0 deletions app/assets/stylesheets/modules/nav_spinner.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.nav-spinner {
height: 2rem;
margin-top: -3rem;
margin-bottom: 1rem;
}

0 comments on commit 61cd4b8

Please sign in to comment.