Skip to content

Commit

Permalink
feat(daffio): use tree in daffio guide nav
Browse files Browse the repository at this point in the history
  • Loading branch information
xelaint committed Sep 7, 2021
1 parent b182bad commit 6e015fe
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ describe('DaffioApiPageComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(DaffioApiPageComponent);
component = fixture.componentInstance;
console.log(doc);
stubActivatedRoute.data.next({ doc });
fixture.detectChanges();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<daff-sidebar-viewport (backdropClicked)="close()" [mode]="mode$ | async" [opened]="showSidebar$ | async">
<daff-sidebar class="daffio-sidebar" (escapePressed)="close()">
<button type="button" daff-button class="daffio-sidebar__button">Get Started</button>
<daffio-guides-nav-tree [guideList]="sidebarContents$ | async"></daffio-guides-nav-tree>
<daffio-guides-nav [guideList]="sidebarContents$ | async"></daffio-guides-nav>
<a routerLink="/api">API Index</a>
</daff-sidebar>
<ng-content></ng-content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
StoreModule,
combineReducers,
} from '@ngrx/store';
import { DaffioGuidesNavTreeModule } from 'apps/daffio/src/app/guides/components/guides-nav-tree/guides-nav-tree.module';
import { DaffioGuidesNavModule } from 'apps/daffio/src/app/guides/components/guides-nav/guides-nav.module';
import { cold } from 'jasmine-marbles';

