PluginProbe
WP Ultimate Post Grid / 4.0.1
WP Ultimate Post Grid v4.0.1
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 / admin-template / menu / properties / Icon.js

Icon.js in WP Ultimate Post Grid 4.0.1, at assets/js/admin-template/menu/properties/Icon.js

91 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React, { Component, Fragment } from 'react';
2 import SVG from 'react-inlinesvg';
3
4 export default class PropertyIcon extends Component {
5 constructor(props) {
6 super(props);
7
8 this.state = {
9 selectingIcon: false,
10 }
11 }
12
13 render() {
14 const customSelected = wpupg_admin_template.icons.hasOwnProperty(this.props.value);
15 const iconUrl = customSelected ? wpupg_admin_template.icons[this.props.value].url : this.props.value;
16
17 return (
18 <Fragment>
19 {
20 ! this.state.selectingIcon
21 ?
22 <span className="wpupg-template-property-icon-selected-container">
23 {
24 iconUrl
25 &&
26 <SVG
27 src={iconUrl}
28 className="wpupg-template-property-icon-select"
29 />
30 }
31 <a href="#" onClick={(e) => {
32 e.preventDefault();
33 this.setState({
34 selectingIcon: true,
35 });
36 }}>{ iconUrl ? 'Change...' : 'Select...' }</a>
37 </span>
38 :
39 <div className="wpupg-template-property-icon-select-container">
40 <a href="#" onClick={(e) => {
41 e.preventDefault();
42 this.setState({
43 selectingIcon: false,
44 });
45
46 return this.props.onValueChange('');
47 }}>Clear icon</a> | <a href="#" onClick={(e) => {
48 e.preventDefault();
49
50 const url = prompt('Set a custom URL for the icon');
51
52 if ( url ) {
53 this.setState({
54 selectingIcon: false,
55 });
56
57 return this.props.onValueChange(url);
58 }
59 }}>Set custom URL</a> | Select:
60 <div className="wpupg-template-property-icon-select-container-icons">
61 {
62 Object.keys(wpupg_admin_template.icons).map((id, index) => {
63 let icon = wpupg_admin_template.icons[id];
64 return (
65 <span href="#"
66 onClick={() => {
67 this.setState({
68 selectingIcon: false,
69 });
70
71 if ( icon.id !== this.props.value ) {
72 return this.props.onValueChange(icon.id);
73 }
74 }}
75 key={index}
76 >
77 <SVG
78 src={icon.url}
79 className={ icon.id === this.props.value ? 'wpupg-template-property-icon-select wpupg-template-property-icon-selected' : 'wpupg-template-property-icon-select' }
80 />
81 </span>
82 );
83 })
84 }
85 </div>
86 </div>
87 }
88 </Fragment>
89 );
90 }
91 }