mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-11 17:46:41 -05:00
Better handling of large responses
This commit is contained in:
24
src-web/components/CopyButton.tsx
Normal file
24
src-web/components/CopyButton.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user