UNPKG

unicorn-components

Version:

<a target="_blank" href="https://getunicorn.io"><img src="https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2017/Jul/07/2615006260-5-nitsnetsstudios-ondemand-UNI_avatar.png" align="left"></a>

55 lines (43 loc) 1.11 kB
import { AfterContentInit, Component, ElementRef, EventEmitter, Output, HostBinding, } from '@angular/core'; export interface ToastOptions { showClose: boolean; } @Component({ selector: 'uni-toast', templateUrl: 'toast.component.html', styleUrls: ['toast.component.scss'], }) export class UniToastComponent implements AfterContentInit { @HostBinding('class.uni-toast') componentClass = true; animateIn = false; animateOut = false; toastOptions: ToastOptions = null; msg = ''; @Output() accept = new EventEmitter(); constructor(private elementRef: ElementRef) { } ngAfterContentInit() { this.animateIn = false; setTimeout(() => this.onEndAnimateOpen(), 50); } onEndAnimateOpen() { this.animateIn = true; } initContent(options: ToastOptions) { this.toastOptions = options; } setMessage(msg: string) { this.msg = msg; } clickClose() { this.accept.emit(true); } close() { this.animateIn = false; this.animateOut = true; } }