Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-notifications

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-notifications - npm Package Compare versions

Comparing version 0.9.0 to 1.0.0

.npmignore

0

docs/md/advanced-setup.md

@@ -0,0 +0,0 @@ # Advanced Setup

6

docs/md/browsers-support.md
# Browsers Support
All `ES5-compatable` browsers are supported \(i.g. starting from `IE11`\).
For more information, please chech [ECMAScript 5 compliant browsers](http://caniuse.com/#feat=es5)
Version v1.0.0 and after guarantees only a support of evergreen browsers.
If you don't give a fuck about browsers support, it would be better to use `ES6-version`
Versions below v1.0.0 supports all `ES5-compatable` browsers \(i.g. starting from `IE11`\).

@@ -31,3 +31,3 @@ # Getting Started

Here we're including `vue-notifications` and `mini-toaster` in our project
Here we're including `vue-notifications` and `mini-toastr` in our project

@@ -39,3 +39,3 @@ ```js

P.S. don't forget to install `mini-toaste` \(`npm i mini-toastr --save`\)
P.S. don't forget to install `mini-toastr` \(`npm i mini-toastr --save`\)

@@ -97,3 +97,3 @@ * Setup types of the messages

// Include mini-toaster (or any other UI-notification library)
// Include mini-toastr (or any other UI-notification library)
import miniToastr from 'mini-toastr'

@@ -100,0 +100,0 @@

@@ -0,0 +0,0 @@ # How it works

# Installation
### NPM
##Latest version
For latest versions you can install it only via npm:
```

@@ -9,3 +11,3 @@ npm i vue-notifications --save

### Yarn
or

@@ -16,2 +18,6 @@ ```

##Legacy version
For legacy versions (below v1.0.0) cdn and bower is also available:
### CDN

@@ -41,3 +47,3 @@

### Dev Build {#dev-build}
## Dev Build {#dev-build}

@@ -44,0 +50,0 @@ You will have to clone directly from GitHub and build`vue-notifications`yourself if you want to use the latest dev build.

@@ -0,0 +0,0 @@ # Introduction and WTF is it?

@@ -0,0 +0,0 @@ # Summary

@@ -63,5 +63,5 @@ # Usage

| timeout | Number | 3000 | time before notifications gone |
| cb | undefined | undefined | Callback function |
| cb | Function | undefined | Callback function |
But actually you can add your own properties as well, if you want. Why and how? You can check it in [Advanced Setup](/advanced-setup.md) section.
# Vue.js Versions Support
`vue-notification` librarry support both `vue.js` versions: `1` \(aka "Evangelion"\) and `2` \(aka "Ghost in the shell"\) as well.
##Latest versions
Versions after v1.0.0 supports only `vue.js` of version `2` and above
##Legacy versions
Legacy versions of `vue-notification` (below v1.0.0) supports both `vue.js` versions: `1` \(aka "Evangelion"\) and `2` \(aka "Ghost in the shell"\) as well.

@@ -0,0 +0,0 @@ # What you should't do

{
"name": "vue-notifications",
"version": "0.9.0",
"version": "1.0.0",
"author": "Sergei Panfilov <se-panfilov@ya.ru> (https://se-panfilov.github.io)",
"description": "Vuejs notifications",
"main": "dist/vue-notifications.es5.js",
"main": "dist/vue-notifications.js",
"typings": "dist/vue-notifications.d.ts",
"scripts": {
"start": "cross-env BABEL_ENV=dev && gulp",
"build": "cross-env BABEL_ENV=production && gulp make",
"docs": "rimraf ./docs/html/** && gitbook build ./docs/md/ ./docs/html",
"docs:to:gh": "rimraf ../dev-server/docs/** && cpx './docs/**' ../dev-server/docs",
"update": "ncu -a && yarn upgrade",
"upgrade": "yarn upgrade",
"test": "cross-env BABEL_ENV=test && mocha --compilers js:babel-core/register ./test/**/*.spec.js",
"lint": "./node_modules/eslint/bin/eslint.js ./src",
"sizes": "gulp sizes"
"build": "tsc -p tsconfig.json",
"minify": "terser ./dist/vue-notifications.js --output ./dist/vue-notifications.min.js --compress --source-map",
"test": "echo 'tests are not specified'",
"lint": "tslint --project .",
"docs": "rimraf ./docs/html/** && gitbook build ./docs/md/ ./docs/html"
},
"engines": {
"node": ">=8.9"
},
"repository": {

@@ -33,3 +34,2 @@ "type": "git",

],
"author": "S.Panfilov <se-panfilov@ya.ru> (https://se-panfilov.github.io)",
"license": "MIT",

@@ -42,53 +42,12 @@ "private": false,

"devDependencies": {
"babel": "6.23.0",
"babel-cli": "6.26.0",
"babel-core": "6.26.0",
"babel-loader": "7.1.2",
"babel-plugin-transform-es3-member-expression-literals": "6.22.0",
"babel-plugin-transform-es3-property-literals": "6.22.0",
"babel-plugin-transform-runtime": "6.23.0",
"babel-preset-es2015": "6.24.1",
"babel-preset-latest": "6.24.1",
"babel-preset-stage-0": "6.24.1",
"babel-runtime": "6.26.0",
"babelify": "7.3.0",
"babili": "0.1.4",
"browserify": "14.4.0",
"chai": "4.1.2",
"cpx": "1.5.0",
"cross-env": "5.0.5",
"eslint": "4.7.1",
"eslint-config-standard": "10.2.1",
"eslint-friendly-formatter": "3.0.0",
"eslint-plugin-import": "2.7.0",
"eslint-plugin-node": "5.1.1",
"eslint-plugin-promise": "3.5.0",
"eslint-plugin-standard": "3.0.1",
"gulp": "3.9.1",
"gulp-babel": "7.0.0",
"gulp-concat": "2.6.1",
"gulp-eslint": "4.0.0",
"gulp-notify": "3.0.0",
"gulp-plumber": "1.1.0",
"gulp-rename": "1.2.2",
"gulp-size": "2.1.0",
"gulp-sourcemaps": "2.6.1",
"gulp-strip-code": "0.1.4",
"gulp-todo": "5.4.0",
"gulp-uglify": "3.0.0",
"gulp-umd": "0.2.1",
"gulp-watch": "4.3.11",
"mocha": "3.5.3",
"require-dir": "0.3.2",
"rimraf": "^2.6.2",
"run-sequence": "2.2.0",
"sinon": "3.3.0",
"sinon-chai": "2.13.0",
"source": "0.0.3",
"through2": "2.0.3",
"to-case": "2.0.0",
"vinyl-buffer": "1.0.0",
"vinyl-source-stream": "1.1.0"
},
"dependencies": {}
"gitbook-cli": "2.3.2",
"rimraf": "2.6.3",
"terser": "3.17.0",
"tslint": "5.10.0",
"tslint-config-prettier": "1.13.0",
"tslint-immutable": "5.5.2",
"typescript": "2.9.1",
"vue": "2.6.10"
}
}
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/8a6dee4e21d04653b53c0a9618a2cc84)](https://www.codacy.com/app/se-panfilov/vue-notifications?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=se-panfilov/vue-notifications&amp;utm_campaign=Badge_Grade)
[![bitHound Overall Score](https://www.bithound.io/github/se-panfilov/vue-notifications/badges/score.svg)](https://www.bithound.io/github/se-panfilov/vue-notifications) [![bitHound Code](https://www.bithound.io/github/se-panfilov/vue-notifications/badges/code.svg)](https://www.bithound.io/github/se-panfilov/vue-notifications)
[![Code Climate](https://codeclimate.com/github/se-panfilov/vue-notifications/badges/gpa.svg)](https://codeclimate.com/github/se-panfilov/vue-notifications)
[![](https://api.codeclimate.com/v1/badges/a4d945aeb21c32fc4bdf/maintainability)](https://codeclimate.com/github/se-panfilov/vue-notifications/maintainability)
[![Build Status](https://travis-ci.org/se-panfilov/vue-notifications.svg?branch=master)](https://travis-ci.org/se-panfilov/vue-notifications)
[![GitHub license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/se-panfilov/vue-notifications/blob/master/LICENSE)
[![Known Vulnerabilities](https://snyk.io/test/github/se-panfilov/vue-notifications/badge.svg?targetFile=examples%2Fsimple_with_swal%2Fpackage.json)](https://snyk.io/test/github/se-panfilov/vue-notifications?targetFile=examples%2Fsimple_with_swal%2Fpackage.json)
[![NPM](https://nodei.co/npm/vue-notifications.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/vue-notifications/)
[![JavaScript Style Guide](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
[![Package Quality](http://npm.packagequality.com/badge/vue-notifications.png)](http://packagequality.com/#?package=vue-notifications)
| [SITE](https://se-panfilov.github.io/vue-notifications/) | [DOCS](https://se-panfilov.github.io/vue-notifications/docs/html/index.html) | [GITHUB](https://github.com/se-panfilov/vue-notifications) |
| [SITE](https://se-panfilov.github.io/vue-notifications/) | [DOCS](https://se-panfilov.github.io/vue-notifications/docs/html/index.html) | [EXAMPLES](https://github.com/se-panfilov/vue-notifications/tree/master/examples) | [GITHUB](https://github.com/se-panfilov/vue-notifications) | [LICENSE](https://github.com/se-panfilov/vue-notifications/blob/master/LICENSE) |
# vue-notifications
**VueNotifications** - agnostic non-blocking notifications library, that allow you to use notifications in declaration style.
[![Greenkeeper badge](https://badges.greenkeeper.io/se-panfilov/vue-notifications.svg)](https://greenkeeper.io/)
**VueNotifications** - agnostic library for non-blocking notifications.
----
## Introduction and WTF is it?
`vue-notifications` is "Vue.js agnostic non-blocking notifications library"... and it's a lie \)\) Seriously.
`vue-notifications`it's basically **a bridge** between your actual app and UI-notfications libs, like [mini-toastr](https://github.com/se-panfilov/mini-toastr).
### Why do we need this?
Because we want to have a way to show notifications and a way to easy replace UI library that show them without rewrite the code.
### What `vue-notifications` actually do?
It's allow you to declare your notifications in blocks like this one:
```js
export default {
name: 'DemoView',
data () {
//...
},
methods: {
//...
},
notifications: {
showLoginError: { // You can have any name you want instead of 'showLoginError'
title: 'Login Failed',
message: 'Failed to authenticate',
type: 'error' // You also can use 'VueNotifications.types.error' instead of 'error'
}
}
}
```
And then call it via `this`: `this.showLoginError()`, and also with some override props: `this.showLoginError({message: 'whatever'})`.
### Why do we need third-party UI lib \(like [mini-toastr](https://github.com/se-panfilov/mini-toastr)\)?
Well, because we want to be agnostic.
That's mean that if at some step you would be fucked up with your UI library, `vue-notifications` will allow you to replace it as much easy as possible. Basically you would be required to replace `vue-notifications`'s config. And that's all.
## Installation
via npm:
Check the Docs: [Installation](https://se-panfilov.github.io/vue-notifications/docs/html/installation.html)

@@ -26,31 +69,50 @@ ```shell

via bower:
or
```sh
bower i vue-notifications --save
```shell
yarn add vue-notifications
```
or download [latest release][1]
include in project:
## Getting started
Check the Docs: [Getting started](https://se-panfilov.github.io/vue-notifications/docs/html/getting-started.html)
```JS
import VueNotifications from 'vue-notifications'
```
```JS
Vue.use(VueNotifications, options)
```
## Setup and configuration
### Setup and configuration \(necessary\)
**Attention:** By default VueNotification send all messages _to console_. To activate non-blocking notifiction you've got to use third-party library, like toasr. I suggest you to use [mini-toastr][2] (`npm i mini-toastr --save`)
As I said above - you have to use UI library that would draw actual notifications for you.
```JS
// Include Plugin in project
For this example I will use [mini-toastr](https://github.com/se-panfilov/mini-toastr)
##### Step-by-step guide
Let's do everything together
> If you don't want spend too much time with this shit - you can go ahead and copy-past whole code from the bottom of this page
Anyway
* Import `vue-notifications`
Here we're including `vue-notifications` and `mini-toastr` in our project
```js
import VueNotifications from 'vue-notifications'
// Include mini-toaster (or any other UI-notification library
import miniToastr from 'mini-toastr'
```
// If using mini-toastr, provide additional configuration
P.S. don't forget to install `mini-toastr` \(`npm i mini-toastr --save`\)
* Setup types of the messages
This one is mostly related to `mini-toastr`. We basically want `mini-toastr` to have these 4 types of messages. Basically 'error' should be red and success - 'green'
```js
const toastTypes = {

@@ -62,6 +124,17 @@ success: 'success',

}
```
* Activate `mini-toastr`
Here we make `mini-toasr` initialization with types from above
```js
miniToastr.init({types: toastTypes})
```
// Here we setup messages output to `mini-toastr`
* Map `vue-notification` to `mini-toastr`
We want our messages to be called via `vue-notification`but be shown by `mini-toastr`, So :
```js
function toast ({title, message, type, timeout, cb}) {

@@ -71,5 +144,2 @@ return miniToastr[type](message, title, timeout, cb)

// Binding for methods .success(), .error() and etc. You can specify and map your own methods here.
// Required to pipe our output to UI library (mini-toastr in example here)
// All not-specified events (types) would be piped to output in console.
const options = {

@@ -81,31 +151,56 @@ success: toast,

}
// Activate plugin
Vue.use(VueNotifications, options)// VueNotifications have auto install but if we want to specify options we've got to do it manually.
```
```JS
// THIS ISN'T REQUIRED IF YOU DON'T USE 'mini-toastr'
// and if you would use "miniToastr" you have to init in in your App.vue
import miniToastr from 'mini-toastr'// don't forget to make "npm i mini-toastr --save"
This stuff will forward our messages, so in case of 'success', it will call `miniToastr.success(message, title, timeout, cb)`, in case of 'error' it will call `miniToastr.error(message, title, timeout, cb)` and etc. Keep in mind that the types\(like "success", "error" and etc\) could be whatever you want. In this example we just use default stuff for both libs.
//in 'ready section
// ...
ready () { //'mounted' instade of ready for Vue 2.0
miniToastr.init()//or "miniToastr.init(miniToastrConfig)" if you want to specify configuration
},
// ...
```
* Activate the plugin
If you want to setup VueNotification's global configuration, you can do it simple:
Okay, now we have to pass our `options` into the plugin. Actually `vue-notification` has auto-install, but we want to pass options from above to it, so that's the case why do we do this manually
```JS
VueNotifications.config.timeout = 4000
```js
Vue.use(VueNotifications, options)
```
Also you can use any other word instead of `notifications` for configs:
##### All together
```JS
VueNotifications.propertyName = 'messages'
You can just copy-paste code below
```js
import VueNotifications from 'vue-notifications'
// Include mini-toaster (or any other UI-notification library)
import miniToastr from 'mini-toastr'
// We shall setup types of the messages. ('error' type - red and 'success' - green in mini-toastr)
const toastTypes = {
success: 'success',
error: 'error',
info: 'info',
warn: 'warn'
}
// This step requires only for mini-toastr, just an initialization
miniToastr.init({types: toastTypes})
// Here we are seting up messages output to `mini-toastr`
// This mean that in case of 'success' message we will call miniToastr.success(message, title, timeout, cb)
// In case of 'error' we will call miniToastr.error(message, title, timeout, cb)
// and etc.
function toast ({title, message, type, timeout, cb}) {
return miniToastr[type](message, title, timeout, cb)
}
// Here we map vue-notifications method to function abowe (to mini-toastr)
// By default vue-notifications can have 4 methods: 'success', 'error', 'info' and 'warn'
// But you can specify whatever methods you want.
// If you won't specify some method here, output would be sent to the browser's console
const options = {
success: toast,
error: toast,
info: toast,
warn: toast
}
// Activate plugin
// VueNotifications have auto install but if we want to specify options we've got to do it manually.
Vue.use(VueNotifications, options)

@@ -116,5 +211,5 @@ ```

You've got to specify notifications config:
Check the Docs: [Usage](https://se-panfilov.github.io/vue-notifications/docs/html/usage.html)
```JS
```js
export default {

@@ -125,5 +220,2 @@ name: 'DemoView',

},
computed: {
//...
},
methods: {

@@ -133,95 +225,64 @@ //...

notifications: {
showLoginError: {
showLoginError: { // You can have any name you want instead of 'showLoginError'
title: 'Login Failed',
message: 'Failed to authenticate',
type: 'error' //Default: 'info', also you can use VueNotifications.types.error instead of 'error'
type: 'error' // You also can use 'VueNotifications.types.error' instead of 'error'
}
},
vuex: {
//...
}
}
```
Now you can call `this.showLoginError()` in any place of this page (i.e. in methods, or whatever).
You also can call `.success()`, `.error()` and other methods directly (for example in JavaScript files):
Now you can call `showLoginError` as a common method via this:
In `some.js`:
```JS
import VueNotifications from 'vue-notifications'
VueNotifications.error({message: 'Some Error'})
```js
this.showLoginError()
```
#### Overriding config.
Even if you have specify config, you can ovverride it in any call simple by sending config object: `this.showLoginError({type: 'warn'})`. i.e.:
> **PRO tip**: Technically there is no difference between methods defined in `notifications: {...}` section and in `methods: {...}` section - they are all the same. So that's basically mean that** you shall not define methods with same name in those sections**, because they would overlap each other.
```JS
notifications: {
showLoginError: {
message: 'Failed to authenticate',
type: 'error'
}
}
So, now you can do something like that:
this.showLoginError() //error message
this.showLoginError({type: 'warn'}) //info message
//Also you can send here whatever params. All would be passed down to `mini-toastr` or any other lib.
Keep in mind that configs merging by `Object.assign` (no deep copying).
```js
methods: {
login () {
loginUtil.login(err => if (err) this.showLoginError())
}
}
```
## Options
But wait. What if I want to show some custom message in example above?
**VueNotification** can work fine with any of your custom options, but by default it would be:
Well, in this case you can override `showLoginError()` method:
| Name | Type | Default | Description |
|---|---|---|---|
| `title` | `String` | `undefined` | Notification's title |
| `message` | `String` | `undefined` | Notification's body message. Normally should be set up; |
| `timeout` | `Number` | `3000` | time before notifications gone |
| `cb` | `Function` | `undefined` | Callback function; |
```js
this.showLoginError({message: err.message})
```
#### How to add custom field?
In the same way you can override all the others properties
Simple: `this.showLoginError({consoleMessage: 'let it be in console'})`. You've passed a custom config here (`{consoleMessage: 'let it be in console'}`) that will be merged with config from `notifications.showLoginError` and with `global config` via `Object.assign` (beware of shallow copy).
```js
this.showLoginError({title: 'my title', message: 'just an error', type: 'warn', timeout: 1000})
```
As other option, you can specify as much custom fields as you want in `notifications` section:
### Options to override
```JS
//...
notifications: {
showLoginError: {
message: 'Failed to authenticate',
type: 'error', //Also you can use VueNotifications.types.error instead of 'error'
consoleMessage: 'let it be in console',
consoleMessage2: 'let it be in console too',
//etc
}
}
//...
```
As I said above, you can specify any of following properties
And do whatever you want after that:
| Name | Type | Default value | Description |
| :--- | :--- | :--- | :--- |
| title | String | undefined | Notification's title \(can be empty\) |
| message | String | undefined | Notification's body message. Normally should be set up |
| timeout | Number | 3000 | time before notifications gone |
| cb | Function | undefined | Callback function |
```JS
function toast ({title, message, type, timeout, cb, consoleMessage}) {
if (consoleMessage) console[type](consoleMessage) //Here we go!
return miniToastr[type](message, title, timeout, cb)
}
But actually you can add your own properties as well, if you want. Why and how? You can check it in [Advanced Setup](https://se-panfilov.github.io/vue-notifications/docs/html/advanced-setup.html) section.
const options = {
success: toast,
error: toast,
info: toast,
warn: toast
}
## Browsers support.
Vue.use(VueNotifications, options)
```
Check the Docs: [Browsers support](https://se-panfilov.github.io/vue-notifications/docs/html/browsers-support.html)
## Browser support.
All modern browsers (`ES5` support require). See [ECMAScript 5 compliant browsers][3].
You can use `ES5` or `ES6` versions as well.
Version v1.0.0 and after guarantees only a support of evergreen browsers.
Versions below v1.0.0 supports all `ES5-compatable` browsers \(i.g. starting from `IE11`\).
## License

@@ -251,4 +312,2 @@

[1]: https://github.com/se-panfilov/vue-notifications/releases
[2]: https://github.com/se-panfilov/mini-toastr
[3]: http://caniuse.com/#feat=es5
[1]: https://github.com/se-panfilov/mini-toastr

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc