changed person-card to use global institution chip
LocationBasedServices/smartguide/pipeline/head This commit looks good

This commit is contained in:
Kazgatari
2026-08-23 16:46:37 +02:00
parent ba1c53b642
commit d8de0c2156
3 changed files with 11 additions and 175 deletions
@@ -51,52 +51,13 @@
<div class="card-body">
@if (institution(); as inst) {
<div class="institution-row" style="margin-bottom: 8px">
<button
type="button"
class="institution-tag"
[class.active]="isInstitutionActive()"
[class.is-loading]="loading()"
[matTooltip]="inst.display_name || ''"
[matTooltipDisabled]="loading()"
matTooltipPosition="above"
(click)="institutionClick.emit(inst); $event.stopPropagation()">
<mat-icon
style="
font-size: 12px;
width: 12px;
height: 12px;
margin-right: 4px;
vertical-align: middle;
"
>{{ APARTMENT_ICON }}</mat-icon
>
<span
[skText]="loading()"
class="institution-name"
style="vertical-align: middle"
>{{ inst.display_name ?? '' }}</span
>
@if (inst.country_code && !loading()) {
<app-country-flag
[countryCode]="inst.country_code"
[height]="10"
[bordered]="false"
style="margin-left: 6px" />
<span
class="country-code"
style="font-size: 9px; margin-left: 2px; vertical-align: middle"
>{{ inst.country_code.toUpperCase() }}</span
>
}
@if (institutionPageId() && !loading()) {
<mat-icon
class="institution-open-icon"
(click)="openInstitutionPage($event)"
aria-label="Institutionsseite öffnen"
>{{ OPEN_IN_NEW_ICON }}</mat-icon
>
}
</button>
<app-institution-chip
[institution]="inst"
size="mini"
[showIcon]="true"
[isClickable]="true"
[isSelected]="isInstitutionActive()"
(handleChipClick)="institutionClick.emit($event)" />
</div>
}
@@ -136,111 +136,6 @@
overflow: hidden;
text-overflow: ellipsis;
}
.institution {
display: flex;
align-items: center;
gap: 6px;
margin: 0;
font-size: 12px;
color: var(--sg-text-muted);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.institution-tag {
background: var(--sg-primary-soft);
border: 1px solid var(--sg-primary-border, var(--sg-border));
color: var(--sg-primary);
font-size: 10px;
font-weight: 600;
padding: 2px 6px;
border-radius: 4px;
cursor: pointer;
display: inline-flex;
align-items: center;
transition: all 0.2s ease;
max-width: 100%;
box-sizing: border-box;
margin: 0;
line-height: normal;
font-family: inherit;
.institution-name {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
min-width: 0;
flex: 1;
}
app-country-flag {
flex-shrink: 0;
}
.country-code {
display: inline-block;
flex-shrink: 0;
white-space: nowrap;
}
.institution-open-icon {
flex-shrink: 0;
width: 12px;
height: 12px;
margin-left: 5px;
font-size: 12px;
line-height: 1;
vertical-align: middle;
cursor: pointer;
opacity: 0;
transition: opacity 0.15s ease;
&:hover {
opacity: 1;
}
}
&:hover .institution-open-icon {
opacity: 0.7;
&:hover {
opacity: 1;
}
}
&:hover,
&:focus-visible {
background: var(--sg-primary);
color: var(--sg-background);
border-color: var(--sg-primary);
outline: none;
box-shadow:
0 0 0 2px var(--sg-background),
0 0 0 4px var(--sg-primary);
}
&.active {
border-color: var(--sg-primary);
box-shadow:
0 0 0 1px var(--sg-background),
0 0 0 3px var(--sg-primary);
}
&.active:hover,
&.active:focus-visible {
background: var(--sg-primary);
color: var(--sg-background);
}
&.is-loading {
pointer-events: none;
background: var(--sg-surface-soft);
border-color: var(--sg-border);
color: var(--sg-text-soft);
box-shadow: none;
}
}
.person-id {
margin: 2px 0 0;
@@ -1,20 +1,18 @@
import { Component, inject, input, computed, output } from '@angular/core';
import { Component, input, computed, output } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Router, RouterLink } from '@angular/router';
import { RouterLink } from '@angular/router';
import { MatIconModule } from '@angular/material/icon';
import { MatTooltipModule } from '@angular/material/tooltip';
import { CustomAuthor, DehydratedInstitution, WorkTopic } from '../../api';
import { SkTextDirective } from '../../custom-directives/sk-text.directive';
import { TopicChipComponent } from '../../shared/ui/topic-chip/topic-chip.component';
import { CountryFlagComponent } from '../../shared/ui/country-flag/country-flag.component';
import { AppInstitutionChipComponent } from '../../shared/ui/app-institution-chip/app-institution-chip.component';
import { CareerStageChipComponent } from '../../shared/ui/career-stage-chip/career-stage-chip.component';
import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
import {
APARTMENT_ICON,
BOOKMARK_BORDER_ICON,
BOOKMARK_ICON,
NETWORK_ICON,
OPEN_IN_NEW_ICON,
OVERVIEW_ICON,
PUBLICATION_ICON,
} from '../../shared/ui/icons';
@@ -29,7 +27,7 @@ import {
SkTextDirective,
MatTooltipModule,
TopicChipComponent,
CountryFlagComponent,
AppInstitutionChipComponent,
CareerStageChipComponent,
],
templateUrl: './person-card.component.html',
@@ -38,14 +36,10 @@ import {
export class PersonCardComponent {
readonly BOOKMARK_ICON = BOOKMARK_ICON;
readonly BOOKMARK_BORDER_ICON = BOOKMARK_BORDER_ICON;
readonly APARTMENT_ICON = APARTMENT_ICON;
readonly OPEN_IN_NEW_ICON = OPEN_IN_NEW_ICON;
readonly OVERVIEW_ICON = OVERVIEW_ICON;
readonly PUBLICATION_ICON = PUBLICATION_ICON;
readonly NETWORK_ICON = NETWORK_ICON;
private readonly router = inject(Router);
person = input.required<CustomAuthor>();
isBookmarked = input<boolean>(false);
loading = input<boolean>(false);
@@ -89,20 +83,6 @@ export class PersonCardComponent {
return newestInstitution;
});
institutionPageId = computed<string | null>(
() => this.institution()?.id?.split('/').pop() ?? null,
);
openInstitutionPage(event: Event): void {
event.stopPropagation();
event.preventDefault();
const id = this.institutionPageId();
if (!id) return;
void this.router.navigate(['/institution', id]);
}
isInstitutionActive = computed<boolean>(() => {
const active = this.normalizeInstitutionId(this.activeInstitutionId());
if (!active) return false;