ldc-supportweb/resources/ts/modules/toast.ts
2023-08-14 09:23:39 +00:00

35 lines
1.1 KiB
TypeScript

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