-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Misc bug fixes and improvements (#108)
* (feat) Can now copy state and init params to clipboard (fix) Remove spurious debug * (fix) Fix syntax * (fix) Fix compilation and syntax * (fix) Fix the bug induced by the typechecker's last attempt to avoid bugs
- Loading branch information
1 parent
57e0cd6
commit 442568b
Showing
9 changed files
with
149 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { faCopy } from "@fortawesome/free-solid-svg-icons"; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import { FC, PropsWithChildren } from "react"; | ||
import docco from "react-syntax-highlighter/dist/esm/styles/hljs/docco"; | ||
import { SyntaxHighlighter } from "../highlight-init.ts"; | ||
|
||
type HighlightedCodeProps = { | ||
language: string; | ||
content: string; | ||
}; | ||
|
||
export const HighlightedCode: FC<PropsWithChildren<HighlightedCodeProps>> = ({ | ||
language, | ||
content, | ||
}) => { | ||
const handleCopy = () => { | ||
navigator.clipboard.writeText(content ?? ""); | ||
}; | ||
return ( | ||
<div className="relative"> | ||
<SyntaxHighlighter language={language} style={docco} showLineNumbers> | ||
{content ?? ""} | ||
</SyntaxHighlighter> | ||
<button | ||
className="absolute top-2 right-2 border bg-skin-button-fill px-2 py-1 text-sm text-skin-button hover:bg-skin-button-hover-fill focus:outline-none" | ||
type="button" | ||
onClick={handleCopy} | ||
title="Copy to clipboard" | ||
> | ||
<FontAwesomeIcon icon={faCopy} /> | ||
</button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default HighlightedCode; |
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
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