PluginProbe
Caddy – WooCommerce Side Cart & Free Shipping Bar / 3.1.1
Caddy – WooCommerce Side Cart & Free Shipping Bar v3.1.1
3.2.0 3.1.1 trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8 1.8.1 1.8.2 1.9 1.9.2 1.9.3 All 46 releases
caddy / editor.js

editor.js in Caddy – WooCommerce Side Cart & Free Shipping Bar 3.1.1, at editor.js

100 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Caddy Cart Block Editor
3 *
4 * Block editor interface for the Caddy cart block.
5 *
6 * @since 2.1.3
7 */
8
9 const { registerBlockType } = wp.blocks;
10 const { InspectorControls } = wp.blockEditor;
11 const { PanelBody, ToggleControl, TextControl } = wp.components;
12 const { __ } = wp.i18n;
13
14 registerBlockType('caddy/cart', {
15 edit: function(props) {
16 const { attributes, setAttributes } = props;
17 const { cartText, showIcon, autoOpen } = attributes;
18
19 return [
20 // Inspector Controls (Block Settings Sidebar)
21 wp.element.createElement(InspectorControls, { key: 'inspector' },
22 wp.element.createElement(PanelBody, {
23 title: __('Cart Settings', 'caddy'),
24 initialOpen: true
25 },
26 wp.element.createElement(TextControl, {
27 label: __('Cart Button Text', 'caddy'),
28 value: cartText,
29 onChange: (value) => setAttributes({ cartText: value }),
30 help: __('Text displayed on the cart trigger button', 'caddy')
31 }),
32 wp.element.createElement(ToggleControl, {
33 label: __('Show Cart Icon', 'caddy'),
34 checked: showIcon,
35 onChange: (value) => setAttributes({ showIcon: value }),
36 help: __('Display cart icon next to the button text', 'caddy')
37 }),
38 wp.element.createElement(ToggleControl, {
39 label: __('Auto-open Cart', 'caddy'),
40 checked: autoOpen,
41 onChange: (value) => setAttributes({ autoOpen: value }),
42 help: __('Automatically open cart when items are added', 'caddy')
43 })
44 )
45 ),
46
47 // Block Preview in Editor
48 wp.element.createElement('div', {
49 key: 'preview',
50 className: 'caddy-cart-block-preview',
51 style: {
52 padding: '20px',
53 border: '2px dashed #ccc',
54 borderRadius: '4px',
55 textAlign: 'center',
56 backgroundColor: '#f9f9f9'
57 }
58 },
59 wp.element.createElement('div', {
60 style: {
61 display: 'inline-flex',
62 alignItems: 'center',
63 gap: '8px',
64 padding: '10px 16px',
65 backgroundColor: '#0073aa',
66 color: 'white',
67 borderRadius: '4px',
68 fontSize: '14px'
69 }
70 },
71 showIcon && wp.element.createElement('span', {
72 style: { fontSize: '16px' }
73 }, '🛒'),
74 cartText && wp.element.createElement('span', null, cartText),
75 wp.element.createElement('span', {
76 style: {
77 backgroundColor: 'rgba(255,255,255,0.2)',
78 padding: '2px 6px',
79 borderRadius: '10px',
80 fontSize: '12px',
81 marginLeft: '4px'
82 }
83 }, '0')
84 ),
85 wp.element.createElement('p', {
86 style: {
87 marginTop: '12px',
88 fontSize: '12px',
89 color: '#666'
90 }
91 }, __('Caddy Smart Side Cart - This preview shows how the cart trigger will appear to visitors.', 'caddy'))
92 )
93 ];
94 },
95
96 save: function() {
97 // Return null since this is a dynamic block (rendered via PHP)
98 return null;
99 }
100 });