class Toast {
	constructor(time) {
		this.time = time;
	}

	setDuration(d) {
		this.time = d;
	}

	create(html, options) {
		window.Materialize ? 
		window.Materialize.toast(html, this.time) :
		window.M && window.M.toast({html, displayLength: this.time, ...options})
	}

	success(html) {
		this.create(html, { classes: "  green darken-3"});
	}
	
	notify(html) {
		this.create(html, { classes: "blue lighten-2"});
	}

	warning(html) {
		this.create(html, { classes: "orange lighten-2"});
	}

	error(html) {
		this.create(html, { classes: "red lighten-2"});
	}

	clear() {
		window.M && window.M.Toast.dismissAll();
	}
}

export default new Toast(2000);
