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

Add a string close button #23

Open
lorraineS opened this issue Apr 30, 2019 · 3 comments
Open

Add a string close button #23

lorraineS opened this issue Apr 30, 2019 · 3 comments

Comments

@lorraineS
Copy link

lorraineS commented Apr 30, 2019

Hello,

Since it is possible to add a string of characters within the content, it would be nice to also be able to customize the closing button with inline SVG, img tag, etc.

Ex:

Toastify({
  text:
    "<p class='notification-p'>" +
      "Simple Exemple." +
     "</p>",
     duration: 3000,
     close:
       "<svg class='icon' aria-hidden='true'>" +
         "<use xlink:href='assets/icons/icons.svg#favorites'></use>" +
       "</svg>",
}).showToast();

If the close property is mentioned then its value is true. Then we can directly add our HTML markup.

What do you think ?

@apvarun
Copy link
Owner

apvarun commented Jun 29, 2019

I feel this is way too much customization for such a small component. Could you explain the intension behind to understand better?

@silverwind
Copy link

silverwind commented Jul 29, 2020

Would also prefer a HTML string option on close. I find the default close icon ugly and would like to replace it with a nicer one.

I implemented a custom close icon using custom HTML in text and binding the click handler but would prefer something better supported and not bound to break when the internal api changes. Here's roughly what I've been doing:

const toast = Toastify({
  text: `
    <div class="toast-message">${htmlEscape(message)}</div>
    <div class="toast-close"><svg/></div>
  `,
});

toast.showToast();

toast.toastElement.querySelector('.toast-close').addEventListener('click', () => {
  toast.removeElement(toast.toastElement);
});

@Shaka-60hp
Copy link

Would also prefer a HTML string option on close. I find the default close icon ugly and would like to replace it with a nicer one.

I implemented a custom close icon using custom HTML in text and binding the click handler but would prefer something better supported and not bound to break when the internal api changes. Here's roughly what I've been doing:

const toast = Toastify({
  text: `
    <div class="toast-message">${htmlEscape(message)}</div>
    <div class="toast-close"><svg/></div>
  `,
});

toast.showToast();

toast.toastElement.querySelector('.toast-close').addEventListener('click', () => {
  toast.removeElement(toast.toastElement);
});

Got the same thing going on

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

4 participants