Hey @caroso1222! Thanks for the project ❤️
I have been thinking about the API and a way to extend the API so it's easier to add more notification types than just success and error.
Seeing that the code that makes the two "types" is nearly identical, it should be pretty "easy" to turn it into a loop:
Instead of using
var notyf = new Notyf({
delay: 1000,
alertIcon: 'fa fa-exclamation-circle',
confirmIcon: 'fa fa-check-circle'
})
I propose moving to:
const notyf = new Notyf({
types: {
success: {
delay: 1000, // #7
duration: 2000, // #6
icon: 'fa-foo-fi-fu'
},
error: {} // use all defaults
}
});
const errorNotification = notyf.error({
title: 'Something went wrong..',
message: 'We had some trouble while processing your request'
});
errorNotification.close(); // #20
errorNotification.on('close', () => console.log('Notification closed'));
notyf.success({
html: "<p>Hooray! <code>image-124.jpg</code> has been uploaded!</p>" // #17
});
By nesting the types in the types key, we keep the "root" level open for global options, for example
position: bottom left|bottom right or classPrefix: noty__.
By using an object instead of a string for the individual
This API change should take care of #6, #7, (half) #13, #17, and #20. Oh, and #21 of course 😉
Hey @caroso1222! Thanks for the project ❤️
I have been thinking about the API and a way to extend the API so it's easier to add more notification types than just
successanderror.Seeing that the code that makes the two "types" is nearly identical, it should be pretty "easy" to turn it into a loop:
Instead of using
I propose moving to:
By nesting the
typesin thetypeskey, we keep the "root" level open for global options, for exampleposition:bottom left|bottom rightorclassPrefix:noty__.By using an object instead of a string for the individual
This API change should take care of #6, #7, (half) #13, #17, and #20. Oh, and #21 of course 😉