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.

36 lines
867 B

import React from 'react';
import CopyToClipboard from 'react-copy-to-clipboard';
7 years ago
import { Icon, Badge } from 'antd';
export default class CopyableIcon extends React.Component {
7 years ago
state = {
justCopied: false,
};
onCopied = () => {
this.setState({ justCopied: true }, () => {
setTimeout(() => {
this.setState({ justCopied: false });
}, 2000);
});
}
render() {
7 years ago
const { type, isNew } = this.props;
const { justCopied } = this.state;
7 years ago
const text = `<Icon type="${type}" />`;
return (
<CopyToClipboard text={text} onCopy={this.onCopied}>
<li className={justCopied ? 'copied' : ''}>
7 years ago
<Icon type={type} />
<span className="anticon-class">
<Badge dot={isNew}>
{type}
</Badge>
</span>
</li>
</CopyToClipboard>
);
}
}