ldc-loue/resources/ts/modules/toast.ts
2022-06-12 16:38:22 +02:00

34 lines
1 KiB
TypeScript

import * as Toastify from "toastify-js";
import { Options } from "toastify-js";
export default {
methods: {
toast(
message: string,
duration = 4000,
className = "notifications"
): void {
const options: Options = {
duration: duration,
newWindow: false,
close: true,
className: className,
gravity: "top",
offset: {
x: "2em",
y: "3em",
},
// * Prevents dismissing of toast on hover
stopOnFocus: true,
};
options.text = message;
Toastify(options).showToast();
},
notify(message: string, duration = 4000): void {
this.toast(message, duration, "notifications");
},
errorNotify(message: string, duration = 4000): void {
this.toast(message, duration, "notifications error");
},
},
};