Giter Club home page Giter Club logo

vue-snotify's Introduction

vue-snotify

Build Status NPM Version NPM Downloads Dev dependencies status list

Example

https://artemsky.github.io/vue-snotify/

Features

  • 9 types of toast notifications (async, confirm, prompt, html and more...)
  • Many config options (icons, backdrop, timeout, position and much more...)
  • Repository includes 3 different styles. So you can use on of them, or create your own.
  • Callbacks
  • 5KB minified and gzipped
  • Typescript definitions
  • ESM, CommonJS, UMD versions
Looking for an Angular version? Here

Snotify Gif

Installation

NPM 5

npm install vue-snotify

yarn

yarn add vue-snotify

see detailed instruction

Documentation and Examples

Documentation - here
Example application source - here
Change Log - here

CDN

License

MIT © artemsky

vue-snotify's People

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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-snotify's Issues

Possible bug on backdrop

We are using your plugin in a project and need to use the backdrop property when displaying a confirm notification (using the option object). When we removethe toast on confirmation action, we are displaying an other notification (success, or error). The backdrop is appearing even without the backdrop property set.
So, we are trying to set backdrop: -1 to the sucess or error notification and this time, the backdrop is not visible but still present in the DOM with the css property opacity: 0. So we can't continue to navigate etc.

Is it a normal behavior ?

Snotify async conflict with Select2

Hi,

I am having an issue using the snotify.async to get my data on page load, it seems to reset the select2 drop downs.

I am using select2 Jquery plugin inside a component like this:
https://vuejs.org/v2/examples/select2.html

I am using select2 as it seems to work perfectly with what I required for drop downs, the ability to search, add etc and seemed to work better than other options.

My snotify.async call is as followed:

this.$snotify.async( 'please wait...', 'Getting Data', () => new Promise((resolve, reject) => { axios.all([ axios.get('/controller/data1', { params: { dataId: dataId} }), axios.get('/controller2/data2'), axios.get('/controller3/data3', { params: { dataId: dataId } }) ]) .then(axios.spread((getDataResult, getData2Result, getData3Result) => { this.data = getDataResult.data; this.data2 = getData2Result.data; this.data3 = getData3Result.data.images; $('#mainImage').attr("src", this.getData3Result[0].pathParameters); resolve({ title: 'Success!!!', body: 'We got an example success!', config: { closeOnClick: true, position: "rightTop", backdrop: 0.5, timeout: 200 } }); })) .catch(function (error) { reject({ title: 'Error Getting Data', body: error, config: { closeOnClick: true, position: "centerCenter", backdrop: 0.5, titleMaxLength: 25 } }); }); }), { position: "centerCenter", closeOnClick: false, backdrop: 0.5, titleMaxLength: 20 });

What appears to happen is:

  • Page first loads
  • Snotify Async spinner appears in middle of page (as expected)
  • All axios gets are done
  • Data returned
  • Can see in background the data load correctly (Select2 Dropdowns all load values as expected)
  • Snotify Async Success is shown in top right corner (as expected)
  • Page loaded and ready for editing, but Select2 dropdowns are now showing the first value in list, not the bound value in data

Has anyone done anything similar?

Using normal selects does not show this issue, however as normal selects do not have the functionality I would like that unfortunately cant be an option.

Possible memory leak on SSR / server side

First off, thanks for this super awesome plugin!

That being said, I think I just discovered a memory leak when using snotify with SSR.
This can be mitigated by only installing the plugin on the client side (which probably makes sense anyway).
I haven't found the root cause of this leak, but by not installing (Vue.use()) this plugin server-side solved the leak.
For anyone wondering how to do this:
make sure you know if you are rendering client or server side eg. in webpack.client.config:

plugins: [
    new webpack.DefinePlugin({
      'process.BROWSER_BUILD': true,
    })
]

Next only use the plugin if this variable is true

if (process.BROWSER_BUILD) {
  Vue.use(Snotify)
}

Can't get confirm notifications to dismiss after button click

I'm using this in VueJS2:

