Code Monkey home page Code Monkey logo

vue-toast-notification's Introduction

Vue Toast Notification

downloads js-delivr npm-version github-tag build license TypeScript

Yet another Vue.js Toast notification plugin.

Version matrix

Vue.js version Package version Branch
2.x 1.x 1.x
3.x 3.x main

Installation

npm install vue-toast-notification@^3

Usage

Plugin usage

Install the plugin

import {createApp} from 'vue';
import ToastPlugin from 'vue-toast-notification';
// Import one of the available themes
//import 'vue-toast-notification/dist/theme-default.css';
import 'vue-toast-notification/dist/theme-bootstrap.css';

const app = createApp({});
app.use(ToastPlugin);
app.mount('#app');

Then use in your components

export default {
    mounted() {
        let instance = this.$toast.open('You did it!');

        // Force dismiss specific toast
        instance.dismiss();

        // Dismiss all opened toast immediately
        this.$toast.clear();
    }
}

Composition API usage

import {useToast} from 'vue-toast-notification';
import 'vue-toast-notification/dist/theme-sugar.css';

const $toast = useToast();
let instance = $toast.success('You did it!');

// Force dismiss specific toast
instance.dismiss();

// Dismiss all opened toast immediately
$toast.clear();

Available options

The API methods accepts these options:

Attribute Type Default Description
message String -- Message text/html (required)
type String success One of success, info, warning, error, default
position String bottom-right One of top, bottom, top-right, bottom-right,top-left, bottom-left
duration Number 3000 Visibility duration in milliseconds, set to 0 to keep toast visible
dismissible Boolean true Allow user dismiss by clicking
onClick Function -- Do something when user clicks
onDismiss Function -- Do something after toast gets dismissed
queue Boolean false Wait for existing to dismiss before showing new
pauseOnHover Boolean true Pause the timer when mouse on over a toast

API methods

this.$toast.open(options)

This is generic method, you can use this method to make any kind of toast.

// Can accept a message as string and apply rest of options from defaults
this.$toast.open('Howdy!');

// Can accept an Object of options
this.$toast.open({
    message: 'Something went wrong!',
    type: 'error',
    // all of other options may go here
});

this.$toast.success(message,?options)

There are some proxy methods to make it more readable.

this.$toast.success('Profile saved.', {
    // optional options Object
})

this.$toast.error(message,?options)

this.$toast.warning(message,?options)

this.$toast.info(message,?options)

this.$toast.default(message,?options)

Global options

You can set options for all the instances during plugin initialization

app.use(VueToast, {
    // One of the options
    position: 'top'
})

Further you can override option when creating new instances

this.$toast.success('Order placed.', {
    // override the global option
    position: 'bottom'
})

Install in non-module environments (without webpack)

<!-- Vue.js -->
<script src="https://cdn.jsdelivr.net/npm/vue@3"></script>
<!-- Lastly add this package -->
<script src="https://cdn.jsdelivr.net/npm/vue-toast-notification@3"></script>
<link href="https://cdn.jsdelivr.net/npm/vue-toast-notification@3/dist/theme-sugar.css" rel="stylesheet">
<!-- Init the plugin -->
<script>
    const app = Vue.createApp({});
    app.use(VueToast.ToastPlugin);
    app.mount('#app');
</script>

Run examples on your localhost

  • Clone this repo
  • Make sure you have node-js >=18.16 and pnpm >=8.3 pre-installed
  • Install dependencies - pnpm install
  • Run webpack dev server - pnpm start
  • This should open the demo page in your default web browser

Acknowledgements

License

MIT License

vue-toast-notification's People

Contributors

ankurk91 avatar hacknug avatar huzaifahj avatar jprodrigues70 avatar krishnahimself avatar macavity avatar notarun avatar rezaeimehr avatar zvizvi 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-toast-notification's Issues

Text separated per alphabet, not per words

