-
-
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): split daffio nav into separate docs and marketing compo…
…nents --------- Co-authored-by: xelaint <xelaint@gmail.com>
- Loading branch information
Showing
15 changed files
with
223 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<daffio-header [bordered]="true"> | ||
<a routerLink="/" daffio-logo> | ||
<daff-branding-logo type="full"></daff-branding-logo> | ||
</a> | ||
<daff-theme-switch-button theme-toggle></daff-theme-switch-button> | ||
@for (link of links$ | async; track $index) { | ||
<ng-container daffioHeaderItem> | ||
@if (link.external) { | ||
<a daffioHeaderItem [href]="link.url" target="_blank">{{link.title}}</a> | ||
} @else { | ||
<a daffioHeaderItem [routerLink]="link.url" [active]="rla.isActive" routerLinkActive #rla="routerLinkActive">{{ link.title }}</a> | ||
} | ||
</ng-container> | ||
} | ||
<button daff-icon-button color="theme-contrast" aria-label="Open Navigation Sidebar" | ||
sidebar-button | ||
(click)="openSidebar()"> | ||
<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
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.
94 changes: 94 additions & 0 deletions
94
apps/daffio/src/app/core/nav/marketing/marketing.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,94 @@ | ||
import { 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 { BehaviorSubject } from 'rxjs'; | ||
|
||
import { DaffRouterDataService } from '@daffodil/router'; | ||
|
||
import { DaffioMarketingNavContainer } from './marketing.component'; | ||
import { DaffioRoute } from '../../router/route.type'; | ||
import { DAFFIO_MARKETING_NAV_SIDEBAR_ID } from '../../sidebar/marketing-sidebar-id'; | ||
import { DaffioSidebarService } from '../../sidebar/services/sidebar.service'; | ||
import { DaffioNavLink } from '../link/type'; | ||
|
||
@Component({ | ||
template: '<daffio-nav-marketing-container></daffio-nav-marketing-container>', | ||
standalone: true, | ||
imports: [ | ||
DaffioMarketingNavContainer, | ||
], | ||
}) | ||
class WrapperComponent {} | ||
|
||
describe('DaffioMarketingNavContainer', () => { | ||
let component: WrapperComponent; | ||
let fixture: ComponentFixture<WrapperComponent>; | ||
let marketingNavContainer: DaffioMarketingNavContainer; | ||
let dataSpy: BehaviorSubject<DaffioRoute['data']>; | ||
let sidebarServiceSpy: jasmine.SpyObj<DaffioSidebarService>; | ||
let links: Array<DaffioNavLink>; | ||
|
||
beforeEach(waitForAsync(() => { | ||
dataSpy = new BehaviorSubject({}); | ||
sidebarServiceSpy = jasmine.createSpyObj('DaffioSidebarService', ['open']); | ||
|
||
TestBed.configureTestingModule({ | ||
imports: [ | ||
RouterTestingModule, | ||
WrapperComponent, | ||
], | ||
providers: [ | ||
{ | ||
provide: DaffRouterDataService, | ||
useValue: jasmine.createSpyObj('DaffRouterDataService', [], { data$: dataSpy }), | ||
}, | ||
{ | ||
provide: DaffioSidebarService, | ||
useValue: sidebarServiceSpy, | ||
}, | ||
], | ||
}) | ||
.compileComponents(); | ||
|
||
links = [ | ||
{ title: 'title1', url: 'url1' }, | ||
{ title: 'title2', url: 'url2' }, | ||
]; | ||
dataSpy.next({ | ||
daffioNavLinks: links, | ||
}); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(WrapperComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
|
||
marketingNavContainer = fixture.debugElement.query(By.css('daffio-nav-marketing-container')).componentInstance; | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should render the links', () => { | ||
fixture.debugElement.queryAll(By.css('a[daffioHeaderItem]')).forEach((de, i) => { | ||
expect(de.attributes['ng-reflect-router-link']).toEqual(links[i].url); | ||
expect(de.nativeElement.innerText).toEqual(links[i].title); | ||
}); | ||
}); | ||
|
||
describe('when [sidebar-button] is clicked', () => { | ||
it('should open the nav sidebar', () => { | ||
const sidebarButton = fixture.debugElement.query(By.css('[sidebar-button]')).nativeElement; | ||
sidebarButton.click(); | ||
|
||
expect(sidebarServiceSpy.open).toHaveBeenCalledWith(DAFFIO_MARKETING_NAV_SIDEBAR_ID); | ||
}); | ||
}); | ||
}); |
72 changes: 72 additions & 0 deletions
72
apps/daffio/src/app/core/nav/marketing/marketing.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,72 @@ | ||
import { | ||
AsyncPipe, | ||
NgFor, | ||
} from '@angular/common'; | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
OnInit, | ||
} from '@angular/core'; | ||
import { | ||
RouterLink, | ||
RouterLinkActive, | ||
} from '@angular/router'; | ||
import { FaIconComponent } from '@fortawesome/angular-fontawesome'; | ||
import { faBars } from '@fortawesome/free-solid-svg-icons'; | ||
import { | ||
Observable, | ||
map, | ||
} from 'rxjs'; | ||
|
||
import { DaffLogoModule } from '@daffodil/branding'; | ||
import { | ||
DaffButtonComponent, | ||
DaffIconButtonComponent, | ||
} from '@daffodil/design/button'; | ||
import { DaffRouterDataService } from '@daffodil/router'; | ||
import { DaffThemeSwitchButtonModule } from '@daffodil/theme-switch'; | ||
|
||
import { DaffioHeaderComponentModule } from '../../header/components/header.module'; | ||
import { DaffioRoute } from '../../router/route.type'; | ||
import { DaffioSidebarService } from '../../sidebar/services/sidebar.service'; | ||
import { DAFFIO_NAV_SIDEBAR_ID } from '../header/sidebar-id'; | ||
import { DaffioNavLink } from '../link/type'; | ||
|
||
@Component({ | ||
selector: 'daffio-nav-marketing-container', | ||
templateUrl: './marketing.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: true, | ||
imports: [ | ||
DaffioHeaderComponentModule, | ||
RouterLink, | ||
RouterLinkActive, | ||
DaffLogoModule, | ||
DaffThemeSwitchButtonModule, | ||
NgFor, | ||
DaffButtonComponent, | ||
DaffIconButtonComponent, | ||
FaIconComponent, | ||
AsyncPipe, | ||
], | ||
}) | ||
export class DaffioMarketingNavContainer implements OnInit { | ||
faBars = faBars; | ||
|
||
links$: Observable<Array<DaffioNavLink>>; | ||
|
||
constructor( | ||
private routerData: DaffRouterDataService<DaffioRoute['data']>, | ||
private sidebarService: DaffioSidebarService, | ||
) {} | ||
|
||
ngOnInit(): void { | ||
this.links$ = this.routerData.data$.pipe( | ||
map((data) => data.daffioNavLinks), | ||
); | ||
} | ||
|
||
openSidebar() { | ||
this.sidebarService.open(DAFFIO_NAV_SIDEBAR_ID); | ||
} | ||
} |
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
4 changes: 4 additions & 0 deletions
4
apps/daffio/src/app/docs/components/docs-list/docs-list.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: 1rem 0 0; | ||
} |
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