Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
ng-snotify
Advanced tools
This project was generated with Angular CLI version 1.0.2.
https://artemsky.github.io/ng-snotify/
To install this library, run:
$ npm install ng-snotify -S
and then from your Angular AppModule
:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
// Import your library
import { SnotifyModule, SnotifyService } from 'ng-snotify';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
// Import SnotifyModule, also you can try SnotifyModule.forRoot() if you have build errors
SnotifyModule
],
providers: [SnotifyService],
bootstrap: [AppComponent]
})
export class AppModule { }
Add app-snotify
component to you root component
<!-- You can now use your library component in app.component.html -->
<app-snotify></app-snotify>
Now you should inject SnotifyService
import {Component, OnInit} from '@angular/core';
// Import SnotifyService
import {SnotifyService} from 'ng-snotify';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
// Inject SnotifyService
constructor(private snotifyService: SnotifyService) {}
//You can set global config like this
ngOnInit() {
this.snotifyService.setConfig({
timeout: 30000
}, {
newOnTop: false,
});
}
//Hopefuly you can add a toast
addToast() {
this.snotifyService.error('Example error!', 'Here we are', {
closeOnClick: false
});
}
//You can remove all toasts from the field
clearToasts() {
this.snotifyService.clear();
}
}
SnotifyService
has method setConfig
, wich takes 2 parametrs
1 - Object typeof SnotifyConfig
or null
export interface SnotifyConfig {
timeout?: number; //default: 1500
showProgressBar?: boolean; //default: true
type?: SnotifyType; //depends on toast type [success, error, warning, bare, info]
closeOnClick?: boolean; //default: true
pauseOnHover?: boolean; //default: true
}
2 - Object typeof SnotifyOptions
or null
export interface SnotifyOptions {
maxOnScreen?: number; //default: 8
newOnTop?: boolean; //default: true
position?: [SnotifyPosition, SnotifyPosition]; //default: Bottom, Right
positionOffset?: {horizontal?: string, vertical?: string}; //default: 10px, 10px
}
You can call toast by calling one of 5 methods
success(title: string, body: string, config?: SnotifyConfig)
warning(title: string, body: string, config?: SnotifyConfig)
info(title: string, body: string, config?: SnotifyConfig)
error(title: string, body: string, config?: SnotifyConfig)
bare(title: string, body: string, config?: SnotifyConfig)
snotifyService.success('Example success!', 'Here we are', {
timeout: 0, // disable timeout,
showProgressBar: true, // won't affect because of timeout, if timeout set to 0. Progress Bar cannot exist anymore
closeOnClick: false
// One important thing: it is not recommended to change the type in all methods except the bare
});
All interfaces can be imported from ng-snotify
The best place to set global config is ngOnInit()
Once your library is imported, you can use its components, interfaces and service in your Angular application:
Go to develop branch and use angular-cli
MIT © artemsky
FAQs
Angular 2+ notifications center
The npm package ng-snotify receives a total of 3,039 weekly downloads. As such, ng-snotify popularity was classified as popular.
We found that ng-snotify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.