mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-16 05:56:47 +01:00
25 lines
611 B
TypeScript
25 lines
611 B
TypeScript
import { useClipboardText } from '../hooks/useClipboardText';
|
|
import { useTimedBoolean } from '../hooks/useTimedBoolean';
|
|
import type { ButtonProps } from './core/Button';
|
|
import { Button } from './core/Button';
|
|
|
|
interface Props extends ButtonProps {
|
|
text: string;
|
|
}
|
|
|
|
export function CopyButton({ text, ...props }: Props) {
|
|
const [, copy] = useClipboardText({ disableToast: true });
|
|
const [copied, setCopied] = useTimedBoolean();
|
|
return (
|
|
<Button
|
|
{...props}
|
|
onClick={() => {
|
|
copy(text);
|
|
setCopied();
|
|
}}
|
|
>
|
|
{copied ? 'Copied' : 'Copy'}
|
|
</Button>
|
|
);
|
|
}
|