npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-infi-toast

v1.1.2

Published

<p align="center"> <img width="80%" height="80%" src="https://raw.githubusercontent.com/gitsobek/ngx-infi-toast/master/logo.svg?sanitize=true"> </p> &nbsp;

Downloads

6

Readme

MIT PRs styled with prettier

Neat, fully customizable and lightweight notifications for your application.

Table of Contents

Installation

Using npm:

npm install ngx-infi-toast --save

Configuration

In order to display your first toast, you have to import NgxInfiToast module in the root module:

import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { NgxInfiToastModule } from 'ngx-infi-toast';

@NgModule({
  declarations: [AppComponent],
  imports: [
    // ...,
    NgxInfiToastModule
  ],
  providers: [],
  bootstrap: [AppComponent],
})
export class AppModule {}

Inject NgxInfiToastService into your component and display a toast notification with a specified message:

import { NgxInfiToastService } from 'ngx-infi-toast';
 
export class PaymentComponent implements OnInit {
  constructor(private toastService: NgxInfiToastService) {}
 
  ngOnInit() {}

  onPaymentReceived(): void {
      this.toastService.open('Payment has been succesfully processed!');
      // ..
  }
}

Provide custom configuration

You can pass your own custom configuration object as a second parameter of the function. Available properties are following:

| Name | Type | Description | |:----------------|:---------------------------|:--------------------------------------------------------------------| | width | string | width of displayed notification (default: 350px) | | contentColor | string | color of content text (default: #777777) | | iconColor | string | color of close icon (default: #5F95E1) | | headerText | string | top header text | | headerColor | string | color of header text (default: #000) | | data | any | data to be emitted in onClose observable after closing notification |

Handlers

At this moment, function open returns a handler object which will be helpful to use for listening on specific actions related to a single notification.

  • onClose() - emits passed data in the configuration object on notification closure, if no data is passed to the configuration object, it will emit true by default, this can be generally used to keep track of the data associated with a specific notification. Example:
const toast = this.toastService.open(
    'Payment has been succesfully processed!',
    {
        width: '500px',
        headerText: 'Payment received',
        data: {
            id: 1,
            type: 'payment',
            status: 'success'
        }
    }
);

toast.onClose().subscribe(data => {
    // data is equal to:
    // {
    //    id: 1,
    //    type: 'payment',
    //    status: 'success'
    // }
    // do something here...
});

Global configuration

You can provide a global configuration which will be applied for all notifications in your application. All available properties are listed below.

| Name | Type | Description | |:----------------|:----------------------------|:--------------------------------------------------------------------| | width | string | width of displayed notification (default: 350px) | | position | 'left', 'center', 'right' | notification alignment (default: center) | | contentColor | string | color of content text (default: #777777) | | iconColor | string | color of close icon (default: #5F95E1) | | headerColor | string | color of header text (default: #000) |

Example:

import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { NgxInfiToastModule } from 'ngx-infi-toast';

@NgModule({
  declarations: [AppComponent],
  imports: [
    // ...,
    NgxInfiToastModule.forRoot({
        width: '500px',
        position: 'left',
        contentColor: '#000',
        iconColor: '#000',
        headerColor: 'red'
    })
  ],
  providers: [],
  bootstrap: [AppComponent],
})
export class AppModule {}

Important: global and component level configuration are merged together, therefore component level values will override global ones in case there is a common property that is included in both configuration objects.

Demo

The showcase of the library can be found under the following link.

Future plans

  • possibility to stack toasts or show them one by one
  • display provided template or component in the toast

Contribution

This project follows the all-contributors specification. Contributions of any kind are welcome!