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

Put nanobar back #1553

Merged
merged 1 commit into from
Jul 27, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- Clean up conditional logic in a couple component templates [#1547](https://github.com/bigcommerce/cornerstone/pull/1547)
- Remove "demo" product conditional logic [#1551](https://github.com/bigcommerce/cornerstone/pull/1551)
- Add responsive breakpoints to product carousel. [#1458](https://github.com/bigcommerce/cornerstone/pull/1458)
- Add nanobar back to fix tests [#1553](https://github.com/bigcommerce/cornerstone/pull/1553)

## 3.5.1 (2019-06-24)
- Fix conditional logic in share.html [#1522](https://github.com/bigcommerce/cornerstone/pull/1522)
Expand Down
2 changes: 2 additions & 0 deletions assets/js/theme/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import cartPreview from './global/cart-preview';
import privacyCookieNotification from './global/cookieNotification';
import maintenanceMode from './global/maintenanceMode';
import carousel from './common/carousel';
import loadingProgressBar from './global/loading-progress-bar';
import svgInjector from './global/svg-injector';

export default class Global extends PageManager {
Expand All @@ -25,6 +26,7 @@ export default class Global extends PageManager {
mobileMenuToggle();
privacyCookieNotification();
maintenanceMode(this.context.maintenanceMode);
loadingProgressBar();
svgInjector();
}
}
41 changes: 41 additions & 0 deletions assets/js/theme/global/loading-progress-bar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import Nanobar from 'nanobar';

export default function () {
// Create the nanobar instance
const nanobar = new Nanobar();

// Timer for moving progress bar during ajax calls
let timer = null;
let current = 0;

function clearTimer() {
if (timer) {
clearInterval(timer);
timer = null;
}
}

function setTimer() {
clearTimer();

current = 0;
timer = setInterval(() => {
current += 3;
if (current <= 100) {
nanobar.go(current);
} else {
clearTimer();
}
}, 50);
}

// Attach global jquery handlers to listen for ajax start
$(document).ajaxSend(() => {
setTimer();
});

$(document).ajaxComplete(() => {
nanobar.go(100);
clearTimer();
});
}
3 changes: 3 additions & 0 deletions assets/scss/components/_components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
// Slick carousel
@import "vendor/slick/component";

// Nanobar Ajax loading progress bar
@import "vendor/nanobar/component";

// SweetAlert2 replacement for JavaScript alert/confirmations
@import "vendor/sweetalert2/component";

Expand Down
5 changes: 5 additions & 0 deletions assets/scss/components/vendor/nanobar/_component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// =============================================================================
// NANOBAR - AJAX LOADING PROGRESS
// =============================================================================

@import "nanobar";
20 changes: 20 additions & 0 deletions assets/scss/components/vendor/nanobar/_nanobar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// =============================================================================
// NANOBAR - AJAX LOADING PROGRESS
// =============================================================================

.nanobar {
display: none;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a straight revert except for this change to hide the bar.

width: 100%;
height: remCalc(5px);
z-index: 9999;
top: 0;
pointer-events: none;
user-select: none;

.bar {
width: 0;
height: 100%;
transition: height .1s;
background-color: stencilColor("pace-progress-backgroundColor");
}
}
Loading