generated from bisco/codex-bootstrap
233 lines
6.0 KiB
TypeScript
233 lines
6.0 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">Public shows</p>
|
|
<h1>Shows</h1>
|
|
</div>
|
|
<p class="supporting">
|
|
Browse current productions published from the AzioneLab backend.
|
|
</p>
|
|
</header>
|
|
|
|
@if (isLoading()) {
|
|
<div class="status-panel" aria-live="polite">
|
|
<mat-progress-spinner mode="indeterminate" diameter="40"></mat-progress-spinner>
|
|
<p>Loading shows...</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>Could not load shows</h2>
|
|
<p>{{ errorMessage() }}</p>
|
|
</div>
|
|
</div>
|
|
</mat-card-content>
|
|
<mat-card-actions>
|
|
<button mat-flat-button type="button" (click)="reload()">Try again</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>No shows published yet</h2>
|
|
<p>Published productions will appear here as soon as they are available.</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>
|
|
}
|
|
<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]">Open detail</a>
|
|
</mat-card-actions>
|
|
</mat-card>
|
|
}
|
|
</div>
|
|
}
|
|
</section>
|
|
`,
|
|
styles: [`
|
|
.page {
|
|
max-width: 1180px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
.page-header {
|
|
display: grid;
|
|
grid-template-columns: minmax(0, 1fr) minmax(260px, 380px);
|
|
gap: 24px;
|
|
align-items: end;
|
|
margin-bottom: 24px;
|
|
}
|
|
|
|
.eyebrow {
|
|
margin: 0 0 10px;
|
|
color: var(--azionelab-accent);
|
|
text-transform: uppercase;
|
|
font-size: 0.78rem;
|
|
font-weight: 700;
|
|
}
|
|
|
|
h1 {
|
|
margin: 0;
|
|
font-size: clamp(2rem, 4vw, 3rem);
|
|
}
|
|
|
|
.supporting {
|
|
margin: 0;
|
|
color: var(--azionelab-muted);
|
|
line-height: 1.6;
|
|
}
|
|
|
|
.show-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
|
|
gap: 20px;
|
|
}
|
|
|
|
.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: 8px;
|
|
border: 1px solid var(--azionelab-border);
|
|
background: var(--azionelab-surface);
|
|
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: 220px;
|
|
border-radius: 8px;
|
|
border: 1px solid var(--azionelab-border);
|
|
background: var(--azionelab-surface);
|
|
box-shadow: var(--azionelab-shadow);
|
|
}
|
|
|
|
.show-image-wrap {
|
|
aspect-ratio: 16 / 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;
|
|
}
|
|
|
|
.show-card mat-card-content {
|
|
flex: 1;
|
|
}
|
|
|
|
.show-card p {
|
|
color: var(--azionelab-muted);
|
|
line-height: 1.6;
|
|
}
|
|
|
|
@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('Please try again in a moment.');
|
|
this.isLoading.set(false);
|
|
},
|
|
});
|
|
}
|
|
}
|