feat(news-details): add pagination to 'mentioned persons' accordion, expand only one accordion at a time

This commit is contained in:
2026-07-06 22:45:19 +02:00
parent 398ea7b56c
commit 0b750d27e7
3 changed files with 97 additions and 11 deletions
@@ -83,8 +83,8 @@
<button
type="button"
class="accordion-header"
(click)="personsOpen = !personsOpen"
[attr.aria-expanded]="personsOpen">
(click)="openPanel = openPanel === 'persons' ? null : 'persons'"
[attr.aria-expanded]="openPanel === 'persons'">
<mat-icon>group</mat-icon>
<span class="accordion-title">Erwähnte Personen</span>
<mat-icon
@@ -97,15 +97,17 @@
@if (article.authors?.length) {
<span class="count-badge">{{ article.authors!.length }}</span>
}
<mat-icon class="chevron" [class.rotated]="!personsOpen"
<mat-icon
class="chevron"
[class.rotated]="openPanel !== 'persons'"
>expand_more</mat-icon
>
</button>
@if (personsOpen) {
@if (openPanel === 'persons') {
<div class="accordion-body">
@if (article.authors && article.authors.length) {
<div class="person-list">
@for (person of article.authors; track person.name) {
@for (person of pagedPersons; track person.name) {
@if (person.is_ude && person.person_id) {
<a
class="person-item is-link"
@@ -130,6 +132,27 @@
}
}
</div>
@if (personsPageCount > 1) {
<div class="persons-pagination">
<button
type="button"
class="page-btn"
[disabled]="personsPage === 0"
(click)="personsPage = personsPage - 1">
<mat-icon>chevron_left</mat-icon>
</button>
<span class="page-indicator"
>{{ personsPage + 1 }} / {{ personsPageCount }}</span
>
<button
type="button"
class="page-btn"
[disabled]="personsPage === personsPageCount - 1"
(click)="personsPage = personsPage + 1">
<mat-icon>chevron_right</mat-icon>
</button>
</div>
}
} @else {
<p class="placeholder">Keine erwähnten Personen gefunden.</p>
}
@@ -143,8 +166,8 @@
<button
type="button"
class="accordion-header"
(click)="topicsOpen = !topicsOpen"
[attr.aria-expanded]="topicsOpen">
(click)="openPanel = openPanel === 'topics' ? null : 'topics'"
[attr.aria-expanded]="openPanel === 'topics'">
<mat-icon>label</mat-icon>
<span class="accordion-title">Themen & Schlüsselwörter</span>
<mat-icon
@@ -157,11 +180,11 @@
@if (article.topics?.length) {
<span class="count-badge">{{ article.topics!.length }}</span>
}
<mat-icon class="chevron" [class.rotated]="!topicsOpen"
<mat-icon class="chevron" [class.rotated]="openPanel !== 'topics'"
>expand_more</mat-icon
>
</button>
@if (topicsOpen) {
@if (openPanel === 'topics') {
<div class="accordion-body">
@if (article.topics && article.topics.length) {
<div class="topics-accordion">
@@ -314,6 +314,52 @@ main {
white-space: nowrap;
}
// ── Persons pagination ────────────────────────────────────────────────────────
.persons-pagination {
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
margin-top: 8px;
}
.page-btn {
display: grid;
place-items: center;
width: 28px;
height: 28px;
border: 1px solid #d7e4ff;
border-radius: 8px;
background: none;
cursor: pointer;
color: var(--sg-text-muted);
transition: background 0.12s;
&:hover:not(:disabled) {
background: #f0f6ff;
color: var(--sg-text);
}
&:disabled {
opacity: 0.35;
cursor: default;
}
mat-icon {
font-size: 18px;
width: 18px;
height: 18px;
}
}
.page-indicator {
font-size: 12px;
color: var(--sg-text-muted);
min-width: 36px;
text-align: center;
}
// ── Topic accordion items ─────────────────────────────────────────────────────
.topics-accordion {
@@ -74,10 +74,26 @@ export class NewsDetailComponent implements OnInit {
loading = false;
notFound = false;
personsOpen = true;
topicsOpen = true;
openPanel: 'persons' | 'topics' | null = 'persons';
expandedTopicId: string | null = null;
personsPage = 0;
readonly personsPageSize = 5;
get pagedPersons(): MentionedPerson[] {
const authors = this.article?.authors ?? [];
return authors.slice(
this.personsPage * this.personsPageSize,
(this.personsPage + 1) * this.personsPageSize,
);
}
get personsPageCount(): number {
return Math.ceil(
(this.article?.authors?.length ?? 0) / this.personsPageSize,
);
}
getTopicColor(topic: MatchedTopic): string {
return topicHierarchyColor({
id: topic.id,
@@ -159,6 +175,7 @@ export class NewsDetailComponent implements OnInit {
this.article = article;
this.highlightedContent = this.buildHighlightedContent(article);
this.expandedTopicId = null;
this.personsPage = 0;
this.loading = false;
},
error: () => {