From 441a7eec2899c6553004ced2245d17ef9cc33a51 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Wed, 29 Jun 2016 14:11:12 -0700 Subject: [PATCH] Add CopyButton component --- ui/app/components/copyButton.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 ui/app/components/copyButton.js diff --git a/ui/app/components/copyButton.js b/ui/app/components/copyButton.js new file mode 100644 index 000000000..74fd673c2 --- /dev/null +++ b/ui/app/components/copyButton.js @@ -0,0 +1,26 @@ +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('img.cursor-pointer.color-orange', { + src: 'images/copy.svg', + title: 'Copy Address', + onClick: (event) => { + event.preventDefault() + event.stopPropagation() + copyToClipboard(value) + }, + }) +}