import React from 'react';
import PropTypes from 'prop-types';
import { Tooltip, message } from 'antd';
import { CopyToClipboard } from 'react-copy-to-clipboard';
import { CopyOutlined } from '@ant-design/icons';
import classNames from 'classnames';
const style = { fontSize: 14, color: '#999' };
ClipBoard.propTypes = {
value: PropTypes.string.isRequired,
className: PropTypes.string,
};
function ClipBoard({ value, className }) {
function onCopy() {
message.destroy();
message.success('复制成功');
}
const _class = classNames({
[className]: Boolean(className),
});
return (
<CopyToClipboard
text={value}
onCopy={onCopy}>
<Tooltip title='复制'>
<CopyOutlined className={_class} style={style} />
</Tooltip>
</CopyToClipboard>
);
}
export default ClipBoard;