Skip to content

Commit

Permalink
Merge branch 'fix/watcher-copy-to-clipboard' into 'dev'
Browse files Browse the repository at this point in the history
refactor(watcher-app): use react-copy-to-clipboard

Closes #72

See merge request ergo/rosen-bridge/ui!78
  • Loading branch information
vorujack committed Nov 2, 2023
2 parents 56743f8 + 951de9a commit cb303b9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
18 changes: 8 additions & 10 deletions apps/watcher/app/(home)/@address/CopyButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { CopyToClipboard } from 'react-copy-to-clipboard';

import { Copy } from '@rosen-bridge/icons';
import {
Expand Down Expand Up @@ -29,18 +30,15 @@ const CopyButton = ({ address }: CopyButtonProps) => {
setOpen(false);
};

const handleCopy = async () => {
await navigator.clipboard.writeText(address);
setOpen(true);
};

return (
<>
<IconButton onClick={handleCopy} sx={{ borderRadius: 0 }}>
<SvgIcon>
<Copy />
</SvgIcon>
</IconButton>
<CopyToClipboard text={address} onCopy={() => setOpen(true)}>
<IconButton sx={{ borderRadius: 0 }}>
<SvgIcon>
<Copy />
</SvgIcon>
</IconButton>
</CopyToClipboard>
<SuccessfulCopySnackbar open={open} handleClose={handleClose} />
</>
);
Expand Down
3 changes: 2 additions & 1 deletion apps/watcher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@rosen-bridge/icons": "^0.1.0",
"@rosen-bridge/json-bigint": "^0.1.0",
"@rosen-bridge/ui-kit": "^0.1.0",
"@rosen-ui/constants": "^0.0.1",
"@rosen-ui/swr-helpers": "^0.0.1",
Expand All @@ -24,9 +25,9 @@
"next": "13.4.4",
"react": "18.2.0",
"react-apexcharts": "^1.4.0",
"react-copy-to-clipboard": "^5.1.0",
"react-dom": "18.2.0",
"react-hook-form": "^7.45.0",
"@rosen-bridge/json-bigint": "^0.1.0",
"swr": "^2.1.5"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cb303b9

Please sign in to comment.