this.$snotify.confirm('Are you sure you want to delete the "' + field + '" column?', 'Confirm', { timeout: 5000, showProgressBar: true, closeOnClick: true, position: 'centerCenter', pauseOnHover: true, buttons: [ {text: 'Yes', action: () => {this.removeColumn(); this.$snotify.remove(this.toast.id);}, bold: false}, {text: 'No', action: () => this.$snotify.remove(this.toast.id)}, ] });

The main issue I'm having is with this.$snotify.remove(this.toast.id);
(toast.id) gives an error that toast is not defined (as recommended in documentation), so I'm trying to target it using (this.toast.id). It doesn't work.

I've tried using this.$snotify.remove() or this.$snotify.clear(), and technically they work, however the click function (this.removeColumn()) doesn't get called.

I believe this is a bug. Is there a work-around, or am I doing something wrong?

Thanks!

How notify on vue router beforeRouteEnter?

I have a component with beforeRouteEnter() to fetch some data with AXIOS before navigate and init the component like so:

// Post.vue
beforeRouteEnter(to, from, next) {
      axios.get(`/posts/${to.params.postId}`)
        .then((response) => {
          next((vm) => {
            vm.setPost(response.data);
          });
        })
        .catch((error) => {
          next(false);
          // Now I need to notify the error with snotify.
        });
    },

I know in this situation I don't have access to the component as it has not been created yet. I also tried in the router instance file but I am in the same situation.

// Post.vue
beforeRouteEnter(to, from, next) {
      axios.get(`/posts/${to.params.postId}`)
        .then((response) => {
          next((vm) => {
            vm.setPost(response.data);
          });
        })
        .catch((error) => {
          const errorJS = new Error(error.data);
          next(errorJS);
        });
    },
// index.js
Vue.use(Router);

const router = new Router({
    mode,
    routes,
});

router.onError((error) => {
  // eslint-disable-next-line
  console.log(error);
  // Same situation here, either of following doesn't work.
  vm.$snotify...
  Vue.$snotify....;
});

export default router;

How can I notify when user can't access to the route?

Object doesn't support property or method 'assign'

IE error thrown.

in this function

while (sources.length > 0) {
   var source = sources.shift();
   if (isObject(source)) {
     for (var key in source) {
       if (isObject(source[key])) {
         target[key] = mergeDeep(target[key], source[key]);
       } else {
         Object.assign(target, defineProperty({}, key, source[key]));
       }
     }
   }
 }
 return target;
}

How to register the vue-snotify?

Hi, I got this error message and can't figure out how to register the component. It is not in the example.
Unknown custom element: <vue-snotify> - did you register the component correctly? For recursive components, make sure to provide the "name" option

Rename Snotify's truncate filter

I've ran into 2 projects where they already have a custom truncate feature that is running into issues because Snotify overrides the filter. Wouldn't it be better to have Snotify's truncate be renamed into a namespace of some sort to prevent collisions? Or maybe we can check to see if a truncate method already exists as a filter?

SnotifyButton - Option "className" not implemented

Hi,

According to the documentation, there is a "className" option for SnotifyButton. But this one is not implemented.

I managed to solve this by replacing the line 1573 of vue-snotify.js:
Before :class=\"{'snotifyToast__buttons--bold': button.bold}\"
After :class=\"[ {'snotifyToast__buttons--bold': button.bold}, button.className ]\"

Could you make the change? Thank you!

this.$snotify does not exist in Vue

Hi there,

Your package is great and I'm trying to integrate it with my system (VueJS/TS stack). I've followed the docs to integrate it but I'm still running into the issue where this.$snotify is non existent.

Here's a console.log(this) on a component inside of my application
screen shot 2017-10-11 at 1 02 10 pm

And here is my setup:

  • yarn add vue-snotify
  • main.ts file
import Vue, { ComponentOptions } from 'vue'
import Snotify from 'vue-snotify'

import App from './app'
import router from './router'

import filters from './filters'
import i18n from './plugins/i18n'
import store from './store'

// Notifications Library
Vue.use(Snotify)