[x] Bug report => search github for a similar issue or PR before submitting
[ ] Feature request
[ ] Other, please describe

MY PLATFORM

  • Vue.js version : 2.6.11
  • Browser name and version : Chrome Latest
  • This package version : 0.4.0

DESCRIPTION

Example, If the text in the notification are too long, it will separated per alphabet that will look like this:

**Mail has been sent. Check your em
ail for activate your account.**

But the text should be separated per words like this:

**Mail has been sent. Check your
email for activate your account.**

[vue-3] Make useToast available from import

I'm submitting a ...

[ ] Bug report => search github for a similar issue or PR before submitting
[x] Feature request
[ ] Other, please describe

Tell about your platform

  • Vue.js version : 3.0.x
  • This package version : next

Current behavior
The $toast object is only available in components, not from imports.

Expected behavior
I would be nice to have useToast available for in .ts files - for instance in Vuex.

example.ts

import { useToast } from "vue-toast-notification";

useToast.success("Hello world.");

It should be as simple matter of exporting { useToast } in index.js and changing the .d.ts file.

Guide: How to use with NuxtJS?

I think it would be a great idea to put how to install with NuxtJS.

Create file ./plugins/vue-toast-notification.js with code below.

import Vue from 'vue'
import VueToast from 'vue-toast-notification'
import 'vue-toast-notification/dist/theme-sugar.css'

Vue.use(VueToast)

Add plugins to nuxt-config.js

plugins: [
  ...,
  { src: '~/plugins/vue-toast-notification.js', mode: 'client' }
]

Replace event bus with mitt

Goal:

  • Make this package ready for vue.js 3.x
  • However, We are NOT targeting for vue 3.x now

Notes:

  • Remove Vue event bus and replace with mitt
  • Public API would be the same, this is not a breaking change for users.
  • Event name would be the same as before toast.clear
  • mitt will be bundled with package itself, so it should be a dev-dependency.
  • There should not be any change in webpack configs or test cases.

//cc @rishabhrpg

Css Naming feature request

[ ] Bug report => search github for a similar issue or PR before submitting
[ X] Feature request
[ ] Other, please describe

Tell about your platform

  • Vue.js version : 2.6.12
  • Browser name and version : Chrome|Firefox|Safari x.x.x
  • This package version : 0.5.4

Current behavior
When using post css to purge unused css classes, we have to add the following classes to the whitelist:

[
    /v-notices.+$/,
    /v-toast.+$/,
    /fade.+$/,
    /is-.+$/,
]

It would be really great if this package used BEM conventions. This way we wouldn't need multiple css classes to white list but just anything starting with v-notices!

Toast Icon not visible?

I'm submitting a ... (check one with "x")

[x] Bug report => search github for a similar issue or PR before submitting
[ ] Feature request
[ ] Other, please describe

Tell about your platform

  • Vue.js version : 2.6.11
  • Browser name and version : Opera
  • This package version : 0.4.0

Current behavior
Toast Icon does not appear. However, it appears on the demo so I doubt it's the browser's fault.

Expected behavior
Toast Icon appears along side with the text.

Minimal reproduction of the problem with instructions

Error in $toast.open

TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.invokeGetter

     Vue.use(VueToast);
     

     var app = new Vue({
         el: '#app',
         data: {
             message: 'You loaded this page on ' + new Date().toLocaleString()
         },

         methods: {
             open() {
                 this.$toast.open({
                     message: "Test message from Vue",
                     type: "success",
                     duration: 5000,
                     dismissible: true
                 });
             }
         }
     })

Using Toast in service file causes an error.

Hi Ankur,
Thank you for this awesome plugin.

I want to to use toast for Axios responses in one of my service.ts file

this is my code:
main.ts

import Vue from 'vue';
import VueToast from 'vue-toast-notification';
import 'vue-toast-notification/dist/index.css';
Vue.use(VueToast, {
  position: 'bottom',
  duration: 5000,
  queue: true,
});

