Skip to content

Commit 4d4ffb7

Browse files
byseif21Miodec
andauthored
fix: some screenshot issues (@byseif21) (#7416)
Co-authored-by: Miodec <jack@monkeytype.com>
1 parent 190f883 commit 4d4ffb7

File tree

5 files changed

+19
-9
lines changed

5 files changed

+19
-9
lines changed

frontend/src/styles/index.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
}
1616
}
1717

18+
// the screenshotting library has some issues with css layers
19+
@import "fonts";
20+
1821
@layer custom-styles {
19-
@import "buttons", "fonts", "404", "ads", "account", "animations", "caret",
22+
@import "buttons", "404", "ads", "account", "animations", "caret",
2023
"commandline", "core", "inputs", "keymap", "login", "monkey", "nav",
2124
"notifications", "popups", "profile", "scroll", "settings",
2225
"account-settings", "leaderboards", "test", "loading", "friends",

frontend/src/styles/vendor.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
@import "normalize.css" layer(normalize);
1+
@import "fontawesome-5"; // the screenshotting library has some issues with css layers
22

3+
@import "normalize.css" layer(normalize);
34
@layer vendor {
4-
@import "fontawesome-5";
55
@import "slim-select/styles";
66
@import "balloon-css/src/balloon";
77
}

frontend/src/ts/components/layout/overlays/Overlays.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { JSXElement } from "solid-js";
22

3+
import { getIsScreenshotting } from "../../../signals/core";
34
import { showModal } from "../../../stores/modals";
5+
import { cn } from "../../../utils/cn";
46
import { ScrollToTop } from "../footer/ScrollToTop";
57

68
import { Banners } from "./Banners";
@@ -15,7 +17,12 @@ export function Overlays(): JSXElement {
1517
<button
1618
type="button"
1719
id="commandLineMobileButton"
18-
class="bg-main text-bg fixed bottom-8 left-8 z-99 hidden h-12 w-12 rounded-full text-center leading-12"
20+
class={cn(
21+
"bg-main text-bg fixed bottom-8 left-8 z-99 hidden h-12 w-12 rounded-full text-center leading-12",
22+
{
23+
"opacity-0": getIsScreenshotting(),
24+
},
25+
)}
1926
onClick={() => {
2027
showModal("Commandline");
2128
}}

frontend/src/ts/signals/core.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ export const [getCommandlineSubgroup, setCommandlineSubgroup] = createSignal<
2828

2929
export const [getFocus, setFocus] = createSignal(false);
3030
export const [getGlobalOffsetTop, setGlobalOffsetTop] = createSignal(0);
31+
export const [getIsScreenshotting, setIsScreenshotting] = createSignal(false);

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { isAuthenticated } from "../firebase";
55
import { getActiveFunboxesWithFunction } from "./funbox/list";
66
import * as DB from "../db";
77
import { format } from "date-fns/format";
8-
import { getActivePage } from "../signals/core";
8+
import { getActivePage, setIsScreenshotting } from "../signals/core";
99
import { getHtmlByUserFlags } from "../controllers/user-flag-controller";
1010
import * as Notifications from "../elements/notifications";
1111
import { convertRemToPixels } from "../utils/numbers";
@@ -17,13 +17,13 @@ let revealReplay = false;
1717
let revertCookie = false;
1818

1919
function revert(): void {
20+
setIsScreenshotting(false);
2021
hideLoaderBar();
2122
qs("#ad-result-wrapper")?.show();
2223
qs("#ad-result-small-wrapper")?.show();
2324
qs("#testConfig")?.show();
2425
qs(".pageTest .screenshotSpacer")?.remove();
2526
qs("#notificationCenter")?.show();
26-
qs("#commandLineMobileButton")?.show();
2727
qs(".pageTest .ssWatermark")?.hide();
2828
qs(".pageTest .ssWatermark")?.setText("monkeytype.com"); // Reset watermark text
2929
qs(".pageTest .buttons")?.show();
@@ -84,9 +84,10 @@ async function generateCanvas(): Promise<HTMLCanvasElement | null> {
8484
.map((el) => `<span>${el}</span>`)
8585
.join("<span class='pipe'>|</span>"),
8686
);
87+
88+
setIsScreenshotting(true);
8789
qs(".pageTest .buttons")?.hide();
8890
qs("#notificationCenter")?.hide();
89-
qs("#commandLineMobileButton")?.hide();
9091
qs(".pageTest .loginTip")?.hide();
9192
qs("noscript")?.hide();
9293
qs("#nocss")?.hide();
@@ -122,8 +123,6 @@ async function generateCanvas(): Promise<HTMLCanvasElement | null> {
122123
const sourceX = src.screenBounds().left ?? 0;
123124
const sourceY = src.screenBounds().top ?? 0;
124125

125-
console.log(sourceX, sourceY);
126-
127126
const sourceWidth = src.getOuterWidth();
128127
const sourceHeight = src.getOuterHeight();
129128
const paddingX = convertRemToPixels(2);

0 commit comments

Comments
 (0)