All Projects → se-panfilov → Mini Toastr

se-panfilov / Mini Toastr

Licence: mit
Small non-blocking notification library. No dependencies

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Mini Toastr

Cogo Toast
Beautiful, Zero Configuration, Toast Messages for React. Only ~ 4kb gzip, with styles and icons
Stars: ✭ 557 (+492.55%)
Mutual labels:  notifications, messages
Toastnotifications
Toast notifications for WPF allows you to create and display rich notifications in WPF applications. It's highly configurable with set of built-in options like positions, behaviours, themes and many others. It's extendable, it gives you possibility to create custom and interactive notifications in simply manner.
Stars: ✭ 507 (+439.36%)
Mutual labels:  notifications, messages
Applozic Web Plugin
Javascript (jQuery) Real Time Chat & Messaging plugin
Stars: ✭ 76 (-19.15%)
Mutual labels:  notifications
React Native Onesignal
React Native Library for OneSignal Push Notifications Service
Stars: ✭ 1,270 (+1251.06%)
Mutual labels:  notifications
Backgroundupdate
后台更新APP(两句代码实现)
Stars: ✭ 80 (-14.89%)
Mutual labels:  notifications
Playlistcore
Media Playlist Service With Notification and Remote View Support
Stars: ✭ 77 (-18.09%)
Mutual labels:  notifications
Updater
基于DownloadManager封装的更新器,使用超简单!
Stars: ✭ 82 (-12.77%)
Mutual labels:  notifications
Soundswitch
C# application to switch default playing device. Download: https://soundswitch.aaflalo.me/
Stars: ✭ 1,190 (+1165.96%)
Mutual labels:  notifications
Pwa Weather
Minimal Weather PWA: Offline, Push Notification and Web Payments
Stars: ✭ 89 (-5.32%)
Mutual labels:  notifications
React Semantic Toasts
React Semantic UI notifications library
Stars: ✭ 80 (-14.89%)
Mutual labels:  notifications
Notificator
Show macOS notifications with a custom icon
Stars: ✭ 85 (-9.57%)
Mutual labels:  notifications
Web Push Php
Web Push library for PHP
Stars: ✭ 1,224 (+1202.13%)
Mutual labels:  notifications
Homebridge Unifi Protect Camera Motion
Camera & Motion sensor support for Unifi Protect cameras in Homekit via Homebridge
Stars: ✭ 79 (-15.96%)
Mutual labels:  notifications
Org Wild Notifier.el
Alert notifications for org-agenda
Stars: ✭ 84 (-10.64%)
Mutual labels:  notifications
Notify
Cross-platform library for desktop notifications for your go application
Stars: ✭ 76 (-19.15%)
Mutual labels:  notifications
Codehub Push
Push notification server built in Node.js for the iOS application CodeHub
Stars: ✭ 86 (-8.51%)
Mutual labels:  notifications
Qmchatviewcontroller Ios
An elegant ready to go chat view controller for iOS applications
Stars: ✭ 75 (-20.21%)
Mutual labels:  messages
Laravel Console Logger
Logging and Notifications for Laravel Console Commands.
Stars: ✭ 79 (-15.96%)
Mutual labels:  notifications
Jquery Toast Plugin
Highly customizable jquery plugin to show toast messages
Stars: ✭ 1,237 (+1215.96%)
Mutual labels:  notifications
Pushkit silentpushnotification
PushKit_SilentPushNotification to receive VOIP call while iOS app is in background or terminated state
Stars: ✭ 93 (-1.06%)
Mutual labels:  notifications

Codacy Badge bitHound Overall Score bitHound Code Code Climate Build Status GitHub license

NPM JavaScript Style Guide Package Quality

mini-toastr

Greenkeeper badge

mini-toastr - it's a small non-blocking notification library. No dependencies.

Demo

================

Instalation

  1. Install

via npm:

npm i mini-toastr --save

or download latest release

  1. Include in project

include in project:

import miniToastr from 'mini-toastr' //ES6
  1. Init
