-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(daffio): implement tree (#1824)
- Loading branch information
1 parent
f211e48
commit e15b6a2
Showing
14 changed files
with
115 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/daffio/src/app/core/sidebar/containers/sidebar-viewport/sidebar-viewport.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
apps/daffio/src/app/guides/components/guides-nav-tree/guides-nav-tree.component.html
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
apps/daffio/src/app/guides/components/guides-nav-tree/guides-nav-tree.component.scss
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
apps/daffio/src/app/guides/components/guides-nav-tree/guides-nav-tree.component.ts
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
apps/daffio/src/app/guides/components/guides-nav-tree/guides-nav-tree.module.ts
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
apps/daffio/src/app/guides/components/guides-nav/guides-nav.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<ul daff-tree [tree]="_tree" *ngIf="_tree"> | ||
<ng-template #daffTreeItemWithChildrenTpl let-node> | ||
<button daffTreeItem [node]="node">{{ node.title }} </button> | ||
</ng-template> | ||
|
||
<ng-template #daffTreeItemTpl let-node> | ||
<a daffTreeItem [node]="node" [routerLink]="node.url">{{ node.title }}</a> | ||
</ng-template> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
apps/daffio/src/app/guides/components/guides-nav/guides-nav.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
Input, | ||
} from '@angular/core'; | ||
import { RouterLinkActive } from '@angular/router'; | ||
|
||
import { | ||
DaffTreeData, | ||
daffTransformTreeInPlace, | ||
} from '@daffodil/design/tree'; | ||
|
||
import { DaffioGuideList } from '../../../docs/models/guide-list'; | ||
|
||
const visit = (guide: DaffioGuideList): DaffTreeData<unknown> => ({ | ||
id: guide.id, | ||
title: guide.title, | ||
url: guide.path, | ||
items: [], | ||
data: {}, | ||
}); | ||
|
||
@Component({ | ||
selector: 'daffio-guides-nav', | ||
templateUrl: './guides-nav.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class DaffioGuidesNavComponent { | ||
|
||
_guideList: DaffioGuideList; | ||
/** | ||
* The guide list to render | ||
*/ | ||
@Input() | ||
get guideList(): DaffioGuideList { | ||
return this._guideList; | ||
}; | ||
set guideList(val: DaffioGuideList) { | ||
if(this._guideList !== val) { | ||
this._tree = daffTransformTreeInPlace(val, visit, 'children'); | ||
} | ||
this._guideList = val; | ||
} | ||
|
||
_tree: DaffTreeData<unknown>; | ||
|
||
activeRouterLinkConfiguration: RouterLinkActive['routerLinkActiveOptions'] = { | ||
exact: true, | ||
}; | ||
} |
22 changes: 22 additions & 0 deletions
22
apps/daffio/src/app/guides/components/guides-nav/guides-nav.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
import { RouterModule } from '@angular/router'; | ||
|
||
import { DaffTreeModule } from '@daffodil/design/tree'; | ||
|
||
import { DaffioGuidesNavComponent } from './guides-nav.component'; | ||
|
||
@NgModule({ | ||
declarations: [ | ||
DaffioGuidesNavComponent, | ||
], | ||
exports: [ | ||
DaffioGuidesNavComponent, | ||
], | ||
imports: [ | ||
CommonModule, | ||
RouterModule, | ||
DaffTreeModule, | ||
], | ||
}) | ||
export class DaffioGuidesNavModule { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters