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 / launch-waitlist / index.js

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

157 lines 12.9 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 __ = wp.i18n.__;
4 var registerBlockType = wp.blocks.registerBlockType;
5 var InspectorControls = wp.blockEditor.InspectorControls;
6 var useBlockProps = wp.blockEditor.useBlockProps;
7 var RichText = wp.blockEditor.RichText;
8 var PanelColorSettings = wp.blockEditor.PanelColorSettings;
9 var PanelBody = wp.components.PanelBody;
10 var ToggleControl = wp.components.ToggleControl;
11 var RangeControl = wp.components.RangeControl;
12 var SelectControl = wp.components.SelectControl;
13 var TextControl = wp.components.TextControl;
14 var TextareaControl = wp.components.TextareaControl;
15 var Button = wp.components.Button;
16
17 var _tc, _tv;
18 function getTypoControl() { return _tc || (_tc = window.bkbgTypographyControl); }
19 function getTypoCssVars() { return _tv || (_tv = window.bkbgTypoCssVars); }
20
21 registerBlockType('blockenberg/launch-waitlist', {
22 edit: function (props) {
23 var attr = props.attributes;
24 var setAttr = props.setAttributes;
25
26 function updateBenefit(idx, val) {
27 var benefits = (attr.benefits || []).map(function (b, i) { return i === idx ? { text: val } : b; });
28 setAttr({ benefits: benefits });
29 }
30
31 var inspector = el(InspectorControls, null,
32 el(PanelBody, { title: __('Layout', 'blockenberg'), initialOpen: true },
33 el(SelectControl, {
34 __nextHasNoMarginBottom: true,
35 label: __('Layout', 'blockenberg'),
36 value: attr.layout,
37 options: [
38 { label: 'Centered', value: 'centered' },
39 { label: 'Split (text | form)', value: 'split' }
40 ],
41 onChange: function (v) { setAttr({ layout: v }); }
42 }),
43 el(RangeControl, { __nextHasNoMarginBottom: true, label: __('Max Width (px)', 'blockenberg'), value: attr.maxWidth, min: 400, max: 1400, onChange: function (v) { setAttr({ maxWidth: v }); } }),
44 el(RangeControl, { __nextHasNoMarginBottom: true, label: __('Padding Top (px)', 'blockenberg'), value: attr.paddingTop, min: 0, max: 240, onChange: function (v) { setAttr({ paddingTop: v }); } }),
45 el(RangeControl, { __nextHasNoMarginBottom: true, label: __('Padding Bottom (px)', 'blockenberg'), value: attr.paddingBottom, min: 0, max: 240, onChange: function (v) { setAttr({ paddingBottom: v }); } })
46 ),
47 el(PanelBody, { title: __('Countdown', 'blockenberg'), initialOpen: false },
48 el(ToggleControl, { __nextHasNoMarginBottom: true, label: __('Show Countdown Timer', 'blockenberg'), checked: attr.showCountdown, onChange: function (v) { setAttr({ showCountdown: v }); } }),
49 attr.showCountdown && el(TextControl, { __nextHasNoMarginBottom: true, label: __('Launch Date (ISO format, e.g. 2025-12-31)', 'blockenberg'), value: attr.launchDate, onChange: function (v) { setAttr({ launchDate: v }); } })
50 ),
51 el(PanelBody, { title: __('Form', 'blockenberg'), initialOpen: false },
52 el(TextControl, { __nextHasNoMarginBottom: true, label: __('Placeholder', 'blockenberg'), value: attr.formPlaceholder, onChange: function (v) { setAttr({ formPlaceholder: v }); } }),
53 el(TextControl, { __nextHasNoMarginBottom: true, label: __('Submit Button Label', 'blockenberg'), value: attr.formSubmitLabel, onChange: function (v) { setAttr({ formSubmitLabel: v }); } }),
54 el(TextControl, { __nextHasNoMarginBottom: true, label: __('Form Action URL (optional)', 'blockenberg'), value: attr.formAction, onChange: function (v) { setAttr({ formAction: v }); } }),
55 el(TextareaControl, { __nextHasNoMarginBottom: true, label: __('Success Message', 'blockenberg'), value: attr.successMessage, onChange: function (v) { setAttr({ successMessage: v }); } })
56 ),
57 el(PanelBody, { title: __('Benefits & Social Proof', 'blockenberg'), initialOpen: false },
58 el(ToggleControl, { __nextHasNoMarginBottom: true, label: __('Show Benefits', 'blockenberg'), checked: attr.showBenefits, onChange: function (v) { setAttr({ showBenefits: v }); } }),
59 (attr.benefits || []).map(function (b, idx) {
60 return el('div', { key: idx, style: { display: 'flex', gap: '8px', marginBottom: '6px' } },
61 el(TextControl, { __nextHasNoMarginBottom: true, label: __('Benefit ' + (idx + 1), 'blockenberg'), value: b.text, onChange: function (v) { updateBenefit(idx, v); } }),
62 el(Button, { isDestructive: true, isSmall: true, onClick: function () { setAttr({ benefits: (attr.benefits || []).filter(function (_, i) { return i !== idx; }) }); } }, '')
63 );
64 }),
65 el(Button, { variant: 'secondary', onClick: function () { setAttr({ benefits: (attr.benefits || []).concat([{ text: 'New benefit' }]) }); } }, __('+ Add Benefit', 'blockenberg')),
66 el(ToggleControl, { __nextHasNoMarginBottom: true, label: __('Show Social Proof', 'blockenberg'), checked: attr.showSocialProof, onChange: function (v) { setAttr({ showSocialProof: v }); } }),
67 attr.showSocialProof && el(TextControl, { __nextHasNoMarginBottom: true, label: __('Social Proof Text', 'blockenberg'), value: attr.socialProof, onChange: function (v) { setAttr({ socialProof: v }); } })
68 ),
69 el(PanelColorSettings, {
70 title: __('Colors', 'blockenberg'),
71 initialOpen: false,
72 colorSettings: [
73 { label: __('Background', 'blockenberg'), value: attr.bgColor, onChange: function (v) { setAttr({ bgColor: v || '#0f172a' }); } },
74 { label: __('Accent', 'blockenberg'), value: attr.accentColor, onChange: function (v) { setAttr({ accentColor: v || '#6366f1' }); } },
75 { label: __('Heading', 'blockenberg'), value: attr.headingColor, onChange: function (v) { setAttr({ headingColor: v || '#f8fafc' }); } },
76 { label: __('Subtext', 'blockenberg'), value: attr.subColor, onChange: function (v) { setAttr({ subColor: v || '#94a3b8' }); } },
77 { label: __('Badge BG', 'blockenberg'), value: attr.badgeBg, onChange: function (v) { setAttr({ badgeBg: v || 'rgba(99,102,241,0.2)' }); } },
78 { label: __('Badge Text', 'blockenberg'), value: attr.badgeColor, onChange: function (v) { setAttr({ badgeColor: v || '#a5b4fc' }); } },
79 { label: __('Countdown Card BG', 'blockenberg'), value: attr.countdownBg, onChange: function (v) { setAttr({ countdownBg: v || '#1e293b' }); } },
80 { label: __('Countdown Numbers', 'blockenberg'), value: attr.countdownNumColor, onChange: function (v) { setAttr({ countdownNumColor: v || '#f8fafc' }); } },
81 { label: __('Input BG', 'blockenberg'), value: attr.inputBg, onChange: function (v) { setAttr({ inputBg: v || '#1e293b' }); } },
82 { label: __('Input Text', 'blockenberg'), value: attr.inputColor, onChange: function (v) { setAttr({ inputColor: v || '#f1f5f9' }); } },
83 { label: __('Submit BG', 'blockenberg'), value: attr.submitBg, onChange: function (v) { setAttr({ submitBg: v || '#6366f1' }); } },
84 { label: __('Submit Text', 'blockenberg'), value: attr.submitColor, onChange: function (v) { setAttr({ submitColor: v || '#ffffff' }); } }
85 ]
86 }),
87 el(PanelBody, { title: 'Typography', initialOpen: false },
88 getTypoControl() && el(getTypoControl(), { label: __('Heading'), value: attr.headingTypo || {}, onChange: function (v) { setAttr({ headingTypo: v }); } }),
89 getTypoControl() && el(getTypoControl(), { label: __('Subtext'), value: attr.subtextTypo || {}, onChange: function (v) { setAttr({ subtextTypo: v }); } }),
90 getTypoControl() && el(getTypoControl(), { label: __('Button'), value: attr.buttonTypo || {}, onChange: function (v) { setAttr({ buttonTypo: v }); } })
91 ),
92
93 );
94
95 var blockProps = useBlockProps((function () {
96 var _tvFn = getTypoCssVars();
97 var s = {};
98 if (_tvFn) {
99 Object.assign(s, _tvFn(attr.headingTypo, '--bkbg-lwl-h-'));
100 Object.assign(s, _tvFn(attr.subtextTypo, '--bkbg-lwl-st-'));
101 Object.assign(s, _tvFn(attr.buttonTypo, '--bkbg-lwl-bt-'));
102 }
103 return { className: 'bkbg-lwl-editor', style: s };
104 })());
105
106 /* Dummy countdown for preview */
107 var dummyUnits = [{ n: '14', l: 'DAYS' }, { n: '08', l: 'HOURS' }, { n: '33', l: 'MINS' }, { n: '21', l: 'SECS' }];
108
109 return el('div', blockProps,
110 inspector,
111 el('div', { style: { background: attr.bgColor, padding: '60px 40px', borderRadius: '8px', fontFamily: 'sans-serif', textAlign: 'center' } },
112 /* Badge */
113 el('div', { style: { display: 'inline-block', background: attr.badgeBg, color: attr.badgeColor, borderRadius: '20px', padding: '6px 16px', fontSize: '14px', fontWeight: 600, marginBottom: '20px' } },
114 el(RichText, { tagName: 'span', value: attr.badge, onChange: function (v) { setAttr({ badge: v }); }, placeholder: __('Badge…', 'blockenberg') })
115 ),
116 /* Heading */
117 el(RichText, { tagName: 'h2', className: 'bkbg-lwl-heading', value: attr.heading, onChange: function (v) { setAttr({ heading: v }); }, placeholder: __('Heading…', 'blockenberg'), style: { color: attr.headingColor, margin: '0 0 16px' } }),
118 el(RichText, { tagName: 'p', className: 'bkbg-lwl-sub', value: attr.subtext, onChange: function (v) { setAttr({ subtext: v }); }, placeholder: __('Subtext…', 'blockenberg'), style: { color: attr.subColor, maxWidth: '560px', margin: '0 auto 32px' } }),
119 /* Countdown */
120 attr.showCountdown && el('div', { style: { display: 'flex', justifyContent: 'center', gap: '12px', marginBottom: '36px' } },
121 dummyUnits.map(function (u, i) {
122 return el('div', { key: i, style: { background: attr.countdownBg, borderRadius: '10px', padding: '16px 20px', minWidth: '72px', textAlign: 'center' } },
123 el('div', { style: { color: attr.countdownNumColor, fontSize: '32px', fontWeight: 800, lineHeight: 1 } }, u.n),
124 el('div', { style: { color: attr.countdownLabelColor, fontSize: '11px', letterSpacing: '0.08em', marginTop: '4px' } }, u.l)
125 );
126 })
127 ),
128 /* Form */
129 el('div', { style: { display: 'flex', gap: '0', maxWidth: '480px', margin: '0 auto 24px', borderRadius: '10px', overflow: 'hidden', border: '1px solid ' + attr.inputBorder } },
130 el('input', { type: 'text', placeholder: attr.formPlaceholder, style: { flex: 1, background: attr.inputBg, color: attr.inputColor, border: 'none', padding: '14px 18px', fontSize: '15px', outline: 'none' }, readOnly: true }),
131 el('button', { className: 'bkbg-lwl-submit', style: { background: attr.submitBg, color: attr.submitColor, border: 'none', padding: '14px 22px', cursor: 'pointer', whiteSpace: 'nowrap' } }, attr.formSubmitLabel)
132 ),
133 /* Benefits */
134 attr.showBenefits && el('div', { style: { display: 'flex', justifyContent: 'center', gap: '20px', flexWrap: 'wrap', marginBottom: '20px' } },
135 (attr.benefits || []).map(function (b, i) {
136 return el('span', { key: i, style: { color: attr.benefitColor, fontSize: '14px', display: 'flex', alignItems: 'center', gap: '6px' } },
137 el('span', { style: { color: attr.accentColor } }, ''),
138 b.text
139 );
140 })
141 ),
142 /* Social proof */
143 attr.showSocialProof && el('p', { style: { color: attr.socialProofColor, fontSize: '14px', margin: 0 } }, attr.socialProof)
144 )
145 );
146 },
147
148 save: function (props) {
149 var attr = props.attributes;
150 var useBlockProps = wp.blockEditor.useBlockProps;
151 return el('div', useBlockProps.save(),
152 el('div', { className: 'bkbg-lwl-app', 'data-opts': JSON.stringify(attr) })
153 );
154 }
155 });
156 }() );
157