import PropTypes from 'prop-types'; import React from 'react'; import Clipboard from 'clipboard'; import InlineSVG from 'react-inlinesvg'; import classNames from 'classnames'; import shareUrl from '../../../images/share.svg'; class CopyableInput extends React.Component { constructor(props) { super(props); this.onMouseLeaveHandler = this.onMouseLeaveHandler.bind(this); } componentDidMount() { this.clipboard = new Clipboard(this.input, { target: () => this.input }); this.clipboard.on('success', (e) => { this.tooltip.classList.add('tooltipped'); this.tooltip.classList.add('tooltipped-n'); }); } componentWillUnmount() { this.clipboard.destroy(); } onMouseLeaveHandler() { this.tooltip.classList.remove('tooltipped'); this.tooltip.classList.remove('tooltipped-n'); } render() { const { label, value, hasPreviewLink } = this.props; const copyableInputClass = classNames({ 'copyable-input': true, 'copyable-input--with-preview': hasPreviewLink }); return (
); } } CopyableInput.propTypes = { label: PropTypes.string.isRequired, value: PropTypes.string.isRequired, hasPreviewLink: PropTypes.bool }; CopyableInput.defaultProps = { hasPreviewLink: false }; export default CopyableInput;