feat(publication-card): clamp title/topics/authors to fixed-height sections

This commit is contained in:
2026-08-16 23:25:58 +02:00
parent 6c3c43ef4f
commit 0f0f30f08c
3 changed files with 108 additions and 8 deletions
@@ -15,15 +15,33 @@
<mat-divider />
<mat-card-content class="mat-card-content">
<div class="chips">
@for (topic of topics(); track topic.id) {
<app-topic-chip-2 [topic]="topic" />
}
@for (author of authors(); track author.id) {
<app-author-chip [author]="author" />
}
<div class="chip-section">
<div class="chip-section-header">
<mat-icon>label</mat-icon>
<span>Themen</span>
</div>
<div class="chips chips-column">
@for (topic of visibleTopics(); track topic.id) {
<app-topic-chip-2 [topic]="topic" />
}
</div>
</div>
<mat-divider />
<div class="chip-section">
<div class="chip-section-header">
<mat-icon>person</mat-icon>
<span>Autoren</span>
</div>
<div class="chips chips-authors">
@for (author of visibleAuthors(); track author.id) {
<app-author-chip [author]="author" />
}
@if (hiddenAuthorCount() > 0) {
<span class="chip-overflow">+{{ hiddenAuthorCount() }}</span>
}
</div>
</div>
<mat-divider />
<div class="metrics">
@@ -1,3 +1,10 @@
:host {
::ng-deep .mat-mdc-card-header-text {
min-width: 0;
width: 100%;
}
}
.card-content {
display: flex;
flex-direction: column;
@@ -5,11 +12,46 @@
height: 100%;
}
mat-card-title {
display: -webkit-box;
width: 100%;
-webkit-box-orient: vertical;
-webkit-line-clamp: 4;
line-clamp: 4;
overflow: hidden;
line-height: 1.3rem;
height: calc(1.3rem * 4);
}
.subtitle {
display: block;
width: 100%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
color: var(--sg-text-muted);
line-height: 1.25rem;
height: 1.25rem;
}
.chip-section {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.chip-section-header {
display: flex;
align-items: center;
gap: 0.5rem;
gap: 0.25rem;
color: var(--sg-text-muted);
font-size: 0.875rem;
mat-icon {
width: 18px;
height: 18px;
font-size: 18px;
}
}
.metrics {
@@ -42,6 +84,35 @@
height: 100%;
}
.chips-column {
flex-direction: column;
flex-wrap: nowrap;
align-items: flex-start;
// 3 rows reserved (32px chip height + 8px gap each) so the divider below
// sits at the same position regardless of how many topics exist.
min-height: calc(3 * 32px + 2 * 0.5rem);
}
.chips-authors {
flex-wrap: nowrap;
align-content: flex-start;
// 1 row reserved, capped so overflowing chips never push the divider down.
min-height: 32px;
max-height: 32px;
overflow: hidden;
}
.chip-overflow {
display: inline-flex;
align-items: center;
padding: 0.25rem 0.5rem;
border-radius: var(--sg-radius-sm);
background: var(--sg-surface-soft);
color: var(--sg-text-muted);
font-size: 0.8rem;
font-weight: 600;
}
.mat-card-content {
display: flex;
flex-direction: column;
@@ -11,6 +11,9 @@ import { LanguageCodePipe } from '../../pipes/language-code.pipe';
import { AppTopicChipComponent } from '../app-topic-chip/app-topic-chip.component';
import { AppAuthorChipComponent } from '../app-author-chip/app-author-chip.component';
const MAX_VISIBLE_TOPICS = 3;
const MAX_VISIBLE_AUTHORS = 3;
@Component({
selector: 'app-publication-card',
imports: [
@@ -55,4 +58,12 @@ export class AppPublicationCardComponent {
.map((authorship) => authorship.author)
.filter((author): author is DehydratedAuthor => !!author);
});
visibleTopics = computed(() => this.topics().slice(0, MAX_VISIBLE_TOPICS));
visibleAuthors = computed(() => this.authors().slice(0, MAX_VISIBLE_AUTHORS));
hiddenAuthorCount = computed(() =>
Math.max(this.authors().length - MAX_VISIBLE_AUTHORS, 0),
);
}