shakee93 / vue-toasted

🖖 Responsive Touch Compatible Toast plugin for VueJS 2+
https://shakee93.github.io/vue-toasted/
MIT License
2.21k stars 194 forks source link

Add example where icon can be added by function #215

Open IlyaBerzhanin opened 2 years ago

IlyaBerzhanin commented 2 years ago

Hi, I had a task to add custom icon to the toast, so tried to find the example in docs, but didn't succeed. Here is the example from docs:

Screenshot 2022-01-10 at 16 13 20

But if after setting "iconPack: 'callback'; " we can use prop "icon" as function which returns us HTMLelement:

Screenshot 2022-01-10 at 16 16 45

So it is not an issue, maybe some kind of recommendation to add such an example to docs as it was not obvious for me and I suppose some people can also get stuck for a while.

Thanks a lot!

malayhm commented 1 year ago

@IlyaBerzhanin Could you please share the code snippet with plugin initialization and usage?

The following seems to work for me: Initialization:

Vue.use(Toasted, { iconPack: 'custom-class' });

Usage:

this.$toasted.info('This is a info alert—check it out!', {
      duration: 0,
      icon: 'my-info-icon',
});