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