mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-12 20:47:19 +03:00
27 lines
536 B
JavaScript
27 lines
536 B
JavaScript
|
import Toastify from 'toastify-js';
|
||
|
|
||
|
function showToast(props) {
|
||
|
if (typeof props === 'string') {
|
||
|
props = { text: props };
|
||
|
}
|
||
|
const { onClick = () => {}, delay, ...rest } = props;
|
||
|
const toast = Toastify({
|
||
|
className: 'shiny-pill',
|
||
|
gravity: 'bottom',
|
||
|
position: 'center',
|
||
|
...rest,
|
||
|
onClick: () => {
|
||
|
onClick(toast); // Pass in the object itself!
|
||
|
},
|
||
|
});
|
||
|
if (delay) {
|
||
|
setTimeout(() => {
|
||
|
toast.showToast();
|
||
|
}, delay);
|
||
|
} else {
|
||
|
toast.showToast();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default showToast;
|