aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/components/toast/toast.component.ts
diff options
context:
space:
mode:
authorGunther6070 <haydenhartman10@yahoo.com>2025-04-01 07:47:16 -0400
committerGunther6070 <haydenhartman10@yahoo.com>2025-04-01 07:47:16 -0400
commitd8330f1ac85b26d08ca4df5ce3875078d7b4f47f (patch)
tree2046e58c146097aac21c9e352771420c31df6589 /ufund-ui/src/app/components/toast/toast.component.ts
parentbc9d3417795d841b4cb3e9fb022f8d61448af946 (diff)
parent233fe120d2a9b30e0150401ebdfeb946dc9c2c07 (diff)
downloadJellySolutions-d8330f1ac85b26d08ca4df5ce3875078d7b4f47f.tar.gz
JellySolutions-d8330f1ac85b26d08ca4df5ce3875078d7b4f47f.tar.bz2
JellySolutions-d8330f1ac85b26d08ca4df5ce3875078d7b4f47f.zip
Merge branch 'main' of https://github.com/RIT-SWEN-261-02/team-project-2245-swen-261-02-2b
Diffstat (limited to 'ufund-ui/src/app/components/toast/toast.component.ts')
-rw-r--r--ufund-ui/src/app/components/toast/toast.component.ts37
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;
+}