• Stars
    star
    264
  • Rank 155,103 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 11 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Notification messages for your Ember.js app

Build Status

ember-notify

ember-notify displays wee little notification messages down the bottom of your Ember.js app.

Compatibility

ember-notify is compatible with the following presentation frameworks:

  • Zurb Foundation 6 (default)
  • Zurb Foundation 5: <EmberNotify @messageStyle="foundation-5" />
  • Thoughtbot Refills: <EmberNotify @messageStyle="refills" />
  • Twitter Bootstrap: <EmberNotify @messageStyle="bootstrap" />
  • Semantic-UI: <EmberNotify @messageStyle="semantic-ui" />
  • UIKit: <EmberNotify @messageStyle="uikit" />

The CSS animations are inspired by CSS from alertify.js. You can also customize the positioning and animations by overriding the default ember-notify CSS class. For usage, see the animations example.

Usage

  1. Add <EmberNotify /> to one of your templates, usually in application.hbs
  2. Inject the notify service
  3. Display messages using the info, success, warning, alert and error methods

Examples

import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';

export default class MyComponent extends Component {
  @service notify;

  @action
  sayHello() {
    this.notify.info('Hello there!');
  }
}

By default the notifications close after 2.5 seconds, although you can control this in your template:

<EmberNotify @closeAfter={{4000}} />

Or you can control when each message is closed:

let message = this.notify.alert('You can control how long it is displayed', {
  closeAfter: 10000 // or set to null to disable auto-hiding
});

...and you can hide messages programmatically:

message.close();

You can specify raw HTML:

this.notify.info({ html: '<div class="my-div">Hooray!</div>' });

Rounded corners, if that's your thing:

this.notify.alert(`This one's got rounded corners.`, {
  radius: true
});

Include custom classNames on your message:

this.notify.alert('Custom CSS class', {
  classNames: ['my-class']
});

Include an identifier to avoid duplicate messages being displayed:

this.notify.alert('Unique Message', { id: 'some-unique-identifier' });

Multiple Containers

If you want to have separate notifications and control where they're inserted into the DOM you can have multiple <EmberNotify /> components, but only one of them can be accessed using the injected service. The others you will need to provide a source property, so secondary containers should be used as follows:

 <EmberNotify @source={{this.alternativeNotify}} />
import Component from '@glimmer/component';
import Notify from 'ember-notify';
import { action } from '@ember/object';

export default class MyComponent extends Component {
  alternativeNotify = Notify.create();

  @action
  clicked() {
    this.alternativeNotify.success('Hello from the controller');
  }
}

Custom message template

You can pass a block with template you want to use for each message (instead of using the default one). It may look like this:

  <EmberNotify as |message close|>
    <a {{on "click" (action close)}} class="close">
      close from block
    </a>
    <span class="message-from-block">
      {{message.text}}
    </span>
  </EmberNotify>

