Skip to content

Commit a4e9791

Browse files
committed
alert design and animation ok
1 parent a550275 commit a4e9791

File tree

3 files changed

+60
-20
lines changed

3 files changed

+60
-20
lines changed

src/app/modules/dashboard/pages/dashboard/dashboard.component.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="pt-5 pb-16">
1+
<div class="pt-5 pb-16" (click)="isOpen = !isOpen">
22
<!-- Welcome panel -->
33
<section aria-labelledby="profile-overview-title">
44
</section>
@@ -160,4 +160,6 @@ <h3 class="text-lg font-medium">
160160

161161
</div>
162162
</section>
163-
</div>
163+
</div>
164+
165+
<alert-success [isOpen]="isOpen" (toggleShowAlert)="toggle($event)" message="Connecté avec succes!"></alert-success>

src/app/modules/dashboard/pages/dashboard/dashboard.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ import { Component, OnInit } from '@angular/core';
55
})
66
export class DashboardComponent implements OnInit {
77

8+
isOpen: boolean = false;
9+
810
constructor() { }
911

1012
ngOnInit(): void {
1113
}
1214

15+
toggle(value: boolean) {
16+
this.isOpen = value
17+
}
18+
1319
}
Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,64 @@
1-
import { Component, Input } from '@angular/core';
1+
import { animate, keyframes, state, style, transition, trigger } from '@angular/animations';
2+
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
23

34
@Component({
45
selector: 'alert-success',
56
template: `
6-
<div class="p-4 rounded-md bg-green-50" [ngClass]="class">
7-
<div class="flex">
8-
<div class="shrink-0">
9-
<svg
10-
class="w-5 h-5 text-green-400"
11-
xmlns="http://www.w3.org/2000/svg"
12-
viewBox="0 0 20 20"
13-
fill="currentColor"
14-
aria-hidden="true">
15-
<path
16-
fill-rule="evenodd"
17-
clip-rule="evenodd"
18-
d="M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm3.857-9.809a.75.75 0 0 0-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 1 0-1.06 1.061l2.5 2.5a.75.75 0 0 0 1.137-.089l4-5.5Z" />
19-
</svg>
20-
</div>
21-
<div class="ml-3">
22-
<p class="text-sm font-medium text-green-800">{{ message }}</p>
7+
<div *ngIf="showAlert" aria-live="assertive" class="pointer-events-none fixed inset-0 flex items-end px-4 py-6 sm:items-start sm:p-6">
8+
<div class="flex w-full flex-col items-center space-y-4 sm:items-end">
9+
10+
<div @showHideNotification class="pointer-events-auto w-full max-w-sm overflow-hidden rounded-lg bg-white shadow-lg ring-1 ring-black ring-opacity-5" [ngClass]="class">
11+
<div class="p-4">
12+
<div class="flex items-start">
13+
<div class="flex-shrink-0">
14+
<svg class="h-6 w-6 text-green-400" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true">
15+
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
16+
</svg>
17+
</div>
18+
<div class="ml-3 w-0 flex-1 pt-0.5">
19+
<p class="text-sm font-medium text-gray-900">{{ message }}</p>
20+
<p class="mt-1 text-sm text-gray-500">{{ description }}</p>
21+
</div>
22+
<div class="ml-4 flex flex-shrink-0">
23+
<button (click)="toggle()" type="button" class="inline-flex rounded-md bg-white text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2">
24+
<span class="sr-only">Close</span>
25+
<svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
26+
<path d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z" />
27+
</svg>
28+
</button>
29+
</div>
30+
</div>
31+
</div>
2332
</div>
33+
2434
</div>
2535
</div>
2636
`,
37+
animations: [
38+
trigger('showHideNotification', [
39+
transition('void => *', [
40+
style({ transform: "translateX(0.5rem)", opacity: 0 }),
41+
animate(300, style({ transform: "translateX(0)", opacity: 1 }))
42+
]),
43+
transition('* => void', [
44+
style({ opacity: 0 }),
45+
animate(100, style({ opacity: 1 }))
46+
])
47+
]),
48+
],
2749
})
2850
export class SuccessComponent {
2951
@Input() class!: string;
3052

53+
@Input('isOpen') showAlert!: boolean;
54+
55+
@Output() toggleShowAlert: EventEmitter<boolean> = new EventEmitter<boolean>();
56+
3157
@Input() message!: string;
58+
59+
@Input() description!: string;
60+
61+
toggle(){
62+
this.toggleShowAlert.emit(false);
63+
}
3264
}

0 commit comments

Comments
 (0)