Skip to content

Commit

Permalink
fix(docs): navigation issues fix, make links work
Browse files Browse the repository at this point in the history
  • Loading branch information
nnixaa committed Jun 28, 2017
1 parent 2e079ad commit 001ca02
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/app/docs/docs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class DocsService {

let menuItems = structure.map((item: any) => {
const menuItem: any = {};
const itemLink = `${parentLink ? parentLink : ''}/${item.name.replace(/\s/, '-').toLowerCase()}`;
const itemLink = `${parentLink ? parentLink : ''}/${item.name.replace(/\s/g, '-').toLowerCase()}`;
if (item.type !== 'section') {
menuItem['link'] = itemLink;
}
Expand Down
8 changes: 8 additions & 0 deletions docs/app/docs/page/page.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ $text-color-active: rgba(255, 40, 36, 0.87);
@include nga-install-component {
/deep/ nga-card {

a {
color: nga-theme(color-fg-active);

@include hover-focus-active() {
color: nga-theme(color-primary);
}
}

nga-card-header {
font-size: nga-theme(font-size-lg);
font-weight: bold;
Expand Down
35 changes: 26 additions & 9 deletions docs/app/docs/page/page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { Component } from '@angular/core';
import { Component, OnDestroy, Renderer2 } from '@angular/core';

import { NgaMenuService } from '@akveo/nga-theme';
import { Subscription } from 'rxjs';
import { NavigationEnd, Router } from '@angular/router';

@Component({
selector: 'ngd-page',
Expand All @@ -32,16 +34,31 @@ import { NgaMenuService } from '@akveo/nga-theme';
</nga-card>
`,
})
export class NgdPageComponent {
export class NgdPageComponent implements OnDestroy {

currentItem: any;
private routerSubscription: Subscription;

constructor(private menuService: NgaMenuService) {
this.menuService.onItemSelect().subscribe((event: {tag: string, item: any}) => {
// TODO: check the tag
if (event && event.item && event.item.data) {
this.currentItem = event.item.data;
}
});
constructor(private menuService: NgaMenuService,
private router: Router,
private renderer: Renderer2) {

this.routerSubscription = this.router.events
.filter(event => event instanceof NavigationEnd)
.subscribe((event) => {

this.menuService.getSelectedItem().subscribe((event: {tag: string, item: any}) => {
if (event && event.item && event.item.data) {
this.currentItem = event.item.data;

this.renderer.setProperty(document.body, 'scrollTop', 0);
}
});

});
}

ngOnDestroy() {
this.routerSubscription.unsubscribe();
}
}

0 comments on commit 001ca02

Please sign in to comment.