2016-06-29 14:11:12 -07:00
|
|
|
const Component = require('react').Component
|
|
|
|
const h = require('react-hyperscript')
|
|
|
|
const inherits = require('util').inherits
|
|
|
|
const copyToClipboard = require('copy-to-clipboard')
|
|
|
|
|
|
|
|
module.exports = CopyButton
|
|
|
|
|
|
|
|
inherits(CopyButton, Component)
|
|
|
|
function CopyButton () {
|
|
|
|
Component.call(this)
|
|
|
|
}
|
|
|
|
|
|
|
|
CopyButton.prototype.render = function () {
|
|
|
|
const props = this.props
|
|
|
|
const value = props.value
|
|
|
|
|
2016-06-29 14:39:25 -07:00
|
|
|
return h('i.fa.fa-clipboard.cursor-pointer.color-orange', {
|
|
|
|
title: props.title || 'Copy',
|
|
|
|
style: {
|
|
|
|
display: 'flex',
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center',
|
|
|
|
margin: '5px',
|
|
|
|
},
|
2016-06-29 14:11:12 -07:00
|
|
|
onClick: (event) => {
|
|
|
|
event.preventDefault()
|
|
|
|
event.stopPropagation()
|
|
|
|
copyToClipboard(value)
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|