@@ -40,7 +40,7 @@ The following list describes the compatibility with Angular:
40
40
| ` 5.x ` | ` 7.x ` |
41
41
| ` 6.x ` | ` 8.x ` |
42
42
| ` 7.x ` | ` 9.x ` |
43
- | ` 8.x ` | ` 10.x ` |
43
+ | ` 8.x ` | ` 10.x ` |
44
44
45
45
<br >
46
46
@@ -49,11 +49,11 @@ The following list describes the compatibility with Angular:
49
49
By default, meaning without any polyfills, ** angular-notifier** is compatible with ** the latest versions of Chrome, Firefox, and Opera** .
50
50
Bringing in the following polyfills will improve browser support:
51
51
52
- - To be able to use the latest and greatest JavaScript features in older browsers (e.g. older version of IE & Safari), you might want to
53
- add ** [ core-js] ( https://github.com/zloirock/core-js ) ** to your polyfills.
54
- - For animation support (in particular, for better
55
- ** [ Web Animations API] ( https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API ) ** support), you might want to use the ** [ web-animations-js] ( https://github.com/web-animations/web-animations-js ) ** polyfill. For details, see the corresponding
56
- ** [ CanIUse page] ( http://caniuse.com/#feat=web-animation ) ** .
52
+ - To be able to use the latest and greatest JavaScript features in older browsers (e.g. older version of IE & Safari), you might want to
53
+ add ** [ core-js] ( https://github.com/zloirock/core-js ) ** to your polyfills.
54
+ - For animation support (in particular, for better
55
+ ** [ Web Animations API] ( https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API ) ** support), you might want to use the ** [ web-animations-js] ( https://github.com/web-animations/web-animations-js ) ** polyfill. For details, see the corresponding
56
+ ** [ CanIUse page] ( http://caniuse.com/#feat=web-animation ) ** .
57
57
58
58
> For detailed information about the Angular browser support read the
59
59
> ** [ official Angular browser support documentation] ( https://angular.io/docs/ts/latest/guide/browser-support.html ) ** . If you generated your
@@ -75,10 +75,10 @@ First of all, make **angular-notifier** globally available to your Angular appli
75
75
` NotifierModule ` the your root Angular module. For example:
76
76
77
77
``` typescript
78
- import { NotifierModule } from " angular-notifier" ;
78
+ import { NotifierModule } from ' angular-notifier' ;
79
79
80
80
@NgModule ({
81
- imports: [NotifierModule ]
81
+ imports: [NotifierModule ],
82
82
})
83
83
export class AppModule {}
84
84
```
@@ -87,14 +87,14 @@ But wait -- your probably might want to customize your notifications' look and b
87
87
call the ` withConfig ` method on the ` NotifierModule ` , and pass in the options. For example:
88
88
89
89
``` typescript
90
- import { NotifierModule } from " angular-notifier" ;
90
+ import { NotifierModule } from ' angular-notifier' ;
91
91
92
92
@NgModule ({
93
- imports: [
94
- NotifierModule .withConfig ({
95
- // Custom options in here
96
- })
97
- ]
93
+ imports: [
94
+ NotifierModule .withConfig ({
95
+ // Custom options in here
96
+ }),
97
+ ],
98
98
})
99
99
export class AppModule {}
100
100
```
@@ -108,11 +108,11 @@ root (app) component. For example:
108
108
109
109
``` typescript
110
110
@Component ({
111
- selector: " my-app" ,
112
- template: `
113
- <h1>Hello World</h1>
114
- <notifier-container></notifier-container>
115
- `
111
+ selector: ' my-app' ,
112
+ template: `
113
+ <h1>Hello World</h1>
114
+ <notifier-container></notifier-container>
115
+ ` ,
116
116
})
117
117
export class AppComponent {}
118
118
```
@@ -137,9 +137,9 @@ the themes and notification types.
137
137
To keep the size if your styles as small as possible (improving performance for the perfect UX), your might instead decide to only import
138
138
the styles actually needed by our application. The ** angular-notifier** styles are modular:
139
139
140
- - The ` ~/angular-notifier/styles/core.(scss|css) ` file is always required, it defines the basic styles (such as the layout)
141
- - Themes can be imported from the ` ~/angular-notifier/styles/theme ` folder
142
- - The different notification types, then, can be imported from the ` ~/angular-notifier/styles/types ` folder
140
+ - The ` ~/angular-notifier/styles/core.(scss|css) ` file is always required, it defines the basic styles (such as the layout)
141
+ - Themes can be imported from the ` ~/angular-notifier/styles/theme ` folder
142
+ - The different notification types, then, can be imported from the ` ~/angular-notifier/styles/types ` folder
143
143
144
144
<br ><br ><br >
145
145
@@ -149,17 +149,17 @@ Using **angular-notifier** is as simple as it can get -- simple import and injec
149
149
service, ...) you want to use in. For example:
150
150
151
151
``` typescript
152
- import { NotifierService } from " angular-notifier" ;
152
+ import { NotifierService } from ' angular-notifier' ;
153
153
154
154
@Component ({
155
- // ...
155
+ // ...
156
156
})
157
157
export class MyAwesomeComponent {
158
- private readonly notifier: NotifierService ;
158
+ private readonly notifier: NotifierService ;
159
159
160
- constructor (notifierService : NotifierService ) {
161
- this .notifier = notifierService ;
162
- }
160
+ constructor (notifierService : NotifierService ) {
161
+ this .notifier = notifierService ;
162
+ }
163
163
}
164
164
```
165
165
@@ -170,18 +170,14 @@ export class MyAwesomeComponent {
170
170
Showing a notification is simple - all your need is a type, and a message to be displayed. For example:
171
171
172
172
``` typescript
173
- this .notifier .notify (" success" , " You are awesome! I mean it!" );
173
+ this .notifier .notify (' success' , ' You are awesome! I mean it!' );
174
174
```
175
175
176
176
You can further pass in a _ notification ID_ as the third (optional) argument. Essentially, such a _ notification ID_ is nothing more but a
177
177
unique string tha can be used later on to gain access (and thus control) to this specific notification. For example:
178
178
179
179
``` typescript
180
- this .notifier .notify (
181
- " success" ,
182
- " You are awesome! I mean it!" ,
183
- " THAT_NOTIFICATION_ID"
184
- );
180
+ this .notifier .notify (' success' , ' You are awesome! I mean it!' , ' THAT_NOTIFICATION_ID' );
185
181
```
186
182
187
183
> For example, you might want to define a _ notification ID_ if you know that, at some point in the future, you will need to remove _ this
@@ -191,9 +187,9 @@ this.notifier.notify(
191
187
192
188
``` typescript
193
189
this .notifier .show ({
194
- type: " success" ,
195
- message: " You are awesome! I mean it!" ,
196
- id: " THAT_NOTIFICATION_ID" // Again, this is optional
190
+ type: ' success' ,
191
+ message: ' You are awesome! I mean it!' ,
192
+ id: ' THAT_NOTIFICATION_ID' , // Again, this is optional
197
193
});
198
194
```
199
195
@@ -205,7 +201,7 @@ You can also hide notifications. To hide a specific notification - assuming you'
205
201
call:
206
202
207
203
``` typescript
208
- this .notifier .hide (" THAT_NOTIFICATION_ID" );
204
+ this .notifier .hide (' THAT_NOTIFICATION_ID' );
209
205
```
210
206
211
207
Furthermore, your can hide the newest notification by calling:
@@ -298,7 +294,7 @@ With the `theme` property you can change the overall look and feel of your notif
298
294
* Defines the notification theme, responsible for the Visual Design of notifications
299
295
* @type {string}
300
296
*/
301
- theme : " material" ;
297
+ theme : ' material' ;
302
298
```
303
299
304
300
#### Theming in detail
@@ -362,9 +358,7 @@ You can define a custom `ng-template` as follows:
362
358
363
359
``` html
364
360
<ng-template #customNotification let-notificationData =" notification" >
365
- <my-custom-alert type =" notificationData.type" >
366
- {{ notificationData.message }}
367
- </my-custom-alert >
361
+ <my-custom-alert type =" notificationData.type" > {{ notificationData.message }} </my-custom-alert >
368
362
</ng-template >
369
363
```
370
364
@@ -373,23 +367,23 @@ In this case you could wrap your own HTML, even a `<my-custom-alert>` component
373
367
Inside your component, you can then reference the ` <ng-template> ` by its template variable ` #customNotification ` using Angular's ` ViewChild ` :
374
368
375
369
``` typescript
376
- import { ViewChild } from " @angular/core" ;
370
+ import { ViewChild } from ' @angular/core' ;
377
371
378
372
@Component ({
379
- // ...
373
+ // ...
380
374
})
381
375
export class SomeComponent {
382
- @ViewChild (" customNotification" , { static: true }) customNotificationTmpl;
376
+ @ViewChild (' customNotification' , { static: true }) customNotificationTmpl;
383
377
384
- constructor (private notifierService : NotifierService ) {}
378
+ constructor (private notifierService : NotifierService ) {}
385
379
386
- showNotification() {
387
- this .notifier .show ({
388
- message: " Hi there!" ,
389
- type: " info" ,
390
- template: this .customNotificationTmpl
391
- });
392
- }
380
+ showNotification() {
381
+ this .notifier .show ({
382
+ message: ' Hi there!' ,
383
+ type: ' info' ,
384
+ template: this .customNotificationTmpl ,
385
+ });
386
+ }
393
387
}
394
388
```
395
389
@@ -491,43 +485,43 @@ To sum it up, the following is the default configuration _(copy-paste-friendly)_
491
485
492
486
``` typescript
493
487
const notifierDefaultOptions: NotifierOptions = {
494
- position: {
495
- horizontal: {
496
- position: " left" ,
497
- distance: 12
498
- },
499
- vertical: {
500
- position: " bottom" ,
501
- distance: 12 ,
502
- gap: 10
503
- }
504
- },
505
- theme: " material" ,
506
- behaviour: {
507
- autoHide: 5000 ,
508
- onClick: false ,
509
- onMouseover: " pauseAutoHide" ,
510
- showDismissButton: true ,
511
- stacking: 4
512
- },
513
- animations: {
514
- enabled: true ,
515
- show: {
516
- preset: " slide" ,
517
- speed: 300 ,
518
- easing: " ease"
519
- },
520
- hide: {
521
- preset: " fade" ,
522
- speed: 300 ,
523
- easing: " ease" ,
524
- offset: 50
525
- },
526
- shift: {
527
- speed: 300 ,
528
- easing: " ease"
529
- },
530
- overlap: 150
531
- }
488
+ position: {
489
+ horizontal: {
490
+ position: ' left' ,
491
+ distance: 12 ,
492
+ },
493
+ vertical: {
494
+ position: ' bottom' ,
495
+ distance: 12 ,
496
+ gap: 10 ,
497
+ },
498
+ },
499
+ theme: ' material' ,
500
+ behaviour: {
501
+ autoHide: 5000 ,
502
+ onClick: false ,
503
+ onMouseover: ' pauseAutoHide' ,
504
+ showDismissButton: true ,
505
+ stacking: 4 ,
506
+ },
507
+ animations: {
508
+ enabled: true ,
509
+ show: {
510
+ preset: ' slide' ,
511
+ speed: 300 ,
512
+ easing: ' ease' ,
513
+ },
514
+ hide: {
515
+ preset: ' fade' ,
516
+ speed: 300 ,
517
+ easing: ' ease' ,
518
+ offset: 50 ,
519
+ },
520
+ shift: {
521
+ speed: 300 ,
522
+ easing: ' ease' ,
523
+ },
524
+ overlap: 150 ,
525
+ },
532
526
};
533
527
```
0 commit comments