/* tslint:disable-line */
new Vue({
  el: '#app',
  store,
  i18n,
  router,
  template: '<App/>',
  components: { App },
} as ComponentOptions<Vue>)
  • app.vue file
<template>
  <div>
    <router-view />
    <vue-snotify></vue-snotify>
  </div>
</template>

<script lang="ts">
export default {
  name: 'App',
}
</script>

My understanding is that Vue.use(Snotify) would make this.$snotify available to my Vue components. What am I missing here? Any help is appreciated!

getAll missing from API doc

I was going to edit however your package.json scripts include a docs build so was unsure if this is automated or not.

Vue.$snotify is undefined from vuex, and other contexts

I want to preface this by saying this is my first large VueJS application and my first foray into the world of SPAs and APIs.

I have been unable to use vue-snotify from the context of vuex (and others). The code base is quite large so I have chopped it up a bit to show the important parts.

snotify.js
This is imported into the main.js file.

import Vue from 'vue'
import Snotify from 'vue-snotify'
Vue.use(Snotify, {
	toast: {
		timeout: 10000
	}
})
const wSnotify = require('vue-snotify')
window.snotify = wSnotify
// window.snotify = require('vue-snotify')

Registration component
When the user completes the registration form and clicks "Register", this method is run

register (user) {
	this.$store.dispatch('auth/register', user)
}

Which calls this vuex action...
Vuex Auth Actions

import Vue from 'vue'
import Proxy from '@/proxies/AuthProxy'
import Transformer from '@/transformers/AccountTransformer'
import store from '@/store'
import * as types from './mutation-types'

export const register = ({ commit, dispatch }, payload) => {
	console.log('store.auth.register')
	let registration = Transformer.register(payload)
	new Proxy().register(registration).then((response) => {
		console.log('store.auth.register response', response)
		commit(types.LOGIN, response.token)
		dispatch('account/save', response.account, { root: true })
		Vue.router.push({ name: 'dashboard' })
	}).catch((error) => {
		console.log('store.auth.register error', error)
		Vue.$snotify.error('The Access Code your entered was not found.', 'Invalid Access Code') // Error here
	})
}

Proxy is a class with various methods that use Promises to talk to the API via Axios

AuthProxy.js

import Proxy from './Proxy'

class AuthProxy extends Proxy {
	/**
	 * AuthProxy constructor
	 *
	 * @param {Object}	parameters	The query paramets
	**/
	constructor (parameters = {}) {
		super('auth', parameters)
	}

	/**
	 * Register a new user
	 *
	 * @param {Object}	data	The registration data
	 *
	 * @return {Promise}	The result in a Promise
	**/
	register (data) {
		// return this.submit('post', `/${this.endpoint}/register`, data) // Default
		return this.sSubmit('post', `/${this.endpoint}/register`, data) // Snotify
	}

	sSubmit (requestType, url, data = null) {
		return Vue.$snotify.async('Called with Promise', 'Test async', () => new Promise((resolve, reject) => { // Error here
			Vue.$http[requestType](url + this.getParameterString(), data).then((success) => {
				resolve({
					title: 'Registration Successful',
					body: 'You will be automatically logged in'
				})
				return success.json()
			}).then((success) =>{
				console.log(success)
				return true
			}).catch((error) => {
				console.log(error.bodyText)
				reject({
					title: 'Error!',
					body: 'Registration failed.'
				})
			})
		}))
	}
}

sSubmit is a new method I built based on the examples in the Documentation and Issue #25. Below is the default submit method.

Proxy.js

import Vue from 'vue'

class BaseProxy {
	/**
	 * BaseProxy constructor
	 *
	 * @param {string}	endpoint	The endpoint being used
	 * @param {Object}	parameters	The parameters for the request
	**/
	constructor (endpoint, parameters = {}) {
		this.endpoint = endpoint
		this.parameters = parameters
	}