miniToastr.init()// config can be passed here miniToastr.init(config)

Usage

miniToastr.success(message, title, timeout, cb, config)
miniToastr.info(message, title, timeout, cb, config)
miniToastr.warn(message, title, timeout, cb, config)
miniToastr.error(message, title, timeout, cb, config)

Attention: You can specify your own types in global config: miniToastr.init({types: {debug: 'debug'}}) and use it - miniToastr.debug(message, title, timeout, cb, config)

Methods arguments

Name Type Default Required Description
message String undefined Yes Message in notification
title String undefined No Title for notification
timeout Number 3000 No Time before notification gone
cb Function undefined No Callback function
config Object undefined No Local config for this menthod call

Global config

You can specify global config.

Here is default config:

const defaultConfig = {
    types: TYPES,
    animation: fadeOut,
    timeout: 3000,
    appendTarget: document.body,
    node: document.createElement('div'),
    style: {
      //Styles
    }
  }
Name Type Default Description
types Object {error: 'error', warn: 'warn', success: 'success', info: 'info'} List of methods that would be accessable via miniToastr i.e. miniToastr.success(), miniToastr.info(), etc
animation Function fadeOut Function for remove notification. Can be overrrided
timeout Number 3000 Notification time of life
appendTarget Node document.body Dom element that miniToastr will be attached to
node Node document.createElement('div') Dom element for notification's container
style Object Object of objects Styles that would be applyied for notifications (after they wuld be translated from js to css

Notifications structure

<!-- Container-->
<div id="mini-toastr" class="mini-toastr">

    <!-- Notification 1-->
    <div class="mini-toastr__notification -error">
        <div class="mini-toastr-notification__title">My Title</div>
        <div class="mini-toastr-notification__message">My message</div>
    </div>

    <!-- Notification 2-->
    <div class="mini-toastr__notification -success">
        <div class="mini-toastr-notification__title">My Title 2</div>
        <div class="mini-toastr-notification__message">My message 2</div>
    </div>

    <!-- Notification 3-->
    <div class="mini-toastr__notification -warning">
        <div class="mini-toastr-notification__title">My Title 3</div>
        <i class="your_class mini-toastr-notification__icon"></i> <!-- You're able to use "img"or whatever instead-->
        <div class="mini-toastr-notification__message">My message 3</div>
    </div>
</div>

You can override those classes in your styles or in global config:

miniToastr.init({
    style: {
        'mini-toastr__notification': {
          'mini-toastr-notification__message': {
              'border-radius': '5px',
              color: 'red'
          }
        }
    }
})

Adding an icon

You're able to add icons

//You can use any font icon
miniToastr.setIcon('error', 'i', {'class': 'fa fa-warning'})
miniToastr.setIcon('info', 'i', {'class': 'fa fa-info-circle'})
miniToastr.setIcon('success', 'i', {'class': 'fa fa-check-circle-o'})

//Or image (or any other element)
miniToastr.setIcon('warn', 'img', {src: 'assets/img/demo-warn.png', style: 'vertical-align: bottom;'})

Basically setIcon get 3 params:

  • type(String) - error, info, success, or warn. So you can specify each event with custom icon
  • nodeType(String) - basically what kind of element it's has to be, e.g. <i></i> or <img/>
  • attrs(Object) - object with attributes for icon, such as class, style, or src (for <img/>)

Usually you have to set miniToastr.setIcon() after miniToastr.init() but also you can do it on each toast call.

Keep in mind, that if you will add class like miniToastr.setIcon('info', 'i', {'class': 'fa fa-info-circle'}), your actual class will be fa fa-info-circle mini-toastr-notification__icon.

So you'll be able to customize all the icons with css

Browser support.

Versions up to v0.6.6 - All modern browsers (ES5 support require). See ECMAScript 5 compliant browsers. Versions v0.7.0 and above - browsers with ES6 support only

License

MIT License

Copyright (c) 2016 Sergei Panfilov

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].