Giter Site home page Giter Site logo

Comments (13)

e-m-s-y avatar e-m-s-y commented on July 17, 2024 4

Overriding the CSS is not a fix for this ticket. It's a workaround. I just want to pass an option with the FontAwesome unicode or icon name.

from toastr.

MaxInMoon avatar MaxInMoon commented on July 17, 2024 4

Why using iconClasseschange the background color?

from toastr.

tbragaf avatar tbragaf commented on July 17, 2024 2

@coderdave You can still do something like this:

toastr.options = {
  iconClasses: {
    error: 'fa fa-close',
    info: 'fa fa-info',
    success: 'something',
    warning: 'something'
  },
};

It is a bit late, but does this help?

from toastr.

kagan94 avatar kagan94 commented on July 17, 2024 1

@MaxInMoon
Because it replaces the toastr container class toast-success.
You could use it in this way:

toastr.options = {
  iconClasses: {
    success: 'toast-success fa fa-close'
  }
};

The implementation is not quite good because it overrides the class of the whole container instead of adding icon as separate <i class="fa fa-close"/> tag

from toastr.

johnpapa avatar johnpapa commented on July 17, 2024

You can do this now by overriding the CSS yourself.

Glad you like toastr!

from toastr.

JamoCA avatar JamoCA commented on July 17, 2024

It's been ~2 years since this initial request. FontAwesome is being used in a lot more web applications now. Could toastr be updated so that it accepts a FontAwesome icon classname or unicode?
http://fortawesome.github.io/Font-Awesome/cheatsheet/

I'd like to customize the icon based on the message "category" (email, cart, photo, social brand, etc) and use the warning/info/success/error classes to continue managing the themed colors. Generating static CSS per message type or using Javascript to temporarily override CSS for a single toastr call isn't optimal.

As a potential work around, is it possible/recommend to use jQuery to chain a icon swap after the toastr message is generated but before it's displayed? Thanks.

from toastr.

TimFerrell avatar TimFerrell commented on July 17, 2024

Font Awesome icons aren't used natively in toastr, but are converted to a base64 representation that is stored within the CSS file. If you'd like to specify additional toast types, you're more than free to modify the toastr.js and toastr.css files to add those additional types.

The existing toastr methods (success, info, etc) already return a jQuery wrapped DOM element reference of the toast that was created by that call.

from toastr.

chuyneloxx avatar chuyneloxx commented on July 17, 2024

I can't hide the original icon of the toast. I have tried with an example with this code.

#toast-container > .toast {
background-image: none !important;
}

But doesn't work. Any idea.

from toastr.

TimFerrell avatar TimFerrell commented on July 17, 2024

@chuynelo - can you please post your question to Stack Overflow?

from toastr.

JamoCA avatar JamoCA commented on July 17, 2024

I found a similar notification jQuery plugin called Lobibox that supports more options (images, sound support, multiple sizes, etc.) I liked the simplicity of Toastr, but found myself continually wishing it were more customization.

from toastr.

TimFerrell avatar TimFerrell commented on July 17, 2024

@tbragaf's snippet looks like it'll work.

@JamoCA - sorry you felt like Toastr wasn't a good fit. Lobibox seems to have a lot more capabilities that toastr intentionally leaves out of its scope.

from toastr.

avalanche1 avatar avalanche1 commented on July 17, 2024

@JamoCA wow, Lobibox looks really kewl!

from toastr.

JoaoHamerski avatar JoaoHamerski commented on July 17, 2024

The solution i found:
Download the icon you want in svg format from FontAwesome site, after that, open the file with some text editor and change "<path fill="currentColor" to "<path fill="#ffffff" (because the default is black and toastr.js use white icons).

After that use https://www.svgtopng.me/ to convert the svg to png file, in this website you have to resize to 24x24 (is the toastr default size of icon but you can choose what you want), and convert.

Now you can use this png image on toastr notification like so:

#toast-container > .toast-success {
    background-image: url('path-to-png-image') !important;
}

or you can encode the png image to base64 using this site: https://www.base64-image.de/

and use it the same way as toastr

#toast-container> .toast-success {
   background-image: url('base-64-image') !important;
}

Live example here: https://codepen.io/JoaoHamerski/pen/zYGpdxK

This solution is a little long but is the most consistent way to replace the icons that i found.

from toastr.

Related Issues (20)

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.