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 / Property.js

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

75 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React from 'react';
2
3 import '../../../css/admin/template/property.scss';
4
5 import Icon from 'Shared/Icon';
6 import Helpers from '../general/Helpers';
7
8 import PropertyColor from './properties/Color';
9 import PropertyDropdown from './properties/Dropdown';
10 import PropertyFont from './properties/Font';
11 import PropertyIcon from './properties/Icon';
12 import PropertyImage from './properties/Image';
13 import PropertyImageSize from './properties/ImageSize';
14 import PropertyNumber from './properties/Number';
15 import PropertySize from './properties/Size';
16 import PropertyText from './properties/Text';
17 import PropertyToggle from './properties/Toggle';
18
19 const propertyTypes = {
20 color: PropertyColor,
21 align: PropertyDropdown,
22 border: PropertyDropdown,
23 dropdown: PropertyDropdown,
24 float: PropertyDropdown,
25 font: PropertyFont,
26 font_size: PropertySize,
27 icon: PropertyIcon,
28 image: PropertyImage,
29 image_size: PropertyImageSize,
30 percentage: PropertyNumber,
31 number: PropertyNumber,
32 size: PropertySize,
33 text: PropertyText,
34 toggle: PropertyToggle,
35 }
36
37 const Property = (props) => {
38 const PropertyComponent = propertyTypes.hasOwnProperty(props.property.type) ? propertyTypes[props.property.type] : false;
39
40 if ( ! PropertyComponent ) {
41 return null;
42 }
43
44 if ( ! Helpers.dependencyMet(props.property, props.properties) ) {
45 return null;
46 }
47
48 let helpIcon = null;
49 if ( props.property.hasOwnProperty( 'help' ) ) {
50 helpIcon = (
51 <Icon
52 type="question"
53 title={ props.property.help }
54 className="wpupg-admin-icon-help"
55 />
56 );
57 }
58
59 return (
60 <div className="wpupg-template-property">
61 <div className="wpupg-template-property-label">
62 { props.property.name } { helpIcon }
63 </div>
64 <div className={ `wpupg-template-property-value wpupg-template-property-value-${props.property.type}` }>
65 <PropertyComponent
66 property={props.property}
67 value={props.property.value}
68 onValueChange={(value) => { props.onPropertyChange(props.property.id, value); } }
69 />
70 </div>
71 </div>
72 );
73 }
74
75 export default Property;