import React from 'react'; import '../css/ShareButton.scss'; import SharePopup from './SharePopup'; import PropTypes from 'prop-types'; import { _ } from '../classes/gettext'; class ShareButton extends React.Component { static defaultProps = { task: null, popupPlacement: 'top' }; static propTypes = { task: PropTypes.object.isRequired, linksTarget: PropTypes.oneOf(['map', '3d']).isRequired, popupPlacement: PropTypes.string } constructor(props){ super(props); this.state = { showPopup: false, task: props.task }; this.handleClick = this.handleClick.bind(this); this.handleTaskChanged = this.handleTaskChanged.bind(this); } handleClick(e){ this.setState({ showPopup: !this.state.showPopup }); } hidePopup(){ this.setState({showPopup: false}); } handleTaskChanged(task){ this.setState({task}); } render() { const popup = ; return (
{ e.stopPropagation(); }}> {this.props.popupPlacement === 'top' && this.state.showPopup ? popup : ""} {this.props.popupPlacement === 'bottom' && this.state.showPopup ? popup : ""}
); } } export default ShareButton;