-
-
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): dynamic nav and sidebar content (#2686)
--------- Co-authored-by: xelaint <[email protected]>
- Loading branch information
Showing
41 changed files
with
507 additions
and
57 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
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: 13 additions & 0 deletions
13
apps/daffio/src/app/core/header/containers/docs-header/docs-header.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,13 @@ | ||
<daffio-header> | ||
<a routerLink="/" daffio-logo> | ||
<daff-branding-logo type="full"></daff-branding-logo> | ||
</a> | ||
<daff-theme-switch-button theme-toggle></daff-theme-switch-button> | ||
<a daffioHeaderItem routerLink="{{ link.path }}" *ngFor="let link of links">{{ link.title }}</a> | ||
<a daff-button color="theme-contrast" href="https://github.com/graycoreio/daffodil" rel="noopener noreferrer" target="_blank" quickstart-button>Get Started</a> | ||
<button daff-icon-button color="theme-contrast" aria-label="Open Docs Sidebar" | ||
sidebar-button | ||
(click)="openDocsSidebar()"> | ||
<fa-icon [icon]="faBars"></fa-icon> | ||
</button> | ||
</daffio-header> |
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
27 changes: 27 additions & 0 deletions
27
apps/daffio/src/app/core/header/containers/docs-header/docs-header.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,27 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
} from '@angular/core'; | ||
import { faBars } from '@fortawesome/free-solid-svg-icons'; | ||
import { Store } from '@ngrx/store'; | ||
|
||
import { ToggleSidebar } from '../../../../core/sidebar/actions/sidebar.actions'; | ||
|
||
@Component({ | ||
selector: 'daffio-docs-header-container', | ||
templateUrl: './docs-header.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class DaffioDocsHeaderContainer { | ||
faBars = faBars; | ||
|
||
links: any[] = [ | ||
{ path: '/api', title: 'API Index' }, | ||
]; | ||
|
||
constructor(private store: Store<any>) { } | ||
|
||
openDocsSidebar() { | ||
this.store.dispatch(new ToggleSidebar()); | ||
} | ||
} |
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
File renamed without changes.
72 changes: 72 additions & 0 deletions
72
...daffio/src/app/core/header/containers/marketing-header/marketing-header.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,72 @@ | ||
import { | ||
CUSTOM_ELEMENTS_SCHEMA, | ||
Component, | ||
} from '@angular/core'; | ||
import { | ||
ComponentFixture, | ||
TestBed, | ||
waitForAsync, | ||
} from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; | ||
import { | ||
StoreModule, | ||
Store, | ||
} from '@ngrx/store'; | ||
|
||
import { DaffioMarketingHeaderContainer } from './marketing-header.component'; | ||
import { ToggleSidebar } from '../../../../core/sidebar/actions/sidebar.actions'; | ||
import * as fromSidebar from '../../../../core/sidebar/reducers/index'; | ||
|
||
@Component({ template: '<daffio-marketing-header-container></daffio-marketing-header-container>' }) | ||
class WrapperComponent {} | ||
|
||
describe('DaffioMarketingHeaderContainer', () => { | ||
let component: WrapperComponent; | ||
let fixture: ComponentFixture<WrapperComponent>; | ||
let daffioMarketingHeaderContainer: DaffioMarketingHeaderContainer; | ||
|
||
let store: Store<fromSidebar.State>; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
StoreModule.forRoot({}), | ||
RouterTestingModule, | ||
FontAwesomeModule, | ||
], | ||
declarations: [ | ||
WrapperComponent, | ||
DaffioMarketingHeaderContainer, | ||
], | ||
schemas: [ | ||
CUSTOM_ELEMENTS_SCHEMA, | ||
], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(WrapperComponent); | ||
component = fixture.componentInstance; | ||
store = TestBed.inject(Store); | ||
spyOn(store, 'dispatch'); | ||
fixture.detectChanges(); | ||
|
||
daffioMarketingHeaderContainer = fixture.debugElement.query(By.css('daffio-marketing-header-container')).componentInstance; | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
describe('when [sidebar-button] is clicked', () => { | ||
it('should call store.dispatch with a ToggleSidebar action', () => { | ||
const sidebarButton = fixture.debugElement.query(By.css('[sidebar-button]')).nativeElement; | ||
sidebarButton.click(); | ||
|
||
expect(store.dispatch).toHaveBeenCalledWith(new ToggleSidebar()); | ||
}); | ||
}); | ||
}); |
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
32 changes: 32 additions & 0 deletions
32
apps/daffio/src/app/core/header/containers/marketing-header/marketing-header.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,32 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
import { RouterModule } from '@angular/router'; | ||
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; | ||
|
||
import { DaffLogoModule } from '@daffodil/branding'; | ||
import { DaffButtonModule } from '@daffodil/design/button'; | ||
import { DaffThemeSwitchButtonModule } from '@daffodil/theme-switch'; | ||
|
||
import { DaffioMarketingHeaderContainer } from './marketing-header.component'; | ||
import { DaffioHeaderComponentModule } from '../../components/header.module'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
RouterModule, | ||
|
||
DaffioHeaderComponentModule, | ||
DaffLogoModule, | ||
DaffButtonModule, | ||
DaffThemeSwitchButtonModule, | ||
|
||
FontAwesomeModule, | ||
], | ||
declarations: [ | ||
DaffioMarketingHeaderContainer, | ||
], | ||
exports: [ | ||
DaffioMarketingHeaderContainer, | ||
], | ||
}) | ||
export class DaffioMarketingHeaderContainerModule { } |
Oops, something went wrong.