PluginProbe
WP Ultimate Post Grid / 3.3.0
WP Ultimate Post Grid v3.3.0
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
wp-ultimate-post-grid / assets / js / shared / CopyToClipboardIcon.js

CopyToClipboardIcon.js in WP Ultimate Post Grid 3.3.0, at assets/js/shared/CopyToClipboardIcon.js

61 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1
2 import React, { Component } from 'react';
3 import CopyToClipboard from 'react-copy-to-clipboard';
4
5 import Icon from 'Shared/Icon';
6 import Tooltip from 'Shared/Tooltip';
7 import { __wpupg } from 'Shared/Translations';
8
9 import '../../css/admin/shared/copy-clipboard.scss';
10
11 export default class CopyToClipboardIcon extends Component {
12 constructor(props) {
13 super(props);
14
15 this.state = {
16 copied: false,
17 }
18 }
19
20 onCopy() {
21 this.setState({
22 copied: true,
23 }, () => {
24 setTimeout(() => {
25 this.setState({
26 copied: false,
27 });
28 }, 2000);
29 });
30 }
31
32 render() {
33 return (
34 <CopyToClipboard
35 text={this.props.text}
36 onCopy={this.onCopy.bind(this)}
37 >
38 <span
39 className="wpupg-admin-table-container-copy"
40 style={{
41 opacity: this.state.copied ? 0.2 : 1
42 }}
43 >
44 {
45 this.props.hasOwnProperty( 'type' )
46 && 'text' === this.props.type
47 ?
48 <Tooltip content={ this.state.copied ? __wpupg( 'Copied!' ) : __wpupg( 'Copy to clipboard' ) }>
49 <span>{ this.props.text }</span>
50 </Tooltip>
51 :
52 <Icon
53 type="clipboard"
54 title={ this.state.copied ? __wpupg( 'Copied!' ) : __wpupg( 'Copy to clipboard' ) }
55 />
56 }
57 </span>
58 </CopyToClipboard>
59 );
60 }
61 }