import { Component, ElementRef, OnInit, Input, Output, HostBinding, EventEmitter } from '@angular/core';
import { SETTINGS } from '../../../assets/settings/notification/settings';
import { NotificationModel } from '../../models/notification';
import { CfCoreComponent } from '../core/core.component';
/**
*
Component for Core Component Notifications
*/
@Component({
selector: 'cf-notification',
template: " {{cfNotification.icon.type === 'mi' ? cfNotification.icon.name : ''}} ",
styles: ["/** * DEFAULT CORE NOTIFICATION STYLES START. Don't change them here. * If you need style chenges - create your own styling clessaes in CUSTOM NOTIFICATION STYLES section below. */ :host { position: absolute; z-index: 100000; } :host small { display: flex; align-items: center; justify-content: center; padding: 0px; min-width: 24px; min-height: 24px; border-radius: 50%; box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12); } :host small span { font-size: 14px; font-weight: bold; line-height: 0px; } :host small .mat-icon { display: flex; justify-content: center; align-items: center; font-size: 16px; } :host.top-right { top: -10px; right: -10px; } :host.bottom-right { bottom: -10px; right: -10px; } :host.bottom-left { bottom: -10px; left: -10px; } :host.top-left { top: -10px; left: -10px; } /* DEFAULT CORE NOTIFICATION STYLES END */ /* CUSTOM NOTIFICATION STYLES START */ /* CUSTOM NOTIFICATION STYLES END */ "]
})
export class CfNotificationComponent extends CfCoreComponent implements OnInit {
/**
* It is position of notification
*/
@HostBinding('class') position = 'top-right';
/**
* It is default core styling options form SETTINGS (file: '/assets/settings/notification/settings.ts')
* There are three main properties:
*
* - position: it is notification position. Default is top-right Can be also: bottom-right, bottom-left, top-left.
* - theme: it is name of theme. Theme will affect on notification colors(background of cantainer, colors of value and icon).
* - classes: it is list of css classes separated by space. It is possible to use Angualr Material primary, accent, warn and any other classes.
*
*/
options = SETTINGS;
/**
* It is Object which will recive data from Core Component notification property. It is used in different components templates.
* Example of NotifcationModel:
* {
* value: this.notificationValue,
* type: 'text'
* }
* value: any
* It is name of property for notification value.
* type: string
* It is type of notification value. Can be text(default) or icon. Optional.
*/
cfNotification: NotificationModel;
/**
* It is [settings] attribute of cf-notification component with json object generated by NotificationModel (described in cfNotification above).
*/
@Input()
settings: NotificationModel;
constructor(public elementRef: ElementRef) {
super(elementRef);
}
/**
* It will be generated cfNotification object and rendered inside component template. Also notification position and type will be set.
*/
ngOnInit() {
this.cfNotification = this.settings;
if(!this.cfNotification.hasOwnProperty('type')) this.cfNotification.type = 'text';
if(this.options.position !=='') this.position = this.options.position;
if(this.cfNotification.position && this.cfNotification.position !=='') this.position = this.cfNotification.position;
}
}