refactor/list-card-heights #287

Merged
Louis merged 11 commits from refactor/list-card-heights into dev 2026-08-17 00:16:04 +02:00
18 changed files with 347 additions and 56 deletions
+6 -2
View File
@@ -788,7 +788,9 @@ export const routes: Routes = [
},
runGuardsAndResolvers: (from, to) => {
return Object.values(workQueryParamKeys).some(
(key) => from.queryParamMap.get(key) !== to.queryParamMap.get(key),
(key) =>
from.queryParamMap.getAll(key).join(',') !==
to.queryParamMap.getAll(key).join(','),
);
},
},
@@ -852,7 +854,9 @@ export const routes: Routes = [
),
runGuardsAndResolvers: (from, to) => {
return Object.values(workQueryParamKeys).some(
(key) => from.queryParamMap.get(key) !== to.queryParamMap.get(key),
(key) =>
from.queryParamMap.getAll(key).join(',') !==
to.queryParamMap.getAll(key).join(','),
);
},
resolve: {
@@ -269,14 +269,16 @@
searchLabel="Suche nach Titel oder Patent-Nr." />
<ng-template #filtersTmp>
<div class="filter-row">
<mat-chip-listbox
[value]="selectedSources"
multiple
(change)="handleSourceChipChange($event)">
<mat-chip-option value="EPO">EPO</mat-chip-option>
<mat-chip-option value="USPTO">USPTO</mat-chip-option>
</mat-chip-listbox>
<div class="additional-filters">
<app-filter-card>
<mat-chip-listbox
[value]="selectedSources"
multiple
(change)="handleSourceChipChange($event)">
<mat-chip-option value="EPO">EPO</mat-chip-option>
<mat-chip-option value="USPTO">USPTO</mat-chip-option>
</mat-chip-listbox>
</app-filter-card>
<app-year-range-slider
class="patent-year-filter"
@@ -20,22 +20,27 @@ h1 {
gap: 0.5rem;
}
.filter-row {
.additional-filters {
display: flex;
justify-content: space-between;
align-items: center;
align-items: stretch;
flex-wrap: wrap;
gap: 1rem;
gap: 1.5rem;
padding: 0 1rem 1rem;
}
.patent-year-filter {
display: flex;
width: min(400px, 100%);
}
::ng-deep app-year-range-slider .year-filter {
height: 100%;
}
.mat-mdc-standard-chip {
border-radius: var(--sg-radius-sm);
}
.patent-year-filter {
width: min(285px, 100%);
}
.state-message {
display: flex;
align-items: center;
@@ -72,6 +77,13 @@ mat-paginator {
background-color: var(--sg-background);
}
:host {
::ng-deep .mat-mdc-card-header-text {
min-width: 0;
width: 100%;
}
}
.card {
padding: 0.5rem;
background-color: var(--sg-card-bg);
@@ -85,9 +97,16 @@ mat-paginator {
}
mat-card-title {
display: -webkit-box;
width: 100%;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
line-clamp: 3;
overflow: hidden;
font-size: 14px;
font-weight: 600;
line-height: 1.4;
height: calc(1.4em * 3);
color: var(--sg-text);
}
}
@@ -22,6 +22,7 @@ import {
CardSearchComponent,
Page,
} from '../../shared/ui/card-search/card-search.component';
import { FilterCardComponent } from '../../shared/ui/filter-card/filter-card.component';
type PatentSource = 'EPO' | 'USPTO';
@@ -54,6 +55,7 @@ const MIN_YEAR = 1978;
LoadingComponent,
YearRangeSliderComponent,
CardSearchComponent,
FilterCardComponent,
],
templateUrl: './patents.component.html',
styleUrl: './patents.component.scss',
@@ -18,13 +18,16 @@
</ng-template>
<ng-template #additionalFiltersTmp>
<mat-chip-listbox
[value]="urlChips()"
(change)="handleChipBoxChange($event)"
multiple
style="padding: 0rem 1rem">
<mat-chip-option value="eu">EU</mat-chip-option>
<mat-chip-option value="bund">BUND</mat-chip-option>
<mat-chip-option value="dfg">DFG</mat-chip-option>
</mat-chip-listbox>
<div class="additional-filters">
<app-filter-card>
<mat-chip-listbox
[value]="urlChips()"
(change)="handleChipBoxChange($event)"
multiple>
<mat-chip-option value="eu">EU</mat-chip-option>
<mat-chip-option value="bund">BUND</mat-chip-option>
<mat-chip-option value="dfg">DFG</mat-chip-option>
</mat-chip-listbox>
</app-filter-card>
</div>
</ng-template>
@@ -4,3 +4,12 @@
gap: 1rem;
padding: 1rem;
}
.additional-filters {
display: flex;
padding: 0 1rem;
app-filter-card {
min-height: 90px;
}
}
@@ -14,6 +14,7 @@ import {
Page,
} from '../../shared/ui/card-search/card-search.component';
import { FilterObserver } from '../../shared/ui/selected-filters/selected-filters.component';
import { FilterCardComponent } from '../../shared/ui/filter-card/filter-card.component';
@Component({
selector: 'app-projects',
@@ -26,6 +27,7 @@ import { FilterObserver } from '../../shared/ui/selected-filters/selected-filter
MatChipsModule,
CardSearchComponent,
AppProjectCardComponent,
FilterCardComponent,
],
templateUrl: './projects.component.html',
styleUrl: './projects.component.scss',
@@ -16,7 +16,10 @@
</div>
<ng-template #cardTmp let-work>
<app-publication-card [work]="work" />
<app-publication-card
[work]="work"
(topicChipClick)="filterByTopic($event)"
(authorChipClick)="filterByAuthor($event)" />
</ng-template>
<ng-template #additionalFiltersTmp>
@@ -1,8 +1,11 @@
import { Component, computed, input } from '@angular/core';
import { Component, computed, inject, input } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import {
Author,
AuthorPage,
InstitutionPageV2,
SortDirection,
Topic,
TopicPageV2,
WorkPageV2,
WorkSortBy,
@@ -15,6 +18,7 @@ import { MatDivider } from '@angular/material/divider';
import { AppPublicationCardComponent } from '../../shared/ui/app-publication-card/app-publication-card.component';
import { PublicationFilterComponent } from '../../shared/ui/publication-filters/publication-filters.component';
import { SelectorOption } from '../../shared/ui/query-param-selector/query-param-selector.component';
import { workQueryParamKeys } from '../../resolvers/work-page.resolver';
@Component({
selector: 'app-publications',
@@ -28,6 +32,9 @@ import { SelectorOption } from '../../shared/ui/query-param-selector/query-param
styleUrl: './publications.component.scss',
})
export class PublicationsComponent {
private readonly route = inject(ActivatedRoute);
private readonly router = inject(Router);
workPage = input.required<WorkPageV2>();
selectedAuthorsPage = input.required<AuthorPage>();
selectedInstitutionsPage = input.required<InstitutionPageV2>();
@@ -48,4 +55,42 @@ export class PublicationsComponent {
{ value: SortDirection.Asc, display_name: 'Aufsteigend' },
{ value: SortDirection.Desc, display_name: 'Absteigend' },
];
filterByTopic(topic: Topic): void {
if (!topic.id) return;
const selectedTopicIds = this.route.snapshot.queryParamMap.getAll(
workQueryParamKeys.topicId,
);
const nextTopicIds = selectedTopicIds.includes(topic.id)
? selectedTopicIds.filter((id) => id !== topic.id)
: [...selectedTopicIds, topic.id];
this.router.navigate([], {
queryParams: {
[workQueryParamKeys.topicId]: nextTopicIds,
[workQueryParamKeys.page]: 0,
},
queryParamsHandling: 'merge',
});
}
filterByAuthor(author: Author): void {
if (!author.id) return;
const selectedAuthorIds = this.route.snapshot.queryParamMap.getAll(
workQueryParamKeys.authorId,
);
const nextAuthorIds = selectedAuthorIds.includes(author.id)
? selectedAuthorIds.filter((id) => id !== author.id)
: [...selectedAuthorIds, author.id];
this.router.navigate([], {
queryParams: {
[workQueryParamKeys.authorId]: nextAuthorIds,
[workQueryParamKeys.page]: 0,
},
queryParamsHandling: 'merge',
});
}
}
@@ -77,8 +77,6 @@ export class AppAuthorChipComponent {
if (this.handleChipClick && author) {
this.handleChipClick.emit(author);
}
console.log('Chip clicked:', event);
}
stripOpenAlexId(id: string | null | undefined): string | undefined {
@@ -1,14 +1,37 @@
:host {
::ng-deep .mat-mdc-card-header-text {
min-width: 0;
width: 100%;
}
}
.card-content {
display: flex;
flex-direction: column;
gap: 1rem;
height: 100%;
}
mat-card-title {
display: -webkit-box;
width: 100%;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
line-clamp: 2;
overflow: hidden;
line-height: 1.3rem;
height: 2.6rem;
}
.city-country {
display: flex;
align-items: center;
gap: 0.5rem;
display: block;
width: 100%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
color: var(--sg-text-muted);
line-height: 1.25rem;
height: 1.25rem;
}
.metrics {
@@ -16,6 +39,8 @@
flex-direction: column;
gap: 0.5rem;
font-size: 0.875rem;
flex: 1 1 auto;
min-height: 0;
}
.metric-item {
@@ -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,26 @@
height: 100%;
}
mat-card-title {
display: -webkit-box;
width: 100%;
-webkit-box-orient: vertical;
-webkit-line-clamp: 5;
line-clamp: 5;
overflow: hidden;
line-height: 1.3rem;
height: 6.5rem;
}
.subtitle {
display: flex;
align-items: center;
gap: 0.5rem;
display: block;
width: 100%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
color: var(--sg-text-muted);
line-height: 1.25rem;
height: 1.25rem;
}
.metrics {
@@ -1,9 +1,6 @@
@let work = this.work();
<mat-card
class="card-content popup"
appearance="outlined"
[routerLink]="work.id ? ['/topic', stripOpenAlexId(work.id)] : null">
<mat-card class="card-content popup" appearance="outlined">
<mat-card-header>
<mat-card-title>{{ work.title }}</mat-card-title>
<mat-card-subtitle class="subtitle">
@@ -15,15 +12,41 @@
<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"
[isClickable]="true"
(handleChipClick)="topicChipClick.emit($event)"
(click)="$event.stopPropagation()" />
}
</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"
[isClickable]="true"
(handleChipClick)="authorChipClick.emit($event)"
(click)="$event.stopPropagation()" />
}
@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;
@@ -1,5 +1,5 @@
import { Component, computed, input } from '@angular/core';
import { DehydratedAuthor, Work } from '../../../api';
import { Component, computed, input, output } from '@angular/core';
import { Author, DehydratedAuthor, Topic, Work } from '../../../api';
import { MatCardModule } from '@angular/material/card';
import { MatIconModule } from '@angular/material/icon';
import { MatButtonModule } from '@angular/material/button';
@@ -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: [
@@ -31,6 +34,9 @@ import { AppAuthorChipComponent } from '../app-author-chip/app-author-chip.compo
export class AppPublicationCardComponent {
work = input.required<Work>();
topicChipClick = output<Topic>();
authorChipClick = output<Author>();
stripOpenAlexId(id: string | null | undefined): string | undefined {
if (!id) {
return undefined;
@@ -55,4 +61,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),
);
}
@@ -12,7 +12,7 @@
<mat-divider />
<mat-card-content>
<p>{{ description() }}</p>
<p class="description">{{ description() }}</p>
<div class="metrics">
<div class="metric-item">
<mat-icon>menu_book</mat-icon>
@@ -15,22 +15,69 @@
::ng-deep .mdc-button--outlined {
border-color: var(--topic-border) !important;
}
::ng-deep .mat-mdc-card-header-text {
min-width: 0;
width: 100%;
}
}
.card-content {
display: flex;
flex-direction: column;
gap: 1rem;
height: 100%;
background-color: var(--topic-background);
border: 1px solid var(--topic-border);
}
mat-card-title {
display: -webkit-box;
width: 100%;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
line-clamp: 2;
overflow: hidden;
line-height: 1.3rem;
height: 2.6rem;
}
.subtitle {
display: flex;
align-items: center;
gap: 0.5rem;
display: -webkit-box;
width: 100%;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
line-clamp: 2;
overflow: hidden;
color: var(--sg-text-muted);
line-height: 1.25rem;
height: 2.5rem;
}
mat-card-content {
display: flex;
flex-direction: column;
gap: 1rem;
flex: 1 1 auto;
min-height: 0;
}
.description {
margin: 0;
max-height: 6.5rem;
overflow-y: auto;
scrollbar-width: thin;
scrollbar-color: var(--topic-border) transparent;
&::-webkit-scrollbar {
width: 6px;
}
&::-webkit-scrollbar-thumb {
background-color: var(--topic-border);
border-radius: 3px;
}
}
.metrics {
@@ -28,7 +28,9 @@
.cards {
display: grid;
gap: 1.5rem;
grid-template-columns: repeat(auto-fit, minmax(var(--card-min-width), 1fr));
// auto-fill (not auto-fit) keeps empty tracks reserved, so a single result
// stays card-width instead of stretching to fill the whole row.
grid-template-columns: repeat(auto-fill, minmax(var(--card-min-width), 1fr));
padding: 0 1rem;
}