tailwind-toast
Version:
Awesome, fun, easy tailwind css based alerts and notifications 🍞
51 lines (47 loc) • 1.45 kB
JavaScript
const config = require("./twtoast.config.js");
const Toast = require("./classes/Toast");
const Snackbar = require("./classes/Snackbar");
if (config.methods) {
config.methods.forEach((method) => {
eval(
"Toast.prototype." +
Object.keys(method)[0] +
" = " +
Object.values(method)
);
eval(
"Snackbar.prototype." +
Object.keys(method)[0] +
" = " +
Object.values(method)
);
});
}
module.exports = {
toast: () => {
return new Toast(
config.color ? config.color : "blue-500",
config.icon ? config.icon : "fas fa-bell",
config.duration ? config.duration : 3000,
config.positionX ? config.positionX : "center",
config.positionY ? config.positionY : "top",
config.fontColor ? config.fontColor : "grey",
config.fontTone ? config.fontTone : 100,
config.shape ? config.shape : "square",
config.speed ? config.speed : 500
);
},
snackbar: () => {
return new Snackbar(
config.color ? config.color : "blue-500",
config.icon ? config.icon : "fas fa-bell",
config.duration ? config.duration : 3000,
config.positionX ? config.positionX : "center",
config.positionY ? config.positionY : "top",
config.fontColor ? config.fontColor : "grey",
config.fontTone ? config.fontTone : 100,
config.shape ? config.shape : "square",
config.speed ? config.speed : 500
);
},
};