PluginProbe
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor / 2.0.7
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor v2.0.7
2.0.13 2.0.12 2.0.11 2.0.10 2.0.9 trunk 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8
blockenberg / blocks / button-group / index.js

index.js in Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor 2.0.7, at blocks/button-group/index.js

405 lines 24.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ( function () {
2 var el = wp.element.createElement;
3 var Fragment = wp.element.Fragment;
4 var __ = wp.i18n.__;
5 var registerBlockType = wp.blocks.registerBlockType;
6 var InspectorControls = wp.blockEditor.InspectorControls;
7 var useBlockProps = wp.blockEditor.useBlockProps;
8 var PanelBody = wp.components.PanelBody;
9 var PanelColorSettings = wp.blockEditor.PanelColorSettings;
10 var Button = wp.components.Button;
11 var ToggleControl = wp.components.ToggleControl;
12 var RangeControl = wp.components.RangeControl;
13 var SelectControl = wp.components.SelectControl;
14 var TextControl = wp.components.TextControl;
15 var ColorPicker = wp.components.ColorPicker;
16 var Popover = wp.components.Popover;
17 var useState = wp.element.useState;
18
19 function getTypographyControl() {
20 return (window.bkbgTypographyControl || function () { return null; });
21 }
22
23 function _tv(typo, prefix) {
24 if (!typo) return {};
25 var s = {};
26 if (typo.family) s[prefix + 'font-family'] = "'" + typo.family + "', sans-serif";
27 if (typo.weight) s[prefix + 'font-weight'] = typo.weight;
28 if (typo.transform) s[prefix + 'text-transform'] = typo.transform;
29 if (typo.style) s[prefix + 'font-style'] = typo.style;
30 if (typo.decoration) s[prefix + 'text-decoration'] = typo.decoration;
31 var su = typo.sizeUnit || 'px';
32 if (typo.sizeDesktop !== '' && typo.sizeDesktop != null) s[prefix + 'font-size-d'] = typo.sizeDesktop + su;
33 if (typo.sizeTablet !== '' && typo.sizeTablet != null) s[prefix + 'font-size-t'] = typo.sizeTablet + su;
34 if (typo.sizeMobile !== '' && typo.sizeMobile != null) s[prefix + 'font-size-m'] = typo.sizeMobile + su;
35 var lhu = typo.lineHeightUnit || '';
36 if (typo.lineHeightDesktop !== '' && typo.lineHeightDesktop != null) s[prefix + 'line-height-d'] = typo.lineHeightDesktop + lhu;
37 if (typo.lineHeightTablet !== '' && typo.lineHeightTablet != null) s[prefix + 'line-height-t'] = typo.lineHeightTablet + lhu;
38 if (typo.lineHeightMobile !== '' && typo.lineHeightMobile != null) s[prefix + 'line-height-m'] = typo.lineHeightMobile + lhu;
39 var lsu = typo.letterSpacingUnit || 'px';
40 if (typo.letterSpacingDesktop !== '' && typo.letterSpacingDesktop != null) s[prefix + 'letter-spacing-d'] = typo.letterSpacingDesktop + lsu;
41 if (typo.letterSpacingTablet !== '' && typo.letterSpacingTablet != null) s[prefix + 'letter-spacing-t'] = typo.letterSpacingTablet + lsu;
42 if (typo.letterSpacingMobile !== '' && typo.letterSpacingMobile != null) s[prefix + 'letter-spacing-m'] = typo.letterSpacingMobile + lsu;
43 var wsu = typo.wordSpacingUnit || 'px';
44 if (typo.wordSpacingDesktop !== '' && typo.wordSpacingDesktop != null) s[prefix + 'word-spacing-d'] = typo.wordSpacingDesktop + wsu;
45 if (typo.wordSpacingTablet !== '' && typo.wordSpacingTablet != null) s[prefix + 'word-spacing-t'] = typo.wordSpacingTablet + wsu;
46 if (typo.wordSpacingMobile !== '' && typo.wordSpacingMobile != null) s[prefix + 'word-spacing-m'] = typo.wordSpacingMobile + wsu;
47 return s;
48 }
49
50 function _tvString(typo, prefix) {
51 var o = _tv(typo, prefix);
52 var parts = [];
53 for (var k in o) { if (o.hasOwnProperty(k)) parts.push(k + ':' + o[k]); }
54 return parts.join(';');
55 }
56
57 var alignOptions = [
58 { label: __('Left', 'blockenberg'), value: 'left' },
59 { label: __('Center', 'blockenberg'), value: 'center' },
60 { label: __('Right', 'blockenberg'), value: 'right' }
61 ];
62
63 var directionOptions = [
64 { label: __('Row (horizontal)', 'blockenberg'), value: 'row' },
65 { label: __('Column (vertical)', 'blockenberg'), value: 'column' }
66 ];
67
68 var styleOptions = [
69 { label: __('Primary (filled)', 'blockenberg'), value: 'primary' },
70 { label: __('Outline', 'blockenberg'), value: 'outline' },
71 { label: __('Ghost / Text', 'blockenberg'), value: 'ghost' },
72 { label: __('Link', 'blockenberg'), value: 'link' }
73 ];
74
75 var sizeOptions = [
76 { label: __('Small', 'blockenberg'), value: 'sm' },
77 { label: __('Medium', 'blockenberg'), value: 'md' },
78 { label: __('Large', 'blockenberg'), value: 'lg' }
79 ];
80
81 var shadowOptions = [
82 { label: __('None', 'blockenberg'), value: 'none' },
83 { label: __('Small', 'blockenberg'), value: 'sm' },
84 { label: __('Medium', 'blockenberg'), value: 'md' }
85 ];
86
87 var hoverOptions = [
88 { label: __('Lift (translate up)', 'blockenberg'), value: 'lift' },
89 { label: __('Scale', 'blockenberg'), value: 'scale' },
90 { label: __('Darken', 'blockenberg'), value: 'darken' },
91 { label: __('None', 'blockenberg'), value: 'none' }
92 ];
93
94 var iconOptions = [
95 { label: __('None', 'blockenberg'), value: 'none' },
96 { label: '→ Arrow Right', value: 'arrow-right' },
97 { label: '↗ External', value: 'external' },
98 { label: '▶ Play', value: 'play' },
99 { label: '�
100 Star', value: 'star' },
101 { label: '↓ Download', value: 'download' }
102 ];
103
104 var iconSvgs = {
105 'none': '',
106 'arrow-right': '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"/><polyline points="12 5 19 12 12 19"/></svg>',
107 'external': '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',
108 'play': '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="15" height="15" fill="currentColor"><polygon points="5 3 19 12 5 21"/></svg>',
109 'star': '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="15" height="15" fill="currentColor"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26"/></svg>',
110 'download': '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>'
111 };
112
113 function getIconEl(iconKey) {
114 var svg = iconSvgs[iconKey];
115 if (!svg) return null;
116 return el('span', {
117 className: 'bkbg-bg-icon',
118 'aria-hidden': 'true',
119 dangerouslySetInnerHTML: { __html: svg }
120 });
121 }
122
123 function getBtnClass(btn, a) {
124 return 'bkbg-bg-btn bkbg-bg-btn-' + btn.style + ' bkbg-bg-btn-' + btn.size;
125 }
126
127 var BkbgColorSwatch = function (props) {
128 var _st = useState(false); var isOpen = _st[0]; var setOpen = _st[1];
129 return el(Fragment, {},
130 el('div', { style: { display: 'flex', alignItems: 'center', gap: '8px', marginBottom: '8px' } },
131 el('span', { style: { fontSize: '11px', fontWeight: 500, textTransform: 'uppercase', color: '#1e1e1e' } }, props.label),
132 el('button', {
133 type: 'button',
134 onClick: function () { setOpen(!isOpen); },
135 style: { width: '28px', height: '28px', borderRadius: '4px', border: '1px solid #ccc', background: props.value || '#ffffff', cursor: 'pointer', padding: 0 }
136 })
137 ),
138 isOpen && el(Popover, { onClose: function () { setOpen(false); } },
139 el('div', { style: { padding: '8px' } },
140 el(ColorPicker, { color: props.value, onChangeComplete: function (c) { props.onChange(c.hex); }, enableAlpha: true })
141 )
142 )
143 );
144 };
145
146 registerBlockType('blockenberg/button-group', {
147 edit: function (props) {
148 var a = props.attributes;
149 var setAttributes = props.setAttributes;
150
151 function updateBtn(index, field, value) {
152 var newBtns = a.buttons.map(function (btn, i) {
153 if (i !== index) return btn;
154 var updated = {};
155 for (var k in btn) { updated[k] = btn[k]; }
156 updated[field] = value;
157 return updated;
158 });
159 setAttributes({ buttons: newBtns });
160 }
161
162 function addBtn() {
163 setAttributes({
164 buttons: a.buttons.concat([{
165 label: 'New Button', url: '#', target: false, rel: '',
166 style: 'primary', size: 'md', icon: 'none', iconPosition: 'left',
167 customBg: '', customColor: '', customBorder: ''
168 }])
169 });
170 }
171
172 function removeBtn(index) {
173 if (a.buttons.length <= 1) return;
174 setAttributes({ buttons: a.buttons.filter(function (_, i) { return i !== index; }) });
175 }
176
177 function moveBtn(index, dir) {
178 var ni = index + dir;
179 if (ni < 0 || ni >= a.buttons.length) return;
180 var newBtns = a.buttons.slice();
181 var tmp = newBtns[index]; newBtns[index] = newBtns[ni]; newBtns[ni] = tmp;
182 setAttributes({ buttons: newBtns });
183 }
184
185 var wrapStyle = Object.assign({
186 '--bkbg-bg-btn-bg': a.btnBg,
187 '--bkbg-bg-btn-color': a.btnColor,
188 '--bkbg-bg-outline-border': a.outlineBorderColor,
189 '--bkbg-bg-outline-color': a.outlineColor,
190 '--bkbg-bg-ghost-color': a.ghostColor,
191 '--bkbg-bg-radius': a.btnRadius + 'px',
192 '--bkbg-bg-padding': a.btnPaddingV + 'px ' + a.btnPaddingH + 'px',
193 '--bkbg-bg-gap': a.gap + 'px'
194 }, _tv(a.typoBtn, '--bkbg-bg-typo-'));
195
196 var blockProps = useBlockProps({
197 className: 'bkbg-bg-wrap bkbg-bg-editor',
198 style: wrapStyle,
199 'data-align': a.alignment,
200 'data-direction': a.direction,
201 'data-shadow': a.btnShadow,
202 'data-hover': a.hoverEffect,
203 'data-mobile-stack': a.mobileStack ? '1' : '0'
204 });
205
206 var inspector = el(InspectorControls, {},
207
208 el(PanelBody, { title: __('Buttons', 'blockenberg'), initialOpen: true },
209 a.buttons.map(function (btn, index) {
210 return el('div', {
211 key: 'btn-' + index,
212 className: 'bkbg-bg-inspector-btn',
213 style: { borderBottom: '1px solid #f0f0f0', paddingBottom: '16px', marginBottom: '16px' }
214 },
215 el('div', {
216 style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: '8px' }
217 },
218 el('strong', { style: { fontSize: '12px', color: '#374151' } }, __('Button', 'blockenberg') + ' ' + (index + 1)),
219 el('div', { style: { display: 'flex', gap: '4px' } },
220 el(Button, { icon: 'arrow-up-alt2', isSmall: true, disabled: index === 0, onClick: function () { moveBtn(index, -1); } }),
221 el(Button, { icon: 'arrow-down-alt2', isSmall: true, disabled: index === a.buttons.length - 1, onClick: function () { moveBtn(index, 1); } }),
222 el(Button, { icon: 'trash', isSmall: true, isDestructive: true, disabled: a.buttons.length <= 1, onClick: function () { removeBtn(index); } })
223 )
224 ),
225 el(TextControl, { label: __('Label', 'blockenberg'), value: btn.label, onChange: function (v) { updateBtn(index, 'label', v); } }),
226 el(TextControl, { label: __('URL', 'blockenberg'), value: btn.url, type: 'url', onChange: function (v) { updateBtn(index, 'url', v); } }),
227 el(ToggleControl, { label: __('Open in new tab', 'blockenberg'), checked: btn.target, __nextHasNoMarginBottom: true, onChange: function (v) { updateBtn(index, 'target', v); } }),
228 el(SelectControl, { label: __('Style', 'blockenberg'), value: btn.style, options: styleOptions, onChange: function (v) { updateBtn(index, 'style', v); } }),
229 el(SelectControl, { label: __('Size', 'blockenberg'), value: btn.size, options: sizeOptions, onChange: function (v) { updateBtn(index, 'size', v); } }),
230 el(SelectControl, { label: __('Icon', 'blockenberg'), value: btn.icon, options: iconOptions, onChange: function (v) { updateBtn(index, 'icon', v); } }),
231 btn.icon !== 'none' && el(SelectControl, {
232 label: __('Icon Position', 'blockenberg'),
233 value: btn.iconPosition,
234 options: [{ label: __('Left', 'blockenberg'), value: 'left' }, { label: __('Right', 'blockenberg'), value: 'right' }],
235 onChange: function (v) { updateBtn(index, 'iconPosition', v); }
236 }),
237 el('details', { style: { fontSize: '12px', marginTop: '4px' } },
238 el('summary', { style: { cursor: 'pointer', color: '#6b7280' } }, __('Custom Colors (overrides)', 'blockenberg')),
239 el('div', { style: { marginTop: '8px' } },
240 el(BkbgColorSwatch, { label: __('Background', 'blockenberg'), value: btn.customBg, onChange: function (v) { updateBtn(index, 'customBg', v); } }),
241 el(BkbgColorSwatch, { label: __('Text Color', 'blockenberg'), value: btn.customColor, onChange: function (v) { updateBtn(index, 'customColor', v); } }),
242 el(BkbgColorSwatch, { label: __('Border Color', 'blockenberg'), value: btn.customBorder, onChange: function (v) { updateBtn(index, 'customBorder', v); } })
243 )
244 )
245 );
246 }),
247 el(Button, {
248 variant: 'secondary',
249 onClick: addBtn,
250 style: { width: '100%' }
251 }, '+ ' + __('Add Button', 'blockenberg'))
252 ),
253
254 el(PanelBody, { title: __('Layout', 'blockenberg'), initialOpen: false },
255 el(SelectControl, { label: __('Alignment', 'blockenberg'), value: a.alignment, options: alignOptions, onChange: function (v) { setAttributes({ alignment: v }); } }),
256 el(SelectControl, { label: __('Direction', 'blockenberg'), value: a.direction, options: directionOptions, onChange: function (v) { setAttributes({ direction: v }); } }),
257 el(RangeControl, { label: __('Gap (px)', 'blockenberg'), value: a.gap, min: 4, max: 48, onChange: function (v) { setAttributes({ gap: v }); } }),
258 el(ToggleControl, { label: __('Stack on mobile', 'blockenberg'), checked: a.mobileStack, __nextHasNoMarginBottom: true, onChange: function (v) { setAttributes({ mobileStack: v }); } }),
259 el(ToggleControl, { label: __('Full width on mobile', 'blockenberg'), checked: a.fullWidthMobile, __nextHasNoMarginBottom: true, onChange: function (v) { setAttributes({ fullWidthMobile: v }); } })
260 ),
261
262 el(PanelBody, { title: __('Global Button Style', 'blockenberg'), initialOpen: false },
263 el(RangeControl, { label: __('Border Radius (px)', 'blockenberg'), value: a.btnRadius, min: 0, max: 50, onChange: function (v) { setAttributes({ btnRadius: v }); } }),
264 el(RangeControl, { label: __('Padding Vertical (px)', 'blockenberg'), value: a.btnPaddingV, min: 4, max: 32, onChange: function (v) { setAttributes({ btnPaddingV: v }); } }),
265 el(RangeControl, { label: __('Padding Horizontal (px)', 'blockenberg'), value: a.btnPaddingH, min: 8, max: 64, onChange: function (v) { setAttributes({ btnPaddingH: v }); } }),
266 el(SelectControl, { label: __('Shadow', 'blockenberg'), value: a.btnShadow, options: shadowOptions, onChange: function (v) { setAttributes({ btnShadow: v }); } }),
267 el(SelectControl, { label: __('Hover Effect', 'blockenberg'), value: a.hoverEffect, options: hoverOptions, onChange: function (v) { setAttributes({ hoverEffect: v }); } })
268 ),
269
270
271 el( PanelBody, { title: __( 'Typography', 'blockenberg' ), initialOpen: false },
272 el(getTypographyControl(), { label: __('Button Text', 'blockenberg'), value: a.typoBtn, onChange: function (v) { setAttributes({ typoBtn: v }); } })
273 ),
274 el(PanelBody, { title: __('Colors', 'blockenberg'), initialOpen: false },
275 el(PanelColorSettings, {
276 title: __('Primary Button', 'blockenberg'),
277 initialOpen: false,
278 colorSettings: [
279 { value: a.btnBg, onChange: function (c) { setAttributes({ btnBg: c || '#2563eb' }); }, label: __('Background', 'blockenberg') },
280 { value: a.btnColor, onChange: function (c) { setAttributes({ btnColor: c || '#ffffff' }); }, label: __('Text', 'blockenberg') }
281 ]
282 }),
283 el(PanelColorSettings, {
284 title: __('Outline & Ghost Button', 'blockenberg'),
285 initialOpen: false,
286 colorSettings: [
287 { value: a.outlineBorderColor, onChange: function (c) { setAttributes({ outlineBorderColor: c || '#2563eb' }); }, label: __('Outline Border', 'blockenberg') },
288 { value: a.outlineColor, onChange: function (c) { setAttributes({ outlineColor: c || '#2563eb' }); }, label: __('Outline Text', 'blockenberg') },
289 { value: a.ghostColor, onChange: function (c) { setAttributes({ ghostColor: c || '#2563eb' }); }, label: __('Ghost / Link Text', 'blockenberg') }
290 ]
291 })
292 )
293 );
294
295 var groupStyle = {
296 justifyContent: a.alignment === 'center' ? 'center' : a.alignment === 'right' ? 'flex-end' : 'flex-start',
297 flexDirection: a.direction
298 };
299
300 var buttonsEl = a.buttons.map(function (btn, index) {
301 var btnStyle = { style: {} };
302 if (btn.customBg) btnStyle.style.background = btn.customBg;
303 if (btn.customColor) btnStyle.style.color = btn.customColor;
304 if (btn.customBorder) btnStyle.style.borderColor = btn.customBorder;
305
306 return el('div', { key: 'btn-' + index, className: 'bkbg-bg-btn-wrap' },
307 el('a', {
308 href: btn.url || '#',
309 className: getBtnClass(btn, a),
310 rel: btn.target ? 'noopener noreferrer' : undefined,
311 style: btnStyle.style
312 },
313 btn.iconPosition === 'left' && btn.icon !== 'none' && getIconEl(btn.icon),
314 el('span', {}, btn.label),
315 btn.iconPosition === 'right' && btn.icon !== 'none' && getIconEl(btn.icon)
316 )
317 );
318 });
319
320 return el(Fragment, {},
321 inspector,
322 el('div', blockProps,
323 el('div', { className: 'bkbg-bg-group', style: groupStyle },
324 buttonsEl
325 )
326 )
327 );
328 },
329
330 save: function (props) {
331 var a = props.attributes;
332
333 var tvStr = _tvString(a.typoBtn, '--bkbg-bg-typo-');
334 var wrapStyle = [
335 '--bkbg-bg-btn-bg:' + a.btnBg,
336 '--bkbg-bg-btn-color:' + a.btnColor,
337 '--bkbg-bg-outline-border:' + a.outlineBorderColor,
338 '--bkbg-bg-outline-color:' + a.outlineColor,
339 '--bkbg-bg-ghost-color:' + a.ghostColor,
340 '--bkbg-bg-radius:' + a.btnRadius + 'px',
341 '--bkbg-bg-padding:' + a.btnPaddingV + 'px ' + a.btnPaddingH + 'px',
342 '--bkbg-bg-gap:' + a.gap + 'px'
343 ].join(';') + (tvStr ? ';' + tvStr : '');
344
345 var blockProps = wp.blockEditor.useBlockProps.save({
346 className: 'bkbg-bg-wrap',
347 style: wrapStyle,
348 'data-align': a.alignment,
349 'data-direction': a.direction,
350 'data-shadow': a.btnShadow,
351 'data-hover': a.hoverEffect,
352 'data-mobile-stack': a.mobileStack ? '1' : '0',
353 'data-full-mobile': a.fullWidthMobile ? '1' : '0'
354 });
355
356 var savedIconSvgs = {
357 'none': '',
358 'arrow-right': '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"/><polyline points="12 5 19 12 12 19"/></svg>',
359 'external': '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',
360 'play': '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="15" height="15" fill="currentColor"><polygon points="5 3 19 12 5 21"/></svg>',
361 'star': '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="15" height="15" fill="currentColor"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26"/></svg>',
362 'download': '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>'
363 };
364
365 var justifyContent = a.alignment === 'center' ? 'center' : a.alignment === 'right' ? 'flex-end' : 'flex-start';
366
367 var buttonsEl = a.buttons.map(function (btn, index) {
368 var btnInlineStyle = {};
369 if (btn.customBg) btnInlineStyle.background = btn.customBg;
370 if (btn.customColor) btnInlineStyle.color = btn.customColor;
371 if (btn.customBorder) btnInlineStyle.borderColor = btn.customBorder;
372
373 var hasStyle = Object.keys(btnInlineStyle).length > 0;
374
375 var iconEl = btn.icon && btn.icon !== 'none' ? wp.element.createElement('span', {
376 className: 'bkbg-bg-icon',
377 'aria-hidden': 'true',
378 dangerouslySetInnerHTML: { __html: savedIconSvgs[btn.icon] || '' }
379 }) : null;
380
381 return wp.element.createElement('div', { key: 'btn-' + index, className: 'bkbg-bg-btn-wrap' },
382 wp.element.createElement('a', {
383 href: btn.url || '#',
384 className: 'bkbg-bg-btn bkbg-bg-btn-' + btn.style + ' bkbg-bg-btn-' + btn.size,
385 target: btn.target ? '_blank' : undefined,
386 rel: btn.target ? 'noopener noreferrer' : undefined,
387 style: hasStyle ? btnInlineStyle : undefined
388 },
389 btn.iconPosition === 'left' && iconEl,
390 wp.element.createElement('span', {}, btn.label),
391 btn.iconPosition === 'right' && iconEl
392 )
393 );
394 });
395
396 return wp.element.createElement('div', blockProps,
397 wp.element.createElement('div', {
398 className: 'bkbg-bg-group',
399 style: { justifyContent: justifyContent, flexDirection: a.direction }
400 }, buttonsEl)
401 );
402 }
403 });
404 }() );
405