Last active
January 20, 2025 07:08
-
-
Save rw3iss/526159aeff1c42b0357e7af197c0c05f to your computer and use it in GitHub Desktop.
toastr Notifications
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import toastr from 'toastr'; | |
export function notify(message, type?, timeout?) { | |
// todo, set options elsewhere/on init ? | |
toastr.options = { | |
"closeButton": false, | |
"debug": false, | |
"newestOnTop": false, | |
"progressBar": false, | |
"positionClass": "toast-bottom-right", | |
"preventDuplicates": false, | |
"onclick": null, | |
"showDuration": "300", | |
"hideDuration": "1000", | |
"timeOut": timeout ? timeout : "2000", | |
"extendedTimeOut": "1000", | |
"showEasing": "swing", | |
"hideEasing": "linear", | |
"showMethod": "fadeIn", | |
"hideMethod": "fadeOut" | |
} | |
toastr.clear(); | |
switch (type) { | |
case 'error': | |
return toastr.error(message); | |
case 'success': | |
return toastr.success(message); | |
default: | |
return toastr.success(message); | |
} | |
} | |
// Usage: | |
import notify from 'notify'; | |
notify('Message', 'success', 2000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment