added main card component
This commit is contained in:
1 parent
fde80005a8
commit
2e5cd93e13
4 files changed
+266
No files matched your search
@@ -0,0 +1,177 @@
|
||||
|
||||
.movie-card {
|
||||
cursor: pointer;
|
||||
display: flex; /* Makes sure the card stretches in flex container */
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.movie-card .card-head {
|
||||
position: relative;
|
||||
border-radius: 10px;
|
||||
height: auto; /* If you set a fixed height, ensure it allows for the aspect ratio */
|
||||
overflow: hidden;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.movie-card .card-img {
|
||||
width: 100%; /* Ensure the image covers the width */
|
||||
height: auto; /* Height should adjust automatically */
|
||||
aspect-ratio: 2 / 3; /* Set the aspect ratio to 2:3 */
|
||||
object-fit: cover; /* Cover the container without losing aspect ratio */
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
/* Update styles for card-body, card-title, and card-info based on the new layout */
|
||||
.movie-card .card-body {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
background: rgba(0, 0, 0, 0.5); /* Semi-transparent background */
|
||||
color: #fff;
|
||||
padding: 10px;
|
||||
box-sizing: border-box;
|
||||
|
||||
transition: max-height 0.3s ease, padding 0.3s ease; /* Smooth transition for height and padding */
|
||||
overflow: hidden; /* Hide overflow by default */
|
||||
max-height: 60px; /* Adjust based on your default card body height */
|
||||
}
|
||||
|
||||
|
||||
/* * 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; /* Adjust based on the needed height to show the full title */
|
||||
padding: 12px; /* Increase padding if desired */
|
||||
}
|
||||
.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; /* Use Flexbox */
|
||||
justify-content: center; /* Center horizontally */
|
||||
align-items: center; /* Center vertically */
|
||||
}
|
||||
|
||||
/* ? 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 {
|
||||
/* color: var(--light-azure); */
|
||||
text-overflow: clip;
|
||||
color: var(--white);
|
||||
}
|
||||
|
||||
.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,29 @@
|
||||
<div class="movie-card">
|
||||
<div class="card-head">
|
||||
<img class="card-img" [src]="'https://image.tmdb.org/t/p/w500' + entry.poster_path" alt="Movie Poster">
|
||||
|
||||
<div class="card-overlay" (click)="logEntry">
|
||||
<div class="rating">
|
||||
<i class='bx bx-star'></i>
|
||||
<span>{{formattedRate}}</span>
|
||||
</div>
|
||||
<div class="bookmark">
|
||||
<i class='bx bxs-bookmark' (click)="addEntry(entry.entryId.tmdb_id)"></i>
|
||||
</div>
|
||||
<div class="info">
|
||||
<i class='bx bx-info-circle'></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- card body moved inside card head -->
|
||||
<div class="card-body" (click)="logEntry()">
|
||||
|
||||
<h3 class="card-title">{{ entry.title }}</h3>
|
||||
<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 { MainCardComponent } from './main-card.component';
|
||||
|
||||
describe('MainCardComponent', () => {
|
||||
let component: MainCardComponent;
|
||||
let fixture: ComponentFixture<MainCardComponent>;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [MainCardComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(MainCardComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,39 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { Entry } from '../../../shared/models/entry.model';
|
||||
import { EntryService } from '../../../core/services/entry.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-main-card',
|
||||
templateUrl: './main-card.component.html',
|
||||
styleUrls: ['./main-card.component.css'],
|
||||
})
|
||||
export class MainCardComponent {
|
||||
@Input() entry!: Entry;
|
||||
|
||||
constructor(private entryService: EntryService) {}
|
||||
|
||||
get releaseYear(): number {
|
||||
return new Date(this.entry.release_date).getFullYear();
|
||||
}
|
||||
|
||||
get formattedRate(): string {
|
||||
return this.entry.entryRating.tmdb_rating.toFixed(1);
|
||||
}
|
||||
|
||||
addEntry(tmdb_id: string) {
|
||||
console.log('Adding Entry To Library.');
|
||||
this.entryService.addEntry(tmdb_id).subscribe({
|
||||
next: (entry) => {
|
||||
console.log(entry);
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error adding entry:', error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
logEntry() {
|
||||
console.log(this.entry);
|
||||
}
|
||||
openInfo() {}
|
||||
}
|
||||
Reference in new issue
Block a user