httpservices.service.ts

import Vue from 'vue';
class HttpService {
    private request (method: string, url: string, data?) {
        return axios
          .request({
            method,
            url,
            data,
          })
          .then((response) => {
              Vue.$toast.success('success');
              return response;
          })
          .catch((error) => {
              Vue.$toast.error(error.response.data.errors);
          });
    }
}

Error:
Property '$toast' does not exist on type 'VueConstructor'.

also tried. this.$toast.error but same error.

vue-toast-notification not working in production

First of all my sincere congratulations on these very nicely designed notifications!

After having tested my application locally for a long time, the application has recently gone into production. But now it looks like nothing happens when I try to trigger a notification. Even no console error messages...

Steps to reproduce

  1. Make a new test project via the vue CLI
  2. Integrate vue-toast-notification as explained in the README
  3. Run npm run build
  4. Move the contents of the dist folder to a test website (e.g. via FTP)
  5. Try to trigger the notification

Result

Nothing happens

types: missing return type in `close()` and `clear()` for strict TS compilation

I'm submitting a Bug Report

  • Vue.js version : 2.6.x
  • This package version : 0.5.3

Current behavior
TS does not compile with strict flag due to missing return types (imlicit any)

Expected behavior
The lib should provide sufficient types to enable strict compiling

Minimal reproduction of the problem with instructions
Will only set it up if you really require it

Solution

// toast.d.ts

  export interface ToastComponent extends ExtendedVue<any, any, any, any, any> {
-   close()
+   close(): void
  }

  export interface ToastApi {
    open(message: string): ToastComponent
  
    open(options: ToastOptions): ToastComponent
  
    success(message: string, options?: ToastOptions): ToastComponent
  
    error(message: string, options?: ToastOptions): ToastComponent
  
    info(message: string, options?: ToastOptions): ToastComponent
  
    warning(message: string, options?: ToastOptions): ToastComponent
  
    default(message: string, options?: ToastOptions): ToastComponent

-    clear()
+    clear(): void
  }

Thanks for this awesome package and adding types!
Cheers and happy coding!

Importing theme through SCSS is broken

[X ] Bug report => search github for a similar issue or PR before submitting
[ ] Feature request
[ ] Other, please describe
  • Vue.js version : 2.6.x
  • Browser name and version : Chrome|Firefox|Safari (last)
  • This package version : 0.4.1

Current behavior
Using webpack trying to import theme (with overriding some of the scss variables) from :

"node_modules/vue-toast-notification/src/themes/default/index.scss"

Module build failed (from ./node_modules/sass-loader/dist/cjs.js):

@import 'src/themes/animations';
^
      File to import not found or unreadable: src/themes/animations.

Expected behavior
importing index.scss doesn't have a path error;
New content of index.scss should be with relative paths, like here:

@import './variables';
@import './../animations';
@import './main';

Currently can be fixed with imorting main files one by one without index.scss:

@import '~vue-toast-notification/src/themes/default/_variables.scss';
@import '~vue-toast-notification/src/themes/_animations.scss';
@import '~vue-toast-notification/src/themes/default/_main.scss';

BUT, if scss files in this npm library will update their name or new dependencies show up - this procedure should be re-done...

Uncaught DOMException: Failed to execute 'setAttribute' on 'Element': '0' is not a valid attribute name.

I'm submitting a ... (check one with "x")

[x] Bug report => search github for a similar issue or PR before submitting
[ ] Feature request
[ ] Other, please describe

Tell about your platform

  • Vue.js version : 3.2.22
  • Browser name and version : Chrome 96
  • This package version : 2.0.1

Current behavior
Whenever I call this.$toast.open('.'); I get:

