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

react-alert-receptiv

v0.0.6

Published

A Receptiv-centered component built off of react-alert

Downloads

13

Readme

react-alert-receptiv

A simple react alert (toaster style) component for specific use by Receptiv. Modified slighly from https://www.npmjs.com/package/react-alert

Installation

$ npm install react-alert-receptiv

Usage

To use it, you have to import the AlertContainer component, like this:

import React, {Component} from 'react'
import AlertContainer from 'react-alert-receptiv'

export default class App extends Component {
  alertOptions = {
    offset: 14,
    position: 'bottom left',
    theme: 'dark',
    time: 5000,
    transition: 'scale'
  }

  showAlert = () => {
    this.msg.show('Some text or component', {
      time: 2000,
      type: 'success',
      icon: <img src="path/to/some/img/32x32.png" />
    })
  }

  render () {
    return (
      <div>
        <AlertContainer ref={a => this.msg = a} {...this.alertOptions} />
        <button onClick={this.showAlert}>Show Alert</button>
      </div>
    )
  }
}

Api

Once you have the reference of the AlertContainer you can call the following methods:

// show an alert
this.msg.show('Some message or component')
// show an info alert
this.msg.info('Some info message or component')
// show a success alert
this.msg.success('Some success message or component')
// show an error alert
this.msg.error('Some error message or component')
// removes all alerts from the page
this.msg.removeAll()

Options

The AlertContainer component accepts the following props:

{
  // defaults
  offset: 14, // the offset of the alert from the page border, can be any number
  position: 'bottom left', // the position of the alert, can be [bottom left, bottom right, top left, top right]
  theme: 'dark', // the color theme of the alert, can be [dark, light]
  time: 5000, // the time in miliseconds to the alert close itself, use 0 to prevent auto close (apply to all alerts)
  transition: 'scale' // the transition animation, can be [scale, fade]
}

When you call show, info, success and error method, you can include the following options as a second parameter:

{
  time: 0, // the time in miliseconds to the alert close itself, use 0 to prevent auto close (apply to this alert only), default is 5000
  icon: <img src="path/to/some/img/32x32.png" />, // the icon to show in the alert, if none is given the default of each type will be showed
  onClose: () => {} // the function called when message is closed
  onOpen: () => {} // the function called when message is opened
}

When you call the show method, you can additionally include the info option:

{
  type: 'info' // the alert type, can be [info, success, error], default is info
}

Using React Components as alert content

You can also use a React Component to show an alert message, like this:

// show an alert with a React Component as content
this.msg.show(<AComponent aProp="some message" />)