import React from 'react'; import Column from 'mastodon/components/column'; import ColumnBackButton from 'mastodon/components/column_back_button'; import PropTypes from 'prop-types'; import { me, domain } from 'mastodon/initial_state'; import { connect } from 'react-redux'; import ImmutablePropTypes from 'react-immutable-proptypes'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import classNames from 'classnames'; import Icon from 'mastodon/components/icon'; import ArrowSmallRight from './components/arrow_small_right'; import { Link } from 'react-router-dom'; const messages = defineMessages({ shareableMessage: { id: 'onboarding.share.message', defaultMessage: 'I\'m {username} on Mastodon! Come follow me at {url}' }, }); const mapStateToProps = state => ({ account: state.getIn(['accounts', me]), }); class CopyPasteText extends React.PureComponent { static propTypes = { value: PropTypes.string, }; state = { copied: false, focused: false, }; setRef = c => { this.input = c; }; handleInputClick = () => { this.setState({ copied: false }); this.input.focus(); this.input.select(); this.input.setSelectionRange(0, this.props.value.length); }; handleButtonClick = e => { e.stopPropagation(); const { value } = this.props; navigator.clipboard.writeText(value); this.input.blur(); this.setState({ copied: true }); this.timeout = setTimeout(() => this.setState({ copied: false }), 700); }; handleFocus = () => { this.setState({ focused: true }); }; handleBlur = () => { this.setState({ focused: false }); }; componentWillUnmount () { if (this.timeout) clearTimeout(this.timeout); } render () { const { value } = this.props; const { copied, focused } = this.state; return (