new ui component for displaying OpenAlex topics on project pages
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<mat-card appearance="outlined" class="card">
|
||||
<div class="section-header">
|
||||
<mat-icon>label</mat-icon>
|
||||
<h2>OpenAlex Themen</h2>
|
||||
<span class="count-badge">{{ getUniqueOATopics().length }}</span>
|
||||
</div>
|
||||
<div class="keyword-stack">
|
||||
@for (topic of getUniqueOATopics(); track $index) {
|
||||
<app-topic-chip
|
||||
[label]="topic.display_name || ''"
|
||||
[subfieldName]="topic.subfield?.display_name || ''"
|
||||
[fieldName]="topic.field?.display_name || ''"
|
||||
[domainName]="topic.domain?.display_name || ''"
|
||||
[color]="getTopicColor(topic)"
|
||||
[active]="true"
|
||||
countIcon="article"
|
||||
descriptionTooltipTarget="button" />
|
||||
}
|
||||
</div>
|
||||
</mat-card>
|
||||
@@ -0,0 +1,48 @@
|
||||
.keyword-stack {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.6rem;
|
||||
padding: 16px 20px 20px;
|
||||
::ng-deep app-topic-chip .topic-chip__count {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
.card {
|
||||
margin-bottom: 24px;
|
||||
border-color: #d9e2f0 !important;
|
||||
border-radius: var(--sg-radius-md) !important;
|
||||
}
|
||||
.section-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 16px 20px;
|
||||
border-bottom: 1px solid #e6e9ed;
|
||||
}
|
||||
.section-header mat-icon {
|
||||
color: var(--sg-text-muted);
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
font-size: 22px;
|
||||
}
|
||||
.section-header h2 {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: var(--sg-text);
|
||||
}
|
||||
.count-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 24px;
|
||||
height: 24px;
|
||||
padding: 0 8px;
|
||||
margin-left: auto;
|
||||
background: #e8edf5;
|
||||
border-radius: 12px;
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { TopicChipComponent } from '../../../shared/ui/topic-chip/topic-chip.component';
|
||||
import { Topic } from '../../../api';
|
||||
import {
|
||||
topicHierarchyColor,
|
||||
TopicHierarchyColorInput,
|
||||
} from '../../../resolvers/utils/topic-colors';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatChipsModule } from '@angular/material/chips';
|
||||
@Component({
|
||||
selector: 'app-project-oa-topics',
|
||||
imports: [TopicChipComponent, MatCardModule, MatIconModule, MatChipsModule],
|
||||
templateUrl: './project-oa-topics.component.html',
|
||||
styleUrl: './project-oa-topics.component.scss',
|
||||
})
|
||||
export class ProjectOaTopicsComponent {
|
||||
@Input() topics: Topic[] | undefined;
|
||||
|
||||
//Topics
|
||||
getUniqueOATopics(): Topic[] {
|
||||
if (!this.topics) return [];
|
||||
const uniqueTopicsMap = new Map<string, Topic>();
|
||||
this.topics.forEach((topic) => {
|
||||
if (topic.id && !uniqueTopicsMap.has(topic.id)) {
|
||||
uniqueTopicsMap.set(topic.id, topic);
|
||||
}
|
||||
});
|
||||
return Array.from(uniqueTopicsMap.values());
|
||||
}
|
||||
|
||||
getTopicColor(topic: Topic | undefined | null): string {
|
||||
const topicInput: TopicHierarchyColorInput = {
|
||||
id: topic?.id ?? null,
|
||||
name: topic?.display_name ?? null,
|
||||
field_id: topic?.field?.id ?? null,
|
||||
field_name: topic?.field?.display_name ?? null,
|
||||
domain_id: topic?.domain?.id ?? null,
|
||||
domain_name: topic?.domain?.display_name ?? null,
|
||||
};
|
||||
|
||||
return topicHierarchyColor(topicInput);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user