feat(aio): add progress bar

closes #16110
This commit is contained in:
Ward Bell 2017-05-19 01:52:37 -07:00 committed by Pete Bacon Darwin
parent f5b2ce0206
commit 368169dc15
5 changed files with 657 additions and 488 deletions

View File

@ -1,3 +1,7 @@
<div *ngIf="isFetching" class="progress-bar-container">
<md-progress-bar mode="indeterminate" color="warn"></md-progress-bar>
</div>
<md-toolbar color="primary" class="app-toolbar"> <md-toolbar color="primary" class="app-toolbar">
<button class="hamburger" md-button <button class="hamburger" md-button
(click)="sidenav.toggle()" title="Docs menu"> (click)="sidenav.toggle()" title="Docs menu">

File diff suppressed because it is too large Load Diff

View File

@ -54,8 +54,10 @@ export class AppComponent implements OnInit {
@HostBinding('class') @HostBinding('class')
hostClasses = ''; hostClasses = '';
isFetching = false;
isStarting = true; isStarting = true;
isSideBySide = false; isSideBySide = false;
private isFetchingTimeout: any;
private isSideNavDoc = false; private isSideNavDoc = false;
private previousNavView: string; private previousNavView: string;
@ -116,14 +118,18 @@ export class AppComponent implements OnInit {
}); });
this.locationService.currentPath.subscribe(path => { this.locationService.currentPath.subscribe(path => {
if (this.currentPath && path === this.currentPath) { if (this.currentPath && path === this.currentPath) {
// scroll only if on same page (most likely a change to the hash) // scroll only if on same page (most likely a change to the hash)
this.autoScroll(); this.autoScroll();
} else { } else {
// don't scroll; leave that to `onDocRendered` // don't scroll; leave that to `onDocRendered`
this.currentPath = path; this.currentPath = path;
}
}); // Start progress bar if doc not rendered within brief time
clearTimeout(this.isFetchingTimeout);
this.isFetchingTimeout = setTimeout(() => this.isFetching = true, 200);
}
});
this.navigationService.currentNode.subscribe(currentNode => { this.navigationService.currentNode.subscribe(currentNode => {
this.currentNode = currentNode; this.currentNode = currentNode;
@ -168,10 +174,16 @@ export class AppComponent implements OnInit {
} }
onDocRendered() { onDocRendered() {
// Stop fetching timeout (which, when render is fast, means progress bar never shown)
clearTimeout(this.isFetchingTimeout);
// Scroll 500ms after the doc-viewer has finished rendering the new doc // Scroll 500ms after the doc-viewer has finished rendering the new doc
// The delay is to allow time for async layout to complete // The delay is to allow time for async layout to complete
setTimeout(() => this.autoScroll(), 500); setTimeout(() => {
this.isStarting = false; this.autoScroll();
this.isStarting = false;
this.isFetching = false;
}, 500);
} }
onDocVersionChange(versionIndex: number) { onDocVersionChange(versionIndex: number) {

View File

@ -5,8 +5,17 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { Location, LocationStrategy, PathLocationStrategy } from '@angular/common'; import { Location, LocationStrategy, PathLocationStrategy } from '@angular/common';
import { MdToolbarModule, MdButtonModule, MdIconModule, MdInputModule, MdSidenavModule, MdTabsModule, Platform, import {
MdIconRegistry } from '@angular/material'; MdButtonModule,
MdIconModule,
MdIconRegistry,
MdInputModule,
MdProgressBarModule,
MdSidenavModule,
MdTabsModule,
MdToolbarModule,
Platform
} from '@angular/material';
// Temporary fix for MdSidenavModule issue: // Temporary fix for MdSidenavModule issue:
// crashes with "missing first" operator when SideNav.mode is "over" // crashes with "missing first" operator when SideNav.mode is "over"
@ -67,9 +76,10 @@ export const svgIconProviders = [
MdButtonModule, MdButtonModule,
MdIconModule, MdIconModule,
MdInputModule, MdInputModule,
MdToolbarModule, MdProgressBarModule,
MdSidenavModule, MdSidenavModule,
MdTabsModule, MdTabsModule,
MdToolbarModule,
SwUpdatesModule SwUpdatesModule
], ],
declarations: [ declarations: [

View File

@ -1,3 +1,12 @@
.progress-bar-container {
height: 2px;
overflow: hidden;
position: fixed;
top: 64px;
width: 100vw;
z-index: 5;
}
.sidenav-content { .sidenav-content {
padding: 1rem 3rem 3rem; padding: 1rem 3rem 3rem;
margin: auto; margin: auto;
@ -12,9 +21,15 @@
aio-menu { aio-menu {
display: none; display: none;
} }
.progress-bar-container {
top: 56px;
}
.sidenav-content { .sidenav-content {
min-height: 450px; min-height: 450px;
} }
} }
.sidenav-container { .sidenav-container {
@ -32,4 +47,4 @@
height: 1px; height: 1px;
margin: 24px 0px; margin: 24px 0px;
background: $lightgray; background: $lightgray;
} }