-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(daffio): add pakcages list sidebar
- Loading branch information
Showing
23 changed files
with
366 additions
and
130 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
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
3 changes: 0 additions & 3 deletions
3
apps/daffio/src/app/docs/containers/sidebar/sidebar.component.html
This file was deleted.
Oops, something went wrong.
Empty file.
70 changes: 0 additions & 70 deletions
70
apps/daffio/src/app/docs/containers/sidebar/sidebar.component.spec.ts
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
apps/daffio/src/app/docs/containers/sidebar/sidebar.component.ts
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
apps/daffio/src/app/docs/containers/sidebar/sidebar.module.ts
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
apps/daffio/src/app/guides/components/packages-list/packages-list.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> |
74 changes: 74 additions & 0 deletions
74
apps/daffio/src/app/guides/components/packages-list/packages-list.component.spec.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,74 @@ | ||
import { | ||
waitForAsync, | ||
ComponentFixture, | ||
TestBed, | ||
} from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
|
||
import { DaffTreeModule } from '@daffodil/design/tree'; | ||
|
||
import { DaffioGuidesNavComponent } from './guides-nav.component'; | ||
|
||
describe('DaffioGuidesNavComponent', () => { | ||
let component: DaffioGuidesNavComponent; | ||
let fixture: ComponentFixture<DaffioGuidesNavComponent>; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ | ||
DaffioGuidesNavComponent, | ||
], | ||
imports: [ | ||
RouterTestingModule, | ||
NoopAnimationsModule, | ||
DaffTreeModule, | ||
], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(DaffioGuidesNavComponent); | ||
component = fixture.componentInstance; | ||
const guideWithoutChildren = { | ||
id: 'id2', | ||
title: 'title2', | ||
children: [], | ||
}; | ||
const guideWithChildren = { | ||
id: 'id3', | ||
title: 'title3', | ||
children: [ | ||
{ | ||
id: 'id4', | ||
title: 'title4', | ||
children: [], | ||
}, | ||
], | ||
}; | ||
|
||
component.guideList = { | ||
id: 'root', | ||
title: 'root', | ||
children: [ | ||
guideWithoutChildren, | ||
guideWithChildren, | ||
], | ||
}; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should render an anchor tag when the guide child has no children', () => { | ||
const anchorTags = fixture.debugElement.queryAll(By.css('a')); | ||
expect(anchorTags.length).toEqual(1); | ||
const buttons = fixture.debugElement.queryAll(By.css('button')); | ||
expect(buttons.length).toEqual(1); | ||
console.log(fixture.debugElement.nativeElement.innerHTML); | ||
}); | ||
}); |
50 changes: 50 additions & 0 deletions
50
apps/daffio/src/app/guides/components/packages-list/packages-list.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-docs-packages-list', | ||
templateUrl: './packages-list.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class DaffioDocsPackagesListComponent { | ||
|
||
_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/packages-list/packages-list.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 { DaffioDocsPackagesListComponent } from './packages-list.component'; | ||
|
||
@NgModule({ | ||
declarations: [ | ||
DaffioDocsPackagesListComponent, | ||
], | ||
exports: [ | ||
DaffioDocsPackagesListComponent, | ||
], | ||
imports: [ | ||
CommonModule, | ||
RouterModule, | ||
DaffTreeModule, | ||
], | ||
}) | ||
export class DaffioDocsPackagesListComponentModule { } |
1 change: 1 addition & 0 deletions
1
apps/daffio/src/app/guides/components/packages-sidebar/packages-sidebar.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 @@ | ||
<daffio-docs-packages-list-container></daffio-docs-packages-list-container> |
4 changes: 4 additions & 0 deletions
4
apps/daffio/src/app/guides/components/packages-sidebar/packages-sidebar.component.scss
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,4 @@ | ||
:host { | ||
display: block; | ||
padding: 24px 0; | ||
} |
Oops, something went wrong.