Skip to content

Commit

Permalink
feat: copy to clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
dlcastillop committed Mar 18, 2023
1 parent 7126e1e commit 06f2c90
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
27 changes: 27 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"preview": "vite preview"
},
"dependencies": {
"copy-to-clipboard": "^3.3.3",
"daisyui": "^2.51.4",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
26 changes: 20 additions & 6 deletions src/components/Payment.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import copy from "copy-to-clipboard";

const Payment = ({ img, label, id, value }) => {
const copyEvent = () => {};
const copyEvent = (e) => {
const tooltip = e.currentTarget;
tooltip.setAttribute("data-tip", "Copied!");

setTimeout(() => {
tooltip.setAttribute("data-tip", "Copy");
}, 3000);

copy(value);
};

return (
<div className="flex justify-between items-center p-4 h-14 sm:mx-0 mx-1 bg-neutral shadow-md rounded-full transition ease-in-out delay-150 sm:hover:scale-105 duration-300">
Expand All @@ -8,12 +19,15 @@ const Payment = ({ img, label, id, value }) => {
{label}
</p>
<div>
<button
className="btn btn-sm bg-neutral border-0 text-neutral-content hover:bg-neutral-focus"
onClick={copyEvent}
<div
className="tooltip tooltip-accent"
data-tip="Copy"
onClick={(e) => copyEvent(e)}
>
<i className="bx bx-copy text-lg"></i>
</button>
<button className="btn btn-sm bg-neutral border-0 text-neutral-content hover:bg-neutral-focus">
<i className="bx bx-copy text-lg"></i>
</button>
</div>
<button className="btn btn-sm bg-neutral border-0 text-neutral-content hover:bg-neutral-focus">
<i className="bx bx-qr text-lg"></i>
</button>
Expand Down

0 comments on commit 06f2c90

Please sign in to comment.