mirror of https://github.com/sgoudham/carbon.git
replace copy button with tacklebox's
parent
40ba1e0f9e
commit
35ed5ae1e7
@ -1,36 +0,0 @@
|
||||
// TODO publish rucksack and import from there
|
||||
|
||||
import React from 'react'
|
||||
import CopyToClipboard from 'react-copy-to-clipboard'
|
||||
|
||||
class CopyButton extends React.Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
||||
this.state = {
|
||||
copied: false
|
||||
}
|
||||
this.onCopy = this.onCopy.bind(this)
|
||||
}
|
||||
|
||||
onCopy() {
|
||||
this.setState({ copied: true })
|
||||
const component = this
|
||||
setTimeout(
|
||||
() => component.setState({ copied: false }),
|
||||
this.props.interval == null ? 1000 : this.props.interval
|
||||
)
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<CopyToClipboard text={this.props.text} onCopy={this.onCopy}>
|
||||
{this.props.children({
|
||||
copied: this.state.copied
|
||||
})}
|
||||
</CopyToClipboard>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default CopyButton
|
Loading…
Reference in New Issue