Two arguments are passed to the block: message object, and close action. Make sure you are using Closure Actions syntax passing the action (e. g. <a {{action close}} or <YourComponent @close={{action close}} />.

Custom Animations

By default, the ember-notify message will appear in the bottom right corner of the screen. You may want to control the positioning or the animation. To do so, you need to pass a CSS class using the defaultClass option. This will render the top level ember-notify element with the class you pass in.

<!-- Gives class="custom-notify"> to top level element -->
<EmberNotify @defaultClass="custom-notify" />

Then you need to add custom styling for each of the elements within the ember-notify structure. The following snippet summarizes rules needed for a custom look. For a complete example that you can drop into your project, see examples/custom-position-animations.css

/* Main container */
.custom-notify {
  position: fixed;
  top: 10px;
  right: 0;
  left: 0;
}

/* Message box */
.custom-notify .callout {
  position: relative;
  overflow: hidden;
}

/* Classes applied for animating in/out */
.custom-notify .ember-notify-show {}
.custom-notify .ember-notify-hide {}

Turn off loading CSS

If youΒ want to use the addon without loading the CSS themes (because you have your own CSS) add this to your ember-cli-build.js file:

let app = new EmberApp({
  emberNotify: {
    importCss: false
  }
});

Installation

This module is an ember-cli addon, so installation is easy as pie.

ember install ember-notify

Upgrading from a previous version

See the CHANGELOG.

More Repositories

1

ember-electron

⚑ Build, test, compile and package desktop apps with Ember and Electron
JavaScript
806
star
2

ember-cp-validations

Ember computed property based validations
JavaScript
443
star
3

ember-changeset

Ember.js flavored changesets, inspired by Ecto
JavaScript
431
star
4

ember-moment

JavaScript
399
star
5

ember-infinity

⚑ Simple, flexible Infinite Scroll for Ember CLI Apps.
JavaScript
377
star
6

ember-data-model-fragments

Ember Data addon to support nested JSON documents
JavaScript
371
star
7

ember-metrics

Send data to multiple analytics integrations without re-implementing new API
JavaScript
367
star
8

ember-cli-flash

Simple, highly configurable flash messages for ember-cli
JavaScript
355
star
9

ember-light-table

Lightweight, contextual component based table for Ember
JavaScript
312
star
10

ember-data-factory-guy

Factories and helper functions for (unit, integration, acceptance) testing + development scenarios with Ember Data
JavaScript
302
star
11

ember-sortable

Sortable UI primitives for Ember.js
JavaScript
295
star
12

ember-burger-menu

An off-canvas sidebar component with a collection of animations and styles using CSS transitions
JavaScript
279
star
13

ember-cli-sass

Use node-sass to preprocess your ember-cli app's files, with support for sourceMaps and include paths
JavaScript
276
star
14

ember-collection

An efficient incremental rendering component for Ember.js with support for custom layouts and large lists
JavaScript
236
star
15

ember-changeset-validations

Validations for ember-changeset
JavaScript
219
star
16

ember-file-upload

File uploads for Ember apps
TypeScript
201
star
17

emberx-select

Select component for Ember based on the native html select element.
JavaScript
200
star
18

ember-keyboard

An Ember.js addon for the painless support of keyboard events
JavaScript
177
star
19

ember-pikaday

A datepicker component for Ember CLI projects.
JavaScript
159
star
20

ember-impagination

An Ember Addon that puts the fun back in asynchronous, paginated datasets
JavaScript
122
star
21

active-model-adapter

Adapters and Serializers for Rails's ActiveModel::Serializers
TypeScript
102
star
22

ember-cli-hot-loader

An early look at what hot reloading might be like in the ember ecosystem
JavaScript
99
star
23

ember-autoresize

Autoresize for Ember Components
JavaScript
88
star
24

ember-cli-windows

🚀 Improve Ember-Cli Performance on Windows
JavaScript
79
star
25

ember-set-helper

A better `mut` helper
JavaScript
68
star
26

ember-inputmask

Ember wrapper around Inputmask.js
JavaScript
68
star
27

ember-collapsible-panel

An unopinionated, zero-dependency panel and accordion
JavaScript
57
star
28

ember-qunit-nice-errors

Because expected true, result false is not enough!
JavaScript
56
star
29

ember-cli-ifa

Ember CLI addon for injecting fingerprinted asset map file into Ember app
JavaScript
54
star
30

emberx-file-input

A tiny Ember component which does one thing and only: select files beautifully.
JavaScript
52
star
31

ember-cognito

AWS Amplify/Cognito and ember-simple-auth integration
JavaScript
32
star
32

ember-validators

A collection of EmberJS validators
JavaScript
24
star
33

ember-cli-bugsnag

Integrates Bugsnag reporting service into your Ember CLI app.
JavaScript
20
star
34

ember-stripe-elements

A simple Ember wrapper for Stripe Elements
JavaScript
18
star
35

ember-popper-modifier

An Ember modifier for working with Popper.js.
TypeScript
14
star
36

ember-launch-darkly

A modern Ember addon to wrap the Launch Darkly service
JavaScript
13
star
37

ember-require-module

Dynamically require modules
JavaScript
7
star
38

ember-indexeddb-adapter

Ember Data adapter for IndexedDB
JavaScript
4
star
39

program-guidelines

Checklist and guidelines for the Adopted Ember Addons org.
JavaScript
3
star
40

ember-cli-deploy-new-relic-sourcemap

Ember CLI Deploy plugin to deploy source maps to new relic
JavaScript
2
star