Refactor buttons

This commit is contained in:
Robert Long
2021-12-07 11:59:57 -08:00
parent db1fb064ca
commit 4cb144809f
19 changed files with 313 additions and 622 deletions

25
src/button/CopyButton.jsx Normal file
View File

@@ -0,0 +1,25 @@
import React from "react";
import useClipboard from "react-use-clipboard";
import { ReactComponent as CheckIcon } from "../icons/Check.svg";
import { ReactComponent as CopyIcon } from "../icons/Copy.svg";
import { Button } from "./Button";
export function CopyButton({ value, children, ...rest }) {
const [isCopied, setCopied] = useClipboard(value, { successDuration: 3000 });
return (
<Button {...rest} variant="copy" on={isCopied} onPress={setCopied}>
{isCopied ? (
<>
<span>Copied!</span>
<CheckIcon />
</>
) : (
<>
<span>{children || value}</span>
<CopyIcon />
</>
)}
</Button>
);
}