HRM-10/HRM.UI/ClientApp/src/app/helper/rating.component.ts

32 lines
804 B
TypeScript
Raw Normal View History

2026-11-03 13:06:00 +06:00
import { Component, OnInit, Input, ChangeDetectionStrategy } from '@angular/core';
@Component({
selector: 'kendo-rating',
template: `
@for (item of stars; track item) {
<span [ngClass]="ratingIcon(item)"></span>
}
`,
styles: [`
.yellow {
color: #ffa600;
}
`],
changeDetection: ChangeDetectionStrategy.Eager,
standalone: false,
})
export class RatingComponent implements OnInit {
@Input() public value: number;
@Input() public max: number;
public stars: number[];
public ngOnInit(): void {
this.stars = new Array(this.max).fill(1).map((item, index) => item + index);
}
public ratingIcon(item: number): string {
return (item <= this.value) ? 'k-icon k-i-star yellow' : 'k-icon k-i-star-outline';
}
}