Giter Club home page Giter Club logo

native-toast's Introduction

native-toast NPM version NPM downloads

Native-like toast notification but for the web. (JS + CSS ≈ 4KB)

Install

$ npm install --save native-toast

NPMCDN: https://unpkg.com/native-toast/dist/

Usage

First import native-toast/dist/native-toast.css, then:

import nativeToast from 'native-toast'

nativeToast({
  message: 'wait wait!',
  position: 'north-east',
  // Self destroy in 5 seconds
  timeout: 5000,
  type: 'warning'
})
// or nativeToast.warning(options)

Four types: success warning info error

API

nativeToast(options)

options

message

Type: string
Default: ''

Toast message.

position

Type: string
Default: south-east
Values: center west east south south-west south-east north north-west north-east

Toast position.

rounded

Type: boolean
Default: false

Set border-radius to 33px instead of 3px. Has no effect when edge === false.

timeout

Type: number
Default: 3000

Self destroy in specfic timeout. If given 0 or `false then toast will never self destroy.

type

Type: string
Default: undefined

One of success warning info error.

A short-hand usage: nativeToast.success(opts) nativeToast.error(opts) and such.

icon

Type: boolean
Default: true

Set to false to disable icon.

edge

Type: boolean
Default: false

Show toast on the edge.

closeOnClick

Type: boolean
Default: false

Close the toast when clicked.

elements

Type: HTMLElement[]

Optionally provide an array of HTML elements to insert after the message.

License

MIT © EGOIST

native-toast's People

Contributors

egoist avatar npmcdn-to-unpkg-bot avatar rajraj avatar stephenlacy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

native-toast's Issues

feature request: click to discard

Thank you for this nice library.

It does exactly what is needed, except one thing: the ability to discard the toast on click. Would it be possible to add a simple option like:

 'disable-on-click': true

ES6 support?

I have using native-toast in my NodeJS projects with great convenience (Thanks!).

Now I am on a Python (with Flask) project and would not be able to use NodeJS. I was wondering if there is a way to use ES6 import of the native-toast library in some manner.

Thanks

Not working in IE

Exception on stupid IE
SCRIPT1004: Expected ';' at

for (var n of ["success", "info", "warning", "error"]) s[n] = function (e) {
        return s(t({
            type: n
        }, e));
    }; 

I don't know how to solve 😹

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.