	/**
	 * Transform parameters object to a string
	 *
	 * @return {string}	The parameter string
	**/
	getParameterString () {
		const keys = Object.keys(this.parameters)

		const parameterStrings = keys.filter(key => !!this.parameters[key]).map(key => `${key}=${this.parameters[key]}`)

		return parameterStrings.length === 0 ? '' : `?${parameterStrings.join('&')}`
	}

	/**
	 * Perform an AJAX request
	 *
	 * @param {string}		requestType	The request type
	 * @param {string}		url			The URL for the request
	 * @param {Object|null}	data		The data to be sent with the request
	 *
	 * @return {Promise}	The result in a promise
	**/
	submit (requestType, url, data = null) {
		return new Promise((resolve, reject) => {
			Vue.$http[requestType](url + this.getParameterString(), data).then((response) => {
				resolve(response.data)
			}).catch(({ response }) => {
				if (response.data) {
					reject(response.data)
				} else {
					reject(response)
				}
			})
		})
	}
}

The lines Vue.$snotify.error (in Vuex Actions) and Vue.$snotify.async (AuthProxy.js) produce similar errors: Uncaught (in promise) TypeError: Cannot read property '[error|async]' of undefined. I have no problem using .$snotify from within the main Vue instance, but it doesn't work when outside of that context. I have also tried adding it to the window object as you can see in the snotify.js above.
but so far none of this has worked.

How can I get access to $snotify from within the vuex (or Proxy) context? Or am I simply doing something wrong?

Animation issue on Firefox

Hi, there is a problem on Firefox with toast exit animation.
In some cases toast, near ending of its exit animation, suddenly goes back for a while and then disappears normally.
I use Firefox Quantum 57.0
Preview

Default messages

Is it possible to make default messages? For example

