fix rating

This commit is contained in:
csimonis 2024-09-24 08:34:17 +02:00
parent 27feb24461
commit 25abd00a4c

View file

@ -6,13 +6,11 @@ import {Component, Input} from '@angular/core';
imports: [], imports: [],
template: ` template: `
@for (_ of getList(); track null) { @for (_ of getList(); track null) {
test <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" color="yellow"><path fill="currentColor" d="m5.825 21l1.625-7.025L2 9.25l7.2-.625L12 2l2.8 6.625l7.2.625l-5.45 4.725L18.175 21L12 17.275z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="m5.825 21l1.625-7.025L2 9.25l7.2-.625L12 2l2.8 6.625l7.2.625l-5.45 4.725L18.175 21L12 17.275z"/></svg>
} }
@if (rating % 1 >= 0.5) { @if (rating % 1 >= 0.5) {
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="m15.15 16.85l-.825-3.6l2.775-2.4l-3.65-.325l-1.45-3.4v7.8zM5.825 21l1.625-7.025L2 9.25l7.2-.625L12 2l2.8 6.625l7.2.625l-5.45 4.725L18.175 21L12 17.275z"/></svg> <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" color="yellow"><path fill="currentColor" d="M12 2L9.19 8.62L2 9.24l5.45 4.73L5.82 21L12 17.27z"/></svg>
} }
`, `,
}) })
export class StarComponent { export class StarComponent {
@ -20,8 +18,11 @@ export class StarComponent {
public rating: number = 0; public rating: number = 0;
public getList(): null[] { public getList(): null[] {
console.log(this.rating) let rating = this.rating;
console.log(Array(this.rating).fill(null)) if (rating % 1 !== 0) {
return Array(this.rating).fill(null); rating = this.rating - 0.5;
}
return Array(rating).fill(null);
} }
} }