add season card component
This commit is contained in:
1 parent
3cde0731a1
commit
3374aa9944
4 files changed
+147
No files matched your search
@@ -0,0 +1,37 @@
|
||||
.list-item-1 {
|
||||
padding-top: 1px;
|
||||
}
|
||||
|
||||
.list-title {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.list-line {
|
||||
max-height: 105px;
|
||||
border-radius: 1px;
|
||||
overflow: hidden;
|
||||
padding: 2px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.overview {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
max-height: 50px;
|
||||
}
|
||||
|
||||
.list-line:hover {
|
||||
background-color: var(--shz-light-bgh);
|
||||
}
|
||||
|
||||
:host-context([data-bs-theme="dark"]) .list-line:hover {
|
||||
background-color: var(--shz-dark-bgh);
|
||||
}
|
||||
|
||||
.progress {
|
||||
flex-grow: 1; /* Makes the progress bar expand to fill available space */
|
||||
margin-right: 10px; /* Adds some space between the progress bar and the checkbox */
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<!-- TODO mark season as seen > check box-->
|
||||
|
||||
<div class="d-flex align-items-start gap-2 list-line" @fadeInOut>
|
||||
<img [src]="posterPath" width="70" height="105" class="" alt="Episode poster">
|
||||
<div class="flex-grow-1 list-item-1">
|
||||
<h6 class="mb-0 list-title">{{season.name}}</h6>
|
||||
<p class="mb-0">{{season.air_date | dateFormat:'yyyy'}}</p>
|
||||
|
||||
<div class="d-flex align-items-center justify-content-between mb-4">
|
||||
<div class="progress" style="height: 7px; width: 90%;"> <!-- Adjust width as needed -->
|
||||
<div class="progress-bar" role="progressbar" style="width: 25%" aria-valuenow="episodesWatchedCount" aria-valuemin="0" [attr.aria-valuemax]="season.episode_count"></div>
|
||||
</div>
|
||||
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" style="height: 20px; width: 20px;">
|
||||
</div>
|
||||
</div>
|
||||
<!-- <p class="mb-0 overview">{{season.overview}}</p> -->
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { SeasonMainCardComponent } from './season-main-card.component';
|
||||
|
||||
describe('SeasonMainCardComponent', () => {
|
||||
let component: SeasonMainCardComponent;
|
||||
let fixture: ComponentFixture<SeasonMainCardComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [SeasonMainCardComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(SeasonMainCardComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,67 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { Season } from '../../models/season.model';
|
||||
import { SeasonService } from '../../../core/services/season.service';
|
||||
import {
|
||||
trigger,
|
||||
state,
|
||||
style,
|
||||
transition,
|
||||
animate,
|
||||
} from '@angular/animations';
|
||||
|
||||
@Component({
|
||||
selector: 'app-season-main-card',
|
||||
templateUrl: './season-main-card.component.html',
|
||||
styleUrl: './season-main-card.component.css',
|
||||
animations: [
|
||||
trigger('fadeInOut', [
|
||||
transition(':enter', [
|
||||
// void => *
|
||||
style({ opacity: 0 }),
|
||||
animate('0.5s ease-in', style({ opacity: 1 })),
|
||||
]),
|
||||
transition(':leave', [
|
||||
// * => void
|
||||
animate('0.5s ease-out', style({ opacity: 0 })),
|
||||
]),
|
||||
]),
|
||||
],
|
||||
})
|
||||
export class SeasonMainCardComponent implements OnInit {
|
||||
@Input() season: Season = {} as Season;
|
||||
|
||||
constructor(private seasonService: SeasonService) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
// // TODO: GET SEASON EPISODES
|
||||
// this.seasonService.getSeasonById(this.season.id).subscribe({
|
||||
// next: (season) => {
|
||||
// console.log(season);
|
||||
// this.season = season;
|
||||
// },
|
||||
// error: (error) => {
|
||||
// console.log(`Couldn't fetch season data:`, error);
|
||||
// // TODO show notification
|
||||
// },
|
||||
// });
|
||||
}
|
||||
|
||||
get posterPath() {
|
||||
if (this.season.poster_path == null)
|
||||
return 'assets/images/default/default-poster.png';
|
||||
|
||||
return 'http://image.tmdb.org/t/p/w154/' + this.season.poster_path;
|
||||
}
|
||||
|
||||
get episodesWatchedCount() {
|
||||
let count = 0;
|
||||
this.season.episodes.forEach((ep) => {
|
||||
if (ep.date_first_seen != null) count++;
|
||||
});
|
||||
|
||||
if (this.season.episode_count == null) return 0;
|
||||
|
||||
let value = (count * 100) / this.season.episode_count;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user