Skip to content

Repository files navigation

ember-cli-notifications

NPM packageBuild StatusEmber Observer Score

An Ember CLI addon that adds Atom inspired notification messages to your app.

Check out the demo.

Installation

ember install ember-cli-notifications

Usage

In v3.1.0 we simplified the API for calling notifications in your Ember application. These were not breaking changes and using the pre v3.1.0 API will still work today.

The old API documentation can be viewed here.

Add a notification

There are four types of notification available.

// Infothis.notifications.info('You have one unread message');// Errorthis.notifications.error('Something went wrong');// Successthis.notifications.success('Saved successfully!');// Warningthis.notifications.warning('You have unsaved changes');

Add a notification with autoClear

actions: {saveOptions(){this.get('model').save().then(()=>{this.notifications.success('Successfully saved your settings',{autoClear: true});}),.catch((err)=>{this.notifications.error('Something went wrong');});}}

Remove all active notifications using clearAll() before adding a new notification

actions: {saveOptions(){this.get('model').save().then(()=>{this.notifications.clearAll();this.notifications.success('Successfully saved your settings');})}}

Set a global, default duration time

This code only needs to be called in one place such as your application route.

this.notifications.setDefaultClearNotification(1000);

Set a global, default auto clear option

This code only needs to be called in one place such as your application route.

this.notifications.setDefaultAutoClear(true);

Template

Include this snippet in your Handlebars template to display the notifications.

{{notification-containernotifications=notifications}}

Icons

Font Awesome is required as part of the addon to display the message type icons on the notifications.

If Font Awesome is not already included in the consuming application, add the following to your applications config/environment.js file as a property of the ENV object.

varENV={'ember-cli-notifications': {includeFontAwesome: true}}

Alternatively, you can use Glyphicons that are packaged with Bootstrap. Glyphicons are not added to your application via this addon.

varENV={'ember-cli-notifications': {icons: 'bootstrap'}}

Options

Auto clear

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

Example

this.notifications.success('Successfully saved your settings',{autoClear: true});

Clear duration

The time in milliseconds that the notification will automatically dismiss after, if autoClear is true.

Default value is 3200

Example

this.notifications.success('Successfully saved your settings',{autoClear: true,clearDuration: 1200});

About

Atom inspired notification messages for ember-cli

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages