Migrate to Vue 3 and Vite
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
55
js/src/plugins/snackbar.ts
Normal file
55
js/src/plugins/snackbar.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import SnackbarComponent from "@/components/core/Snackbar.vue";
|
||||
import { App } from "vue";
|
||||
|
||||
export class Snackbar {
|
||||
private app: App;
|
||||
|
||||
constructor(app: App) {
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
open({
|
||||
message,
|
||||
queue,
|
||||
indefinite,
|
||||
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);
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user