Frontend: Added PersonCardComponent
This commit is contained in:
1 parent
996c445020
commit
02b4caa6ef
3 files changed
+141
No files matched your search
@@ -0,0 +1,63 @@
|
||||
.person-card {
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
||||
cursor: pointer;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.person-card:hover {
|
||||
transform: translateY(-5px);
|
||||
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.person-image {
|
||||
width: 100%;
|
||||
height: 250px;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.person-info {
|
||||
padding: 12px;
|
||||
flex-grow: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.person-name {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 600;
|
||||
margin-bottom: 5px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.person-department {
|
||||
font-size: 0.9rem;
|
||||
color: #666;
|
||||
margin-bottom: 8px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.person-details {
|
||||
font-size: 0.85rem;
|
||||
color: #888;
|
||||
margin-top: auto;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.person-popularity {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.person-gender {
|
||||
font-style: italic;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<div class="person-card" (click)="navigateToDetails()">
|
||||
<img [src]="getProfileImageUrl()" [alt]="person?.name" class="person-image">
|
||||
<div class="person-info">
|
||||
<h3 class="person-name">{{ person?.name }}</h3>
|
||||
<div class="person-details">
|
||||
<div class="person-popularity">
|
||||
<i class="bi bi-star-fill me-1"></i>
|
||||
{{ (person?.popularity || 0) | floatFormat:2 }}
|
||||
</div>
|
||||
<div class="person-department">{{ person?.known_for_department || 'Unknown' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,65 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { Person } from '../../../shared/models/person.model';
|
||||
import { Router } from '@angular/router';
|
||||
import { ConfigService } from '../../../core/services/config.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-person-card',
|
||||
templateUrl: './person-card.component.html',
|
||||
styleUrls: ['./person-card.component.css'],
|
||||
})
|
||||
export class PersonCardComponent implements OnInit {
|
||||
@Input() person: Person | null = null;
|
||||
backendUrl: string;
|
||||
defaultImage = 'assets/images/default-profile.png';
|
||||
|
||||
constructor(private router: Router, private configService: ConfigService) {
|
||||
this.backendUrl = this.configService.getBackendApiUrl();
|
||||
}
|
||||
|
||||
ngOnInit() {}
|
||||
|
||||
getProfileImageUrl(): string {
|
||||
if (!this.person) return this.defaultImage;
|
||||
|
||||
// First check if we have a local media
|
||||
// if (this.person.medias && this.person.medias.length > 0) {
|
||||
// const profileMedia = this.person.medias.find(m => m.type === 'profile');
|
||||
// if (profileMedia) {
|
||||
// return `${this.backendUrl}/images/people/profiles/${profileMedia.file_name}`;
|
||||
// }
|
||||
// }
|
||||
|
||||
// Fallback to TMDB image if available
|
||||
if (this.person.profile_path) {
|
||||
return `https://image.tmdb.org/t/p/w185${this.person.profile_path}`;
|
||||
}
|
||||
|
||||
// Default image if nothing else is available
|
||||
return this.defaultImage;
|
||||
}
|
||||
|
||||
getGenderText(): string {
|
||||
if (!this.person || this.person.gender === undefined)
|
||||
return 'Not specified';
|
||||
|
||||
switch (this.person.gender) {
|
||||
case 0:
|
||||
return 'Not specified';
|
||||
case 1:
|
||||
return 'Female';
|
||||
case 2:
|
||||
return 'Male';
|
||||
case 3:
|
||||
return 'Non-binary';
|
||||
default:
|
||||
return 'Not specified';
|
||||
}
|
||||
}
|
||||
|
||||
navigateToDetails() {
|
||||
if (this.person && this.person.id) {
|
||||
this.router.navigate(['/people', this.person.id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user