Skip to content

Commit

Permalink
CSS classes (#119)
Browse files Browse the repository at this point in the history
* ✨ Allow custom CSS classes to be added to notification component

Fixes #118

* 📚 Updating dummy app, docs
  • Loading branch information
ynnoj authored Nov 7, 2016
1 parent 8950780 commit 0d4826d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions addon/components/notification-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export default Component.extend({
'processedType'
],

classNameBindings: [
'notification.cssClasses'
],

paused: false,

dismissClass: computed('notification.dismiss', function() {
Expand Down
3 changes: 2 additions & 1 deletion addon/services/notification-messages-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export default Ember.ArrayProxy.extend({
autoClear: (Ember.isEmpty(options.autoClear) ? this.get('defaultAutoClear') : options.autoClear),
clearDuration: options.clearDuration || this.get('defaultClearDuration'),
onClick: options.onClick,
htmlContent: options.htmlContent || false
htmlContent: options.htmlContent || false,
cssClasses: options.cssClasses
});

this.pushObject(notification);
Expand Down
2 changes: 2 additions & 0 deletions tests/dummy/app/controllers/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default Controller.extend({
clearDuration: 2400,
htmlContent: false,
position: 'top',
cssClasses: 'profile-saved-success-notification',

notifications: service('notification-messages'),

Expand All @@ -27,6 +28,7 @@ export default Controller.extend({
this.get('notifications').clearAll();
}
this.get('notifications').addNotification({
cssClasses: this.get('cssClasses'),
message: this.get('computedMessage'),
type: this.get('type'),
autoClear: this.get('autoClear'),
Expand Down
11 changes: 11 additions & 0 deletions tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,17 @@ this.get('notifications').success('Saved successfully!', {
<button class="btn btn-primary" {{action "showNotifcation"}}>Show</button>
</div>
</div>
<div class="py2">
<h2>Notification with custom CSS</h2>
<hr>
<p>Pass a string of CSS classes to the notification component.</p>
{{#themed-syntax lang="js" theme="dark" class="h5" withBuffers=false}}
this.get('notifications').success('Saved successfully!', {
autoClear: true,
cssClasses: 'profile-saved-success-notification'
});
{{/themed-syntax}}
</div>
<div class="py2">
<h2>Notification with callback</h2>
<hr>
Expand Down

0 comments on commit 0d4826d

Please sign in to comment.