-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed modal and added copy functionality
- Loading branch information
1 parent
2ac0718
commit ecbd3ee
Showing
8 changed files
with
101 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { useState } from "react"; | ||
import { useAppContext } from "../contexts/AppContext"; | ||
import Button from "./Button"; | ||
import { CopyIcon } from "./Icons"; | ||
|
||
const CopyToClipboard = ({ ...props }) => { | ||
const { snippet } = useAppContext(); | ||
const [isCopied, setIsCopied] = useState(false); | ||
|
||
const snippetCode = snippet ? snippet.code : ""; | ||
|
||
const copySnippetCode = () => { | ||
navigator.clipboard | ||
.writeText(snippetCode) | ||
.then(() => { | ||
setIsCopied(true); | ||
setTimeout(() => setIsCopied(false), 2000); | ||
}) | ||
.catch((err) => alert("Error occured: " + err)); | ||
}; | ||
|
||
return ( | ||
<Button isIcon={true} onClick={copySnippetCode} {...props}> | ||
{isCopied ? "Copied!" : <CopyIcon />} | ||
</Button> | ||
); | ||
}; | ||
|
||
export default CopyToClipboard; |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import { Link } from "react-router-dom"; | ||
import { LogoIcon } from "./Icons"; | ||
|
||
const Logo = () => { | ||
|
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