ldc-le-gaulois-pro/resources/ts/modules/toast.ts
2023-07-28 12:58:41 +00: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 = {
text: message,
duration: duration,
newWindow: false,
close: true,
className: className,
gravity: "top",
offset: {
x: "2rem",
y: "7rem",
},
// * Prevents dismissing of toast on hover
stopOnFocus: true,
};
Toastify(options).showToast();
},
notify(message: string, duration = 4000): void {
this.toast(message, duration, "border-gradient");
},
errorNotify(message: string, duration = 4000): void {
this.toast(message, duration, "border-gradient error");
},
},
};