diff options
Diffstat (limited to 'animism-align/frontend/common/copyToClipboardButton.component.js')
| -rw-r--r-- | animism-align/frontend/common/copyToClipboardButton.component.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/animism-align/frontend/common/copyToClipboardButton.component.js b/animism-align/frontend/common/copyToClipboardButton.component.js new file mode 100644 index 0000000..cfe7103 --- /dev/null +++ b/animism-align/frontend/common/copyToClipboardButton.component.js @@ -0,0 +1,24 @@ +import React, { Component } from 'react'; +import { writeToClipboard } from '../util' + +export default class CopyToClipboardButton extends Component { + state = { + copied: false, + } + + handleClick() { + writeToClipboard(this.props.data) + this.setState({ copied: true }) + } + + render() { + return ( + <button + className={this.state.copied ? 'copyButton copied' : 'copyButton'} + onClick={this.handleClick.bind(this)} + > + {this.state.copied ? 'Copied!' : 'Copy'} + </button> + ) + } +} |
