Skip to content

Commit

Permalink
feat(package): added an alert container for user's feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyNahas committed Aug 3, 2018
1 parent cea06a4 commit 60b36b5
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p *ngFor="let alert of alerts">
<ngb-alert [type]="alert.type" (close)="closeAlert(alert)">{{ alert.message }}</ngb-alert>
</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:host{
display: block;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {async, ComponentFixture, TestBed} from '@angular/core/testing';

import {NgbAlertsContainerComponent} from './ngb-alerts-container.component';
import {NgbModule} from '@ng-bootstrap/ng-bootstrap';

describe('AlertsContainerComponent', () => {
let component: NgbAlertsContainerComponent;
let fixture: ComponentFixture<NgbAlertsContainerComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [NgbModule.forRoot()],
declarations: [NgbAlertsContainerComponent]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(NgbAlertsContainerComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {Component, Input, OnInit} from '@angular/core';
import {IAlert} from '../../../..';

@Component({
selector: 'ngb-alerts-container',
templateUrl: './ngb-alerts-container.component.html',
styleUrls: ['./ngb-alerts-container.component.scss']
})
export class NgbAlertsContainerComponent {

@Input()
public alerts: Array<IAlert> = [];

public closeAlert(alert: IAlert) {
const index: number = this.alerts.indexOf(alert);
this.alerts.splice(index, 1);
}
}

0 comments on commit 60b36b5

Please sign in to comment.