starshard/peafowl
Template
1
Fork 0
mirror of https://github.com/starshardstudio/peafowl.git synced 2024-12-01 17:24:17 +00:00
peafowl/_utils/rating.ts

44 lines
903 B
TypeScript
Raw Normal View History

2024-06-16 11:49:13 +00:00
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"
}
}