From 87c39f066c373c747e848d1499551994eea35831 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Thu, 10 Nov 2016 17:27:04 +0100 Subject: [PATCH] Form/Input: use CopyToClipboard --- js/src/ui/Form/Input/input.css | 4 --- js/src/ui/Form/Input/input.js | 62 +++------------------------------- 2 files changed, 5 insertions(+), 61 deletions(-) diff --git a/js/src/ui/Form/Input/input.css b/js/src/ui/Form/Input/input.css index 62c2e39b2..bc7cfb840 100644 --- a/js/src/ui/Form/Input/input.css +++ b/js/src/ui/Form/Input/input.css @@ -24,8 +24,4 @@ .copy { margin-right: 0.5em; - - svg { - transition: all .5s ease-in-out; - } } diff --git a/js/src/ui/Form/Input/input.js b/js/src/ui/Form/Input/input.js index 24a0a8089..27c270834 100644 --- a/js/src/ui/Form/Input/input.js +++ b/js/src/ui/Form/Input/input.js @@ -15,11 +15,9 @@ // along with Parity. If not, see . import React, { Component, PropTypes } from 'react'; +import { TextField } from 'material-ui'; -import CopyToClipboard from 'react-copy-to-clipboard'; -import CopyIcon from 'material-ui/svg-icons/content/content-copy'; -import { TextField, IconButton } from 'material-ui'; -import { lightWhite, fullWhite } from 'material-ui/styles/colors'; +import CopyToClipboard from '../../CopyToClipboard'; import styles from './input.css'; @@ -77,9 +75,7 @@ export default class Input extends Component { } state = { - value: this.props.value || '', - timeoutId: null, - copied: false + value: this.props.value || '' } componentWillReceiveProps (newProps) { @@ -88,14 +84,6 @@ export default class Input extends Component { } } - componentWillUnmount () { - const { timeoutId } = this.state; - - if (timeoutId) { - window.clearTimeout(timeoutId); - } - } - render () { const { value } = this.state; const { children, className, hideUnderline, disabled, error, label, hint, multiLine, rows, type } = this.props; @@ -151,7 +139,7 @@ export default class Input extends Component { renderCopyButton () { const { allowCopy, hideUnderline, label, hint, floatCopy } = this.props; - const { copied, value } = this.state; + const { value } = this.state; if (!allowCopy) { return null; @@ -165,8 +153,6 @@ export default class Input extends Component { ? allowCopy : value; - const scale = copied ? 'scale(1.15)' : 'scale(1)'; - if (hideUnderline && !label) { style.marginBottom = 2; } else if (label && !hint) { @@ -184,49 +170,11 @@ export default class Input extends Component { return (
- - - - - +
); } - handleCopy = () => { - if (this.state.timeoutId) { - window.clearTimeout(this.state.timeoutId); - } - - this.setState({ copied: true }, () => { - const timeoutId = window.setTimeout(() => { - this.setState({ copied: false }); - }, 500); - - this.setState({ timeoutId }); - }); - } - onChange = (event, value) => { this.setValue(value);