runtime-core.esm-bundler.js?5c40:6769 Uncaught DOMException: Failed to execute 'setAttribute' on 'Element': '0' is not a valid attribute name.
    at patchAttr (webpack-internal:///./node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js:473:16)
    at patchProp (webpack-internal:///./node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js:672:9)
    at mountElement (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:3946:25)
    at processElement (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:3918:13)
    at patch (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:3838:21)
    at ReactiveEffect.componentUpdateFn [as fn] (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:4377:21)
    at ReactiveEffect.run (webpack-internal:///./node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js:195:29)
    at setupRenderEffect (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:4496:9)
    at mountComponent (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:4279:9)
    at processComponent (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:4237:17)
logError @ runtime-core.esm-bundler.js?5c40:6769
handleError @ runtime-core.esm-bundler.js?5c40:6755
callWithErrorHandling @ runtime-core.esm-bundler.js?5c40:6709
callWithAsyncErrorHandling @ runtime-core.esm-bundler.js?5c40:6715
invoker @ runtime-dom.esm-bundler.js?830f:350

Minimal reproduction of the problem with instructions

I just followed the instructions. I have the line above to show the toast and createApp(App).use(router).use(VueToast).mount('#app'); in main.ts

using class components and hammer but no other libs

Enhancements

  • pause timer on hover
  • define positions as constants and expose them to consumer
  • rename close() to dismiss() and same goes for onClose prop, [#39]
  • add indefinite option, which will make toast to be visible forever until user click
  • update a running toast instance
  • toast id/group to replace existing running toast
  • check if toast is active by id
  • allow to set container, default is body
  • Animations similar to this
  • slots

ref
https://maronato.github.io/vue-toastification/

failed to compile

error while importing import 'vue-toast-notification/dist/dist/theme-default.css' in main.js
Module not found: Error: Can't resolve 'vue-toast-notification/dist/dist/theme-default.css'

Toast height broken in bootstrap 4.5.1+

[X] Bug report 
  • vue 2.6.11
  • Browser name and version : Chrome 84.0.4147.105
  • This package version : 0.4.1

Current behavior
When updating bootstrap to version 4.5.2, the height of the toast became 350px. If you roll back bootstrap to version 4.5.0, the toast becomes normal size.

Minimal reproduction of the problem with instructions
Investigation has shown that in bootstrap 4.5.1+ the .toast class has a property flex-basis: 350px;
Native bootstrap toast renders correctly.

How can I use your library in component?

I installed the library
I added the library in main.js file like this:

import VueToast from "vue-toast-notification";
import "vue-toast-notification/dist/theme-default.css";

Vue.use(VueAgile, VeeValidate, VueToast);

Then I tried to use library in component but it doesn't work:

methods: {
deleteVideo(id) {
      VideoDataService.delete(id)
       
 .then(response => {
          this.videos = response.data;
          this.getAllVideos();
          this.$toast.open("You did it!");
        })
        .catch(function(error) {
          console.log(error);
        });
    },
}

How can i use your library properly in component?

Help to override color

I am trying to override the css colors, so far no success.
Please provide the steps to make the changes,

Thanks

styling issue

I'm submitting a request of help with styling

I have just installed this great toaster (npm install vue-toast-notification --save). Mechanism works great just like on jsfiddle( https://jsfiddle.net/ankurk91/ebakcs62/). But I would like to have great styling like on demo ( https://ankurk91.github.io/vue-toast-notification/). As far as I understand styles should be included by import 'vue-toast-notification/dist/dist/theme-default.css';. Problem is that this line gives me errors "Module not found: Error: Can't resolve 'vue-toast-notification/dist/dist/theme-default.css' in...."

another thing is that
Vue.use(VueToast, { position: 'bottom-right' });
does not work for me... what ever I try with postion it does not affect message ;/

Any ideas?

Stable Release?

I'm submitting a ... (check one with "x")

[ ] Bug report => search github for a similar issue or PR before submitting
[ ] Feature request
[x] Other, please describe

I see that the latest version is 0.6.1. Are you following semantic versioning? If so, a version <1 would suggest that this package is not yet stable. Any idea when you'll be at a v1.x release?

Broken build during SSR due to `webpack@5` defaults

I'm submitting a ...

[x] Bug report => search github for a similar issue or PR before submitting
[ ] Feature request
[ ] Other, please describe

Tell about your platform

  • Vue.js version: ^2.6.10 (via [email protected])
  • Browser name and version: Chrome|Firefox|Edge x.x.x
  • This package version: 0.6.1

Current behavior
Latest published version of the plugin breaks my project's build suring SSR due to the recent change to webpack@5.

ReferenceError: self is not defined
    at Object.8TqK (node_modules/vue-toast-notification/dist/index.js:10:1)
    at __webpack_require__ (webpack/bootstrap:25:0)
    at Module.O/VM (assets/js/app.c97f0adb.js:6730:12)
    at __webpack_require__ (webpack/bootstrap:25:0)
    at Object.0 (assets/js/app.c97f0adb.js:308:18)
    at __webpack_require__ (webpack/bootstrap:25:0)
    at assets/js/app.c97f0adb.js:118:18
    at Object.<anonymous> (assets/js/app.c97f0adb.js:121:10)
    at o (/Users/nestor/Code/freelance/_archive/oasis-senses/node_modules/vue-server-renderer/build.prod.js:1:77545)
    at /Users/nestor/Code/freelance/_archive/oasis-senses/node_modules/vue-server-renderer/build.prod.js:1:78138
error Command failed with exit code 1.

Expected behavior
Project build shouldn't be affected by this change. It should be as simple as adding one line to our current webpack.config.js file as per the following documents:

Let me know if you want me to open a PR with the change ๐Ÿ‘

Feature request: No duration & embedding Vue component

I just recently started using this plugin and I really quite like it, though it still lacks a bunch of features and options in my opinion. Two of those features which I personally would require are:

  1. No duration: There are some cases where you'd want to have messages sticking out and staying visible until the user interacts with it - this of course should force the dismissible option, and maybe also provide a close icon for more intuitive design.
  2. Embedded Vue components: Since we're already dealing with Vue here, why not make the toasts be able to render Vue components inside them as well?

Problems when using with vuex

I'm submitting a ...

[x] Bug report => search github for a similar issue or PR before submitting
[ ] Feature request
[ ] Other, please describe

Tell about your platform

  • Vue.js version : 3.2.12
  • Browser name and version : Edge 94.0.992.47
  • This package version : 2.0.1

Current behavior
I get an error when when calling


VueToast.success('Success');
`Uncaught (in promise) Error: TypeError: vue_toast_notification__WEBPACK_IMPORTED_MODULE_6___default.a.success is not a function`

I get an error when calling this.$toast.success('Success!');
Uncaught (in promise) Error: TypeError: Cannot read properties of undefined (reading 'success')

Expected behavior
I would get the toast notification popup with success message.

Minimal reproduction of the problem with instructions
STEPS TO REPRODUCE

import { createStore } from 'vuex';
import axios from 'axios';
import VueToast from 'vue-toast-notification';

export default createStore({
  ...
  actions: {
    async update({ commit }, data) {
      return new Promise((resolve, reject) => {
        axios.put(...)
          .then((response) => {
            if (response.status === 200 || response.status === 201) {

              VueToast.success('Success!'); <-- gives error
              this.$toast.success('Success!'); <-- gives error

              resolve(response.data);
            }
    
            if (response.status === 404) {
              ...
            }
    
            return null;
          })
          .catch((error) => reject(...));
      });
    },
  },
  ...
});

NOT WORKING AT ALL

[ ] Bug report => no error, silently showing nothing

Tell about your platform

  • Vue.js version : 2.6.11
  • Browser name and version : Chrome|Firefox|Edge x.x.x
  • This package version : 0.6.0

Current behavior

Expected behavior

Minimal reproduction of the problem with instructions

Add some code formatter like Prettier and some Linter like ESLint

I'm submitting a pattern request.

I was codding in this project, and my edittor replaced ' with " and adds ; or , on end lines, and if you establishes some code formatter and some linter, it never will happen.

[ ] Bug report => search github for a similar issue or PR before submitting
[ ] Feature request
[x] Other, please describe

Change duration milliseconds to seconds

I love how small this is, good work. Can we change milliseconds to seconds though? Seems unlikely someone would use milliseconds, and if they do they still can with a decimal - but most would just use seconds.

I've already made changes if I can make a pull request.

Overriding colors

I'm submitting a ... (check one with "x")

[ ] Bug report => search github for a similar issue or PR before submitting
[ ] Feature request
[x] Question

Tell about your platform

  • Vue.js version : 3
  • Browser name and version : Firefox
  • This package version : 2.0.1

Hi Ankurk,

I was just wondering, is there an easy way to override the colors used for the toasts?
I'm fairly new to web development, but working on a project now where we would like to use the application color scheme for the toasts as well.

Thanks for this plugin, it's great :-)
Any help with the colors would be aweome too!

Cheers!

Error when using vuex

I'm trying to use toast with vuex, but I can't seem to make it work.

import { createStore } from 'vuex';
import axios from 'axios';
import VueToast from 'vue-toast-notification';

export default createStore({
  ...
  actions: {
    async update({ commit }, data) {
      return new Promise((resolve, reject) => {
        axios.put(...)
          .then((response) => {
            if (response.status === 200 || response.status === 201) {

              VueToast.success('Success!'); <-- gives error
              this.$toast.success('Success!'); <-- gives error

              resolve(response.data);
            }
    
            if (response.status === 404) {
              ...
            }
    
            return null;
          })
          .catch((error) => reject(...));
      });
    },
  },
  ...
});

The error from VueToast.success('Success');
Uncaught (in promise) Error: TypeError: vue_toast_notification__WEBPACK_IMPORTED_MODULE_6___default.a.success is not a function

The error from this.$toast.success('Success!');
Uncaught (in promise) Error: TypeError: Cannot read properties of undefined (reading 'success')

Am I doing something wrong?

Vue 3 support?

Tell about your platform

  • Vue.js version : ^3.0.0
  • Browser name and version : Chrome|Firefox|Safari x.x.x
  • This package version : 0.5.4

Current behavior
This plugin works fine with vue version < 3.0.0

Expected behavior
Upgraded to Vue3 and Vue.extend is not supported in Vue3.
Also, the way to use the plugin in Vue3 is changed.

Minimal reproduction of the problem with instructions

  • Upgrade to Vue version 3.0.0.

@ankurk91 Can you please help me with this?

Can we trigger a toast from vuex store action

I'm submitting a ... (check one with "x")


[x ] Question=> can i use this to trigger a toast from the vuex store.

Tell about your platform

  • Vue.js version : 2.6.x
  • Browser name and version : Chrome|Firefox|Edge x.x.x
  • This package version : 0.x.x

Current behavior

Expected behavior

Minimal reproduction of the problem with instructions

we are using something like this in bootstrap vue

import { BToast } from 'bootstrap-vue' let bootStrapToaster = new BToast(); bootStrapToaster.$bvToast.toast(error.response.data.message, { title: 'Error', variant: 'danger', solid: true })

Css not loaded after deployment on Heroku

Did someone use this plugin on Heroku ? On localhost, it works perfectly. On production, deploy pass but nothing happens. No errors, the text is displayed but no toast at all. Is the path to the css file correct in the documentation ?

[Proposal] More toast themes

Hi! This is a really great library, with high-quality codebase in my opinion.
I was thinking about writing my own toast library, before I found this one. Now I would like to help you with the development. I have some great ideas for new features, for example I think that it would be great to ship this package with a few themes available, so users can choose which one suits their needs.
I've prepared some proposal for other toast design than the default one:
toast-1
Let, me know what do you think about it! ๐Ÿ˜ธ

Help Icons

Hi, I'm trying to use the library, but I'm having problems rendering the icons in the alert.

image

image

The warning icon is not displayed

Namespace CSS

It would be great if all of the CSS could be namespaced. This would allow to use whitelistPatterns with purgecss to prevent styles from being removed.

Brilliant project, Feature request?

So I think that this project is great! It's simple and straightforward, too. However, there are a few things that I feel could be good features on top of what's already implemented.

  • Add support for dismissing a toast programmatically, especially with a bulk dismiss function
  • Add support for custom toast templates, so that a header and body could be used (Slots?)
  • Add support for other actions to exist on the toast
  • Add TypeScript support

Are any of these on the radar? The TypeScript support shouldn't be hard to create, and I've created what should work for dismissing all of the components (though it's using a property on an element that likely isn't supposed to be used for non-Vue-core code to access a component instance). Would you appreciate PRs for some of these suggestions?

Add id to toast, auto overriding previous toast with same id

Hello, thank you for this plugin, it is very light and get the job done quick.
I have one suggestion sir.

Its very common for web app to have recurrent messages (shown as toast), like errors occuring for the same reason (or related to), or steps in the app workflow that shows a toast for each step but it would be less overwhelming to override the previous toast if step get finished fast. Because it is related.

I would suggest to add an "id" property to the toast, optional of course, but if it is set and a toast already exists with the same id, immediately hide this previous toast and show new one.

I could try a PR if you agree that it could be a good addition.

Provision to show long notifications in multiple lines

I'm submitting a ... (check one with "x")

[ ] Bug report => search github for a similar issue or PR before submitting
[X ] Feature request
[ ] Other, please describe

Tell about your platform

  • Vue.js version : 2.6.x
  • Browser name and version : Chrome|Firefox|Edge x.x.x
  • This package version : 0.6.1

Current behavior
For very short notifications the toast looks good. But for longer notifications the toast length increases.

Expected behavior
The toast would look better if we can specify the max length of the toast so that the text will be shown in multiple lines if notification is little longer.

Minimal reproduction of the problem with instructions
Capture

HTML tags support in "message"

I'm submitting a ...

[ ] Bug report => search github for a similar issue or PR before submitting
[X] Feature request
[ ] Other, please describe

Tell about your platform

  • Vue.js version : 2+
  • Browser name and version : Chrome 81
  • This package version : 0.3.0

Current behavior
Toast message is only displayed as a plain text.

Expected behavior
It would be great if we could use HTML tags in message if needed (could be an additional option). E.g. to make part of the message bold.

Minimal reproduction of the problem with instructions

  1. Call toast with a message containing HTML tags:
    Vue.$toast.error('Something went <b>wrong</b>!');
  2. It will be displayed as a plain text:
    Something went <b>wrong</b>!

Support only 1 toast show.

What about have only 1 toast each time show?

  • My expect is: If have previous toast => closed it immediately and open new toast.

Because:

Now i using clear() before open new event. => it work. but still have ghosting previous toasts (because animations fadeIn). This make bad UX :(

This case help mobile UX well.

Thanks so much!

ERROR in build.js from UglifyJs

Hello,

I am getting the following error while building a Vue.js application. How to fix it?

ERROR in build.js from UglifyJs Unexpected token: punc ()) [./node_modules/vue-toast-notification/dist/index.min.js:1,225][build.js:23778,189] npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! [email protected] build: cross-env NODE_ENV=production webpack --progress --hide-modules npm ERR! Exit status 2

Thanks.

Is there a typescript version for this library?

I'm submitting a ... (check one with "x")

[ ] Bug report => search github for a similar issue or PR before submitting
[ ] Feature request
[x] Other, please describe

Is there a typescript version for this library?
I couldn't find @types/vue-toast-notification

Please let me know
Thanks in advance,

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.