PluginProbe ʕ •ᴥ•ʔ
ShopPress – Shop Builder for Elementor and WooCommerce / trunk
ShopPress – Shop Builder for Elementor and WooCommerce vtrunk
shop-press / blocks / src / loop / stock / edit.js
shop-press / blocks / src / loop / stock Last commit date
block.json 1 year ago edit.js 1 year ago index.js 2 years ago render.php 2 years ago
edit.js
77 lines
1 import { __ } from '@wordpress/i18n';
2 import { useBlockProps, InspectorControls } from '@wordpress/block-editor';
3 import { PanelBody, TextControl } from '@wordpress/components';
4 import Styler from '../../styler';
5 import Wrapper from '../../wrapper';
6
7 const Inspector = ( { attributes, setAttributes, clientId } ) => {
8 const { label } = attributes;
9
10 return (
11 <InspectorControls>
12 <PanelBody
13 title={ __( 'General', 'shop-press' ) }
14 initialOpen={ true }
15 >
16 <TextControl
17 label={ __( 'Label', 'shop-press' ) }
18 value={ label }
19 onChange={ ( value ) => setAttributes( { label: value } ) }
20 />
21 </PanelBody>
22 <PanelBody title={ __( 'Styles', 'shop-press' ) }>
23 <Styler
24 clientId={ clientId }
25 label={ __( 'Wrapper', 'shop-press' ) }
26 selector=".sp-product-stock"
27 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
28 attributes={ attributes }
29 setAttributes={ setAttributes }
30 />
31
32 <Styler
33 clientId={ clientId }
34 label={ __( 'Label', 'shop-press' ) }
35 selector=".sp-stock-label"
36 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
37 attributes={ attributes }
38 setAttributes={ setAttributes }
39 />
40
41 <Styler
42 clientId={ clientId }
43 label={ __( 'Availability', 'shop-press' ) }
44 selector=".sp-stock-availability"
45 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
46 attributes={ attributes }
47 setAttributes={ setAttributes }
48 />
49 </PanelBody>
50 </InspectorControls>
51 );
52 };
53
54 const Edit = ( props ) => {
55 const { attributes, setAttributes, clientId } = props;
56 const { label } = attributes;
57 const blockProps = useBlockProps();
58
59 return (
60 <div { ...blockProps }>
61 <Inspector
62 attributes={ attributes }
63 setAttributes={ setAttributes }
64 clientId={ clientId }
65 />
66 <Wrapper { ...props }>
67 <p className="sp-product-stock">
68 <span className="sp-stock-label">{ label }</span>
69 <span className="sp-stock-availability">Out of stock</span>
70 </p>
71 </Wrapper>
72 </div>
73 );
74 };
75
76 export default Edit;
77