Commit 9c9f34a0 authored by Amaury Martiny's avatar Amaury Martiny

Remove react-tooltip

parent 739f1eff
......@@ -54,7 +54,6 @@
"react-markdown": "^3.3.4",
"react-router-dom": "^4.2.2",
"react-scripts": "1.1.4",
"react-tooltip": "^3.6.1",
"recompose": "^0.27.1",
"rxjs": "^6.2.0"
},
......
......@@ -33,7 +33,6 @@
"dependencies": {
"react-blockies": "^1.3.0",
"react-content-loader": "^3.1.2",
"react-tooltip": "^3.6.1",
"semantic-ui-css": "^2.3.2",
"semantic-ui-react": "^0.81.3"
},
......
......@@ -4,8 +4,9 @@
// SPDX-License-Identifier: BSD-3-Clause
import React, { PureComponent } from 'react';
import { Popup } from 'semantic-ui-react';
import PropTypes from 'prop-types';
import ReactTooltip from 'react-tooltip';
import 'semantic-ui-css/components/popup.min.css';
export class ClickToCopy extends PureComponent {
static defaultProps = {
......@@ -21,10 +22,6 @@ export class ClickToCopy extends PureComponent {
copied: false
};
componentWillUnmount () {
window.clearTimeout(this.timeout);
}
handleCopy = () => {
// https://hackernoon.com/copying-text-to-clipboard-with-javascript-df4d4988697f
// Note react-copy-to-clipboard created a bug, https://github.com/nkbt/react-copy-to-clipboard/issues/92
......@@ -36,35 +33,27 @@ export class ClickToCopy extends PureComponent {
document.body.removeChild(el);
this.setState({ copied: true });
// Show the copied state only for 1s
if (this.timeout) {
window.clearTimeout(this.timeout);
}
this.timeout = window.setTimeout(
() => this.setState({ copied: false }),
1000
);
};
handleResetCopied = () => {};
handleResetCopied = () => this.setState({ copied: false });
render () {
const { children, label, ...otherProps } = this.props;
const { copied } = this.state;
return (
<div data-tip='' onClick={this.handleCopy}>
{children}
<ReactTooltip
effect='solid'
event='mouseover'
eventOff='mouseout'
place='bottom'
getContent={[() => (copied ? 'Copied.' : label), 50]}
{...otherProps}
/>
</div>
<Popup
content={copied ? 'Copied.' : 'Click to copy'}
inverted
onClose={this.handleResetCopied}
position='bottom center'
size='mini'
trigger={
<div onClick={this.handleCopy} {...otherProps}>
{children}
</div>
}
/>
);
}
}
......@@ -9667,13 +9667,6 @@ react-scripts@1.1.4:
optionalDependencies:
fsevents "^1.1.3"
react-tooltip@^3.6.1:
version "3.6.1"
resolved "https://registry.yarnpkg.com/react-tooltip/-/react-tooltip-3.6.1.tgz#2ca993baa50d7e0271b8d13c6024445a883842eb"
dependencies:
classnames "^2.2.5"
prop-types "^15.6.0"
react@^16.3.2, react@^16.4.0:
version "16.4.1"
resolved "https://registry.yarnpkg.com/react/-/react-16.4.1.tgz#de51ba5764b5dbcd1f9079037b862bd26b82fe32"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment