diff --git a/src/app/pages/components/components.module.ts b/src/app/pages/components/components.module.ts index b126781e..a1726ec9 100644 --- a/src/app/pages/components/components.module.ts +++ b/src/app/pages/components/components.module.ts @@ -1,4 +1,5 @@ import { NgModule } from '@angular/core'; +import { NgaCheckboxModule } from '@akveo/nga-theme'; import { TreeModule } from 'ng2-tree'; import { ToasterModule } from 'angular2-toaster'; @@ -13,6 +14,7 @@ import { ComponentsRoutingModule, routedComponents } from './components-routing. ComponentsRoutingModule, TreeModule, ToasterModule, + NgaCheckboxModule, ], declarations: [ ...routedComponents, diff --git a/src/app/pages/components/notifications/notifications.component.html b/src/app/pages/components/notifications/notifications.component.html index 183c08c5..c18648ac 100644 --- a/src/app/pages/components/notifications/notifications.component.html +++ b/src/app/pages/components/notifications/notifications.component.html @@ -5,53 +5,78 @@ -
- - -
-
- - -
-
- - -
-
-
- - +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ + +
+ +
+ + +
+ +
+ + +
+
+ +
+
+ + +
+
+ +
+ + +
+
+ +
Newest on top
+
Hide on click
+
Prevent arising of duplicate toast
+
Close button
- -
-
-
- -
-
- - -
-
- -
-
- -
-
- -
-
- -
- - + + + + + + diff --git a/src/app/pages/components/notifications/notifications.component.scss b/src/app/pages/components/notifications/notifications.component.scss index 9f5627b2..95f91b9e 100644 --- a/src/app/pages/components/notifications/notifications.component.scss +++ b/src/app/pages/components/notifications/notifications.component.scss @@ -1,3 +1,12 @@ -input[type='checkbox'] { - margin-right: 0.5rem; +@import '../../../@theme/styles/variables'; + +@include nga-install-component() { + + nga-card-footer { + padding-bottom: 0.25rem; + + button { + margin: 0 1rem 1rem 0; + } + } } diff --git a/src/app/pages/components/notifications/notifications.component.ts b/src/app/pages/components/notifications/notifications.component.ts index c06a0152..4c21b802 100644 --- a/src/app/pages/components/notifications/notifications.component.ts +++ b/src/app/pages/components/notifications/notifications.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; -import { ToasterService, ToasterConfig, Toast } from 'angular2-toaster'; +import { ToasterService, ToasterConfig, Toast, BodyOutputType } from 'angular2-toaster'; -// import 'style-loader!angular2-notifications/notifications.css'; +import 'style-loader!angular2-toaster/toaster.css'; @Component({ selector: 'ngx-notifications', @@ -11,37 +11,60 @@ import { ToasterService, ToasterConfig, Toast } from 'angular2-toaster'; export class NotificationsComponent { constructor(private toasterService: ToasterService) {} - title: string = 'HI there!'; - content: string = `I'm cool toaster!`; - type: string = 'default'; - isCloseButton: boolean = true; config: ToasterConfig; - isHideOnClick: boolean = true; - isNewestOnTop: boolean = true; - toastsLimit: number = 5; - position: string = 'toast-bottom-right'; - timeout: number = 5000; - isDuplicatesPrevented: boolean = false; + position: string = 'toast-top-right'; animationType: string = 'fade'; - types: string[] = ['default', 'info', 'wait', 'success', 'warning', 'error']; + title: string = 'HI there!'; + content: string = `I'm cool toaster!`; + timeout: number = 5000; + toastsLimit: number = 5; + type: string = 'default'; + + isNewestOnTop: boolean = true; + isHideOnClick: boolean = true; + isDuplicatesPrevented: boolean = false; + isCloseButton: boolean = true; + + types: string[] = ['default', 'info', 'success', 'warning', 'error']; animations: string[] = ['fade', 'flyLeft', 'flyRight', 'slideDown', 'slideUp']; positions: string[] = ['toast-top-full-width', 'toast-bottom-full-width', 'toast-top-left', 'toast-top-center', 'toast-top-right', 'toast-bottom-right', 'toast-bottom-center', 'toast-bottom-left', 'toast-center']; + quotes = [ + { title: null, body: 'We rock at Angular' }, + { title: null, body: 'Titles are not always needed' }, + { title: null, body: 'Toastr rock!' }, + { title: 'What about nice html?', body: 'Sure you can!' }, + ]; + makeToast() { + this.showToast(this.type, this.title, this.content); + } + + openRandomToast () { + const typeIndex = Math.floor(Math.random() * this.types.length); + const quoteIndex = Math.floor(Math.random() * this.quotes.length); + const type = this.types[typeIndex]; + const quote = this.quotes[quoteIndex]; + + this.showToast(type, quote.title, quote.body); + }; + + private showToast(type: string, title: string, body: string) { this.config = new ToasterConfig({ positionClass: this.position, timeout: this.timeout, newestOnTop: this.isNewestOnTop, + tapToDismiss: this.isHideOnClick, preventDuplicates: this.isDuplicatesPrevented, animation: this.animationType, limit: this.toastsLimit, }); const toast: Toast = { - type: this.type, - title: this.title, - body: this.content, + type: type, + title: title, + body: body, timeout: this.timeout, showCloseButton: this.isCloseButton, }; diff --git a/src/app/pages/pages-menu.ts b/src/app/pages/pages-menu.ts index 9bf0173a..9531804c 100644 --- a/src/app/pages/pages-menu.ts +++ b/src/app/pages/pages-menu.ts @@ -56,7 +56,7 @@ export const MENU_ITEMS: List = List([ title: 'Tree', link: '/pages/components/tree', }, { - title: 'Toaster', + title: 'Notifications', link: '/pages/components/notifications', }, ]),