PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 3.1.4
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v3.1.4
3.3.0 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.1 trunk 1.0.4 1.1.0 1.1.0.1 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 All 162 releases
cartflows / modules / gutenberg / src / components / responsive-select / index.js

index.js in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 3.1.4, at modules/gutenberg/src/components/responsive-select/index.js

74 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * External dependencies
3 */
4 import React, { useLayoutEffect } from 'react';
5 import { SelectControl } from '@wordpress/components';
6 import { useDeviceType } from '@Controls/getPreviewType';
7 import ResponsiveToggle from '../responsive-toggle';
8 import styles from './editor.lazy.scss';
9
10 const ResponsiveSelectControl = ( props ) => {
11
12 // Add and remove the CSS on the drop and remove of the component.
13 useLayoutEffect( () => {
14 styles.use();
15 return () => {
16 styles.unuse();
17 };
18 }, [] );
19
20 const { label, data, setAttributes, options } = props;
21
22 const responsive = true;
23
24 const deviceType = useDeviceType();
25
26 const output = {};
27 output.Desktop = (
28 <SelectControl
29 value={ data.desktop.value }
30 onChange={ ( value ) =>
31 setAttributes( { [ data.desktop.label ]: value } )
32 }
33 options={ options.desktop }
34 />
35 );
36 output.Tablet = (
37 <SelectControl
38 value={ data.tablet.value }
39 onChange={ ( value ) =>
40 setAttributes( { [ data.tablet.label ]: value } )
41 }
42 options={ options.tablet || options.desktop }
43 />
44 );
45 output.Mobile = (
46 <SelectControl
47 value={ data.mobile.value }
48 onChange={ ( value ) =>
49 setAttributes( { [ data.mobile.label ]: value } )
50 }
51 options={ options.mobile || options.desktop }
52 />
53 );
54
55 return (
56 <div className="components-base-control uagb-responsive-select-control">
57 <div className="uagb-size-type-field-tabs">
58 <div className="uagb-control__header">
59 <ResponsiveToggle
60 label= { label }
61 responsive= { responsive }
62 />
63 </div>
64 { output[ deviceType ] ? output[ deviceType ] : output.Desktop }
65 </div>
66 { props.help && (
67 <p className="uag-control-help-notice">{ props.help }</p>
68 ) }
69 </div>
70 );
71 };
72
73 export default ResponsiveSelectControl;
74