-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nav): initial nav implementation
- Loading branch information
1 parent
cb9d3c7
commit 783d983
Showing
9 changed files
with
1,192 additions
and
251 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {NgbNavConfig} from './nav-config'; | ||
|
||
describe('ngb-nav-config', () => { | ||
it('should have sensible default values', () => { | ||
const config = new NgbNavConfig(); | ||
|
||
expect(config.destroyOnHide).toBe(true); | ||
expect(config.orientation).toBe('horizontal'); | ||
expect(config.roles).toBe('tablist'); | ||
}); | ||
}); |
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,14 @@ | ||
import {Injectable} from '@angular/core'; | ||
|
||
/** | ||
* A configuration service for the [`NgbNav`](#/components/nav/api#NgbNav) component. | ||
* | ||
* You can inject this service, typically in your root component, and customize the values of its properties in | ||
* order to provide default values for all the navs used in the application. | ||
*/ | ||
@Injectable({providedIn: 'root'}) | ||
export class NgbNavConfig { | ||
destroyOnHide = true; | ||
orientation: 'horizontal' | 'vertical' = 'horizontal'; | ||
roles: 'tablist' | false = 'tablist'; | ||
} |
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,34 @@ | ||
import {Component, Input, ViewEncapsulation} from '@angular/core'; | ||
import {NgbNav} from './nav'; | ||
|
||
/** | ||
* The outlet where currently active nav content will be displayed. | ||
*/ | ||
@Component({ | ||
selector: '[ngbNavOutlet]', | ||
host: {'[class.tab-content]': 'true'}, | ||
encapsulation: ViewEncapsulation.None, | ||
template: ` | ||
<ng-template ngFor let-item [ngForOf]="nav.items"> | ||
<div class="tab-pane" | ||
*ngIf="item.isPanelInDom()" | ||
[id]="item.panelDomId" | ||
[class.active]="item.active" | ||
[attr.role]="paneRole ? paneRole : nav.roles ? 'tabpanel' : undefined" | ||
[attr.aria-labelledby]="item.domId"> | ||
<ng-template [ngTemplateOutlet]="item.contentTpl?.templateRef" [ngTemplateOutletContext]="{$implicit: item.active}"></ng-template> | ||
</div> | ||
</ng-template> | ||
` | ||
}) | ||
export class NgbNavOutlet { | ||
/** | ||
* A role to set on the nav pane | ||
*/ | ||
@Input() paneRole; | ||
|
||
/** | ||
* Reference to the `NgbNav` | ||
*/ | ||
@Input('ngbNavOutlet') nav: NgbNav; | ||
} |
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,15 @@ | ||
import {NgModule} from '@angular/core'; | ||
import {CommonModule} from '@angular/common'; | ||
|
||
import {NgbNav, NgbNavContent, NgbNavItem, NgbNavLink} from './nav'; | ||
import {NgbNavOutlet} from './nav-outlet'; | ||
|
||
export {NgbNav, NgbNavContent, NgbNavContentContext, NgbNavItem, NgbNavLink, NgbNavChangeEvent} from './nav'; | ||
export {NgbNavOutlet} from './nav-outlet'; | ||
export {NgbNavConfig} from './nav-config'; | ||
|
||
const NGB_NAV_DIRECTIVES = [NgbNavContent, NgbNav, NgbNavItem, NgbNavLink, NgbNavOutlet]; | ||
|
||
@NgModule({declarations: NGB_NAV_DIRECTIVES, exports: NGB_NAV_DIRECTIVES, imports: [CommonModule]}) | ||
export class NgbNavModule { | ||
} |
Oops, something went wrong.