mosha-vue-toastify icon indicating copy to clipboard operation
mosha-vue-toastify copied to clipboard

how to set default options

Open apm29 opened this issue 1 year ago • 1 comments

is there any api to set the default options, for example: set default duration to 10000ms.

apm29 avatar Apr 12 '23 01:04 apm29

hello, i tried manually this :

import 'mosha-vue-toastify/dist/style.css';
import { clearToasts } from "mosha-vue-toastify"

const toast = {
	success: (message: string, duration: number = 3000) => {
		createToast(message, {
			hideProgressBar: false,
			showIcon: true,
			position: 'top-center',
			type: 'success',
			transition: 'bounce',
			swipeClose: true,
			timeout: duration
		});
	},
	error: (message: string, duration: number = 3000) => {
		createToast(message, {
			hideProgressBar: false,
			showIcon: true,
			position: 'top-center',
			type: 'danger',
			transition: 'bounce',
			swipeClose: true,
			timeout: duration
		});
	},
	warning: (message: string, duration: number = 3000) => {
		createToast(message, {
			hideProgressBar: false,
			showIcon: true,
			position: 'top-center',
			type: 'warning',
			transition: 'bounce',
			swipeClose: true,
			timeout: duration
		});
	},
	info: (message: string, duration: number = 3000) => {
		createToast(message, {
			hideProgressBar: false,
			showIcon: true,
			position: 'top-center',
			type: 'info',
			transition: 'bounce',
			swipeClose: true,
			timeout: duration
		});
	},
	loading: (message: string) => {
		createToast(message, {
			hideProgressBar: false,
			showIcon: true,
			position: 'top-center',
			type: 'info',
			transition: 'bounce',
			timeout: -1,
		});
	},
	clearAll: () => {
		clearToasts()
	}
}

export default toast;```

And maybe u can define default duration in props on Toast object

huiitre avatar Dec 12 '23 13:12 huiitre