add UserList entry card component
This commit is contained in:
1 parent
85ca240c0b
commit
605dd762ff
5 files changed
+345
-1
No files matched your search
@@ -30,6 +30,11 @@ import { UserListItemComponent } from './features/cards/user-list-item/user-list
|
|||||||
import { UserListItemCardComponent } from './features/cards/user-list-item-card/user-list-item-card.component';
|
import { UserListItemCardComponent } from './features/cards/user-list-item-card/user-list-item-card.component';
|
||||||
import { DateFormatPipe } from './core/pipes/date-format/date-format.pipe';
|
import { DateFormatPipe } from './core/pipes/date-format/date-format.pipe';
|
||||||
import { SharedModule } from './shared/shared.module';
|
import { SharedModule } from './shared/shared.module';
|
||||||
|
import { ListInfoComponent } from './features/list-info/list-info.component';
|
||||||
|
import { ListEntryCardComponent } from './features/cards/list-entry-card/list-entry-card.component';
|
||||||
|
import { CollectionEntryListComponent } from './features/lists/collection-entry-list/collection-entry-list.component';
|
||||||
|
import { DatePipe } from '@angular/common';
|
||||||
|
import { DragDropModule } from '@angular/cdk/drag-drop';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@@ -49,6 +54,9 @@ import { SharedModule } from './shared/shared.module';
|
|||||||
UserListItemComponent,
|
UserListItemComponent,
|
||||||
UserListItemCardComponent,
|
UserListItemCardComponent,
|
||||||
DateFormatPipe,
|
DateFormatPipe,
|
||||||
|
ListInfoComponent,
|
||||||
|
ListEntryCardComponent,
|
||||||
|
CollectionEntryListComponent,
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
CoreModule,
|
CoreModule,
|
||||||
@@ -66,8 +74,10 @@ import { SharedModule } from './shared/shared.module';
|
|||||||
MatCheckboxModule,
|
MatCheckboxModule,
|
||||||
MatListModule,
|
MatListModule,
|
||||||
BrowserAnimationsModule,
|
BrowserAnimationsModule,
|
||||||
|
|
||||||
|
DragDropModule,
|
||||||
],
|
],
|
||||||
providers: [],
|
providers: [DatePipe],
|
||||||
bootstrap: [AppComponent],
|
bootstrap: [AppComponent],
|
||||||
})
|
})
|
||||||
export class AppModule {}
|
export class AppModule {}
|
||||||
@@ -0,0 +1,176 @@
|
|||||||
|
.movie-card {
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.movie-card .card-head {
|
||||||
|
position: relative;
|
||||||
|
border-radius: 10px;
|
||||||
|
height: auto;
|
||||||
|
overflow: hidden;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
.movie-card .card-img {
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
aspect-ratio: 2 / 3;
|
||||||
|
object-fit: cover;
|
||||||
|
transition: transform 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.movie-card .card-body {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
background: rgba(0, 0, 0, 0.5);
|
||||||
|
color: #fff;
|
||||||
|
padding: 10px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
transition: max-height 0.3s ease, padding 0.3s ease;
|
||||||
|
overflow: hidden;
|
||||||
|
max-height: 60px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* * HOVER */
|
||||||
|
.movie-card:hover .card-img {
|
||||||
|
transform: scale(1.1);
|
||||||
|
}
|
||||||
|
.movie-card .card-overlay {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
opacity: 0;
|
||||||
|
backdrop-filter: blur(2px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.movie-card:hover .card-overlay {
|
||||||
|
opacity: 1;
|
||||||
|
transition: 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.movie-card:hover .card-body {
|
||||||
|
max-height: 100px;
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
.movie-card:hover .card-title {
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ! HOVER END*/
|
||||||
|
|
||||||
|
/* * BUTTONS */
|
||||||
|
.movie-card .bookmark,
|
||||||
|
.movie-card .info,
|
||||||
|
.movie-card .rating {
|
||||||
|
position: absolute;
|
||||||
|
top: 15px;
|
||||||
|
padding: 6px;
|
||||||
|
border-radius: 10px;
|
||||||
|
color: var(--light-azure);
|
||||||
|
transform: scale(var(--mv-card-scale));
|
||||||
|
background: rgba(51, 50, 50, 0.224);
|
||||||
|
color: var(--white);
|
||||||
|
}
|
||||||
|
|
||||||
|
.movie-card .bookmark {
|
||||||
|
left: 15px;
|
||||||
|
}
|
||||||
|
.movie-card .info {
|
||||||
|
left: 15px;
|
||||||
|
top: 60px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.movie-card .bookmark i,
|
||||||
|
.movie-card .info i {
|
||||||
|
size: 50px;
|
||||||
|
font-size: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.movie-card .bookmark:hover,
|
||||||
|
.movie-card .info:hover {
|
||||||
|
color: var(--light-azure);
|
||||||
|
background: rgba(0, 0, 0, 0.5);
|
||||||
|
transition: color 0.3s ease, background-color 0.3s ease;
|
||||||
|
}
|
||||||
|
.movie-card:hover :is(.bookmark, .rating, .info) {
|
||||||
|
--mv-card-scale: 1;
|
||||||
|
}
|
||||||
|
.bookmark,
|
||||||
|
.info {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ? rating */
|
||||||
|
.movie-card .rating {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
right: 15px;
|
||||||
|
/* color: var(--light-azure); */
|
||||||
|
color: var(--white);
|
||||||
|
}
|
||||||
|
.movie-card .rating span {
|
||||||
|
/* color: var(--light-azure); */
|
||||||
|
color: var(--white);
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: var(--fw-5);
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.movie-card .rating i {
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: var(--fw-5);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ! BUTTONS */
|
||||||
|
|
||||||
|
.movie-card .card-title {
|
||||||
|
font-size: 1.05em;
|
||||||
|
font-weight: var(--fw-5);
|
||||||
|
margin-bottom: 5px;
|
||||||
|
|
||||||
|
width: auto;
|
||||||
|
white-space: nowrap;
|
||||||
|
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.movie-card:hover .card-title,
|
||||||
|
.movie-card:hover .card-info {
|
||||||
|
text-overflow: clip;
|
||||||
|
color: var(--white);
|
||||||
|
}
|
||||||
|
|
||||||
|
.movie-card:hover .card-title {
|
||||||
|
color: var(--yellow);
|
||||||
|
}
|
||||||
|
.movie-card .card-info {
|
||||||
|
display: flex;
|
||||||
|
font-family: -apple-system, "Segoe UI", BlinkMacSystemFont, sans-serif;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
.movie-card .duration {
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-dot {
|
||||||
|
width: 3px;
|
||||||
|
height: 3px;
|
||||||
|
vertical-align: 2px;
|
||||||
|
border-radius: 50%;
|
||||||
|
display: inline-block;
|
||||||
|
background: #6d7583;
|
||||||
|
content: "";
|
||||||
|
margin: 9px 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.movie-card .card-title,
|
||||||
|
.movie-card .card-info {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<div class="movie-card" @fadeInOut>
|
||||||
|
<div class="card-head">
|
||||||
|
<img class="card-img" [src]="getPostPath()" alt="Movie Poster">
|
||||||
|
|
||||||
|
<div class="card-overlay" (click)="cardClick()">
|
||||||
|
<div class="rating">
|
||||||
|
<i class='bx bx-star'></i>
|
||||||
|
<span>{{formattedRate}}</span>
|
||||||
|
</div>
|
||||||
|
<!-- <div class="bookmark" *ngIf="!entry.isInLibrary">
|
||||||
|
<i class='bx bxs-add-to-queue' (click)="addEntry(entry.entryId.tmdb_id, entry.is_tvseries)"></i>
|
||||||
|
</div> -->
|
||||||
|
<div class="bookmark">
|
||||||
|
<i class='bx bxs-trash' (click)="removeEntryFromList()" style="color: #d42f50;"></i>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- <div [ngClass]="{'info': !entry.isInLibrary, 'bookmark': entry.isInLibrary}"> -->
|
||||||
|
<!-- <div class="info" *ngIf="entry.isInLibrary">
|
||||||
|
<i class='bx bx-list-plus' (click)="showAddToListModal()"></i>
|
||||||
|
</div> -->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- card body moved inside card head -->
|
||||||
|
<div class="card-body" (click)="cardClick()">
|
||||||
|
<a [href]="getTmdbLink()" target="_blank" rel="noopener noreferrer">
|
||||||
|
<h3 class="card-title">{{ entry.title }}</h3>
|
||||||
|
</a>
|
||||||
|
<div class="card-info">
|
||||||
|
<span class="Year">{{releaseYear}}</span>
|
||||||
|
<i class="card-dot"></i>
|
||||||
|
<span class="duration">137 min</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ListEntryCardComponent } from './list-entry-card.component';
|
||||||
|
|
||||||
|
describe('ListEntryCardComponent', () => {
|
||||||
|
let component: ListEntryCardComponent;
|
||||||
|
let fixture: ComponentFixture<ListEntryCardComponent>;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ListEntryCardComponent]
|
||||||
|
});
|
||||||
|
fixture = TestBed.createComponent(ListEntryCardComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||||
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
|
import { LibraryService } from '../../../core/services/library.service';
|
||||||
|
import { Entry } from '../../../shared/models/entry.model';
|
||||||
|
import { trigger, transition, style, animate } from '@angular/animations';
|
||||||
|
import { ListService } from '../../../core/services/list.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-list-entry-card',
|
||||||
|
templateUrl: './list-entry-card.component.html',
|
||||||
|
styleUrls: ['./list-entry-card.component.css'],
|
||||||
|
animations: [
|
||||||
|
trigger('fadeInOut', [
|
||||||
|
transition(':enter', [
|
||||||
|
style({ opacity: 0 }),
|
||||||
|
animate('0.5s ease-out', style({ opacity: 1 })),
|
||||||
|
]),
|
||||||
|
transition(':leave', [animate('0.5s ease-in', style({ opacity: 0 }))]),
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class ListEntryCardComponent {
|
||||||
|
@Input() entry!: Entry;
|
||||||
|
@Input() listId: string = '';
|
||||||
|
@Output() refrechEvent = new EventEmitter();
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private libraryService: LibraryService,
|
||||||
|
private listService: ListService,
|
||||||
|
public dialog: MatDialog
|
||||||
|
) {}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.libraryService.isInLibrary(this.entry.entryId.tmdb_id).subscribe({
|
||||||
|
next: (e) => {
|
||||||
|
if (e != null) {
|
||||||
|
e.isInLibrary = true;
|
||||||
|
this.entry = e;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: (error) => {},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
get releaseYear(): number {
|
||||||
|
return new Date(this.entry.release_date).getFullYear();
|
||||||
|
}
|
||||||
|
|
||||||
|
get formattedRate(): string {
|
||||||
|
return this.entry.entryRating.tmdb_rating.toFixed(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
getTmdbLink() {
|
||||||
|
let type = this.entry.is_tvseries ? 'tv' : 'movie';
|
||||||
|
return `https://www.themoviedb.org/${type}/${this.entry.entryId.tmdb_id}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
getPostPath() {
|
||||||
|
if (this.entry.poster_path == null) return 'https://pic.pnnet.dev/256x256';
|
||||||
|
|
||||||
|
return `https://image.tmdb.org/t/p/w500` + this.entry.poster_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
addEntry(tmdb_id: string, is_tvserie: boolean) {
|
||||||
|
console.log('Adding Entry To Library.');
|
||||||
|
this.libraryService.addEntry(tmdb_id, is_tvserie).subscribe({
|
||||||
|
next: (entry) => {
|
||||||
|
if (entry != null) {
|
||||||
|
entry.isInLibrary = true;
|
||||||
|
this.entry = entry;
|
||||||
|
this.libraryService.getAllEntries(true);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: (error) => {
|
||||||
|
console.error('Error adding entry:', error);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
removeEntryFromList() {
|
||||||
|
// todo: add confirm modal
|
||||||
|
this.listService.removeEntryFromList(this.listId, this.entry.id).subscribe({
|
||||||
|
next: (response) => {
|
||||||
|
console.log('Entry successfully removed from list.', response);
|
||||||
|
this.entry.id = 0;
|
||||||
|
this.entry.isInLibrary = false;
|
||||||
|
},
|
||||||
|
error: (error) => {
|
||||||
|
console.error('Error removing entry from list:', error);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ? EVENTS
|
||||||
|
cardClick() {}
|
||||||
|
|
||||||
|
// ? EVENT EMITTER
|
||||||
|
emitRefrechEvent() {
|
||||||
|
this.refrechEvent.emit();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user