bc01d60728
* style: add eslint configuration as per bee-js * chore: add `plugin:react/reocommended` in `.eslintrc` Co-authored-by: nugaon <50576770+nugaon@users.noreply.github.com> * chore: add `consistent` to `array-bracket-newline` as per review * style: after automatic fixes with `npm run lint` * style: fixed all linter errors * refactor: fixed all linter warnings * chore: added missing new line at end of `.prettierrc` file Co-authored-by: nugaon <50576770+nugaon@users.noreply.github.com>
29 lines
863 B
TypeScript
29 lines
863 B
TypeScript
import { ReactElement, useState } from 'react'
|
|
import { IconButton, Snackbar } from '@material-ui/core'
|
|
import { CopyToClipboard } from 'react-copy-to-clipboard'
|
|
import { Clipboard } from 'react-feather'
|
|
|
|
interface Props {
|
|
value: string
|
|
}
|
|
|
|
export default function ClipboardCopy(props: Props): ReactElement {
|
|
const [copied, setCopied] = useState(false)
|
|
|
|
const handleCopy = () => {
|
|
setCopied(true)
|
|
setTimeout(() => setCopied(false), 3000)
|
|
}
|
|
|
|
return (
|
|
<div style={{ marginRight: '3px', marginLeft: '3px' }}>
|
|
<Snackbar anchorOrigin={{ vertical: 'top', horizontal: 'center' }} open={copied} message="Copied" />
|
|
<IconButton color="primary" size="small" onClick={handleCopy}>
|
|
<CopyToClipboard text={props.value}>
|
|
<Clipboard style={{ height: '20px' }} />
|
|
</CopyToClipboard>
|
|
</IconButton>
|
|
</div>
|
|
)
|
|
}
|