diff options
author | Tyler Ferrari <69283684+Sowgro@users.noreply.github.com> | 2025-04-01 02:17:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-01 02:17:25 -0400 |
commit | 233fe120d2a9b30e0150401ebdfeb946dc9c2c07 (patch) | |
tree | 98583e1b1d21d1a0cc57e8ff3489fbbf758eccff /ufund-ui/src/app/components/toast/toast.component.ts | |
parent | c6bbb29f42eaea7d0c8aebdb7b95be0287cbf4f9 (diff) | |
parent | 0e9c0803e35a23ef2e873dc7ebf224a49a92f207 (diff) | |
download | JellySolutions-233fe120d2a9b30e0150401ebdfeb946dc9c2c07.tar.gz JellySolutions-233fe120d2a9b30e0150401ebdfeb946dc9c2c07.tar.bz2 JellySolutions-233fe120d2a9b30e0150401ebdfeb946dc9c2c07.zip |
Merge pull request #22 from RIT-SWEN-261-02/css
Merge css into main
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; +} |