refactor: update crown type names

This commit is contained in:
Miodec 2024-05-28 18:20:31 +02:00
parent 5306d6fe2c
commit a279744ef3
2 changed files with 11 additions and 6 deletions

View file

@ -3,7 +3,12 @@ export function hide(): void {
$("#result .stats .wpm .crown").css("opacity", 0).addClass("hidden");
}
export type CrownType = "normal" | "broken" | "half" | "error" | "warning";
export type CrownType =
| "normal"
| "ineligible"
| "pending"
| "error"
| "warning";
let visible = false;
let currentType: CrownType = "normal";
@ -28,8 +33,8 @@ export function show(): void {
export function update(type: CrownType): void {
currentType = type;
const el = $("#result .stats .wpm .crown");
el.removeClass("broken");
el.removeClass("half");
el.removeClass("ineligible");
el.removeClass("pending");
el.removeClass("error");
el.removeClass("warning");
el.addClass(type);

View file

@ -397,7 +397,7 @@ export async function updateCrown(dontSave: boolean): Promise<void> {
hideCrown();
} else {
//show half crown as the pb is not confirmed by the server
showCrown("half");
showCrown("pending");
$("#result .stats .wpm .crown").attr(
"aria-label",
"+" + Format.typingSpeed(pbDiff, { showDecimalPlaces: true })
@ -423,7 +423,7 @@ export async function updateCrown(dontSave: boolean): Promise<void> {
`This result is not eligible for a new PB (${canGetPb.reason})`
);
} else {
showCrown("broken");
showCrown("ineligible");
$("#result .stats .wpm .crown").attr(
"aria-label",
`You could've gotten a new PB (+${Format.typingSpeed(pbDiff, {
@ -440,7 +440,7 @@ export function hideCrown(): void {
}
export function showErrorCrownIfNeeded(): void {
if (PbCrown.getCurrentType() !== "half") return;
if (PbCrown.getCurrentType() !== "pending") return;
PbCrown.show();
PbCrown.update("error");
$("#result .stats .wpm .crown").attr(