An Ember CLI addon that adds Atom inspired notification messages to your app.
Check out the demo.
ember install:addon ember-cli-notifications
This addon requires broccoli-sass to compile CSS for the included message themes.
If not already a part of your project, install using ember install:npm broccoli-sass
in your project directory.
From within your controller or route.
actions: {
saveOptions: function() {
this.notifications.addNotification({
message: 'Saved successfully!',
type: 'success'
});
}
}
actions: {
saveOptions: function() {
this.get('model').save()
.then(function(){
this.notifications.addNotification({
message: 'Successfully saved your settings',
type: 'success',
autoClear: true
});
}.bind(this),
.catch(function(err) {
this.notifications.addNotification({
message: 'Something went wrong'
type: 'error'
});
}.bind(this));
}
}
Include this snippet in your Handlebars template to display the notifications.
The string that is displayed within the notification. This is the only required option.
this.notifications.addNotification({
message: 'Successfully saved your settings'
});
Define the type of notification that should be presented. This sets the CSS of the notification, as well as the Font Awesome icon.
Default value is info
error
info
success
warning
this.notifications.addNotification({
message: 'Successfully saved your settings',
type: 'success'
});
Boolean value that defines whether the notification message dismisses automatically, or whether it needs to be dismissed manually by the user.
If true, inherits the default clearDuration
value unless specified.
Default value is false
false
true
this.notifications.addNotification({
message: 'Successfully saved your settings',
type: 'success',
autoClear: true
});
The time in milliseconds that the notification will automatically dismiss after, if autoClear
is true
.
Default value is 3200
this.notifications.addNotification({
message: 'Successfully saved your settings',
type: 'success',
autoClear: true,
clearDuration: 1200
});