GithubHelp home page GithubHelp logo

lukaswoj / react-toastr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tomchentw/react-toastr

0.0 2.0 0.0 2.48 MB

React.js toastr component

Home Page: https://tomchentw.github.io/react-toastr/

License: MIT License

JavaScript 92.50% HTML 2.37% CSS 5.13%

react-toastr's Introduction

react-toastr

React.js toastr component

Version Travis CI Quality Coverage Dependencies Gitter

Installation

npm i --save react-toastr

Demo

Static hosted demo site on GitHub.

Example

Check src/app folder.

Usage

This module requires to be bundled with webpack/browserify and loads react/addons internally.
You'll need to download animate.css from here Animate @github

Link to css for styles:

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.1.3/toastr.min.css">

Then:

var ReactToastr = require("react-toastr");
var {ToastContainer} = ReactToastr; // This is a React Element.
// For Non ES6...
// var ToastContainer = ReactToastr.ToastContainer;
var ToastMessageFactory = React.createFactory(ReactToastr.ToastMessage.animation);

  // In a react component:
  render () {
    return (
      <div>
        <ToastContainer ref="container"
                        toastMessageFactory={ToastMessageFactory}
                        className="toast-top-right" />
        <button onClick={this.addAlert}>GGininder</button>
      </div>
    );
  }

Here's a list of React Elements:

ToastContainer

This is the container where all ToastMessage elements will go. Use it by retaining a ref to publish a new toast message:

  addAlert () {
    this.refs.container.success(
      "Welcome welcome welcome!!",
      "You are now home my friend. Welcome home my friend.", {
      timeOut: 30000,
      extendedTimeOut: 10000
    });
    window.open("http://youtu.be/3SR75k7Oggg");
  }

or integrated with your flux architecture?

  componentDidMount: function() {
    InInDerStore.addChangeListener(this.addAlert);
  }

Options

Directly migrated from toastr.js library, and can be overrided via props in a React way:

ToastContainer::getDefaultProps

Close Button

The close button on the toastr is an optional functionality.

  closeButton:true
Time Out

Set the time(in ms) after which the toastr message should automatically close.

  timeOut:5000
Prevent Duplicates

This prevents duplicate messages from getting triggered.

  preventDuplicates:true

Displaying HTML

To display HTML simply pass JSX instead of strings for title and message arguments:

this.refs.container.success(
  <strong>I am a strong title</strong>,
  <em>I am an emphasized message</em>
});

ToastMessage

Base class for holding a toast message, it will not animate in and out during it's lifecycle. Provides ToastMessage.animation and ToastMessage.jQuery for your choice.

Options

Directly migrated from toastr.js library, and can be overrided via props in a React way:

react-toastr's People

Contributors

abalhier avatar appleboy avatar janekk avatar jerairrest avatar marcus avatar mikechau avatar rangarajkaushiksundar avatar shihminlee-ami avatar simoneb avatar tomchentw avatar yfxie avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.