Vue.use(Snotify, {
    toast: {
        position: SnotifyPosition.rightTop,
    },
    global: {
        newOnTop: true,
    },
    type: {
        success: {
            timeout: 500,
            title: 'Success',
            body: 'All done',
        },
}

Snotify Async - Adding Config Options Makes 2 Async Calls

Hi,

I did create an issue about Snotify not working correctly with Select2, but I believe this is not the case, Select2 was refreshing the drop downs due to a 2nd call being made in the Async.

From what I can tell if I add extra config values into the config option of the resolve / reject this causes the async call to be done twice instead of once.

Here is the example resolve Async from the documentation with a few added config values into the resolve config option, if you run this up you will see that the console log ("calling1") ill be shown twice in the console.

this.$snotify.async('Called with promise', 'Success async', () => new Promise((resolve, reject) => {
            console.log('calling1');
            setTimeout(() => resolve({
              title: 'Success!!!',
              body: 'We got an example success!',
              config: {
                closeOnClick: true,
                position: "rightTop",
                backdrop: 0.5,
                timeout: 200
              }
            }), 2000);
          }));

Is there anything I can do to change this?

basically I want to have the Async appear in the middle of the screen, then I want the resolve "success" popup to show in the top right hand corner, doing this however causes this double axios call issue.

Thanks
Peter

VueJS - VueX and flash messages

I use VueJS 2, VueX, NuxtJS and Vue-Snotify for flash notifications.

It may not be the correct use of VueX, but I'd like to dispatch the errors caught in a try/catch.

try {
	throw new Error('test')
} catch (error) {
	this.$store.dispatch('errorHandler', error)
}

Then the dispatch, with VueX should display the notifications with Snotify-View with a loop if there are several errors.

actions: {
    async errorHandler (error) {
    	this.$snotify.error(error)
    	// and if multiple errors, then while on error
    }
}

What do you think and how to recover the instance of $snotify in VueX?

Using with vue-resource

I use vue-resource to do query

this.$http.post('people', this.person)
    .then(
        success => {
            this.$snotify.success('Example body content');
            return success.json();
        },
    ).then(
        success => {
            console.log(success);
            return true;
        }
).catch(
    (error) => {
        console.log(error.bodyText);
    }
);

How can I use Snotify Async example with my vue-resource code?

Add passing in a custom id for toast

At the moment I am adding a local reference for the toast id so I can remove it later.
It would be easier to be able to call this.$snotify.simple(body, title, {id:'docSave'}).
Then later in your code you can call this.$snotify.$emit('remove', 'docSave')

Material theme overwrites global SCSS variables

Issue

Importing vue-snotify Material theme via SCSS @import overwrites global variables with identical names.

Background

I am using the Bulma CSS framework and a number of color variables are being overwritten by vue-snotify's Material theme.

app.scss

// How Bulma recommends customizing colors
$primary: #f58220;
$primary-invert: findColorInvert($primary);
$info: #007eb9;
$info-invert: findColorInvert($info);
$success: #4f8f31;
$success-invert: findColorInvert($success);
$success-bg: lighten($success, 45%);
$success-border: darken($success, 10%);
$warning: #8a6d3b;
$warning-invert: findColorInvert($warning);
$danger: #d9534f;
$danger-invert: findColorInvert($danger);
$danger-bg: lighten($danger, 38%);
$danger-border: darken($danger, 10%);

@import '~bulma/sass/utilities/derived-variables';
$add-colors: (
	"primary":($primary, $primary-invert),
	"info":($info, $info-invert),
	"success":($success, $success-invert),
	"warning":($warning, $warning-invert),
	"danger":($danger, $danger-invert)
);
$colors: map-merge($colors, $add-colors);

node_modules/vue-snotify/styles/material/icon.scss

$success: #c8e6c9;
$info: #bbdefb;
$warning: #ffccbc;
$error: #ffcdd2;
$async: $info;

Example
Text colored with $success displays as #c8e6c9 instead of #4f8f31.

Workaround

I have found a couple ways to work around this:

  • Import Material theme before any other SCSS
  • Import Material theme via ES6

Possible Solution

Change Material color variable names to something unique, perhaps with a prefix or suffix: $snotify-success or $success-snotify. This is less of a bug and more of a hiccup that users may stumble across while using this plugin.

Thanks for the awesome plugin, and keep up the good work!

Docs need to add CSS to the install section

Technically the component will do nothing if you don't add either your styling or write your own. Please add a reference to the styling into the installation part of the documentation.

Next animation issues

Hi, it's me again 😆
Today I found next problems with animations.
Tested on Firefox 57.0 and Chrome 62.0

First major issue:
when the newOnTop option is disabled and a lot of toasts are sent with a very small interval (about 200-300ms) something strange is happening. This is probably the case when a new toast is sent when the oldest expires
Preview1
Code for reproduction

Vue.use(Snotify, { global: { newOnTop: false } })
setInterval(() => {
  vm.$snotify.success('Example body content', 'Example Title')
}, 200)

Second minor issue:
when the newOnTop option is enabled there is no "dropdown" animation when the oldest toast disappears. Rest of toasts just "jumps" down
Prewiev2

button class

Is there any possibility to add class to a button?

Custom toast position in px, offset, margin

I have a top navigation bar and the toast overlaps on top of it, i would like to set an offset/margin to the "topRight" position for example, maybe a porcentage, pixels or both.

icon not showing

Great project! The notifications seem to work well, however I'm not sure if the icons are supposed to display by default or not. Do I need to set the icons manually? I am using the material design. Thanks!

Add SSR support

Great one! But I think it doesn't work with SSR. I'm using Nuxtjs and I couldn't add the plugin.

getting runtime-only build

Hi. Great looking package here. I'm trying to use it in a vue app, but when I include the component in my App.vue, I get a warning saying:

"you are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build."
found in ---> <Snotify> ...

In my main.js, i have:

import {Snotify} from 'vue-snotify';
Vue.use(Snotify)

And in App.vue, I put in:

<template>
  <div>
    <vue-snotify></vue-snotify>
    <div class="conteudo">
      <main>
        <router-view></router-view>
      </main>
    </div>
  </div>
</template>

Any ideas on what I may be doing wrong?

integrate it in HTML + JS

Hi,
I'm approaching to this amazing component of Vue, unfortunately, I'm still having an issue.

my code is:

<!DOCTYPE html>
<html>
<head>

	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<div id='app'>
	<div> </div>	
</div>

	<script src='https://code.jquery.com/jquery-3.2.1.min.js'></script>
	<script src='js/vue.js'></script>
	<script src='js/vue-strap.js'></script>
	<script src='js/vue-snotify.js'></script>
	<script>
	var vm = new Vue({
			el:"#app",
			data:{ },
		});
	setTimeout(function(){
		console.log("Hello World");
		vm.$snotify.simple("hello world..!");
	}, 2000);
	</script>

</body>
</html>

When I open this page on my browser, the script is executed without errors or warnings, vue event is raised, but nothing happens on the screen.
Here a screenshot of the result
schermata 2017-11-20 alle 21 50 47

Can you help me to understand where the error is?

Thanks in advance,
Salvo

Add close button

Hi, could you please add a close button as an X on the top - right corner? I am using a hack right now by positioning a button absolute but when I click on it the main click event is also triggered and I run a different code for that event. You should put the main click event on a separated container and add a simple close button with his own event. I can help you with it if you want.

Can't get any notification to show up

Hello,
I'd like to use your gorgeous notification VueJs plugin but I probably miss something here.
I've set up a dead simple example on CodeSandbox to show you the issue : https://codesandbox.io/s/yw77q7y36j

A click on the "Show" button should show a success notification, right ? There's no js error in the console, but no notification either. Could you give me a hint ?

Thanks for reading

Async toast missing config argument

Hi @artemsky,
I was just using the async toast again in a different component and found I didn't want the backdrop for this notification. I can't disable it within the async call because it doesn't have a config option.

I'm not using the action option, however even if I was using the action I may want to change the default behavior of the async notification.

I managed to get around it by setting the this.$snotify.config.backdrop = -1 however this is not the default that I would like.

Am I missing something?

You could change the api to be something like this:

async (body, title, config, action) {
  if (Object.prototype.toString.call(config.then) === '[object Function]') {
    action = config
  }
  // Process config...
}

By doing this users can pass in a body, title, config, action, or just the body, title, action.
You could check for the config being an being an object also if needed.

Reading through your code to ask this question I have discovered the async toast is really a simple toast. I might change to using the simple toast and set the type to async.

angular SnotifyModule Show template error

When i add SnotifyModule to the app.module.ts -> imports array [ SnotifyModule ], the page not renders and throw the error shown below to the browser console window. please guide. thanks in advance

Unhandled Promise rejection: Template parse errors:
Can't bind to 'ngIfElse' since it isn't a known property of 'div'. ("fy-prompt *ngIf="toast.config.type === state.promptType" [toast]="toast"> <div [ERROR ->]*ngIf="!toast.config.icon; else elseBlock" [ngClass]="['snotify-icon', (toast.config.iconClass || 'sn"): ToastComponent@0:1167
Property binding ngIfElse not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations". ("snotify-prompt *ngIf="toast.config.type === state.promptType" [toast]="toast"> [ERROR ->]<div *ngIf="!toast.config.icon; else elseBlock" [ngClass]="['snotify-icon', (toast.config.iconClass |"): ToastComponent@0:1162
'ng-template' is not a known element:

  1. If 'ng-template' is an Angular component, then verify that it is part of this module.
  2. If 'ng-template' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("gClass]="['snotify-icon', (toast.config.iconClass || 'snotify-icon--' + toast.config.type)]"> [ERROR ->]<ng-template #elseBlock> <img class="snotify-icon" [src]='toast.config.icon' /> "): ToastComponent@0:1312
    Can't bind to 'ngIfElse' since it isn't a known property of 'div'. ("[ngStyle]="{'width': (state.progress * 100) + '%'}"> <div class="snotifyToast__inner" [ERROR ->]*ngIf="!toast.config.html; else toastHTML"> <div class="snotifyToast__title" *ngIf="toast.title">{{to"): ToastComponent@0:786
    Property binding ngIfElse not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations". ("yToast__progressBar__percentage" [ngStyle]="{'width': (state.progress * 100) + '%'}"> [ERROR ->]<div class="snotifyToast__inner" *ngIf="!toast.config.html; else toastHTML"> <div class="snotifyToast"): ToastComponent@0:753
    'ng-template' is not a known element:

Render body and title as html

Hello there,
is it possible to render the body and title string as html?
I need to do something like this:
vm.$snotify.error('<a href="somewhere">Link to somewhere</a>','error')

The html in the config will override the default layout (title/body/icon). So i must readd them.

Singleton

I want to open only on message a time. This is exists today?

Example:

I made two rest calls and errors happen to both but I want to show only on error message.

Notification not showing on route change

Hello! I am having an issue when trying to show a notification right before changing the route. For example, if a user logs in, I want to show a "Login successful" notification and immediately direct the user from the "/login" route to "/" like so:

            this.$snotify.success('Login successful', 'Success!')
            this.$router.push('/')

I would expect the notification to display on the next view, but it does not. However, if I then call a separate notification while in the same view, both the new notification and the old "Login successful" notification will appear. After experimenting with this, it appears that any time a notification is called immediately before the route is changed, the notification will be added to a queue, but will not display. As soon as a notification is called without a route change, all of the queued notifications will display along with the new one.

Text notification cutted in Internet Explorer

Hello @artemsky @ALL !
The module works perfectly in Google Chrome and Firefox. On the other hand, I have a problem using snotify on Internet explorer. In fact, the text in the notification is hidden. There is no newline. This happens using Material design theme.

hidden

Please can someone help me to fix this problem?
Thanks.

Cannot reference Parent Component "this".

Thanks for taking the time to develop this awesome notification component. I checked out the others on Awesome Vue and this was the better one in my opinion.

I have one slight issue. When I use the async method. After I resolve something, I then want to execute a method in the parent component. However, when I console.log "this". I see it's the snotify component.

How can I reference parent component, so that I can execute the intended method?

Thanks

My code:


this.$snotify.async(
    'Deleting Design', 
    'Delete in Progress...', 
    () => new Promise((resolve, reject) => {                    
        axios.post("/api/contentEditor/deleteTemplate", qs.stringify(data))
        .then((response) => {
            if (response.data.result) {
                resolve({
                    title: response.data.title,
                    body: response.data.text,
                    config: this.$appConfig.snotifyConfig
                });

                this.getDataResult(); <---  "this" references the snotify component
            } else {
                reject({
                    title: response.data.title,
                    body: response.data.text,
                    config: this.$appConfig.snotifyConfig
                });
            }
        }, (error) => {
            reject({
                title: error.response.data.title,
                body: error.response.data.text,
                config: this.$appConfig.snotifyConfig
            });
        })
    }),
    { 
        position: "rightTop" 
    }
)

SnotifyType is no longer being exported

Hi @artemsky,

I have been away from my project for a while and am just upgrading to the new version.
My code fails because SnotifyType is no longer being exported from the VueSnotify package.
Is this by design?
I noticed in the node_modules package I have locally that the default main package file and the esm version of the file do not export SnotifyType.

I may be missing something.

Unexpected token: name (code)

I'm unable to compile my project with webpack because an error is thrown by UglifyJS : Unexpected token: name (code). Its because my project does not use babel or ES6 syntax, but there is ES6 syntax in the compiled version of this module (version 3.2.0).

Solution

I fixed it by doing :

import Snotify from 'vue-snotify/vue-snotify.min.js'

instead of

import Snotify from 'vue-snotify'

which loads the minimified version instead of the commonjs module, it works fine.

I'm creating this issue because

1. I looked into other vue-* modules (ex: vue-router) and there is no ES6 syntax in their final /dist files. It could be a good idea to transpile the code of this module too !

2. I also noticed that every files of this project get installed by npm :

vue-snotify-screenshot

There is probably stuff we don't need in there ? I think you can choose files installed using the files property in the package.json like so :

https://github.com/vuejs/vue-router/blob/e2a19cc9177a476051143f97ac21f231ff263406/package.json#L16-L19

Feel free to do something (or nothing) about it ! 😄

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.