-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added button for hiding debug/dev tools, made debug info ignore curso…
…r events (#484)
- Loading branch information
1 parent
25a23a6
commit 15bf744
Showing
7 changed files
with
108 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
frontend/src/framework/internal/components/ToggleDevToolsButton/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { ToggleDevToolsButton } from "./toggleDevToolsButton"; | ||
export type { ToggleDevToolsButtonProps } from "./toggleDevToolsButton"; |
44 changes: 44 additions & 0 deletions
44
frontend/src/framework/internal/components/ToggleDevToolsButton/toggleDevToolsButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from "react"; | ||
|
||
import { GuiMessageBroker, GuiState, useGuiState } from "@framework/GuiMessageBroker"; | ||
import { isDevMode } from "@lib/utils/devMode"; | ||
import { resolveClassNames } from "@lib/utils/resolveClassNames"; | ||
import { BugReport } from "@mui/icons-material"; | ||
|
||
export type ToggleDevToolsButtonProps = { | ||
guiMessageBroker: GuiMessageBroker; | ||
}; | ||
|
||
export const ToggleDevToolsButton: React.FC<ToggleDevToolsButtonProps> = (props) => { | ||
const [devToolsVisible, setDevToolsVisible] = useGuiState(props.guiMessageBroker, GuiState.DevToolsVisible); | ||
|
||
React.useEffect(() => { | ||
if (!devToolsVisible) { | ||
document.querySelector(".tsqd-parent-container")?.classList.add("hidden"); | ||
} else { | ||
document.querySelector(".tsqd-parent-container")?.classList.remove("hidden"); | ||
} | ||
}, [devToolsVisible]); | ||
|
||
if (!isDevMode()) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div | ||
className={resolveClassNames( | ||
"absolute bottom-2 shadow left-3 z-50 m-2 p-2 rounded-full flex items-center justify-center w-8 h-8 bg-gray-800 text-white text-m cursor-pointer", | ||
{ | ||
"bg-green-700 hover: hover:bg-green-600": devToolsVisible, | ||
"bg-gray-800 hover:bg-gray-700": !devToolsVisible, | ||
} | ||
)} | ||
title={devToolsVisible ? "Hide dev tools" : "Show dev tools"} | ||
onClick={() => { | ||
setDevToolsVisible(!devToolsVisible); | ||
}} | ||
> | ||
<BugReport fontSize="inherit" /> | ||
</div> | ||
); | ||
}; |