Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to set default options #30

Open
apm29 opened this issue Apr 12, 2023 · 1 comment
Open

how to set default options #30

apm29 opened this issue Apr 12, 2023 · 1 comment

Comments

@apm29
Copy link

apm29 commented Apr 12, 2023

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

@huiitre
Copy link

huiitre commented Dec 12, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants