Small (but powerful) toast library.
Text (required):
SimpleToast('Text');
SimpleToast({text: 'Text'});
Title with text:
SimpleToast({title: 'Title', text: 'Text'});
Targets:
- css (or) css.toast: Applies to toast
- css.title: Applies to title
- css.button: Applies to buttons
// Apply a red-ish background
SimpleToast({text: 'Text', css: {background: '#c8354e'}});
SimpleToast({
css: {
// Applies to toast (unless toast is present)
toast: {
// Applies to toast
},
title: {
// Applies to title
},
button: {
// Applies to buttons
mouseOver: {
// Applies to buttons when moused over
}
},
},
});
You can provide a single button within an object, or an array of buttons.
// Single button
SimpleToast({
buttons: {
text: 'Text', // Required
onclick: () => {
// Runs on click
},
css: {
// Applies to button
mouseOver: {
// Applies to button when moused over
},
},
},
});
// Multiple Buttons
SimpleToast({
buttons: [
{
// Button data goes here
},
{
// Button data goes here
},
],
});
const toast = new SimpleToast({
title: '',
text: '',
buttons: [...button] || {
text: '',
className: '',
css: {},
onclick(event, toast) {
// this; // toast reference
},
},
footer: '',
className: '' || [''] || {
toast: '' || [''],
button: '' || [''],
},
css: {
toast: {},
title: {},
button: {},
},
timeout: 0, // Close toast after # milliseconds
onClose(reason, toast) {
// this; // toast reference
},
});
// Methods on toast
toast.setText(newText); // Change text to newText
toast.exists(); // Does toast still exist?
toast.close(reason); // Close toast for optional reason
SimpleToast.version; // Version in number form
SimpleToast.versionString; // Readable string of version
SimpleToast.count(); // Number of toasts open