From 02b4caa6efae3c6871f025fef6b4042acea3cabd Mon Sep 17 00:00:00 2001 From: X4Lo Date: Fri, 11 Jul 2025 23:34:49 +0100 Subject: [PATCH] Frontend: Added PersonCardComponent --- .../person-card/person-card.component.css | 63 ++++++++++++++++++ .../person-card/person-card.component.html | 13 ++++ .../person-card/person-card.component.ts | 65 +++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 frontend/src/app/features/people/person-card/person-card.component.css create mode 100644 frontend/src/app/features/people/person-card/person-card.component.html create mode 100644 frontend/src/app/features/people/person-card/person-card.component.ts diff --git a/frontend/src/app/features/people/person-card/person-card.component.css b/frontend/src/app/features/people/person-card/person-card.component.css new file mode 100644 index 0000000..da17ddd --- /dev/null +++ b/frontend/src/app/features/people/person-card/person-card.component.css @@ -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; +} diff --git a/frontend/src/app/features/people/person-card/person-card.component.html b/frontend/src/app/features/people/person-card/person-card.component.html new file mode 100644 index 0000000..5c02bd9 --- /dev/null +++ b/frontend/src/app/features/people/person-card/person-card.component.html @@ -0,0 +1,13 @@ +
+ +
+

{{ person?.name }}

+
+
+ + {{ (person?.popularity || 0) | floatFormat:2 }} +
+
{{ person?.known_for_department || 'Unknown' }}
+
+
+
\ No newline at end of file diff --git a/frontend/src/app/features/people/person-card/person-card.component.ts b/frontend/src/app/features/people/person-card/person-card.component.ts new file mode 100644 index 0000000..727dfd3 --- /dev/null +++ b/frontend/src/app/features/people/person-card/person-card.component.ts @@ -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]); + } + } +}