UNPKG

ngx-notification

Version:

Angular Library to display all types of notifications in a Toast Notification format. Tested on Angular 6

2 lines (1 loc) 5.43 kB
{"version":3,"file":"ngx-notification.js.map","sources":["ng://ngx-notification/lib/ngx-notification.service.ts","ng://ngx-notification/lib/ngx-notification.component.ts","ng://ngx-notification/lib/ngx-notification.module.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { Observable, Subject} from 'rxjs';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class NgxNotificationService {\n\n constructor() { }\n\n private subject = new Subject<any>();\n\n sendMessage(message: string, theme: string, position: string) {\n this.subject.next(\n {\n text: message,\n theme: theme,\n position: position\n }\n );\n }\n\n clearMessage() {\n this.subject.next();\n }\n\n getMessage(): Observable<any> {\n return this.subject.asObservable();\n }\n\n}\n","import { Component, OnInit, OnDestroy } from '@angular/core';\nimport { Subscription } from 'rxjs';\nimport { NgxNotificationService } from './ngx-notification.service';\n\n@Component({\n selector: 'lib-ngx-notification',\n template: `<div *ngIf='show' class='ngx-notification {{ message.position }} {{ message.theme }} show'>{{message?.text }}</div>`,\n styles: [`\n .ngx-notification.dark {\n background-color: #2d2d30;\n border-color: #272729;\n color: #c9c9c9;\n }\n .ngx-notification.light {\n background-color: #ffffff;\n border-color: #cccccc;\n color: #2d2d30;\n }\n .ngx-notification.success {\n background-color: #dff0d8;\n border-color: #d0e9c6;\n color: #3c763d;\n }\n .ngx-notification.info {\n background-color: #d9edf7;\n border-color: #bcdff1;\n color: #31708f;\n }\n .ngx-notification.warning {\n background-color: #fcf8e3;\n border-color: #faf2cc;\n color: #8a6d3b;\n }\n .ngx-notification.danger {\n background-color: #f2dede;\n border-color: #ebcccc;\n color: #a94442;\n }\n .ngx-notification.top-left {\n position: fixed;\n left: 10px;\n top: 10px;\n }\n .ngx-notification.top-right {\n position: fixed;\n right: 10px;\n top: 10px;\n }\n .ngx-notification.bottom-right {\n position: fixed;\n right: 10px;\n bottom: 10px;\n }\n .ngx-notification.bottom-left {\n position: fixed;\n left: 10px;\n bottom: 10px;\n }\n .ngx-notification.center {\n position:absolute;\n top: 50%;\n left: 50%;\n margin-top: -9em;\n margin-left: -15em;\n }\n .ngx-notification {\n padding: .75rem 1.25rem;\n margin-bottom: 1rem;\n border: 1px solid transparent;\n border-radius: .25rem;\n -webkit-animation: fadein 1.5s, fadeout 1.5s 3.5s;\n animation: fadein 1.5s, fadeout 1.5s 3.5s;\n z-index : 1;\n }\n\n /* Animations to fade the snackbar in and out */\n @-webkit-keyframes fadein {\n from {opacity: 0;}\n to {opacity: 1;}\n }\n\n @keyframes fadein {\n from {opacity: 0;}\n to {opacity: 1;}\n }\n\n @-webkit-keyframes fadeout {\n from {opacity: 1;}\n to {opacity: 0;}\n }\n\n @keyframes fadeout {\n from {opacity: 1;}\n to {opacity: 0;}\n }\n `]\n})\nexport class NgxNotificationComponent implements OnInit, OnDestroy {\n\n show;\n message: any = {};\n subscription: Subscription;\n\n constructor(private ngxNotificationService: NgxNotificationService) {\n this.subscription = this.ngxNotificationService.getMessage()\n .subscribe(\n message => {\n this.show = true;\n this.message = message;\n console.log(this.message);\n this.autoHideMessage();\n }\n );\n }\n\n ngOnInit() {}\n\n ngOnDestroy() {\n this.subscription.unsubscribe();\n }\n\n autoHideMessage() {\n setTimeout(() => {\n this.show = false;\n }, 5000);\n }\n\n}\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { BrowserModule } from '@angular/platform-browser';\nimport { NgxNotificationComponent } from './ngx-notification.component';\n\n@NgModule({\n imports: [\n CommonModule,\n BrowserModule\n ],\n declarations: [NgxNotificationComponent],\n exports: [NgxNotificationComponent]\n})\nexport class NgxNotificationModule { }\n"],"names":[],"mappings":";;;;;;;;;AAAA;IAQE;uBAEkB,IAAI,OAAO,EAAO;KAFnB;;;;;;;IAIjB,WAAW,CAAC,OAAe,EAAE,KAAa,EAAE,QAAgB;QAC1D,IAAI,CAAC,OAAO,CAAC,IAAI,CACf;YACE,IAAI,EAAE,OAAO;YACb,KAA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