Skip to content

Commit ac1f154

Browse files
committed
feat: add missing Navbars example - thanks @EliasDerHai
1 parent 5337769 commit ac1f154

File tree

7 files changed

+132
-4
lines changed

7 files changed

+132
-4
lines changed

src/app/_nav.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ export const navItems: INavData[] = [
5353
url: '/base/forms',
5454
icon: 'icon-puzzle'
5555
},
56+
{
57+
name: 'Navbars',
58+
url: '/base/navbars',
59+
icon: 'icon-puzzle'
60+
61+
},
5662
{
5763
name: 'Pagination',
5864
url: '/base/paginations',

src/app/views/base/base-routing.module.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import { TabsComponent } from './tabs.component';
99
import { CarouselsComponent } from './carousels.component';
1010
import { CollapsesComponent } from './collapses.component';
1111
import { PaginationsComponent } from './paginations.component';
12-
import {PopoversComponent} from './popovers.component';
13-
import {ProgressComponent} from './progress.component';
14-
import {TooltipsComponent} from './tooltips.component';
12+
import { PopoversComponent } from './popovers.component';
13+
import { ProgressComponent } from './progress.component';
14+
import { TooltipsComponent } from './tooltips.component';
15+
import { NavbarsComponent } from './navbars/navbars.component';
1516

1617
const routes: Routes = [
1718
{
@@ -100,6 +101,13 @@ const routes: Routes = [
100101
data: {
101102
title: 'Tooltips'
102103
}
104+
},
105+
{
106+
path: 'navbars',
107+
component: NavbarsComponent,
108+
data: {
109+
title: 'Navbars'
110+
}
103111
}
104112
]
105113
}

src/app/views/base/base.module.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ import { ProgressComponent } from './progress.component';
4242
import { TooltipModule } from 'ngx-bootstrap/tooltip';
4343
import { TooltipsComponent } from './tooltips.component';
4444

45+
// navbars
46+
import { NavbarsComponent } from './navbars/navbars.component';
4547

4648
// Components Routing
4749
import { BaseRoutingModule } from './base-routing.module';
@@ -71,7 +73,8 @@ import { BaseRoutingModule } from './base-routing.module';
7173
PaginationsComponent,
7274
PopoversComponent,
7375
ProgressComponent,
74-
TooltipsComponent
76+
TooltipsComponent,
77+
NavbarsComponent
7578
]
7679
})
7780
export class BaseModule { }

src/app/views/base/navbars/navbars.component.css

Whitespace-only changes.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<div class="animated fadeIn">
2+
<div class="row">
3+
<div class="col">
4+
<div class="card">
5+
<div class="card-header">
6+
Bootstrap Navbar
7+
</div>
8+
<div class="card-body">
9+
<nav class="navbar navbar-expand-lg navbar-light bg-light">
10+
<a class="navbar-brand" href="#">Navbar</a>
11+
<button aria-controls="navbarSupportedContent" (click)="isCollapsed = !isCollapsed" [attr.aria-expanded]="!isCollapsed" class="navbar-toggler" type="button" aria-label="Toggle navigation">
12+
<span class="navbar-toggler-icon"></span>
13+
</button>
14+
15+
<div class="collapse navbar-collapse" id="navbarSupportedContent" [collapse]="isCollapsed" [isAnimated]="true">
16+
<ul class="navbar-nav mr-auto">
17+
<li class="nav-item active">
18+
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
19+
</li>
20+
<li class="nav-item">
21+
<a class="nav-link" href="#">Link</a>
22+
</li>
23+
<li class="nav-item dropdown" dropdown>
24+
<a id="link-dropdown" class="nav-link dropdown-toggle" href dropdownToggle (click)="false" aria-controls="your-dropdown">
25+
Dropdown
26+
</a>
27+
<div id="your-dropdown" class="dropdown-menu" aria-labelledby="link-dropdown" *dropdownMenu>
28+
<a class="dropdown-item" href="#">Action</a>
29+
<a class="dropdown-item" href="#">Another action</a>
30+
<div class="dropdown-divider"></div>
31+
<a class="dropdown-item" href="#">Something else here</a>
32+
</div>
33+
</li>
34+
<li class="nav-item">
35+
<a class="nav-link disabled" href="#">Disabled</a>
36+
</li>
37+
</ul>
38+
<form class="form-inline my-2 my-lg-0">
39+
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
40+
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
41+
</form>
42+
</div>
43+
</nav>
44+
</div>
45+
</div>
46+
</div>
47+
</div>
48+
</div>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { NavbarsComponent } from './navbars.component';
4+
5+
describe('NavbarsComponent', () => {
6+
let component: NavbarsComponent;
7+
let fixture: ComponentFixture<NavbarsComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ NavbarsComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(NavbarsComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import {AfterViewChecked, Component, ElementRef, OnInit, Renderer2, ViewChild} from '@angular/core';
2+
import {CollapseDirective} from 'ngx-bootstrap';
3+
4+
@Component({
5+
selector: 'app-navbars',
6+
templateUrl: './navbars.component.html',
7+
styleUrls: ['./navbars.component.css']
8+
})
9+
export class NavbarsComponent implements OnInit, AfterViewChecked {
10+
11+
private _isCollapsed: boolean = true;
12+
set isCollapsed(value) {
13+
this._isCollapsed = value;
14+
}
15+
get isCollapsed() {
16+
if (this.collapseRef) {
17+
// temp fix for "overflow: hidden"
18+
if (getComputedStyle(this.collapseRef.nativeElement).getPropertyValue('display') === 'flex') {
19+
this.renderer.removeStyle(this.collapseRef.nativeElement, 'overflow');
20+
}
21+
}
22+
return this._isCollapsed;
23+
}
24+
25+
@ViewChild(CollapseDirective, { read: ElementRef, static: false }) collapse !: CollapseDirective;
26+
27+
collapseRef;
28+
29+
constructor(
30+
private renderer: Renderer2,
31+
) { }
32+
33+
ngOnInit() {}
34+
35+
ngAfterViewChecked (): void {
36+
this.collapseRef = this.collapse;
37+
}
38+
}

0 commit comments

Comments
 (0)