diff --git a/CHANGELOG.md b/CHANGELOG.md
index f931fa27..0fbbc296 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -48,6 +48,9 @@ to `toaster-config.defaultToastType`.
correctly changed to `info` instead of `toast-info` for the fallback case.
* **toaster.css:** The close button positioning has been corrected.
Closes [#192](https://github.com/Stabzs/Angular2-Toaster/issues/192).
+* **toast.component:** The `BodyOutputType.TrustedHtml` body content did not properly update on change. A pipe has been
+added at the suggestion of @rmeshksar to force re-rendering of the content if it changes. Replaces
+[#185]](https://github.com/Stabzs/Angular2-Toaster/pull/185).
# 10.0.0
diff --git a/README.md b/README.md
index 4c56d9aa..66979ebb 100644
--- a/README.md
+++ b/README.md
@@ -8,9 +8,11 @@ largely based off of [AngularJS-Toaster](https://github.com/jirikavi/AngularJS-T
[![Build Status](https://travis-ci.org/Stabzs/Angular2-Toaster.svg?branch=master)](https://travis-ci.org/Stabzs/Angular2-Toaster)
[![Coverage Status](https://coveralls.io/repos/github/Stabzs/Angular2-Toaster/badge.svg?branch=master&b=8.0.0)](https://coveralls.io/github/Stabzs/Angular2-Toaster?branch=master)
+Version ^11.0.0 has a number of new features, type definitions, and break changesing. Please review the
+[CHANGELOG](CHANGELOG.md/#11.0.0) for a list of features and breaking changes before upgrading.
Version ^5.0.0 requires either `.forRoot()` or `.forChild()` `ToasterModule` inclusion. Please
-read the 5.x.x release notes and the `Getting Started` section before upgraded.
+read the 5.x.x release notes and the `Getting Started` section before upgrading.
Version ^4.0.0 now supports @angular/animations, which is a breaking change.
Please read both the Getting Started and Animations sections before upgrading.
@@ -257,16 +259,47 @@ If you need to target a non-supported browser, a [polyfill](https://github.com/w
# Configurable Options
### Toast Types
-By default, five toast types are defined: 'error, 'info', 'wait', 'success', and 'warning'.
+By default, five toast types are defined via the `ToastType` type: 'error, 'info', 'wait', 'success', and 'warning'.
-The default options can be overridden by passing a mapping object to the config, where the key corresponds to the toast type and the value corresponds to a custom style:
+The existing toast type configurations can be overridden by passing a mapping object that uses the
+same type names but overrides the style class:
```typescript
template:
``
public config: ToasterConfig =
- new ToasterConfig({typeClasses: {'partial-success': '.toaster-partial-success' }});
+ new ToasterConfig({typeClasses: {
+ error: 'custom-toast-error',
+ info: 'custom-toast-info',
+ wait: 'custom-toast-wait',
+ success: 'custom-toast-success',
+ warning: 'custom-toast-warning'
+ }});
+```
+
+In addition, the default options can be overridden, replaced, or expanded, by extending the toast type with a
+custom type and passing a mapping object to the config, where the key corresponds to the toast type and the
+value corresponds to a custom class:
+
+**NOTE: When providing a custom type, both the typeClasses and iconClasses objects must be updated.
+In the case where either are not provided, the toast type will fall back to the `defaultToastType` which
+defaults to `info`.**
+```typescript
+import {DefaultTypeClasses, DefaultIconClasses} from 'angular2-toaster';
+type ExtendedToastType = ('partial-success') & ToastType;
+
+template:
+ ``
+
+extendedTypeClasses = { ...DefaultTypeClasses, ...{ 'partial-success': 'toast-partial-success' }};
+extendedIconClasses = { ...DefaultIconClasses, ...{ 'partial-success': 'icon-partial-success' }};
+
+public config: ToasterConfig =
+ new ToasterConfig({
+ typeClasses: this.extendedTypeClasses,
+ iconClasses: this.extendedIconClasses
+ });
```
### Animations
@@ -548,6 +581,20 @@ var toast: Toast = {
this.toasterService.pop(toast);
```
+### On Click Callback
+An onClick callback function can be attached to each toast instance. The callback will be invoked upon the toast being
+clicked, even if the click is the close button. The callback will be invoked before the toast is removed.
+
+```typescript
+var toast: Toast = {
+ type: 'success',
+ title: 'parent',
+ onClickCallback: (toast) => this.toasterService.pop('success', 'invoked from ' + toast.title + ' onClick callback')
+};
+
+this.toasterService.pop(toast);
+```
+
# Building the Source
In order to build Angular2-Toaster for development, you will need to have Git and Node.js installed.
@@ -570,7 +617,7 @@ npm run build
Run Karma test instance with coverage report:
```bash
-npm run test
+ng test angular2-toaster --code-coverage
```
# Frequently Asked Questions and Issues
diff --git a/src/angular2-toaster/src/lib/toast.component.spec.ts b/src/angular2-toaster/src/lib/toast.component.spec.ts
index a54af85d..09515ce5 100644
--- a/src/angular2-toaster/src/lib/toast.component.spec.ts
+++ b/src/angular2-toaster/src/lib/toast.component.spec.ts
@@ -286,7 +286,8 @@ describe('ToastComponent', () => {
component['removeToastTick'] = new Date().getTime() + 75;
component['updateProgressBar']();
- expect(component.progressBarWidth).toBe(75);
+ expect(component.progressBarWidth).toBeGreaterThan(70);
+ expect(component.progressBarWidth).toBeLessThan(80);
});
it('should invert progressBarWidth if progressBarDirection is increasing', () => {
@@ -299,7 +300,8 @@ describe('ToastComponent', () => {
component['removeToastTick'] = new Date().getTime() + 75;
component['updateProgressBar']();
- expect(component.progressBarWidth).toBe(25);
+ expect(component.progressBarWidth).toBeGreaterThan(20);
+ expect(component.progressBarWidth).toBeLessThan(30);
});
it('should set progressBarWidth to 0 if offset is less than 0', () => {
diff --git a/src/angular2-toaster/src/lib/toast.component.ts b/src/angular2-toaster/src/lib/toast.component.ts
index f1ef8c1d..36aff714 100644
--- a/src/angular2-toaster/src/lib/toast.component.ts
+++ b/src/angular2-toaster/src/lib/toast.component.ts
@@ -15,7 +15,6 @@ import {
ElementRef,
Renderer2
} from '@angular/core';
-import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { Toast } from './toast';
import { BodyOutputType } from './bodyOutputType';
import { ToasterConfig } from './toaster-config';
@@ -27,12 +26,12 @@ import { ToasterConfig } from './toaster-config';