Colors for stars
This commit is contained in:
@@ -46,6 +46,7 @@ import {MultiSelectModule} from 'primeng/multiselect';
|
|||||||
import {SelectButton} from "primeng/selectbutton";
|
import {SelectButton} from "primeng/selectbutton";
|
||||||
import {BookTableComponent} from './book/component/book-table/book-table.component';
|
import {BookTableComponent} from './book/component/book-table/book-table.component';
|
||||||
import {RadioButton} from 'primeng/radiobutton';
|
import {RadioButton} from 'primeng/radiobutton';
|
||||||
|
import {Select} from 'primeng/select';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@@ -88,7 +89,8 @@ import {RadioButton} from 'primeng/radiobutton';
|
|||||||
MultiSelectModule,
|
MultiSelectModule,
|
||||||
SelectButton,
|
SelectButton,
|
||||||
BookTableComponent,
|
BookTableComponent,
|
||||||
RadioButton
|
RadioButton,
|
||||||
|
Select
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
DialogService,
|
DialogService,
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
<div class="header-right-items">
|
<div class="header-right-items">
|
||||||
<input type="text" pInputText placeholder="Search by title..." [(ngModel)]="bookTitle" (ngModelChange)="onBookTitleChange($event)"/>
|
<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">
|
<div *ngFor="let option of stateOptions" class="field-checkbox">
|
||||||
<p-radioButton [inputId]="option.key" [value]="option.value" [(ngModel)]="value" (onClick)="viewChanged($event)"></p-radioButton>
|
<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>
|
<label [for]="option.key" class="ml-2">{{ option.label }}</label>
|
||||||
@@ -76,7 +76,7 @@
|
|||||||
(click)="unshelfBooks()">
|
(click)="unshelfBooks()">
|
||||||
</p-button>
|
</p-button>
|
||||||
<p-button icon="pi pi-times"
|
<p-button icon="pi pi-times"
|
||||||
label="Deselect"
|
label="Deselect All"
|
||||||
severity="warn"
|
severity="warn"
|
||||||
(click)="deselectAllBooks()">
|
(click)="deselectAllBooks()">
|
||||||
</p-button>
|
</p-button>
|
||||||
|
|||||||
@@ -69,8 +69,8 @@
|
|||||||
.book-browser-footer {
|
.book-browser-footer {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 37%;
|
left: 38%;
|
||||||
right: 37%;
|
right: 38%;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 1.1rem;
|
padding: 1.1rem;
|
||||||
@@ -104,6 +104,6 @@
|
|||||||
.footer-items-container {
|
.footer-items-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
gap: 1.5rem;
|
gap: 2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,9 @@
|
|||||||
<th>Rating</th>
|
<th>Rating</th>
|
||||||
<th>Pages</th>
|
<th>Pages</th>
|
||||||
<th>Reviews</th>
|
<th>Reviews</th>
|
||||||
<th><p-tableHeaderCheckbox/></th>
|
<th>
|
||||||
|
<p-tableHeaderCheckbox/>
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
<ng-template #body let-book>
|
<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-28 overflow-hidden truncate">{{ book.metadata?.language }}</td>
|
||||||
<td class="w-1/12 max-w-30 overflow-hidden truncate">
|
<td class="w-1/12 max-w-30 overflow-hidden truncate">
|
||||||
<ng-container *ngIf="book.metadata">
|
<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>
|
</ng-container>
|
||||||
</td>
|
</td>
|
||||||
<td class="w-1/12 max-w-32 overflow-hidden truncate">{{ book.metadata?.pageCount }}</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 {AfterContentChecked, AfterViewChecked, AfterViewInit, Component, EventEmitter, Input, NgZone, OnChanges, Output} from '@angular/core';
|
||||||
import {TableModule} from 'primeng/table';
|
import {TableModule} from 'primeng/table';
|
||||||
import {NgIf} from '@angular/common';
|
import {NgClass, NgIf} from '@angular/common';
|
||||||
import {BookService} from '../../service/book.service';
|
import {BookService} from '../../service/book.service';
|
||||||
import {Rating} from 'primeng/rating';
|
import {Rating} from 'primeng/rating';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
@@ -17,7 +17,8 @@ import {SortDirection, SortOption} from '../../model/sort.model';
|
|||||||
TableModule,
|
TableModule,
|
||||||
NgIf,
|
NgIf,
|
||||||
Rating,
|
Rating,
|
||||||
FormsModule
|
FormsModule,
|
||||||
|
NgClass
|
||||||
],
|
],
|
||||||
styleUrl: './book-table.component.scss'
|
styleUrl: './book-table.component.scss'
|
||||||
})
|
})
|
||||||
@@ -98,9 +99,17 @@ export class BookTableComponent implements OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
testzzz($event: any) {
|
getStarColor(rating: number): string {
|
||||||
console.log($event)
|
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