mirror of https://github.com/abpframework/abp.git
3 changed files with 69 additions and 0 deletions
@ -0,0 +1,11 @@ |
|||||
|
<div |
||||
|
class="toast-container" |
||||
|
[style.top]="top || 'auto'" |
||||
|
[style.right]="right || 'auto'" |
||||
|
[style.bottom]="bottom || 'auto'" |
||||
|
[style.left]="left || 'auto'" |
||||
|
[style.display]="toasts.length ? 'flex' : 'none'" |
||||
|
[@toastInOut]="toasts.length - 1 || 0" |
||||
|
> |
||||
|
<abp-toast [toast]="toast" *ngFor="let toast of toasts; trackBy: trackByFunc"></abp-toast> |
||||
|
</div> |
||||
@ -0,0 +1,12 @@ |
|||||
|
.toast-container { |
||||
|
position: fixed; |
||||
|
display: flex; |
||||
|
flex-direction: column; |
||||
|
align-items: center; |
||||
|
justify-content: flex-end; |
||||
|
min-width: 350px; |
||||
|
min-height: 80px; |
||||
|
&.new-on-top { |
||||
|
flex-direction: column-reverse; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,46 @@ |
|||||
|
import { Component, Input, OnInit } from '@angular/core'; |
||||
|
import { Toaster } from '../../models'; |
||||
|
import { toastInOut } from '../../animations'; |
||||
|
import { ToasterService } from '../../services/toaster.service'; |
||||
|
|
||||
|
@Component({ |
||||
|
selector: 'abp-toast-container', |
||||
|
templateUrl: './toast-container.component.html', |
||||
|
styleUrls: ['./toast-container.component.scss'], |
||||
|
animations: [toastInOut], |
||||
|
}) |
||||
|
export class ToastContainerComponent implements OnInit { |
||||
|
toasts = [] as Toaster.Toast[]; |
||||
|
|
||||
|
@Input() |
||||
|
top: number; |
||||
|
|
||||
|
@Input() |
||||
|
right: number; |
||||
|
|
||||
|
@Input() |
||||
|
bottom: number; |
||||
|
|
||||
|
@Input() |
||||
|
left: number; |
||||
|
|
||||
|
@Input() |
||||
|
toastKey: string; |
||||
|
|
||||
|
constructor(private toastService: ToasterService) {} |
||||
|
|
||||
|
ngOnInit() { |
||||
|
this.toastService.toasts$.subscribe(toasts => { |
||||
|
this.toasts = this.toastKey |
||||
|
? toasts.filter(t => { |
||||
|
return t.options && t.options.containerKey !== this.toastKey; |
||||
|
}) |
||||
|
: toasts; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
trackByFunc(index, toast) { |
||||
|
if (!toast) return null; |
||||
|
return toast.options.id; |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue