PluginProbe ʕ •ᴥ•ʔ
ShopPress – Shop Builder for Elementor and WooCommerce / trunk
ShopPress – Shop Builder for Elementor and WooCommerce vtrunk
shop-press / blocks / src / compare / edit.js
shop-press / blocks / src / compare Last commit date
block.json 2 years ago edit.js 2 years ago index.js 2 years ago render.php 2 months ago
edit.js
248 lines
1 import { __ } from '@wordpress/i18n';
2 import ServerSideRender from '@wordpress/server-side-render';
3 import { PanelBody } from '@wordpress/components';
4 import { useBlockProps, InspectorControls } from '@wordpress/block-editor';
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-compare"
19 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
20 attributes={ attributes }
21 setAttributes={ setAttributes }
22 />
23
24 <Styler
25 clientId={ clientId }
26 label={ __( 'table', 'shop-press' ) }
27 selector=".sp-compare table"
28 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
29 attributes={ attributes }
30 setAttributes={ setAttributes }
31 />
32
33 <Styler
34 clientId={ clientId }
35 label={ __( 'tr', 'shop-press' ) }
36 selector=".sp-compare tr"
37 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
38 attributes={ attributes }
39 setAttributes={ setAttributes }
40 />
41
42 <Styler
43 clientId={ clientId }
44 label={ __( 'td', 'shop-press' ) }
45 selector=".sp-compare td"
46 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
47 attributes={ attributes }
48 setAttributes={ setAttributes }
49 />
50
51 <Styler
52 clientId={ clientId }
53 label={ __( 'tbody', 'shop-press' ) }
54 selector=".sp-compare tbody"
55 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
56 attributes={ attributes }
57 setAttributes={ setAttributes }
58 />
59
60 <Styler
61 clientId={ clientId }
62 label={ __( 'Remove Button Wrapper', 'shop-press' ) }
63 selector=".sp-compare-button"
64 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
65 attributes={ attributes }
66 setAttributes={ setAttributes }
67 />
68
69 <Styler
70 clientId={ clientId }
71 label={ __( 'Remove Button Icon', 'shop-press' ) }
72 selector=".sp-compare-button svg"
73 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
74 attributes={ attributes }
75 setAttributes={ setAttributes }
76 />
77
78 <Styler
79 clientId={ clientId }
80 label={ __( 'Thumbnail Wrapper', 'shop-press' ) }
81 selector="tr.thumbnail td:last-child"
82 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
83 attributes={ attributes }
84 setAttributes={ setAttributes }
85 />
86
87 <Styler
88 clientId={ clientId }
89 label={ __( 'Thumbnail', 'shop-press' ) }
90 selector="tr.thumbnail img"
91 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
92 attributes={ attributes }
93 setAttributes={ setAttributes }
94 />
95
96 <Styler
97 clientId={ clientId }
98 label={ __( 'Title Wrapper', 'shop-press' ) }
99 selector="tr.title"
100 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
101 attributes={ attributes }
102 setAttributes={ setAttributes }
103 />
104
105 <Styler
106 clientId={ clientId }
107 label={ __( 'Title', 'shop-press' ) }
108 selector="tr.title td:last-child"
109 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
110 attributes={ attributes }
111 setAttributes={ setAttributes }
112 />
113
114 <Styler
115 clientId={ clientId }
116 label={ __( 'Categories Wrapper', 'shop-press' ) }
117 selector="tr.categories"
118 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
119 attributes={ attributes }
120 setAttributes={ setAttributes }
121 />
122
123 <Styler
124 clientId={ clientId }
125 label={ __( 'Categories Link', 'shop-press' ) }
126 selector="tr.categories a"
127 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
128 attributes={ attributes }
129 setAttributes={ setAttributes }
130 />
131
132 <Styler
133 clientId={ clientId }
134 label={ __( 'Price Wrapper', 'shop-press' ) }
135 selector="tr.price"
136 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
137 attributes={ attributes }
138 setAttributes={ setAttributes }
139 />
140
141 <Styler
142 clientId={ clientId }
143 label={ __( 'Price', 'shop-press' ) }
144 selector="span.woocommerce-Price-amount.amount"
145 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
146 attributes={ attributes }
147 setAttributes={ setAttributes }
148 />
149
150 <Styler
151 clientId={ clientId }
152 label={ __( 'Attribute Wrapper', 'shop-press' ) }
153 selector="tr.attribute"
154 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
155 attributes={ attributes }
156 setAttributes={ setAttributes }
157 />
158
159 <Styler
160 clientId={ clientId }
161 label={ __( 'Attribute Label', 'shop-press' ) }
162 selector="tr.attribute .attribute-label"
163 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
164 attributes={ attributes }
165 setAttributes={ setAttributes }
166 />
167
168 <Styler
169 clientId={ clientId }
170 label={ __( 'Attribute Value', 'shop-press' ) }
171 selector="tr.attribute .attribute-value"
172 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
173 attributes={ attributes }
174 setAttributes={ setAttributes }
175 />
176
177 <Styler
178 clientId={ clientId }
179 label={ __( 'Attribute Value Names', 'shop-press' ) }
180 selector="tr.attribute .attribute-value p"
181 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
182 attributes={ attributes }
183 setAttributes={ setAttributes }
184 />
185
186 <Styler
187 clientId={ clientId }
188 label={ __( 'Rating Stars', 'shop-press' ) }
189 selector="tr.attribute .attribute-value.ratings .star-rating"
190 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
191 attributes={ attributes }
192 setAttributes={ setAttributes }
193 />
194
195 <Styler
196 clientId={ clientId }
197 label={ __( 'Rating Full Stars', 'shop-press' ) }
198 selector="tr.attribute .attribute-value.ratings .star-rating span"
199 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
200 attributes={ attributes }
201 setAttributes={ setAttributes }
202 />
203
204 <Styler
205 clientId={ clientId }
206 label={ __( 'Add To Cart Button Wrapper', 'shop-press' ) }
207 selector="tr.add_to_cart"
208 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
209 attributes={ attributes }
210 setAttributes={ setAttributes }
211 />
212
213 <Styler
214 clientId={ clientId }
215 label={ __( 'Add To Cart Button', 'shop-press' ) }
216 selector="tr.add_to_cart .button"
217 wrapper={ `.${ attributes[ 'wrapperID' ] }` }
218 attributes={ attributes }
219 setAttributes={ setAttributes }
220 />
221 </PanelBody>
222 </InspectorControls>
223 );
224 };
225
226 const Edit = ( props ) => {
227 const { attributes, setAttributes, clientId } = props;
228 const blockProps = useBlockProps();
229
230 return (
231 <div { ...blockProps }>
232 <Inspector
233 attributes={ attributes }
234 setAttributes={ setAttributes }
235 clientId={ clientId }
236 />
237 <Wrapper { ...props }>
238 <ServerSideRender
239 block="shop-press/compare"
240 attributes={ attributes }
241 />
242 </Wrapper>
243 </div>
244 );
245 };
246
247 export default Edit;
248