Skip to content

Commit d59140a

Browse files
authored
feat(daffio): highlight active tree item in sidebar (#2926)
1 parent ecf8ef4 commit d59140a

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

apps/daffio/src/app/docs/components/docs-list/docs-list.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</ng-template>
66

77
<ng-template #daffTreeItemTpl let-node>
8-
<a daffTreeItem [node]="node" [routerLink]="node.url">{{ node.title }}</a>
8+
<a daffTreeItem [selected]="rla.isActive" routerLinkActive [routerLinkActiveOptions]="ROUTER_LINK_ACTIVE_CONFIG" #rla="routerLinkActive" [node]="node" [routerLink]="node.url">{{ node.title }}</a>
99
</ng-template>
1010
</ul>
1111
}

apps/daffio/src/app/docs/components/docs-list/docs-list.component.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ import {
2525

2626
import { DaffioDocList } from '../../models/doc-list';
2727

28+
const DEFAULT_ROUTER_LINK_ACTIVE_CONFIG: RouterLinkActive['routerLinkActiveOptions'] = {
29+
exact: true,
30+
};
31+
2832
const visit = (guide: DaffioDocList): DaffTreeData<unknown> => ({
2933
id: guide.id,
3034
title: guide.title,
@@ -42,11 +46,14 @@ const visit = (guide: DaffioDocList): DaffTreeData<unknown> => ({
4246
AsyncPipe,
4347
RouterLink,
4448
DaffTreeModule,
49+
RouterLinkActive,
4550
],
4651
})
4752
export class DaffioDocsListComponent implements OnInit {
4853
private _list$ = new BehaviorSubject<DaffioDocList>(null);
4954

55+
readonly ROUTER_LINK_ACTIVE_CONFIG = DEFAULT_ROUTER_LINK_ACTIVE_CONFIG;
56+
5057
/**
5158
* The guide list to render
5259
*/
@@ -56,9 +63,6 @@ export class DaffioDocsListComponent implements OnInit {
5663
}
5764

5865
tree$: Observable<DaffTreeData<unknown>>;
59-
activeRouterLinkConfiguration: RouterLinkActive['routerLinkActiveOptions'] = {
60-
exact: true,
61-
};
6266

6367
ngOnInit(): void {
6468
this.tree$ = this._list$.pipe(

0 commit comments

Comments
 (0)