openreplay/frontend/app/components/shared/CopyText/CopyText.tsx
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

31 lines
701 B
TypeScript

import React, { useState } from 'react';
import { Tooltip } from 'antd';
import copy from 'copy-to-clipboard';
interface Props {
label?: string;
afterLabel?: string;
children: any;
content: string;
}
function CopyText(props: Props) {
const {
children,
label = 'Click to copy',
afterLabel = 'Copied',
content = '',
} = props;
const [isCopied, setIsCopied] = useState(false);
const onClick = () => {
copy(content);
setIsCopied(true);
setTimeout(() => setIsCopied(false), 5000);
};
return (
<Tooltip title={isCopied ? afterLabel : label} placement="top">
<span onClick={onClick}>{children}</span>
</Tooltip>
);
}
export default CopyText;