# ember-addon-toast-message

> The default blueprint for ember-cli addons.

Latest version **1.2.1** (published 2020-05-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install ember-addon-toast-message
pnpm add ember-addon-toast-message
yarn add ember-addon-toast-message
bun add ember-addon-toast-message
```

## Health

**Score 5/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2020-05-05 |
| First published | 2018-04-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | ^4.5 \|\| 6.* \|\| >= 7.* |
| Dependencies | 4 |
| Unpacked size | 57.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | fourth |
| Keywords | ember-addon |

## Links

- npm: https://www.npmjs.com/package/ember-addon-toast-message
- npm.io page: https://npm.io/package/ember-addon-toast-message

## Dependencies (4)

- [fourth-css](https://npm.io/package/fourth-css.md) git+ssh://git@github.com/fourth/fourth-css.git
- [ember-cli-sass](https://npm.io/package/ember-cli-sass.md) ^7.0.0
- [ember-cli-babel](https://npm.io/package/ember-cli-babel.md) ^6.3.0
- [ember-cli-htmlbars](https://npm.io/package/ember-cli-htmlbars.md) ^2.0.1

## Recent versions

- 1.2.1 (latest) — 2020-05-05
- 1.2.0 — 2020-04-30
- 1.1.0 — 2020-04-30
- 0.0.2 — 2018-04-12
- 0.0.0 — 2018-04-12

## README

# Ember-addon-toast-message

![alt text](https://github.com/fourth/ember-addon-toast-message/blob/master/github-examples/toast-without-action-example.gif "Example toast")

## Installation
* `ember install ember-addon-toast-message`

or add it to the package.json and run `npm install`

The add-on contains a service `notification` and a component `notification-toast-message`.
To use the add-on you need to bind the service to the component properties.

## Example usage

In your template
```javascript
{{notification-toast-message
  isOpen=notification.isOpen
  type=notification.type
  message=notification.message
  icon=notification.icon
  actionToBeExecuted=notification.actionToBeExecuted
  actionText=notification.actionText
  transitionObjectSelector=notification.transitionObjectSelector}}
```

In your controller
```javascript
notification: Ember.inject.service(),
```

And to activate your toast you need to call the `show()` method of the service.
```javascript
this.get('notification').show(
                "Could not save your record", //Message to be shown
                "default",  //Type of the notification
                this.retryAction, //Action the toast message will invoked once clicked on the button
                "Retry", //Message for the button which invoked the action
                ".save-btn") //This is a query selector for one html element
```

* When calling the show method, Type error is thrown if query selector is passed and no element is found.
* Every property is mandatory except the message in the toast.
* If an action is passed to the show() method, the toast will last 5 seconds (5000ms) and if not 2 seconds (2000ms)

## Meaning of the components properties.

1. `isOpen` Controlls if the toast is shown or not. When this property changes (from the `show()` function in the service) it will display the toast.
2. `type` This is the type of the notification (default / static-notification)
3. `message` The message which will be displayed in the toast.
4. `icon` The icon which will be displayed in the toast.
5. `actionToBeExecuted` Closure which will be invoked if the action button is clicked.
6. `actionText` The text of the action button.
7. `transitionObjectSelector` This is a query selector for one html element. If present in the DOM, that element will be moved up to compensate the height of the toast.

###### If the `show()` method is called twice, the service will wait untill the first toast disappears.

## TODO

- [ ] Currently the toast transitions with fixed height (75px) for desktop, remove the hardcoded px

---
_Source: https://npm.io/package/ember-addon-toast-message · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
