You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
802 B
33 lines
802 B
9 years ago
|
import React from 'react';
|
||
|
import CopyToClipboard from 'react-copy-to-clipboard';
|
||
9 years ago
|
import { Icon } from 'antd';
|
||
9 years ago
|
|
||
|
export default class CopyableIcon extends React.Component {
|
||
|
constructor(props) {
|
||
|
super(props);
|
||
|
this.state = {
|
||
9 years ago
|
justCopied: false,
|
||
9 years ago
|
};
|
||
|
}
|
||
|
|
||
|
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>
|
||
|
);
|
||
|
}
|
||
|
}
|