entry card: add redifrect to entry page + inlibrary badge

This commit is contained in:
X4Lo committed 2024-04-16 10:22:23 +01:00
1 parent d695e6fa0f
commit 7dec0d6149
3 files changed
+55 -13

No files matched your search

@@ -11,6 +11,7 @@
overflow: hidden; overflow: hidden;
margin-bottom: 15px; margin-bottom: 15px;
} }
.movie-card .card-img { .movie-card .card-img {
width: 100%; width: 100%;
height: auto; height: auto;
@@ -38,6 +39,7 @@
.movie-card:hover .card-img { .movie-card:hover .card-img {
transform: scale(1.1); transform: scale(1.1);
} }
.movie-card .card-overlay { .movie-card .card-overlay {
position: absolute; position: absolute;
inset: 0; inset: 0;
@@ -54,10 +56,29 @@
max-height: 100px; max-height: 100px;
padding: 12px; padding: 12px;
} }
.movie-card:hover .card-title { .movie-card:hover .card-title {
white-space: normal; white-space: normal;
} }
/* ! OVER LAY 2 */
.movie-card:hover .card-overlay-2 {
opacity: 0;
transition: 0.3s ease;
}
.movie-card .in-library {
position: absolute;
top: -7px;
right: 11px;
color: var(--white);
}
.movie-card .in-library span {
font-size: 37px;
color: var(--shz-gold-1);
}
/* ! HOVER END*/ /* ! HOVER END*/
/* * BUTTONS */ /* * BUTTONS */
@@ -77,6 +98,7 @@
.movie-card .bookmark { .movie-card .bookmark {
left: 15px; left: 15px;
} }
.movie-card .info { .movie-card .info {
left: 15px; left: 15px;
top: 60px; top: 60px;
@@ -94,9 +116,11 @@
background: rgba(0, 0, 0, 0.5); background: rgba(0, 0, 0, 0.5);
transition: color 0.3s ease, background-color 0.3s ease; transition: color 0.3s ease, background-color 0.3s ease;
} }
.movie-card:hover :is(.bookmark, .rating, .info) { .movie-card:hover :is(.bookmark, .rating, .info) {
--mv-card-scale: 1; --mv-card-scale: 1;
} }
.bookmark, .bookmark,
.info { .info {
display: flex; display: flex;
@@ -112,6 +136,7 @@
/* color: var(--light-azure); */ /* color: var(--light-azure); */
color: var(--white); color: var(--white);
} }
.movie-card .rating span { .movie-card .rating span {
/* color: var(--light-azure); */ /* color: var(--light-azure); */
color: var(--white); color: var(--white);
@@ -148,6 +173,7 @@
.movie-card:hover .card-title { .movie-card:hover .card-title {
color: var(--yellow); color: var(--yellow);
} }
.movie-card .card-info { .movie-card .card-info {
display: flex; display: flex;
font-family: -apple-system, "Segoe UI", BlinkMacSystemFont, sans-serif; font-family: -apple-system, "Segoe UI", BlinkMacSystemFont, sans-serif;
@@ -1,8 +1,16 @@
<div class="movie-card" @fadeInOut> <div class="movie-card" @fadeInOut>
<div class="card-head"> <div class="card-head">
<img class="card-img" [src]="getPostPath()" alt="Movie Poster"> <img class="card-img" [src]="postPath" alt="Movie Poster">
<div class="card-overlay" (click)="cardClick()"> <div class="card-overlay-2">
<div class="in-library" *ngIf="entry.isInLibrary">
<span class="material-symbols-outlined">
beenhere
</span>
</div>
</div>
<div class="card-overlay">
<div class="rating"> <div class="rating">
<i class='bx bx-star'></i> <i class='bx bx-star'></i>
<span>{{formattedRate}}</span> <span>{{formattedRate}}</span>
@@ -21,15 +29,15 @@
</div> </div>
<!-- card body moved inside card head --> <!-- card body : title, -->
<div class="card-body" (click)="cardClick()"> <div class="card-body">
<a [href]="getTmdbLink()" target="_blank" rel="noopener noreferrer"> <a (click)="cardClick()" rel="noopener noreferrer">
<h3 class="card-title">{{ entry.title }}</h3> <h3 class="card-title">{{ entry.title }}</h3>
</a> </a>
<div class="card-info"> <div class="card-info">
<span class="Year">{{releaseYear}}</span> <span class="Year">{{releaseYear}}</span>
<i class="card-dot"></i> <i class="card-dot"></i>
<span class="duration">137 min</span> <span class="duration">{{runtime}} min</span>
</div> </div>
</div> </div>
</div> </div>
@@ -4,6 +4,7 @@ import { MatDialog } from '@angular/material/dialog';
import { trigger, transition, style, animate } from '@angular/animations'; import { trigger, transition, style, animate } from '@angular/animations';
import { Entry } from '../../../models/entry.model'; import { Entry } from '../../../models/entry.model';
import { LibraryService } from '../../../../core/services/library.service'; import { LibraryService } from '../../../../core/services/library.service';
import { Router } from '@angular/router';
@Component({ @Component({
selector: 'app-main-card', selector: 'app-main-card',
@@ -28,7 +29,8 @@ export class MainCardComponent implements OnInit {
constructor( constructor(
private libraryService: LibraryService, private libraryService: LibraryService,
public dialog: MatDialog public dialog: MatDialog,
private router: Router
) {} ) {}
ngOnInit(): void { ngOnInit(): void {
@@ -59,6 +61,7 @@ export class MainCardComponent implements OnInit {
entry.isInLibrary = true; entry.isInLibrary = true;
this.entry = entry; this.entry = entry;
this.libraryService.getAllEntries(true); this.libraryService.getAllEntries(true);
console.log(entry);
} }
}, },
error: (error) => { error: (error) => {
@@ -77,9 +80,7 @@ export class MainCardComponent implements OnInit {
this.entry.isInLibrary = false; this.entry.isInLibrary = false;
}, },
error: (error) => { error: (error) => {
// Handle error scenario
console.error('Error deleting entry:', error); console.error('Error deleting entry:', error);
// Optionally, display an error message to the user using a service or a component
}, },
}); });
} }
@@ -101,7 +102,8 @@ export class MainCardComponent implements OnInit {
} }
cardClick() { cardClick() {
console.log(this.entry); if (this.entry.isInLibrary)
this.router.navigate([`/entry/${this.entry.id}`]);
} }
getTmdbLink() { getTmdbLink() {
@@ -109,9 +111,15 @@ export class MainCardComponent implements OnInit {
return `https://www.themoviedb.org/${type}/${this.entry.entryId.tmdb_id}`; return `https://www.themoviedb.org/${type}/${this.entry.entryId.tmdb_id}`;
} }
getPostPath() { get postPath() {
if (this.entry.poster_path == null) return 'assets/images/default/default-poster.png'; if (this.entry.poster_path == null)
return 'assets/images/default/default-poster.png';
return `https://image.tmdb.org/t/p/w500` + this.entry.poster_path; return `https://image.tmdb.org/t/p/w154` + this.entry.poster_path;
}
get runtime() {
if (this.entry.runtime == null) return '';
return this.entry.runtime;
} }
} }