marcelodolza / iziToast

Elegant, responsive, flexible and lightweight notification plugin with no dependencies.
https://marcelodolza.github.io/iziToast/
Apache License 2.0
2.61k stars 304 forks source link

Change iconText option to accept raw HTML (so we can use it to inject SVG icons) #142

Closed gerbenqikker closed 6 years ago

gerbenqikker commented 6 years ago

Hi there,

First of all, loving the library; so far the only thing that I've not been able to get working is to use my own SVG icons instead of an icon font with this library.

I got to the point where I am passing these parameters:

        icon: 'icon-placeholder',
        iconText: function () {
          return require(`~/assets/svg/icons/check.svg`)
        },

Sadly this does not work since the iconText login in Izitoast injects a text node rather then just appending the HTML.

I think it would be a relatively small change, and would make the entire thing a lot more customisable.

tronjs commented 6 years ago

up, I also need this option.

marcelodolza commented 6 years ago

Implemented, could you test? @tronjs @gerbenqikker https://github.com/dolce/iziToast/releases/tag/v1.4.0

qikkeronline commented 6 years ago

Hi @dolce - I'm currently not working on the project where we ran into this and due to time we chose to just run with the icons that are included with iziToast instead. For the foreseeable future I won't be able to help you to test this; I'll see if I can squeeze it in between projects somewhere :)

Thanks for picking it up though - this will definately make me use it again on future projects!

marcelodolza commented 6 years ago

Ok @qikkeronline , but it's simple, just use the iconUrl option, example:

iconUrl: 'assets/star.svg'
marcelodolza commented 6 years ago

v1.4.0 released. https://www.npmjs.com/package/izitoast

qikkeronline commented 5 years ago

Just tried this @dolce, and even though it works good with images; it does not work with any HTML element but just populates the src attribute of an image node in stead. The reason I would like this is so I could just inject the SVG node here and hence can manipulate the SVG color etc with CSS. Right now I could make this work but it was only because I exported the SVG files with set fill attributes. But this prevents me from being able to style the SVG with CSS.

For now good enough for my use but I think it would be nice if we could append any HTML there.

Thanks!