Skip to content

Commit 1e68c02

Browse files
committed
add flash for mini
1 parent 2b2fa3c commit 1e68c02

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

frontend/src/ts/test/timer-progress.ts

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,15 @@ export function show(): void {
3636
textEl.classList.remove("hidden");
3737
},
3838
});
39-
} else if (Config.timerStyle === "flash") {
39+
} else if (Config.timerStyle === "flash mini") {
40+
animate(miniEl, {
41+
opacity: [0, 1],
42+
duration: applyReducedMotion(125),
43+
onBegin: () => {
44+
miniEl.classList.remove("hidden");
45+
},
46+
});
47+
} else if (Config.timerStyle === "flash text") {
4048
animate(textEl, {
4149
opacity: [0, 1],
4250
duration: applyReducedMotion(125),
@@ -132,7 +140,18 @@ export function update(): void {
132140
if (textEl !== null) {
133141
textEl.innerHTML = "<div>" + displayTime + "</div>";
134142
}
135-
} else if (Config.timerStyle === "flash") {
143+
} else if (Config.timerStyle === "flash mini") {
144+
let displayTime = DateTime.secondsToString(maxtime - time);
145+
if (maxtime === 0) {
146+
displayTime = DateTime.secondsToString(time);
147+
}
148+
if (miniEl !== null) {
149+
miniEl.innerHTML =
150+
"<div>" +
151+
`${(maxtime - time) % 15 !== 0 ? "" : displayTime}` +
152+
"</div>";
153+
}
154+
} else if (Config.timerStyle === "flash text") {
136155
let displayTime = DateTime.secondsToString(maxtime - time);
137156
if (maxtime === 0) {
138157
displayTime = DateTime.secondsToString(time);
@@ -182,7 +201,13 @@ export function update(): void {
182201
} else {
183202
textEl.innerHTML = `<div>${getCurrentCount()}/${outof}</div>`;
184203
}
185-
} else if (Config.timerStyle === "flash") {
204+
} else if (Config.timerStyle === "flash mini") {
205+
if (outof === 0) {
206+
miniEl.innerHTML = `${TestInput.input.getHistory().length}`;
207+
} else {
208+
miniEl.innerHTML = `${getCurrentCount()}/${outof}`;
209+
}
210+
} else if (Config.timerStyle === "flash text") {
186211
if (outof === 0) {
187212
textEl.innerHTML = `<div>${TestInput.input.getHistory().length}</div>`;
188213
} else {
@@ -198,7 +223,9 @@ export function update(): void {
198223
} else if (Config.mode === "zen") {
199224
if (Config.timerStyle === "text") {
200225
textEl.innerHTML = `<div>${TestInput.input.getHistory().length}</div>`;
201-
} else if (Config.timerStyle === "flash") {
226+
} else if (Config.timerStyle === "flash mini") {
227+
miniEl.innerHTML = `${TestInput.input.getHistory().length}`;
228+
} else if (Config.timerStyle === "flash text") {
202229
textEl.innerHTML = `<div>${TestInput.input.getHistory().length}</div>`;
203230
} else {
204231
miniEl.innerHTML = `${TestInput.input.getHistory().length}`;

packages/schemas/src/configs.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@ export type ConfidenceMode = z.infer<typeof ConfidenceModeSchema>;
5454
export const IndicateTyposSchema = z.enum(["off", "below", "replace", "both"]);
5555
export type IndicateTypos = z.infer<typeof IndicateTyposSchema>;
5656

57-
export const TimerStyleSchema = z.enum(["off", "bar", "text", "mini", "flash"]);
57+
export const TimerStyleSchema = z.enum([
58+
"off",
59+
"bar",
60+
"text",
61+
"mini",
62+
"flash text",
63+
"flash mini",
64+
]);
5865
export type TimerStyle = z.infer<typeof TimerStyleSchema>;
5966

6067
export const LiveSpeedAccBurstStyleSchema = z.enum(["off", "text", "mini"]);

0 commit comments

Comments
 (0)