Colors for stars
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
<div class="header-right-items">
|
||||
<input type="text" pInputText placeholder="Search by title..." [(ngModel)]="bookTitle" (ngModelChange)="onBookTitleChange($event)"/>
|
||||
<p-dropdown [options]="sortOptions" optionLabel="label" placeholder="Select Sorting" [(ngModel)]="selectedSort" (onChange)="updateSortOption($event.value)"></p-dropdown>
|
||||
<p-select [options]="sortOptions" optionLabel="label" placeholder="Select Sorting" [(ngModel)]="selectedSort" (onChange)="updateSortOption($event.value)"></p-select>
|
||||
<div *ngFor="let option of stateOptions" class="field-checkbox">
|
||||
<p-radioButton [inputId]="option.key" [value]="option.value" [(ngModel)]="value" (onClick)="viewChanged($event)"></p-radioButton>
|
||||
<label [for]="option.key" class="ml-2">{{ option.label }}</label>
|
||||
@@ -76,7 +76,7 @@
|
||||
(click)="unshelfBooks()">
|
||||
</p-button>
|
||||
<p-button icon="pi pi-times"
|
||||
label="Deselect"
|
||||
label="Deselect All"
|
||||
severity="warn"
|
||||
(click)="deselectAllBooks()">
|
||||
</p-button>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
<th>Rating</th>
|
||||
<th>Pages</th>
|
||||
<th>Reviews</th>
|
||||
<th><p-tableHeaderCheckbox/></th>
|
||||
<th>
|
||||
<p-tableHeaderCheckbox/>
|
||||
</th>
|
||||
</tr>
|
||||
</ng-template>
|
||||
<ng-template #body let-book>
|
||||
@@ -35,7 +37,12 @@
|
||||
<td class="w-1/12 max-w-28 overflow-hidden truncate">{{ book.metadata?.language }}</td>
|
||||
<td class="w-1/12 max-w-30 overflow-hidden truncate">
|
||||
<ng-container *ngIf="book.metadata">
|
||||
<p-rating [(ngModel)]="book.metadata.rating" readonly stars="5"></p-rating>
|
||||
<p-rating
|
||||
[(ngModel)]="book.metadata.rating"
|
||||
readonly
|
||||
stars="5"
|
||||
[style.--p-rating-icon-active-color]="getStarColor(book.metadata.rating)">
|
||||
</p-rating>
|
||||
</ng-container>
|
||||
</td>
|
||||
<td class="w-1/12 max-w-32 overflow-hidden truncate">{{ book.metadata?.pageCount }}</td>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user