From 3407caeb5f975f88c911ea24a24359070ef3fbb7 Mon Sep 17 00:00:00 2001 From: "aditya.chandel" <> Date: Thu, 9 Jan 2025 00:22:53 -0700 Subject: [PATCH] Colors for stars --- booklore-ui/src/app/app.module.ts | 4 +++- .../book-browser/book-browser.component.html | 4 ++-- .../book-browser/book-browser.component.scss | 6 +++--- .../book-table/book-table.component.html | 11 ++++++++-- .../book-table/book-table.component.ts | 21 +++++++++++++------ 5 files changed, 32 insertions(+), 14 deletions(-) diff --git a/booklore-ui/src/app/app.module.ts b/booklore-ui/src/app/app.module.ts index 8b3a96dc8..e1af2dd9b 100644 --- a/booklore-ui/src/app/app.module.ts +++ b/booklore-ui/src/app/app.module.ts @@ -46,6 +46,7 @@ import {MultiSelectModule} from 'primeng/multiselect'; import {SelectButton} from "primeng/selectbutton"; import {BookTableComponent} from './book/component/book-table/book-table.component'; import {RadioButton} from 'primeng/radiobutton'; +import {Select} from 'primeng/select'; @NgModule({ declarations: [ @@ -88,7 +89,8 @@ import {RadioButton} from 'primeng/radiobutton'; MultiSelectModule, SelectButton, BookTableComponent, - RadioButton + RadioButton, + Select ], providers: [ DialogService, diff --git a/booklore-ui/src/app/book/component/book-browser/book-browser.component.html b/booklore-ui/src/app/book/component/book-browser/book-browser.component.html index 2584ceaf0..2750849d3 100644 --- a/booklore-ui/src/app/book/component/book-browser/book-browser.component.html +++ b/booklore-ui/src/app/book/component/book-browser/book-browser.component.html @@ -16,7 +16,7 @@
- +
@@ -76,7 +76,7 @@ (click)="unshelfBooks()"> diff --git a/booklore-ui/src/app/book/component/book-browser/book-browser.component.scss b/booklore-ui/src/app/book/component/book-browser/book-browser.component.scss index ecea847b9..64dd2e3d2 100644 --- a/booklore-ui/src/app/book/component/book-browser/book-browser.component.scss +++ b/booklore-ui/src/app/book/component/book-browser/book-browser.component.scss @@ -69,8 +69,8 @@ .book-browser-footer { position: absolute; bottom: 0; - left: 37%; - right: 37%; + left: 38%; + right: 38%; display: flex; justify-content: center; padding: 1.1rem; @@ -104,6 +104,6 @@ .footer-items-container { display: flex; justify-content: space-between; - gap: 1.5rem; + gap: 2rem; } diff --git a/booklore-ui/src/app/book/component/book-table/book-table.component.html b/booklore-ui/src/app/book/component/book-table/book-table.component.html index 0f540fd09..62ff73bf8 100644 --- a/booklore-ui/src/app/book/component/book-table/book-table.component.html +++ b/booklore-ui/src/app/book/component/book-table/book-table.component.html @@ -22,7 +22,9 @@ Rating Pages Reviews - + + + @@ -35,7 +37,12 @@ {{ book.metadata?.language }} - + + {{ book.metadata?.pageCount }} diff --git a/booklore-ui/src/app/book/component/book-table/book-table.component.ts b/booklore-ui/src/app/book/component/book-table/book-table.component.ts index 67b52d794..ae0ad9d1c 100644 --- a/booklore-ui/src/app/book/component/book-table/book-table.component.ts +++ b/booklore-ui/src/app/book/component/book-table/book-table.component.ts @@ -1,6 +1,6 @@ import {AfterContentChecked, AfterViewChecked, AfterViewInit, Component, EventEmitter, Input, NgZone, OnChanges, Output} from '@angular/core'; import {TableModule} from 'primeng/table'; -import {NgIf} from '@angular/common'; +import {NgClass, NgIf} from '@angular/common'; import {BookService} from '../../service/book.service'; import {Rating} from 'primeng/rating'; import {FormsModule} from '@angular/forms'; @@ -17,7 +17,8 @@ import {SortDirection, SortOption} from '../../model/sort.model'; TableModule, NgIf, Rating, - FormsModule + FormsModule, + NgClass ], styleUrl: './book-table.component.scss' }) @@ -98,9 +99,17 @@ export class BookTableComponent implements OnChanges { } - testzzz($event: any) { - console.log($event) + getStarColor(rating: number): string { + if (rating >= 4.5) { + return 'rgb(34, 197, 94)'; + } else if (rating >= 4) { + return 'rgb(52, 211, 153)'; + } else if (rating >= 3.5) { + return 'rgb(234, 179, 8)'; + } else if (rating >= 2.5) { + return 'rgb(249, 115, 22)'; + } else { + return 'rgb(239, 68, 68)'; + } } - - protected readonly SortDirection = SortDirection; }