Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

fix(navbar): shadow and routing #225

Merged
merged 4 commits into from
Aug 29, 2017
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: 0 additions & 1 deletion src/app/app-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import {DocViewerModule} from './shared/doc-viewer/doc-viewer-module';
DocViewerModule,
FooterModule,
GuideListModule,
GuideListModule,
GuideViewerModule,
HomepageModule,
NavBarModule,
Expand Down
26 changes: 16 additions & 10 deletions src/app/material-docs-app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Component, ViewEncapsulation} from '@angular/core';
import {Router, NavigationStart} from '@angular/router';
import {Router, NavigationEnd} from '@angular/router';
import 'rxjs/add/operator/filter';


@Component({
Expand All @@ -12,19 +13,24 @@ export class MaterialDocsApp {
showShadow = false;

constructor(router: Router) {
const routesWithNavbarShadow = ['/categories', '/components'];

let previousRoute = router.routerState.snapshot.url;

router.events.subscribe((data: NavigationStart) => {
this.showShadow = data.url.startsWith('/components');
router.events
.filter(event => event instanceof NavigationEnd )
.subscribe((data: NavigationEnd) => {
this.showShadow = !!routesWithNavbarShadow
.find(route => data.urlAfterRedirects.startsWith(route));

// We want to reset the scroll position on navigation except when navigating within
// the documentation for a single component.
if (!isNavigationWithinComponentView(previousRoute, data.url)) {
resetScrollPosition();
}
// We want to reset the scroll position on navigation except when navigating within
// the documentation for a single component.
if (!isNavigationWithinComponentView(previousRoute, data.urlAfterRedirects)) {
resetScrollPosition();
}

previousRoute = data.url;
});
previousRoute = data.urlAfterRedirects;
});
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/homepage/homepage.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ <h1 class="mat-h1">Angular Material</h1>
<h2> Material Design components for Angular</h2>
</div>
<div class="docs-header-start">
<a md-raised-button class="docs-button" routerLink="guide/getting-started">Get started</a>
<a md-raised-button class="docs-button" routerLink="/guide/getting-started">Get started</a>
</div>
</div>
</header>
Expand Down Expand Up @@ -59,7 +59,7 @@ <h2>Optimized for Angular</h2>
</div>
</div>
<div class="docs-homepage-bottom-start">
<a md-raised-button class="docs-button" routerLink="guide/getting-started">Get started</a>
<a md-raised-button class="docs-button" routerLink="/guide/getting-started">Get started</a>
</div>
</div>

Expand Down