Files
bee-dashboard/src/components/ClipboardCopy.tsx
T
Vojtech Simetka bec84051a9 feat: unified notification with notistack (#127)
* feat: unified existing notification with notistack

* chore: replaced with useSnackbar, added missing notifications

* chore: removed FIXME as per PR review
2021-06-02 13:36:39 +02:00

25 lines
772 B
TypeScript

import type { ReactElement } from 'react'
import IconButton from '@material-ui/core/IconButton'
import { CopyToClipboard } from 'react-copy-to-clipboard'
import { Clipboard } from 'react-feather'
import { useSnackbar } from 'notistack'
interface Props {
value: string
}
export default function ClipboardCopy({ value }: Props): ReactElement {
const { enqueueSnackbar } = useSnackbar()
const handleCopy = () => enqueueSnackbar(`Copied: ${value}`, { variant: 'success' })
return (
<div style={{ marginRight: '3px', marginLeft: '3px' }}>
<IconButton color="primary" size="small" onClick={handleCopy}>
<CopyToClipboard text={value}>
<Clipboard style={{ height: '20px' }} />
</CopyToClipboard>
</IconButton>
</div>
)
}