aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/copyButton.js
blob: 1fdc3f822100a5cbe8fae19c946820c79a58c1a1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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

  return h('i.fa.fa-clipboard.cursor-pointer.color-orange', {
    title: props.title || 'Copy',
    style: {
      display: 'flex',
      justifyContent: 'center',
      alignItems: 'center',
      margin: '5px',
    },
    onClick: (event) => {
      event.preventDefault()
      event.stopPropagation()
      copyToClipboard(value)
    },
  })
}