-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1433 from SenseNet/release/2022-08
- Loading branch information
Showing
105 changed files
with
11,282 additions
and
3,945 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,43 @@ | ||
import Button from '@material-ui/core/Button' | ||
import CheckCircleOutlineOutlinedIcon from '@material-ui/icons/CheckCircleOutlineOutlined' | ||
import FileCopyOutlinedIcon from '@material-ui/icons/FileCopyOutlined' | ||
import React, { useState } from 'react' | ||
|
||
type Props = { copyText: string } | ||
|
||
const CopyPath = ({ copyText }: Props) => { | ||
const [isCopied, setIsCopied] = useState(false) | ||
|
||
const copyTextToClipboard = async (text: string) => { | ||
if ('clipboard' in navigator) { | ||
return await navigator.clipboard.writeText(text) | ||
} else { | ||
return document.execCommand('copy', true, text) | ||
} | ||
} | ||
|
||
const handleCopyClick = () => { | ||
copyTextToClipboard(copyText) | ||
.then(() => { | ||
setIsCopied(true) | ||
setTimeout(() => { | ||
setIsCopied(false) | ||
}, 1500) | ||
}) | ||
.catch((err) => { | ||
console.log(err) | ||
}) | ||
} | ||
|
||
return ( | ||
<div> | ||
<Button onClick={handleCopyClick}> | ||
<span> | ||
{isCopied ? <CheckCircleOutlineOutlinedIcon style={{ color: 'lightgreen' }} /> : <FileCopyOutlinedIcon />} | ||
</span> | ||
</Button> | ||
</div> | ||
) | ||
} | ||
|
||
export default CopyPath |
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
Oops, something went wrong.