import {
Expand Down Expand Up @@ -47,7 +47,7 @@ describe('DaffioSidebarViewportContainer', () => {
RouterTestingModule,
NoopAnimationsModule,
DaffSidebarModule,
DaffioGuidesNavTreeModule,
DaffioGuidesNavModule,
HttpClientTestingModule,
],
declarations: [
Expand Down
4 changes: 2 additions & 2 deletions apps/daffio/src/app/core/sidebar/sidebar.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
DaffButtonModule,
} from '@daffodil/design';

import { DaffioGuidesNavTreeModule } from '../../guides/components/guides-nav-tree/guides-nav-tree.module';
import { DaffioGuidesNavModule } from '../../guides/components/guides-nav/guides-nav.module';
import { DaffioSidebarViewportContainer } from './containers/sidebar-viewport/sidebar-viewport.component';
import { DaffioSidebarStateModule } from './sidebar.state.module';

Expand All @@ -18,7 +18,7 @@ import { DaffioSidebarStateModule } from './sidebar.state.module';
DaffioSidebarStateModule,
DaffSidebarModule,
DaffButtonModule,
DaffioGuidesNavTreeModule,
DaffioGuidesNavModule,
],
declarations: [
DaffioSidebarViewportContainer,
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<daff-tree *ngIf="guideList">
<ng-container *ngFor="let guide of guideList.children">
<ng-container *ngIf="guide.children.length === 0">
<a daff-tree-item [selected]="rla.isActive" [routerLink]="guide.path" routerLinkActive #rla="routerLinkActive" [routerLinkActiveOptions]="activeRouterLinkConfiguration">
<span daffTreeItemTitle>{{ guide.title }}</span>
</a>
</ng-container>
<ng-container *ngIf="guide.children.length > 0">
<daff-tree-item>
<div daffTreeItemTitle>{{ guide.title }}</div>
<ng-container *ngFor="let guide of guide.children">
<ng-container *ngIf="guide.children.length === 0">
<a daff-tree-item [selected]="rla.isActive" [routerLink]="guide.path" routerLinkActive #rla="routerLinkActive" [routerLinkActiveOptions]="activeRouterLinkConfiguration">
<span daffTreeItemTitle>{{ guide.title }}</span>
</a>
</ng-container>
<ng-container *ngIf="guide.children.length > 0">
<daff-tree-item>
<div daffTreeItemTitle>{{ guide.title }}</div>
<ng-container *ngFor="let guide of guide.children">
<ng-container *ngIf="guide.children.length === 0">
<a daff-tree-item [selected]="rla.isActive" [routerLink]="guide.path" routerLinkActive #rla="routerLinkActive" [routerLinkActiveOptions]="activeRouterLinkConfiguration">
<span daffTreeItemTitle>{{ guide.title }}</span>
</a>
</ng-container>
<ng-container *ngIf="guide.children.length > 0">
<daff-tree-item>
<div daffTreeItemTitle>{{ guide.title }}</div>
<ng-container *ngFor="let guide of guide.children">
<ng-container *ngIf="guide.children.length === 0">
<a daff-tree-item [selected]="rla.isActive" [routerLink]="guide.path" routerLinkActive #rla="routerLinkActive" [routerLinkActiveOptions]="activeRouterLinkConfiguration">
<span daffTreeItemTitle>{{ guide.title }}</span>
</a>
</ng-container>
<ng-container *ngIf="guide.children.length > 0">
<daff-tree-item>
<div daffTreeItemTitle>{{ guide.title }}</div>
<ng-container *ngFor="let guide of guide.children">
<ng-container *ngIf="guide.children.length === 0">
<a daff-tree-item [selected]="rla.isActive" [routerLink]="guide.path" routerLinkActive #rla="routerLinkActive" [routerLinkActiveOptions]="activeRouterLinkConfiguration">
<span daffTreeItemTitle>{{ guide.title }}</span>
</a>
</ng-container>
</ng-container>
</daff-tree-item>
</ng-container>
</ng-container>
</daff-tree-item>
</ng-container>
</ng-container>
</daff-tree-item>
</ng-container>
</ng-container>
</daff-tree-item>
</ng-container>
</ng-container>
</daff-tree>
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { RouterTestingModule } from '@angular/router/testing';

import { DaffLinkSetModule } from '@daffodil/design';

import { DaffioGuidesNavTreeComponent } from './guides-nav-tree.component';
import { DaffioGuidesNavComponent } from './guides-nav.component';

describe('DaffioGuidesNavTreeComponent', () => {
let component: DaffioGuidesNavTreeComponent;
let fixture: ComponentFixture<DaffioGuidesNavTreeComponent>;
describe('DaffioGuidesNavComponent', () => {
let component: DaffioGuidesNavComponent;
let fixture: ComponentFixture<DaffioGuidesNavComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [DaffioGuidesNavTreeComponent],
declarations: [DaffioGuidesNavComponent],
imports: [
RouterTestingModule,
DaffLinkSetModule,
Expand All @@ -26,7 +26,7 @@ describe('DaffioGuidesNavTreeComponent', () => {
}));

beforeEach(() => {
fixture = TestBed.createComponent(DaffioGuidesNavTreeComponent);
fixture = TestBed.createComponent(DaffioGuidesNavComponent);
component = fixture.componentInstance;
const guideWithoutChildren = {
id: 'id2',
Expand Down Expand Up @@ -65,8 +65,8 @@ describe('DaffioGuidesNavTreeComponent', () => {
expect(anchorTags.length).toEqual(2);
});

it('should render a daff-nav-accordion-item for each guide', () => {
const daffNavAccordionItem = fixture.debugElement.queryAll(By.css('daff-nav-accordion-item'));
expect(daffNavAccordionItem.length).toEqual(4);
it('should render a daff-tree-item for each guide', () => {
const daffTreeItem = fixture.debugElement.queryAll(By.css('daff-tree-item'));
expect(daffTreeItem.length).toEqual(4);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@ import {
Component,
Input,
} from '@angular/core';
import { RouterLinkActive } from '@angular/router';

import { DaffioGuideList } from '../../../docs/models/guide-list';

@Component({
selector: 'daffio-guides-nav-tree',
templateUrl: './guides-nav-tree.component.html',
styleUrls: ['guides-nav-tree.component.scss'],
selector: 'daffio-guides-nav',
templateUrl: './guides-nav.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DaffioGuidesNavTreeComponent {
export class DaffioGuidesNavComponent {
/**
* The guide list to render
*/
@Input() guideList: DaffioGuideList;

activeRouterLinkConfiguration: RouterLinkActive['routerLinkActiveOptions'] = {
exact: true,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@ import { RouterModule } from '@angular/router';
import {
DaffListModule,
DaffLinkSetModule,
DaffAccordionModule,
} from '@daffodil/design';
import { DaffTreeModule } from '@daffodil/design/tree';

import { DaffioGuidesNavTreeComponent } from './guides-nav-tree.component';

import { DaffioGuidesNavComponent } from './guides-nav.component';

@NgModule({
declarations: [
DaffioGuidesNavTreeComponent,
DaffioGuidesNavComponent,
],
exports: [
DaffioGuidesNavTreeComponent,
DaffioGuidesNavComponent,
],
imports: [
CommonModule,
RouterModule,
DaffLinkSetModule,
DaffListModule,
RouterModule,
DaffAccordionModule,
DaffTreeModule,
],
})
export class DaffioGuidesNavTreeModule { }
export class DaffioGuidesNavModule { }
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ describe('DaffioGuidesPageComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(DaffioGuidesPageComponent);
component = fixture.componentInstance;
console.log(doc);
stubActivatedRoute.data.next({ doc });
fixture.detectChanges();
});
Expand Down

0 comments on commit 6e015fe

Please sign in to comment.