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 / value-proposition / index.js

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

443 lines 24.4 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 RichText = wp.blockEditor.RichText;
5 var __ = wp.i18n.__;
6 var registerBlockType = wp.blocks.registerBlockType;
7 var InspectorControls = wp.blockEditor.InspectorControls;
8 var useBlockProps = wp.blockEditor.useBlockProps;
9 var PanelColorSettings = wp.blockEditor.PanelColorSettings;
10 var PanelBody = wp.components.PanelBody;
11 var Button = wp.components.Button;
12 var TextControl = wp.components.TextControl;
13 var ToggleControl = wp.components.ToggleControl;
14 var RangeControl = wp.components.RangeControl;
15 var SelectControl = wp.components.SelectControl;
16
17 var _tc, _tvf;
18 Object.defineProperty(window, '_tc', { get: function () { return _tc || (_tc = window.bkbgTypographyControl); } });
19 Object.defineProperty(window, '_tvf', { get: function () { return _tvf || (_tvf = window.bkbgTypoCssVars); } });
20 function getTypoControl(label, key, attrs, setA) { return _tc(label, key, attrs, setA); }
21 function getTypoCssVars(attrs) {
22 var v = {};
23 _tvf(v, 'headlineTypo', attrs, '--bkvp-hl-');
24 _tvf(v, 'subTypo', attrs, '--bkvp-sb-');
25 _tvf(v, 'benefitTitleTypo', attrs, '--bkvp-bt-');
26 _tvf(v, 'benefitTextTypo', attrs, '--bkvp-bd-');
27 return v;
28 }
29
30 function updateItem(arr, idx, field, val) {
31 return arr.map(function (e, i) {
32 if (i !== idx) return e;
33 var u = {}; u[field] = val;
34 return Object.assign({}, e, u);
35 });
36 }
37
38 registerBlockType('blockenberg/value-proposition', {
39 title: __('Value Proposition', 'blockenberg'),
40 icon: 'star-filled',
41 category: 'bkbg-marketing',
42 description: __('Compelling value prop section with headline, USP benefits, proof badges, and CTA.', 'blockenberg'),
43
44 edit: function (props) {
45 var a = props.attributes;
46 var set = props.setAttributes;
47
48 var layoutOptions = [
49 { label: __('Centered', 'blockenberg'), value: 'center' },
50 { label: __('Left aligned', 'blockenberg'), value: 'left' }
51 ];
52 var styleOptions = [
53 { label: __('Clean', 'blockenberg'), value: 'clean' },
54 { label: __('Card', 'blockenberg'), value: 'card' },
55 { label: __('Bordered', 'blockenberg'), value: 'bordered' }
56 ];
57 var colOptions = [
58 { label: '1 column', value: 1 },
59 { label: '2 columns', value: 2 },
60 { label: '3 columns', value: 3 }
61 ];
62 var fontWeightOptions = [
63 { label: '400', value: 400 }, { label: '500', value: 500 },
64 { label: '600', value: 600 }, { label: '700', value: 700 },
65 { label: '800', value: 800 }, { label: '900', value: 900 }
66 ];
67
68 var textAlign = a.layout === 'center' ? 'center' : 'left';
69 var justifyContent = a.layout === 'center' ? 'center' : 'flex-start';
70
71 var inspector = el(InspectorControls, {},
72 // Structure
73 el(PanelBody, { title: __('Structure', 'blockenberg'), initialOpen: true },
74 el(SelectControl, {
75 label: __('Layout', 'blockenberg'),
76 value: a.layout, options: layoutOptions, __nextHasNoMarginBottom: true,
77 onChange: function (v) { set({ layout: v }); }
78 }),
79 el(SelectControl, {
80 label: __('Benefit columns', 'blockenberg'),
81 value: a.benefitColumns, options: colOptions, __nextHasNoMarginBottom: true,
82 onChange: function (v) { set({ benefitColumns: parseInt(v, 10) }); }
83 }),
84 el(SelectControl, {
85 label: __('Style', 'blockenberg'),
86 value: a.style, options: styleOptions, __nextHasNoMarginBottom: true,
87 onChange: function (v) { set({ style: v }); }
88 }),
89 el(ToggleControl, {
90 label: __('Show eyebrow label', 'blockenberg'),
91 checked: a.showEyebrow, __nextHasNoMarginBottom: true,
92 onChange: function (v) { set({ showEyebrow: v }); }
93 }),
94 el(ToggleControl, {
95 label: __('Show subheadline', 'blockenberg'),
96 checked: a.showSubheadline, __nextHasNoMarginBottom: true,
97 onChange: function (v) { set({ showSubheadline: v }); }
98 }),
99 el(ToggleControl, {
100 label: __('Show proof badges', 'blockenberg'),
101 checked: a.showBadges, __nextHasNoMarginBottom: true,
102 onChange: function (v) { set({ showBadges: v }); }
103 }),
104 el(ToggleControl, {
105 label: __('Show primary CTA', 'blockenberg'),
106 checked: a.showCta, __nextHasNoMarginBottom: true,
107 onChange: function (v) { set({ showCta: v }); }
108 }),
109 el(ToggleControl, {
110 label: __('Show secondary CTA', 'blockenberg'),
111 checked: a.showSecondaryCta, __nextHasNoMarginBottom: true,
112 onChange: function (v) { set({ showSecondaryCta: v }); }
113 })
114 ),
115
116 // CTA Links
117 el(PanelBody, { title: __('CTA Links', 'blockenberg'), initialOpen: false },
118 el(TextControl, {
119 label: __('Primary CTA URL', 'blockenberg'),
120 value: a.ctaUrl, type: 'url', __nextHasNoMarginBottom: true,
121 onChange: function (v) { set({ ctaUrl: v }); }
122 }),
123 el(TextControl, {
124 label: __('Secondary CTA URL', 'blockenberg'),
125 value: a.ctaSecondaryUrl, type: 'url', __nextHasNoMarginBottom: true,
126 onChange: function (v) { set({ ctaSecondaryUrl: v }); }
127 })
128 ),
129
130 // Badges
131 el(PanelBody, { title: __('Proof Badges', 'blockenberg'), initialOpen: false },
132 a.badges.map(function (badge, i) {
133 return el('div', { key: 'badge-' + i, style: { marginBottom: '12px', padding: '10px', background: '#f8fafc', borderRadius: '6px' } },
134 el('div', { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: '6px' } },
135 el('strong', {}, __('Badge', 'blockenberg') + ' ' + (i + 1)),
136 el(Button, { isDestructive: true, isSmall: true, icon: 'trash',
137 onClick: function () { set({ badges: a.badges.filter(function (_, j) { return j !== i; }) }); }
138 })
139 ),
140 el(TextControl, {
141 label: __('Icon / Emoji', 'blockenberg'), value: badge.icon, __nextHasNoMarginBottom: true,
142 onChange: function (v) { set({ badges: updateItem(a.badges, i, 'icon', v) }); }
143 }),
144 el(TextControl, {
145 label: __('Text', 'blockenberg'), value: badge.text, __nextHasNoMarginBottom: true,
146 onChange: function (v) { set({ badges: updateItem(a.badges, i, 'text', v) }); }
147 })
148 );
149 }),
150 el(Button, {
151 variant: 'secondary', isSmall: true, icon: 'plus-alt2',
152 onClick: function () { set({ badges: a.badges.concat([{ icon: '', text: 'New Badge' }]) }); }
153 }, __('Add Badge', 'blockenberg'))
154 ),
155
156 // Benefits (managed in sidebar for icon/description, inline for title)
157 el(PanelBody, { title: __('Benefits', 'blockenberg'), initialOpen: false },
158 a.benefits.map(function (ben, i) {
159 return el('div', { key: 'ben-' + i, style: { marginBottom: '12px', padding: '10px', background: '#f8fafc', borderRadius: '6px' } },
160 el('div', { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: '6px' } },
161 el('strong', {}, __('Benefit', 'blockenberg') + ' ' + (i + 1)),
162 el(Button, { isDestructive: true, isSmall: true, icon: 'trash',
163 onClick: function () { set({ benefits: a.benefits.filter(function (_, j) { return j !== i; }) }); }
164 })
165 ),
166 el(TextControl, {
167 label: __('Icon / Emoji', 'blockenberg'), value: ben.icon, __nextHasNoMarginBottom: true,
168 onChange: function (v) { set({ benefits: updateItem(a.benefits, i, 'icon', v) }); }
169 }),
170 el(TextControl, {
171 label: __('Title', 'blockenberg'), value: ben.title, __nextHasNoMarginBottom: true,
172 onChange: function (v) { set({ benefits: updateItem(a.benefits, i, 'title', v) }); }
173 }),
174 el(TextControl, {
175 label: __('Description', 'blockenberg'), value: ben.description, __nextHasNoMarginBottom: true,
176 onChange: function (v) { set({ benefits: updateItem(a.benefits, i, 'description', v) }); }
177 })
178 );
179 }),
180 el(Button, {
181 variant: 'secondary', isSmall: true, icon: 'plus-alt2',
182 onClick: function () {
183 set({ benefits: a.benefits.concat([{ icon: '', title: 'New Benefit', description: 'Describe this benefit here.' }]) });
184 }
185 }, __('Add Benefit', 'blockenberg'))
186 ),
187
188 // Spacing
189 el(PanelBody, { title: __('Spacing & Shape', 'blockenberg'), initialOpen: false },
190 el(RangeControl, {
191 label: __('Section padding (vertical)', 'blockenberg'),
192 value: a.paddingV, min: 16, max: 120, __nextHasNoMarginBottom: true,
193 onChange: function (v) { set({ paddingV: v }); }
194 }),
195 el(RangeControl, {
196 label: __('Section padding (horizontal)', 'blockenberg'),
197 value: a.paddingH, min: 0, max: 80, __nextHasNoMarginBottom: true,
198 onChange: function (v) { set({ paddingH: v }); }
199 }),
200 el(RangeControl, {
201 label: __('Benefit card gap', 'blockenberg'),
202 value: a.gap, min: 8, max: 48, __nextHasNoMarginBottom: true,
203 onChange: function (v) { set({ gap: v }); }
204 }),
205 el(RangeControl, {
206 label: __('Border radius', 'blockenberg'),
207 value: a.borderRadius, min: 0, max: 32, __nextHasNoMarginBottom: true,
208 onChange: function (v) { set({ borderRadius: v }); }
209 })
210 ),
211
212 // Typography
213 el(PanelBody, { title: __('Typography', 'blockenberg'), initialOpen: false },
214 getTypoControl(__('Headline', 'blockenberg'), 'headlineTypo', a, set),
215 getTypoControl(__('Subheadline', 'blockenberg'), 'subTypo', a, set),
216 getTypoControl(__('Benefit Title', 'blockenberg'), 'benefitTitleTypo', a, set),
217 getTypoControl(__('Benefit Text', 'blockenberg'), 'benefitTextTypo', a, set)
218 ),
219
220 // Colors
221 el(PanelBody, { title: __('Colors', 'blockenberg'), initialOpen: false },
222 el(PanelColorSettings, {
223 title: __('Header Colors', 'blockenberg'), initialOpen: false,
224 colorSettings: [
225 { value: a.bgColor, label: __('Section background', 'blockenberg'), onChange: function (c) { set({ bgColor: c }); } },
226 { value: a.accentColor, label: __('Accent', 'blockenberg'), onChange: function (c) { set({ accentColor: c }); } },
227 { value: a.eyebrowColor, label: __('Eyebrow', 'blockenberg'), onChange: function (c) { set({ eyebrowColor: c }); } },
228 { value: a.headlineColor, label: __('Headline', 'blockenberg'), onChange: function (c) { set({ headlineColor: c }); } },
229 { value: a.subColor, label: __('Subheadline', 'blockenberg'), onChange: function (c) { set({ subColor: c }); } }
230 ]
231 }),
232 el(PanelColorSettings, {
233 title: __('Benefit Card Colors', 'blockenberg'), initialOpen: false,
234 colorSettings: [
235 { value: a.benefitBg, label: __('Card background', 'blockenberg'), onChange: function (c) { set({ benefitBg: c }); } },
236 { value: a.benefitBorderColor, label: __('Card border', 'blockenberg'), onChange: function (c) { set({ benefitBorderColor: c }); } },
237 { value: a.iconBg, label: __('Icon background', 'blockenberg'), onChange: function (c) { set({ iconBg: c }); } },
238 { value: a.benefitTitleColor, label: __('Benefit title', 'blockenberg'), onChange: function (c) { set({ benefitTitleColor: c }); } },
239 { value: a.benefitTextColor, label: __('Benefit text', 'blockenberg'), onChange: function (c) { set({ benefitTextColor: c }); } }
240 ]
241 }),
242 el(PanelColorSettings, {
243 title: __('CTA & Badge Colors', 'blockenberg'), initialOpen: false,
244 colorSettings: [
245 { value: a.ctaBg, label: __('CTA background', 'blockenberg'), onChange: function (c) { set({ ctaBg: c }); } },
246 { value: a.ctaColor, label: __('CTA text', 'blockenberg'), onChange: function (c) { set({ ctaColor: c }); } },
247 { value: a.ctaSecondaryColor, label: __('Secondary CTA', 'blockenberg'), onChange: function (c) { set({ ctaSecondaryColor: c }); } },
248 { value: a.badgeBg, label: __('Badge background', 'blockenberg'), onChange: function (c) { set({ badgeBg: c }); } },
249 { value: a.badgeColor, label: __('Badge text', 'blockenberg'), onChange: function (c) { set({ badgeColor: c }); } }
250 ]
251 })
252 )
253 );
254
255 // ── Preview ──────────────────────────────────────────────
256 var colTemplate = a.benefitColumns === 1 ? '1fr' : a.benefitColumns === 3 ? '1fr 1fr 1fr' : '1fr 1fr';
257
258 var benefitsGrid = el('div', {
259 style: {
260 display: 'grid', gridTemplateColumns: colTemplate,
261 gap: a.gap + 'px', marginTop: '32px'
262 }
263 },
264 a.benefits.map(function (ben, i) {
265 var cardStyle = {
266 padding: '20px',
267 background: a.benefitBg,
268 borderRadius: a.borderRadius + 'px'
269 };
270 if (a.style === 'card') {
271 cardStyle.boxShadow = '0 2px 12px rgba(0,0,0,0.07)';
272 cardStyle.border = '1px solid ' + a.benefitBorderColor;
273 } else if (a.style === 'bordered') {
274 cardStyle.border = '1px solid ' + a.benefitBorderColor;
275 }
276
277 return el('div', { key: 'ben-' + i, style: cardStyle },
278 el('div', {
279 style: {
280 width: '44px', height: '44px', borderRadius: '10px',
281 background: a.iconBg, display: 'flex', alignItems: 'center',
282 justifyContent: 'center', fontSize: '22px', marginBottom: '12px'
283 }
284 }, ben.icon),
285 el('div', {
286 className: 'bkbg-vp-benefit-title',
287 style: {
288 color: a.benefitTitleColor
289 }
290 }, ben.title),
291 el('div', {
292 className: 'bkbg-vp-benefit-text',
293 style: { color: a.benefitTextColor }
294 }, ben.description)
295 );
296 })
297 );
298
299 var blockProps = useBlockProps((function () {
300 var s = getTypoCssVars(a);
301 return { className: 'bkbg-editor-wrap', 'data-block-label': 'Value Proposition', style: s };
302 })());
303
304 return el('div', blockProps,
305 inspector,
306 el('div', {
307 className: 'bkbg-vp-block',
308 style: {
309 background: a.bgColor,
310 padding: a.paddingV + 'px ' + a.paddingH + 'px',
311 textAlign: textAlign
312 }
313 },
314 // Eyebrow
315 a.showEyebrow && el('div', {
316 style: {
317 display: 'inline-block', background: a.accentColor + '18',
318 color: a.eyebrowColor, fontWeight: 700, fontSize: '13px',
319 letterSpacing: '.07em', textTransform: 'uppercase',
320 padding: '4px 14px', borderRadius: '100px', marginBottom: '16px'
321 }
322 },
323 el('input', {
324 type: 'text', value: a.eyebrow,
325 style: {
326 background: 'transparent', border: 'none', outline: 'none',
327 color: 'inherit', fontWeight: 'inherit', fontSize: 'inherit',
328 letterSpacing: 'inherit', textAlign: textAlign, width: '100%'
329 },
330 onChange: function (e) { set({ eyebrow: e.target.value }); }
331 })
332 ),
333
334 // Headline
335 el('h2', {
336 className: 'bkbg-vp-headline',
337 style: {
338 color: a.headlineColor, maxWidth: '800px',
339 marginLeft: a.layout === 'center' ? 'auto' : '0',
340 marginRight: a.layout === 'center' ? 'auto' : '0'
341 }
342 },
343 el('textarea', {
344 value: a.headline, rows: 2,
345 style: {
346 width: '100%', background: 'transparent', border: 'none', outline: 'none',
347 resize: 'none', font: 'inherit', letterSpacing: 'inherit', wordSpacing: 'inherit',
348 textTransform: 'inherit', fontStyle: 'inherit', textDecoration: 'inherit',
349 color: 'inherit', textAlign: textAlign
350 },
351 onChange: function (e) { set({ headline: e.target.value }); }
352 })
353 ),
354
355 // Subheadline
356 a.showSubheadline && el('p', {
357 className: 'bkbg-vp-sub',
358 style: {
359 color: a.subColor, maxWidth: '640px',
360 marginLeft: a.layout === 'center' ? 'auto' : '0',
361 marginRight: a.layout === 'center' ? 'auto' : '0'
362 }
363 },
364 el('textarea', {
365 value: a.subheadline, rows: 3,
366 style: {
367 width: '100%', background: 'transparent', border: 'none', outline: 'none',
368 resize: 'none', font: 'inherit', letterSpacing: 'inherit', wordSpacing: 'inherit',
369 textTransform: 'inherit', fontStyle: 'inherit', textDecoration: 'inherit',
370 color: 'inherit', textAlign: textAlign
371 },
372 onChange: function (e) { set({ subheadline: e.target.value }); }
373 })
374 ),
375
376 // CTA buttons
377 (a.showCta || a.showSecondaryCta) && el('div', {
378 style: {
379 display: 'flex', gap: '12px', flexWrap: 'wrap',
380 justifyContent: justifyContent, marginBottom: '32px'
381 }
382 },
383 a.showCta && el('input', {
384 type: 'text', value: a.ctaText,
385 style: {
386 background: a.ctaBg, color: a.ctaColor, fontWeight: 700,
387 fontSize: '15px', padding: '12px 24px', borderRadius: a.borderRadius + 'px',
388 border: 'none', outline: 'none', cursor: 'text'
389 },
390 onChange: function (e) { set({ ctaText: e.target.value }); }
391 }),
392 a.showSecondaryCta && el('input', {
393 type: 'text', value: a.ctaSecondaryText,
394 style: {
395 background: 'transparent', color: a.ctaSecondaryColor, fontWeight: 600,
396 fontSize: '15px', padding: '12px 0', border: 'none', outline: 'none', cursor: 'text'
397 },
398 onChange: function (e) { set({ ctaSecondaryText: e.target.value }); }
399 })
400 ),
401
402 // Benefits grid
403 benefitsGrid,
404
405 // Badges
406 a.showBadges && el('div', {
407 style: {
408 display: 'flex', gap: '10px', flexWrap: 'wrap',
409 justifyContent: justifyContent, marginTop: '32px'
410 }
411 },
412 a.badges.map(function (badge, i) {
413 return el('div', {
414 key: 'badge-' + i,
415 style: {
416 display: 'flex', alignItems: 'center', gap: '6px',
417 background: a.badgeBg, color: a.badgeColor, fontSize: '13px',
418 fontWeight: 600, padding: '6px 14px', borderRadius: '100px',
419 border: '1px solid ' + a.benefitBorderColor
420 }
421 },
422 el('span', {}, badge.icon),
423 el('span', {}, badge.text)
424 );
425 })
426 )
427 )
428 );
429 },
430
431 save: function (props) {
432 var a = props.attributes;
433 var blockProps = wp.blockEditor.useBlockProps.save((function () { var _tv = getTypoCssVars(a); return { style: _tv }; })());
434 return el('div', blockProps,
435 el('div', {
436 className: 'bkbg-value-proposition-app',
437 'data-opts': JSON.stringify(props.attributes)
438 })
439 );
440 }
441 });
442 }() );
443