mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-20 04:24:29 +08:00
ff31a5b555
This reverts commit 7a07b128d1
.
33 lines
802 B
JavaScript
33 lines
802 B
JavaScript
import React from 'react';
|
|
import CopyToClipboard from 'react-copy-to-clipboard';
|
|
import { Icon } from 'antd';
|
|
|
|
export default class CopyableIcon extends React.Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
justCopied: false,
|
|
};
|
|
}
|
|
|
|
onCopied = () => {
|
|
this.setState({ justCopied: true }, () => {
|
|
setTimeout(() => {
|
|
this.setState({ justCopied: false });
|
|
}, 1000);
|
|
});
|
|
}
|
|
|
|
render() {
|
|
const text = `<Icon type="${this.props.type}" />`;
|
|
return (
|
|
<CopyToClipboard text={text} onCopy={this.onCopied}>
|
|
<li className={this.state.justCopied ? 'copied' : ''}>
|
|
<Icon type={this.props.type} />
|
|
<span className="anticon-class">{this.props.type}</span>
|
|
</li>
|
|
</CopyToClipboard>
|
|
);
|
|
}
|
|
}
|