feat: add comprehensive loading feedback (#18)

This commit is contained in:
nessar committed 2026-08-17 14:18:15 +02:00
1 parent 45de0cebcc
commit ec3319494b
47 files changed
+1753 -406

No files matched your search

@@ -4,6 +4,12 @@
.page-heading {
margin-bottom: 30px;
}
.content-region > mat-progress-bar {
margin-bottom: 16px;
}
.refresh-error {
margin-bottom: 16px;
}
.page-heading h1 {
margin-bottom: 8px;
font-size: clamp(2rem, 7vw, 3.2rem);
@@ -127,6 +133,16 @@
.apt-actions .danger-action.mat-mdc-button {
--mdc-text-button-label-text-color: var(--danger);
}
.apt-actions mat-spinner {
display: inline-block;
margin-right: 6px;
vertical-align: middle;
}
.card-error {
margin: 14px 0 0;
color: var(--danger);
font-size: 0.84rem;
}
@media (min-width: 700px) {
.page-heading {
display: flex;
@@ -9,62 +9,109 @@
</button>
</header>
@if (apartments().length === 0) {
<article class="empty-state">
<div class="empty-illustration" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6">
<path d="m4 10 8-6 8 6v10H4z" />
<path d="M9 20v-6h6v6" />
</svg>
<div class="content-region" [attr.aria-busy]="loadState().loading">
@if (loadState().loaded && loadState().loading) {
<mat-progress-bar mode="indeterminate" aria-label="Actualisation des appartements" />
}
@if (loadState().loaded && loadState().error) {
<div class="refresh-error" role="alert">
<p>{{ loadState().error }}</p>
<button mat-button type="button" (click)="retryRequested.emit()">Réessayer</button>
</div>
<p class="eyebrow">Commencez ici</p>
<h2>Aucun appartement enregistré</h2>
<p>Ajoutez votre premier bien pour construire votre portefeuille.</p>
<button mat-stroked-button type="button" (click)="addRequested.emit()">
Ajouter un appartement
</button>
</article>
} @else {
<div class="apartments-grid">
@for (apt of apartments(); track apt.id) {
<article class="apartment-card">
<div class="apartment-card-topline">
<span class="property-label">Bien immobilier</span>
<span class="property-value">{{ apt.purchasePrice.toLocaleString('fr-FR') }} €</span>
</div>
<div class="apt-info">
<h2>{{ apt.name }}</h2>
<p class="apt-address">
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.8"
aria-hidden="true"
>
<path d="M20 10c0 5-8 11-8 11S4 15 4 10a8 8 0 1 1 16 0Z" />
<circle cx="12" cy="10" r="2.5" />
</svg>
{{ apt.address }}
</p>
@if (apt.description) {
<p class="apt-desc">{{ apt.description }}</p>
}
@if (!loadState().loaded && loadState().loading) {
<div
class="apartments-grid loading-region"
aria-busy="true"
aria-label="Chargement des appartements"
>
@for (placeholder of [1, 2, 3]; track placeholder) {
<article class="apartment-card skeleton-card" aria-hidden="true">
<span class="skeleton-line skeleton-line-short"></span>
<span class="skeleton-line skeleton-line-title"></span>
<span class="skeleton-line"></span>
<span class="skeleton-line skeleton-line-medium"></span>
</article>
}
</div>
} @else if (!loadState().loaded && loadState().error) {
<article class="load-error" role="alert">
<h2>Chargement impossible</h2>
<p>{{ loadState().error }}</p>
<button mat-stroked-button type="button" (click)="retryRequested.emit()">Réessayer</button>
</article>
} @else if (apartments().length === 0) {
<article class="empty-state">
<div class="empty-illustration" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6">
<path d="m4 10 8-6 8 6v10H4z" />
<path d="M9 20v-6h6v6" />
</svg>
</div>
<p class="eyebrow">Commencez ici</p>
<h2>Aucun appartement enregistré</h2>
<p>Ajoutez votre premier bien pour construire votre portefeuille.</p>
<button mat-stroked-button type="button" (click)="addRequested.emit()">
Ajouter un appartement
</button>
</article>
} @else {
<div class="apartments-grid">
@for (apt of apartments(); track apt.id) {
<article class="apartment-card" [attr.aria-busy]="!!apt.id && deletingIds().has(apt.id)">
<div class="apartment-card-topline">
<span class="property-label">Bien immobilier</span>
<span class="property-value">{{ apt.purchasePrice.toLocaleString('fr-FR') }} €</span>
</div>
<div class="apt-info">
<h2>{{ apt.name }}</h2>
<p class="apt-address">
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.8"
aria-hidden="true"
>
<path d="M20 10c0 5-8 11-8 11S4 15 4 10a8 8 0 1 1 16 0Z" />
<circle cx="12" cy="10" r="2.5" />
</svg>
{{ apt.address }}
</p>
@if (apt.description) {
<p class="apt-desc">{{ apt.description }}</p>
}
</div>
@if (apt.id && deleteErrors()[apt.id]) {
<p class="card-error" role="alert">{{ deleteErrors()[apt.id] }}</p>
}
</div>
<div class="apt-actions">
<button mat-button type="button" (click)="editRequested.emit(apt)">Modifier</button>
@if (apt.id) {
<div class="apt-actions" aria-live="polite">
<button
mat-button
type="button"
class="danger-action"
(click)="deleteRequested.emit(apt.id)"
[disabled]="!!apt.id && deletingIds().has(apt.id)"
(click)="editRequested.emit(apt)"
>
Supprimer
Modifier
</button>
}
</div>
</article>
}
</div>
}
@if (apt.id) {
<button
mat-button
type="button"
class="danger-action"
[disabled]="deletingIds().has(apt.id)"
(click)="deleteRequested.emit(apt.id)"
>
@if (deletingIds().has(apt.id)) {
<mat-spinner diameter="16" aria-hidden="true" /> Suppression…
} @else {
Supprimer
}
</button>
}
</div>
</article>
}
</div>
}
</div>
@@ -1,16 +1,23 @@
import { Component, input, output } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatProgressBarModule } from '@angular/material/progress-bar';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { Apartment } from '../../services/apartment.service';
import { LoadState } from '../../services/workspace.service';
@Component({
selector: 'app-apartment-list',
imports: [MatButtonModule],
imports: [MatButtonModule, MatProgressBarModule, MatProgressSpinnerModule],
templateUrl: './apartment-list.html',
styleUrl: './apartment-list.css',
})
export class ApartmentList {
readonly apartments = input.required<Apartment[]>();
readonly loadState = input.required<LoadState>();
readonly deletingIds = input<ReadonlySet<string>>(new Set());
readonly deleteErrors = input<Record<string, string>>({});
readonly addRequested = output<void>();
readonly editRequested = output<Apartment>();
readonly deleteRequested = output<string>();
readonly retryRequested = output<void>();
}