mobilizon.chapril.org-mobil.../js/src/plugins/snackbar.ts
Thomas Citharel 48935e2168
Add global search
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2022-08-28 10:02:06 +02:00

54 lines
1.1 KiB
TypeScript

import SnackbarComponent from "@/components/core/CustomSnackbar.vue";
import { App } from "vue";
export class Snackbar {
private app: App;
constructor(app: App) {
this.app = app;
}
open({
message,
variant,
position,
actionText,
cancelText,
onAction,
}: {
message?: string;
queue?: boolean;
indefinite?: boolean;
variant?: string;
position?: string;
actionText?: string;
cancelText?: string;
onAction?: () => any;
}) {
this.app.config.globalProperties.$oruga.notification.open({
component: SnackbarComponent,
props: {
message,
// queue,
// indefinite,
actionText,
cancelText,
onAction,
position: position ?? "bottom-right",
variant: variant ?? "dark",
},
position: position ?? "bottom-right",
variant: variant ?? "dark",
duration: 5000000,
});
}
}
export const snackbarPlugin = {
install(app: App) {
const snackbar = new Snackbar(app);
app.config.globalProperties.$snackbar = snackbar;
app.provide("snackbar", snackbar);
},
};