Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit 89bfe7c

Browse files
committed
💄 creation du component pour gerer les erreurs
1 parent 732b1a7 commit 89bfe7c

File tree

5 files changed

+45
-3
lines changed

5 files changed

+45
-3
lines changed
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
<button
22
[type]="type"
3-
[disabled]="disabled"
3+
[disabled]="(loading$ | async)"
44
[ngClass]="class"
55
class="inline-flex items-center font-mono px-4 py-2 text-sm font-medium uppercase tracking-[1.25px] text-white bg-primary-600 border border-transparent rounded-md shadow-md hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 disabled:opacity-25 transition ease-in-out duration-150"
66
>
7+
<span *ngIf="(loading$ | async)" class="absolute inset-y-0 left-0 flex items-center pl-3">
8+
<svg class="w-5 h-5 mr-3 -ml-1 text-white animate-spin" fill="none" viewBox="0 0 24 24">
9+
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"/>
10+
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"/>
11+
</svg>
12+
</span>
713
<ng-content></ng-content>
814
</button>
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, Input } from '@angular/core';
2+
import { Observable } from 'rxjs';
23

34
@Component({
45
selector: 'cosna-button-primary',
@@ -8,8 +9,8 @@ export class PrimaryComponent {
89

910
@Input() type: string = 'button';
1011

11-
@Input() disabled: boolean = false;
12+
@Input() loading$!: Observable<boolean>;
1213

13-
@Input() class: string = '';
14+
@Input() class!: string;
1415

1516
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<div class="p-4 rounded-md bg-red-50" [ngClass]="class">
2+
<div class="flex">
3+
<div class="flex-shrink-0">
4+
<svg class="w-5 h-5 text-red-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
5+
<path fill-rule="evenodd" clip-rule="evenodd" d="M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16ZM8.28 7.22a.75.75 0 0 0-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 1 0 1.06 1.06L10 11.06l1.72 1.72a.75.75 0 1 0 1.06-1.06L11.06 10l1.72-1.72a.75.75 0 0 0-1.06-1.06L10 8.94 8.28 7.22Z" />
6+
</svg>
7+
</div>
8+
<div class="ml-3">
9+
<h3 *ngIf="message" class="text-sm font-medium text-red-800">{{ message }}</h3>
10+
<div *ngIf="errors.length" class="mt-2 text-sm text-red-700">
11+
<ul role="list" class="pl-5 space-y-1 list-disc">
12+
<li *ngFor="let error of errors">{{ error }}</li>
13+
</ul>
14+
</div>
15+
</div>
16+
</div>
17+
</div>

src/app/shared/components/error/error.component.scss

Whitespace-only changes.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Component, Input, OnInit } from '@angular/core';
2+
3+
@Component({
4+
selector: 'cosna-errors',
5+
templateUrl: './error.component.html',
6+
styleUrls: ['./error.component.scss']
7+
})
8+
export class ErrorComponent implements OnInit {
9+
@Input() class!: string;
10+
@Input() message!: string;
11+
@Input() errors: string[] = [];
12+
13+
constructor() { }
14+
15+
ngOnInit(): void {
16+
}
17+
18+
}

0 commit comments

Comments
 (0)