mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-12-24 19:28:15 +03:00
29 lines
616 B
JavaScript
29 lines
616 B
JavaScript
import Toastify from 'toastify-js';
|
|
|
|
window._showToast = showToast;
|
|
|
|
function showToast(props) {
|
|
if (typeof props === 'string') {
|
|
props = { text: props };
|
|
}
|
|
const { onClick, delay, ...rest } = props;
|
|
const toast = Toastify({
|
|
className: `${onClick || props.destination ? 'shiny-pill' : ''}`,
|
|
gravity: 'bottom',
|
|
position: 'center',
|
|
...rest,
|
|
onClick: () => {
|
|
onClick?.(toast); // Pass in the object itself!
|
|
},
|
|
});
|
|
if (delay) {
|
|
setTimeout(() => {
|
|
toast.showToast();
|
|
}, delay);
|
|
} else {
|
|
toast.showToast();
|
|
}
|
|
return toast;
|
|
}
|
|
|
|
export default showToast;
|