-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: copy button * fix: styling * fix: tooltip * fix: removed header * fix: add parisnet examples
- Loading branch information
1 parent
d66563d
commit b56e869
Showing
9 changed files
with
1,062 additions
and
1,197 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { useState } from "react"; | ||
import { useColorMode } from "@docusaurus/theme-common"; | ||
import "../styles.module.css"; | ||
|
||
const CopyButton = ({ text }) => { | ||
const [isCopied, setIsCopied] = useState(false); | ||
const { colorMode } = useColorMode(); | ||
|
||
return ( | ||
<> | ||
<button | ||
type="button" | ||
title="Copy code to clipboard" | ||
style={{ | ||
backgroundColor: "transparent", | ||
border: "none", | ||
cursor: "pointer", | ||
}} | ||
onClick={() => { | ||
navigator.clipboard.writeText(text).then(() => { | ||
setIsCopied(true); | ||
setTimeout(() => setIsCopied(false), 3000); | ||
}); | ||
}} | ||
> | ||
<span style={{ display: "inline-block" }} aria-hidden="true"> | ||
{!isCopied ? ( | ||
<> | ||
<svg style={{ maxWidth: "24px", maxHeight: "24px" }}> | ||
<path | ||
fill={colorMode === "dark" ? "#000" : "#fff"} | ||
d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z" | ||
></path> | ||
</svg> | ||
</> | ||
) : ( | ||
<svg | ||
fill={colorMode === "dark" ? "#000" : "#fff"} | ||
width="24px" | ||
height="24px" | ||
style={{ maxWidth: "24px", maxHeight: "24px" }} | ||
> | ||
<path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" /> | ||
</svg> | ||
)} | ||
</span> | ||
</button> | ||
</> | ||
); | ||
}; | ||
export default CopyButton; |
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