Skip to content

Commit a50eacc

Browse files
eswarprbengry
authored andcommitted
Added Nav component and module (#88)
1 parent ca4b474 commit a50eacc

File tree

5 files changed

+130
-7
lines changed

5 files changed

+130
-7
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
import { ReactWrapperComponent } from '@angular-react/core';
5+
import { INavProps, INavLink, INav } from 'office-ui-fabric-react';
6+
import {
7+
Component,
8+
ChangeDetectionStrategy,
9+
Input,
10+
ViewChild,
11+
ElementRef,
12+
ChangeDetectorRef,
13+
Renderer2,
14+
Output,
15+
EventEmitter,
16+
} from '@angular/core';
17+
18+
@Component({
19+
selector: 'fab-nav',
20+
exportAs: 'fabNav',
21+
template: `
22+
<Nav
23+
#reactNode
24+
[groups]="groups"
25+
[LinkClick]="onLinkClickHandler"
26+
[selectedKey]="selectedKey"
27+
[expandButtonAriaLabel]="expandButtonAriaLabel"
28+
[expandedStateText]="expandedStateText"
29+
[collapsedStateText]="collapsedStateText"
30+
[LinkExpandClick]="onLinkExpandClickHandler"
31+
[isOnTop]="isOnTop"
32+
[initialSelectedKey]="initialSelectedKey"
33+
[ariaLabel]="ariaLabel"
34+
>
35+
</Nav>
36+
`,
37+
styles: ['react-renderer'],
38+
changeDetection: ChangeDetectionStrategy.OnPush,
39+
})
40+
export class FabNavComponent extends ReactWrapperComponent<INavProps> {
41+
@ViewChild('reactNode')
42+
protected reactNodeRef: ElementRef;
43+
44+
@Input() componentRef?: INavProps['componentRef'];
45+
@Input() groups: INavProps["groups"];
46+
@Input() selectedKey: INavProps["selectedKey"];
47+
@Input() expandedStateText: INavProps["expandedStateText"];
48+
@Input() collapsedStateText: INavProps["collapsedStateText"];
49+
@Input() isOnTop: INavProps["isOnTop"];
50+
@Input() initialSelectedKey: INavProps["initialSelectedKey"];
51+
@Input() ariaLabel: INavProps["ariaLabel"];
52+
@Input() expandButtonAriaLabel: INavProps["expandButtonAriaLabel"];
53+
54+
55+
@Output() readonly onLinkClick = new EventEmitter<{
56+
event: Event,
57+
link: INavLink
58+
}>();
59+
@Output() readonly onLinkExpandClick = new EventEmitter<{
60+
event: Event,
61+
link: INavLink
62+
}>();
63+
64+
constructor(elementRef: ElementRef, changeDetectorRef: ChangeDetectorRef, renderer: Renderer2) {
65+
super(elementRef, changeDetectorRef, renderer);
66+
this.onLinkClickHandler = this.onLinkClickHandler.bind(this);
67+
this.onLinkExpandClickHandler = this.onLinkExpandClickHandler.bind(this);
68+
}
69+
70+
onLinkClickHandler(event: React.MouseEvent<HTMLElement>, link?: INavLink): void {
71+
this.onLinkClick.emit({
72+
event: event.nativeEvent,
73+
link: link
74+
});
75+
}
76+
77+
onLinkExpandClickHandler(event: React.MouseEvent<HTMLElement>, link?: INavLink): void {
78+
this.onLinkExpandClick.emit({
79+
event: event.nativeEvent,
80+
link: link
81+
});
82+
}
83+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
import { registerElement } from "@angular-react/core";
5+
import { Nav } from "office-ui-fabric-react";
6+
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
7+
import { CommonModule } from "@angular/common";
8+
import { FabNavComponent } from "./nav.component";
9+
10+
@NgModule({
11+
imports: [CommonModule],
12+
declarations: [FabNavComponent],
13+
exports: [FabNavComponent],
14+
schemas: [NO_ERRORS_SCHEMA]
15+
})
16+
export class FabNavModule {
17+
constructor() {
18+
registerElement('Nav', () => Nav)
19+
}
20+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
export * from './nav.module';
5+
export * from './nav.component';

libs/fabric/src/public-api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export * from './lib/components/spinner/public-api';
3636
export * from './lib/components/text-field/public-api';
3737
export * from './lib/components/toggle/public-api';
3838
export * from './lib/components/tooltip/public-api';
39+
export * from './lib/components/nav/public-api';
3940

4041
// Pickers had some warnings at runtime. Leaving out of public API for now
4142
// export * from './lib/components/pickers/public-api';

package-lock.json

Lines changed: 21 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)