Skip to content

Commit 3724389

Browse files
raaid3Miodec
andauthored
impr(test-screenshot): Show download screenshot button when holding shift on result page (@raaid3) (monkeytypegame#6673)
### Description Previously, if you shift clicked on the `copy screenshot` button, you could download a screenshot. But many users probably don't know about this because it's not mentioned anywhere on the result page and there are no visual indicators hinting at there being such a feature. So I added a "(shift click to download)" message to the `aria-label` of the `#saveScreenshot` button. I also added the ability for the icon inside the button to switch to `fa-download` when shift is held as a visual indicator that clicking the button would download a screenshot. --------- Co-authored-by: Miodec <[email protected]>
1 parent afbff1b commit 3724389

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

frontend/src/html/pages/test.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,10 @@
447447
<button
448448
class="text"
449449
id="saveScreenshotButton"
450-
aria-label="Copy screenshot to clipboard"
450+
aria-label="Copy screenshot to clipboard&#10;(shift click to download)"
451451
role="button"
452452
data-balloon-pos="down"
453+
data-balloon-break
453454
>
454455
<i class="far fa-fw fa-image"></i>
455456
</button>

frontend/src/ts/test/test-screenshot.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { getActiveFunboxesWithFunction } from "./funbox/list";
66
import * as DB from "../db";
77
import * as ThemeColors from "../elements/theme-colors";
88
import { format } from "date-fns/format";
9-
9+
import * as TestUI from "./test-ui";
10+
import * as ActivePage from "../states/active-page";
1011
import { getHtmlByUserFlags } from "../controllers/user-flag-controller";
1112
import * as Notifications from "../elements/notifications";
1213
import { convertRemToPixels } from "../utils/numbers";
@@ -281,4 +282,25 @@ $(".pageTest").on("click", "#saveScreenshotButton", (event) => {
281282
} else {
282283
void copyToClipboard();
283284
}
285+
286+
// reset save screenshot button icon
287+
$("#saveScreenshotButton i")
288+
.removeClass("fas fa-download")
289+
.addClass("far fa-image");
290+
});
291+
292+
$(document).on("keydown", (event) => {
293+
if (!(TestUI.resultVisible && ActivePage.get() === "test")) return;
294+
if (event.key !== "Shift") return;
295+
$("#typingTest #result #saveScreenshotButton i")
296+
.removeClass("far fa-image")
297+
.addClass("fas fa-download");
298+
});
299+
300+
$(document).on("keyup", (event) => {
301+
if (!(TestUI.resultVisible && ActivePage.get() === "test")) return;
302+
if (event.key !== "Shift") return;
303+
$("#typingTest #result #saveScreenshotButton i")
304+
.removeClass("fas fa-download")
305+
.addClass("far fa-image");
284306
});

0 commit comments

Comments
 (0)