|
1 |
| -import { Component, Input } from '@angular/core'; |
| 1 | +import { animate, style, transition, trigger } from '@angular/animations'; |
| 2 | +import { Component, Input, OnInit } from '@angular/core'; |
2 | 3 |
|
3 | 4 | @Component({
|
4 | 5 | selector: 'network-status',
|
5 | 6 | template: `
|
6 | 7 | <div
|
| 8 | + *ngIf="showNetworkStatus" |
| 9 | + @showHideNotification |
7 | 10 | aria-live="assertive"
|
8 | 11 | class="pointer-events-none fixed inset-0 flex items-end px-4 py-6 sm:p-6">
|
9 | 12 | <div class="flex w-full flex-col items-end space-y-4">
|
@@ -48,8 +51,27 @@ import { Component, Input } from '@angular/core';
|
48 | 51 | <span>{{ networkStatusMessage }}</span>
|
49 | 52 | </div>
|
50 | 53 | `,
|
| 54 | + animations: [ |
| 55 | + trigger('showHideNotification', [ |
| 56 | + transition('void => *', [ |
| 57 | + style({ transform: "translateX(0.5rem)", opacity: 0 }), |
| 58 | + animate(300, style({ transform: "translateX(0)", opacity: 1 })) |
| 59 | + ]), |
| 60 | + transition('* => void', [ |
| 61 | + animate(100, style({ opacity: 0 })) |
| 62 | + ]) |
| 63 | + ]), |
| 64 | + ], |
51 | 65 | })
|
52 |
| -export class NetworkStatusComponent { |
| 66 | +export class NetworkStatusComponent implements OnInit { |
53 | 67 | @Input() networkStatusMessage!: string;
|
54 | 68 | @Input() networkStatus!: string;
|
| 69 | + |
| 70 | + showNetworkStatus: boolean = true; |
| 71 | + |
| 72 | + ngOnInit() { |
| 73 | + setTimeout(() => { |
| 74 | + this.showNetworkStatus = false; |
| 75 | + }, 3000); |
| 76 | + } |
55 | 77 | }
|
0 commit comments