From 3374aa9944e4f7ebc38507b19afd0a0f9ac2cd6a Mon Sep 17 00:00:00 2001 From: Mohammed Abad Date: Tue, 16 Apr 2024 19:04:54 +0100 Subject: [PATCH] add season card component --- .../season-main-card.component.css | 37 ++++++++++ .../season-main-card.component.html | 20 ++++++ .../season-main-card.component.spec.ts | 23 +++++++ .../season-main-card.component.ts | 67 +++++++++++++++++++ 4 files changed, 147 insertions(+) create mode 100644 frontend/src/app/shared/cards/season-main-card/season-main-card.component.css create mode 100644 frontend/src/app/shared/cards/season-main-card/season-main-card.component.html create mode 100644 frontend/src/app/shared/cards/season-main-card/season-main-card.component.spec.ts create mode 100644 frontend/src/app/shared/cards/season-main-card/season-main-card.component.ts diff --git a/frontend/src/app/shared/cards/season-main-card/season-main-card.component.css b/frontend/src/app/shared/cards/season-main-card/season-main-card.component.css new file mode 100644 index 0000000..49b3fc6 --- /dev/null +++ b/frontend/src/app/shared/cards/season-main-card/season-main-card.component.css @@ -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 */ +} \ No newline at end of file diff --git a/frontend/src/app/shared/cards/season-main-card/season-main-card.component.html b/frontend/src/app/shared/cards/season-main-card/season-main-card.component.html new file mode 100644 index 0000000..4e15ff2 --- /dev/null +++ b/frontend/src/app/shared/cards/season-main-card/season-main-card.component.html @@ -0,0 +1,20 @@ + + +
+ Episode poster +
+
{{season.name}}
+

{{season.air_date | dateFormat:'yyyy'}}

+ +
+
+
+
+ +
+ +
+
+ +
+
\ No newline at end of file diff --git a/frontend/src/app/shared/cards/season-main-card/season-main-card.component.spec.ts b/frontend/src/app/shared/cards/season-main-card/season-main-card.component.spec.ts new file mode 100644 index 0000000..a8826cd --- /dev/null +++ b/frontend/src/app/shared/cards/season-main-card/season-main-card.component.spec.ts @@ -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; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [SeasonMainCardComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(SeasonMainCardComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/shared/cards/season-main-card/season-main-card.component.ts b/frontend/src/app/shared/cards/season-main-card/season-main-card.component.ts new file mode 100644 index 0000000..515f2e1 --- /dev/null +++ b/frontend/src/app/shared/cards/season-main-card/season-main-card.component.ts @@ -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; + } +}