Skip to content

Commit

Permalink
feat: copy solve details to clipboard
Browse files Browse the repository at this point in the history
Co-Authored-By: Miguel García García <15983884+miguelgrc@users.noreply.github.com>
  • Loading branch information
bryanlundberg and miguelgrc committed Dec 20, 2023
1 parent dfd1e72 commit 2752ca5
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/components/solves/ModalSolve.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ export default function ModalSolve() {
setStatus(false);
};

const handleCopyToClipboard = async (text: string) => {
if ("clipboard" in navigator) {
await navigator.clipboard.writeText(text);
}
setStatus(false);
};

return (
<>
<div
Expand Down Expand Up @@ -174,7 +181,14 @@ export default function ModalSolve() {
</div>
<div>Archive</div>
</div>
<div className="flex items-center gap-1 py-1 transition duration-200 ps-2 hover:text-neutral-500 hover:cursor-pointer">
<div
className="flex items-center gap-1 py-1 transition duration-200 ps-2 hover:text-neutral-500 hover:cursor-pointer"
onClick={() =>
handleCopyToClipboard(
`[${formatTime(solve.time)}s] - ${solve.scramble}`
)
}
>
<div className="w-4 h-4">
<DocumentDuplicate />
</div>
Expand Down

0 comments on commit 2752ca5

Please sign in to comment.