Better navbar behavior

Home is now highlighted
This commit is contained in:
Andrea Cavalli 2019-06-17 14:37:10 +02:00
parent f150f9561d
commit 659803dcf0
2 changed files with 10 additions and 3 deletions

View File

@ -7,14 +7,14 @@
[href]="link.address"
[target]="link.newtab === undefined || link.newtab === true ? '_blank' : '_self'"
rel="noopener"
[class.forcefocus] = "(currentDocument.onDocumentChange() | async)?.id == link.address"
[class.forcefocus] = "currentDocument?.id == link.address"
><span>{{link.text}}</span></a>
<a
*ngIf="link.external !== true"
[routerLink]="link.address"
[target]="link.newtab === true ? '_blank' : '_self'"
rel="noopener"
[class.force-focus] = "'/page/' + (currentDocument.onDocumentChange() | async)?.id == link.address"
[class.force-focus] = "'/page/' + currentDocument?.id == link.address || (currentDocument?.id == 'index' && link.address == '/')"
><span>{{link.text}}</span></a>
</li>
</ul>

View File

@ -4,6 +4,8 @@ import { ActivatedRoute, UrlSegment } from "@angular/router";
import { map } from "rxjs/operators";
import { CurrentDocumentService } from "src/app/services/current-document.service";
import { navigationLinks } from "src/app/app-routing.module";
import { DocumentData } from "src/app/symbols/DocumentData";
import { Observable } from "rxjs";
@Component({
selector: "app-navbar",
@ -18,8 +20,13 @@ export class NavbarComponent implements OnInit, AfterViewInit {
overflowMax = false;
@ViewChild("navlogo") navLogo: ElementRef<HTMLElement>;
@ViewChild("navbuttons") navButtons: ElementRef<HTMLElement>;
currentDocument: DocumentData;
constructor(private elRef: ElementRef<HTMLElement>, public currentDocument: CurrentDocumentService) { }
constructor(private elRef: ElementRef<HTMLElement>, currentDocument: CurrentDocumentService) {
currentDocument.onDocumentChange().subscribe(docData => {
this.currentDocument = docData;
});
}
ngOnInit() {
}