Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icons don't display on warn, info type #136

Open
FuckingToasters opened this issue Jan 11, 2024 · 1 comment
Open

Icons don't display on warn, info type #136

FuckingToasters opened this issue Jan 11, 2024 · 1 comment

Comments

@FuckingToasters
Copy link

FuckingToasters commented Jan 11, 2024

Hello, so let's get straight to the point:

var notyf = new Notyf({
  types: [
    {
      type: 'info',
      background: 'blue',
      icon: {
        className: 'material-icons',
        tagName: 'i',
        text: 'info'
      }
    },
    {
      type: 'warning',
      background: 'orange',
      icon: {
        className: 'material-icons',
        tagName: 'i',
        text: 'warning'
      }
    },
  ]
});

// Function to show the success message
function showMessage(msgtype, msg) {
    var showMsg = document.getElementById("showMsg");
    
    // Check if the success message should be displayed
    if (showMsg.dataset.display !== 'false') {

        // Use Notyf for displaying success message
        if (msgtype == 'success') {
            notyf.success({
                message: msg,
                duration: 9500,
                dismissible: true
            });
        } else if (msgtype == 'warn') {
            notyf.open({
                type: "warning",
                message: msg,
                duration: 9500,
                dismissible: true
            });
        } else if (msgtype == 'info') {
            notyf.open({
                type: "info",
                message: msg,
                duration: 9500,
                dismissible: true
            });
        } else if (msgtype == 'error') {
            notyf.error({
                message: msg,
                duration: 9500,
                dismissible: true
            });
        }
    }
}

The issue is, that the icons are not displayd correctly (only if you select everything on a notification modal, you see the icon. Otherwise it won't display.

2024-01-11_10 40 39

@Plazzmex
Copy link

Plazzmex commented Aug 30, 2024

Hey, I know you probably moved on or figured it out,
but maybe someone else will find it useful, because I had the same problem and then i realized you need to set the color of the icon, as mentioned in the readme

Icon color. It must be a valid CSS color value. Defaults to background color.

So the notification is basically shown flush with the background.
If you set the color, for example like this:

type: 'info', background: 'blue', icon: { className: 'material-icons', tagName: 'i', text: 'info', color: 'white' }

then it will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants