{"size": 898, "ext": "js", "max_stars_repo_path": "docs/src/containers/CopyButtonContainer/CopyButtonContainer.js", "max_stars_repo_name": "fpoumian/react-devicon", "max_stars_repo_stars_event_min_datetime": "2017-10-11T18:35:08.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-28T09:16:07.000Z", "max_issues_repo_path": "docs/src/containers/CopyButtonContainer/CopyButtonContainer.js", "max_issues_repo_name": "heyitsvivek/react-devicon", "max_issues_repo_issues_event_min_datetime": "2017-10-12T03:45:14.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-09T12:28:25.000Z", "max_forks_repo_path": "docs/src/containers/CopyButtonContainer/CopyButtonContainer.js", "max_forks_repo_name": "heyitsvivek/react-devicon", "max_forks_repo_forks_event_min_datetime": "2017-10-28T18:09:19.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-23T17:36:10.000Z"}
{"max_stars_count": 25, "max_issues_count": 3, "max_forks_count": 3, "avg_line_length": 19.5217391304, "max_line_length": 63, "alphanum_fraction": 0.5924276169}
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import CopyButton from '../../components/CopyButton/CopyButton'

import copy from 'copy-to-clipboard'

class CopyButtonContainer extends Component {
  state = {
    copedLabelVisible: false,
  }

  handleCopyButtonClick = () => {
    copy(this.props.toCopy)
    this.setState(
      {
        copedLabelVisible: true,
      },
      () =>
        setTimeout(() =>
          this.setState(
            {
              copedLabelVisible: false,
            },
            1000
          )
        )
    )
  }

  render() {
    return (
      <CopyButton
        copiedLabelVisible={this.state.copedLabelVisible}
        dataTip={'Copy to Clipboard'}
        onCopyBtnClick={this.handleCopyButtonClick}
      />
    )
  }
}

CopyButtonContainer.propTypes = {
  toCopy: PropTypes.string,
}

export default CopyButtonContainer
