openreplay/frontend/app/components/ui/CopyButton/CopyButton.js
Andrey Babushkin fd5c0c9747
Add lokalisation (#3092)
* applied eslint

* add locales and lint the project

* removed error boundary

* updated locales

* fix min files

* fix locales
2025-03-06 17:43:15 +01:00

34 lines
663 B
JavaScript

import React, { useState } from 'react';
import copy from 'copy-to-clipboard';
import { Button } from 'antd';
function CopyButton({
content,
variant = 'text',
className = 'capitalize mt-2 font-medium text-neutral-400',
btnText = 'copy',
size = 'small',
}) {
const [copied, setCopied] = useState(false);
const copyHandler = () => {
setCopied(true);
copy(content);
setTimeout(() => {
setCopied(false);
}, 1000);
};
return (
<Button
type={variant}
onClick={copyHandler}
size={size}
className={className}
>
{copied ? 'copied' : btnText}
</Button>
);
}
export default CopyButton;