diff options
author | sowgro <tpoke.ferrari@gmail.com> | 2025-03-31 17:33:04 -0400 |
---|---|---|
committer | sowgro <tpoke.ferrari@gmail.com> | 2025-03-31 17:33:04 -0400 |
commit | 97c9e1e0bb73c7b08c830c47548ac1c4b5bebd0b (patch) | |
tree | 76d437e3349be177d0105b9a7a6bae9b7bd1b33a /ufund-ui/src/app/components/toast/toast.component.ts | |
parent | f7a0ce90b0ead17ad4002108d7e868899954c69d (diff) | |
download | JellySolutions-97c9e1e0bb73c7b08c830c47548ac1c4b5bebd0b.tar.gz JellySolutions-97c9e1e0bb73c7b08c830c47548ac1c4b5bebd0b.tar.bz2 JellySolutions-97c9e1e0bb73c7b08c830c47548ac1c4b5bebd0b.zip |
TOASTS
Diffstat (limited to 'ufund-ui/src/app/components/toast/toast.component.ts')
-rw-r--r-- | ufund-ui/src/app/components/toast/toast.component.ts | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ufund-ui/src/app/components/toast/toast.component.ts b/ufund-ui/src/app/components/toast/toast.component.ts new file mode 100644 index 0000000..47fd7ff --- /dev/null +++ b/ufund-ui/src/app/components/toast/toast.component.ts @@ -0,0 +1,37 @@ +import {Component, ElementRef, Input, OnInit, ViewChild} from '@angular/core'; +import {ToastType} from '../../services/toasts.service'; + +@Component({ + selector: 'app-toast', + standalone: false, + templateUrl: './toast.component.html', + styleUrl: './toast.component.css' +}) +export class ToastComponent implements OnInit{ + @Input() type!: ToastType + @Input() message!: string + @Input() action?: {label: string, onAction: () => void} + + @ViewChild("toastDiv") toastDiv!: ElementRef<HTMLDivElement> + + ngOnInit() { + setTimeout(() => { + this.hide(); + }, 3000) + } + + hide() { + console.log(this.toastDiv, typeof this.toastDiv) + this.toastDiv.nativeElement.classList.add('hide') + } + + getColor() { + switch (this.type) { + case ToastType.ERROR: return "red"; + case ToastType.INFO: return ""; + case ToastType.WARNING: return "yellow"; + } + } + + protected readonly ToastType = ToastType; +} |