generated from bisco/codex-bootstrap
255 lines
6.9 KiB
TypeScript
255 lines
6.9 KiB
TypeScript
import { ChangeDetectionStrategy, Component, DestroyRef, inject, signal } from '@angular/core';
|
|
import { RouterLink } from '@angular/router';
|
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
import { MatButtonModule } from '@angular/material/button';
|
|
import { MatCardModule } from '@angular/material/card';
|
|
import { MatIconModule } from '@angular/material/icon';
|
|
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
|
|
|
import { ShowListItem, ShowsApiService } from '../services/shows-api.service';
|
|
|
|
@Component({
|
|
standalone: true,
|
|
imports: [RouterLink, MatButtonModule, MatCardModule, MatIconModule, MatProgressSpinnerModule],
|
|
template: `
|
|
<section class="page">
|
|
<header class="page-header">
|
|
<div>
|
|
<p class="eyebrow">Programmazione</p>
|
|
<h1>Spettacoli</h1>
|
|
</div>
|
|
<p class="supporting">
|
|
Scopri le produzioni di AzioneLab, apri la scheda di ogni spettacolo e avvicinati alla prenotazione con semplicità.
|
|
</p>
|
|
</header>
|
|
|
|
@if (isLoading()) {
|
|
<div class="status-panel" aria-live="polite">
|
|
<mat-progress-spinner mode="indeterminate" diameter="40"></mat-progress-spinner>
|
|
<p>Caricamento degli spettacoli in corso...</p>
|
|
</div>
|
|
} @else if (errorMessage()) {
|
|
<mat-card class="status-card" aria-live="assertive">
|
|
<mat-card-content>
|
|
<div class="status-copy">
|
|
<mat-icon>error</mat-icon>
|
|
<div>
|
|
<h2>Non siamo riusciti a caricare gli spettacoli</h2>
|
|
<p>{{ errorMessage() }}</p>
|
|
</div>
|
|
</div>
|
|
</mat-card-content>
|
|
<mat-card-actions>
|
|
<button mat-flat-button type="button" (click)="reload()">Riprova</button>
|
|
</mat-card-actions>
|
|
</mat-card>
|
|
} @else if (shows().length === 0) {
|
|
<mat-card class="status-card" aria-live="polite">
|
|
<mat-card-content>
|
|
<div class="status-copy">
|
|
<mat-icon>theaters</mat-icon>
|
|
<div>
|
|
<h2>Nessuno spettacolo pubblicato per ora</h2>
|
|
<p>Le produzioni disponibili compariranno qui non appena saranno online.</p>
|
|
</div>
|
|
</div>
|
|
</mat-card-content>
|
|
</mat-card>
|
|
} @else {
|
|
<div class="show-grid">
|
|
@for (show of shows(); track show.slug) {
|
|
<mat-card class="show-card">
|
|
@if (show.image_url) {
|
|
<div class="show-image-wrap">
|
|
<img class="show-image" [src]="show.image_url" [alt]="show.title" />
|
|
</div>
|
|
}
|
|
<div class="card-topline">
|
|
<span class="card-label">Spettacolo in evidenza</span>
|
|
</div>
|
|
<mat-card-title>{{ show.title }}</mat-card-title>
|
|
<mat-card-content>
|
|
<p>{{ show.summary }}</p>
|
|
</mat-card-content>
|
|
<mat-card-actions>
|
|
<a mat-button [routerLink]="['/shows', show.slug]">Apri scheda</a>
|
|
</mat-card-actions>
|
|
</mat-card>
|
|
}
|
|
</div>
|
|
}
|
|
</section>
|
|
`,
|
|
styles: [`
|
|
.page-header {
|
|
display: grid;
|
|
grid-template-columns: minmax(0, 1fr) minmax(260px, 410px);
|
|
gap: 24px;
|
|
align-items: end;
|
|
margin-bottom: 28px;
|
|
}
|
|
|
|
.supporting {
|
|
margin: 0;
|
|
max-width: 34ch;
|
|
}
|
|
|
|
.show-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
|
gap: 22px;
|
|
}
|
|
|
|
.status-panel,
|
|
.status-copy {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 16px;
|
|
}
|
|
|
|
.status-panel {
|
|
min-height: 220px;
|
|
justify-content: center;
|
|
color: var(--azionelab-muted);
|
|
}
|
|
|
|
.status-card {
|
|
max-width: 680px;
|
|
border-radius: var(--azionelab-radius-md);
|
|
border: 1px solid var(--azionelab-border);
|
|
background: var(--azionelab-surface-strong);
|
|
box-shadow: var(--azionelab-shadow);
|
|
}
|
|
|
|
.status-copy {
|
|
align-items: flex-start;
|
|
}
|
|
|
|
.status-copy h2 {
|
|
margin: 0 0 8px;
|
|
font-size: 1.2rem;
|
|
}
|
|
|
|
.status-copy p {
|
|
margin: 0;
|
|
color: var(--azionelab-muted);
|
|
line-height: 1.6;
|
|
}
|
|
|
|
.show-card {
|
|
display: flex;
|
|
flex-direction: column;
|
|
min-height: 360px;
|
|
overflow: hidden;
|
|
border-radius: var(--azionelab-radius-md);
|
|
border: 1px solid var(--azionelab-border);
|
|
background: linear-gradient(180deg, rgba(255, 253, 249, 0.98), rgba(250, 243, 233, 0.94));
|
|
box-shadow: var(--azionelab-shadow);
|
|
}
|
|
|
|
.show-image-wrap {
|
|
aspect-ratio: 15 / 10;
|
|
overflow: hidden;
|
|
border-bottom: 1px solid var(--azionelab-border);
|
|
background:
|
|
linear-gradient(135deg, rgba(207, 71, 51, 0.14), rgba(15, 22, 36, 0.06)),
|
|
#f8f1ea;
|
|
}
|
|
|
|
.show-image {
|
|
width: 100%;
|
|
height: 100%;
|
|
display: block;
|
|
object-fit: cover;
|
|
transition: transform 180ms ease;
|
|
}
|
|
|
|
.show-card:hover .show-image {
|
|
transform: scale(1.03);
|
|
}
|
|
|
|
.card-topline {
|
|
padding: 18px 18px 0;
|
|
}
|
|
|
|
.card-label {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
min-height: 28px;
|
|
padding: 0 12px;
|
|
border-radius: 999px;
|
|
background: rgba(143, 51, 45, 0.08);
|
|
color: var(--azionelab-accent-strong);
|
|
font-size: 0.78rem;
|
|
font-weight: 700;
|
|
}
|
|
|
|
.show-card mat-card-content {
|
|
flex: 1;
|
|
}
|
|
|
|
.show-card mat-card-title,
|
|
.show-card mat-card-content,
|
|
.show-card mat-card-actions {
|
|
padding-left: 18px;
|
|
padding-right: 18px;
|
|
}
|
|
|
|
.show-card mat-card-title {
|
|
margin-top: 10px;
|
|
font-family: var(--azionelab-serif);
|
|
font-size: 1.45rem;
|
|
font-weight: 700;
|
|
line-height: 1.12;
|
|
}
|
|
|
|
.show-card p {
|
|
color: var(--azionelab-muted);
|
|
line-height: 1.6;
|
|
margin: 0;
|
|
}
|
|
|
|
@media (max-width: 860px) {
|
|
.page-header {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
}
|
|
`],
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
})
|
|
export class ShowListPageComponent {
|
|
private readonly destroyRef = inject(DestroyRef);
|
|
private readonly showsApi = inject(ShowsApiService);
|
|
|
|
protected readonly shows = signal<ShowListItem[]>([]);
|
|
protected readonly isLoading = signal(true);
|
|
protected readonly errorMessage = signal('');
|
|
|
|
constructor() {
|
|
this.loadShows();
|
|
}
|
|
|
|
protected reload(): void {
|
|
this.loadShows();
|
|
}
|
|
|
|
private loadShows(): void {
|
|
this.isLoading.set(true);
|
|
this.errorMessage.set('');
|
|
|
|
this.showsApi.listShows()
|
|
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
.subscribe({
|
|
next: ({ results }) => {
|
|
this.shows.set(results);
|
|
this.isLoading.set(false);
|
|
},
|
|
error: () => {
|
|
this.shows.set([]);
|
|
this.errorMessage.set('Riprova tra qualche istante.');
|
|
this.isLoading.set(false);
|
|
},
|
|
});
|
|
}
|
|
}
|