Skip to content

Commit 60b36b5

Browse files
committed
feat(package): added an alert container for user's feedback
1 parent cea06a4 commit 60b36b5

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<p *ngFor="let alert of alerts">
2+
<ngb-alert [type]="alert.type" (close)="closeAlert(alert)">{{ alert.message }}</ngb-alert>
3+
</p>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:host{
2+
display: block;
3+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
2+
3+
import {NgbAlertsContainerComponent} from './ngb-alerts-container.component';
4+
import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
5+
6+
describe('AlertsContainerComponent', () => {
7+
let component: NgbAlertsContainerComponent;
8+
let fixture: ComponentFixture<NgbAlertsContainerComponent>;
9+
10+
beforeEach(async(() => {
11+
TestBed.configureTestingModule({
12+
imports: [NgbModule.forRoot()],
13+
declarations: [NgbAlertsContainerComponent]
14+
})
15+
.compileComponents();
16+
}));
17+
18+
beforeEach(() => {
19+
fixture = TestBed.createComponent(NgbAlertsContainerComponent);
20+
component = fixture.componentInstance;
21+
fixture.detectChanges();
22+
});
23+
24+
it('should create', () => {
25+
expect(component).toBeTruthy();
26+
});
27+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {Component, Input, OnInit} from '@angular/core';
2+
import {IAlert} from '../../../..';
3+
4+
@Component({
5+
selector: 'ngb-alerts-container',
6+
templateUrl: './ngb-alerts-container.component.html',
7+
styleUrls: ['./ngb-alerts-container.component.scss']
8+
})
9+
export class NgbAlertsContainerComponent {
10+
11+
@Input()
12+
public alerts: Array<IAlert> = [];
13+
14+
public closeAlert(alert: IAlert) {
15+
const index: number = this.alerts.indexOf(alert);
16+
this.alerts.splice(index, 1);
17+
}
18+
}

0 commit comments

Comments
 (0)