starshard/peafowl
Template
1
Fork 0
mirror of https://github.com/starshardstudio/peafowl.git synced 2024-11-24 22:14:19 +00:00
peafowl/_utils/rating.ts
2024-07-01 16:44:56 +02:00

43 lines
903 B
TypeScript

export type Rating = number
export function ratingToIconDef(rating?: Rating): string {
if(rating === undefined) {
return "fa-face-meh-blank"
}
else if(rating == 0) {
return "fa-face-meh-blank"
}
else if(rating < 35) {
return "fa-face-frown"
}
else if(rating < 65) {
return "fa-face-meh"
}
else if(rating < 95) {
return "fa-face-smile"
}
else {
return "fa-face-grin-stars"
}
}
export function ratingToClassName(rating?: Rating): string {
if(rating === undefined) {
return "rating-unset"
}
else if(rating === 0) {
return "rating-unset"
}
else if(rating < 35) {
return "rating-bad"
}
else if(rating < 65) {
return "rating-mixed"
}
else if(rating < 95) {
return "rating-good"
}
else {
return "rating-perfect"
}
}