fix rating
This commit is contained in:
parent
27feb24461
commit
25abd00a4c
1 changed files with 8 additions and 7 deletions
|
@ -6,13 +6,11 @@ import {Component, Input} from '@angular/core';
|
|||
imports: [],
|
||||
template: `
|
||||
@for (_ of getList(); track null) {
|
||||
test
|
||||
<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>
|
||||
<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>
|
||||
}
|
||||
@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 {
|
||||
|
@ -20,8 +18,11 @@ export class StarComponent {
|
|||
public rating: number = 0;
|
||||
|
||||
public getList(): null[] {
|
||||
console.log(this.rating)
|
||||
console.log(Array(this.rating).fill(null))
|
||||
return Array(this.rating).fill(null);
|
||||
let rating = this.rating;
|
||||
if (rating % 1 !== 0) {
|
||||
rating = this.rating - 0.5;
|
||||
}
|
||||
|
||||
return Array(rating).fill(null);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue