ng-ytl-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
120 lines (109 loc) • 3.72 kB
text/typescript
import {
Component,
EventEmitter,
Input,
OnChanges,
OnInit,
Output,
ViewEncapsulation,
} from '@angular/core';
import { fadeAnimation } from '../core/animation/fade-animations';
import { toBoolean } from '../util/convert';
export class NzAlertComponent implements OnChanges {
private _banner = false;
private _closeable = false;
private _showIcon = false;
_display = true;
antAlert = 'ant-alert';
nzType = 'info';
nzDescription: string;
nzCloseText: string;
nzMessage: string;
nzOnClose: EventEmitter<boolean> = new EventEmitter();
set nzBanner(value: boolean) {
this._banner = toBoolean(value);
}
get nzBanner(): boolean {
return this._banner;
}
set nzCloseable(value: boolean) {
this._closeable = toBoolean(value);
}
get nzCloseable(): boolean {
return this._closeable;
}
set nzShowIcon(value: boolean) {
this._showIcon = toBoolean(value);
}
get nzShowIcon(): boolean {
return this._showIcon;
}
_classMap = {
[`${this.antAlert}`] : true,
[`${this.antAlert}-${this.nzType}`] : true,
[`${this.antAlert}-no-icon`] : !this.nzShowIcon,
[`${this.antAlert}-banner`] : this.nzBanner,
[`${this.antAlert}-with-description`]: !!this.nzDescription
};
closeAlert(): void {
this._display = false;
this.nzOnClose.emit(true);
}
ngOnChanges(): void {
this._classMap = {
[`${this.antAlert}`] : true,
[`${this.antAlert}-${this.nzType}`] : true,
[`${this.antAlert}-no-icon`] : !this.nzShowIcon,
[`${this.antAlert}-banner`] : this.nzBanner,
[`${this.antAlert}-with-description`]: !!this.nzDescription
};
}
}