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 / feature-announcement / index.js

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

270 lines 20.3 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 registerBlockType = wp.blocks.registerBlockType;
5 var InspectorControls = wp.blockEditor.InspectorControls;
6 var useBlockProps = wp.blockEditor.useBlockProps;
7 var PanelBody = wp.components.PanelBody;
8 var PanelColorSettings = wp.blockEditor.PanelColorSettings;
9 var ToggleControl = wp.components.ToggleControl;
10 var RangeControl = wp.components.RangeControl;
11 var SelectControl = wp.components.SelectControl;
12 var TextControl = wp.components.TextControl;
13 var TextareaControl = wp.components.TextareaControl;
14 var Button = wp.components.Button;
15
16 var _fanTC, _fanTV;
17 function _tc() { return _fanTC || (_fanTC = window.bkbgTypographyControl); }
18 function _tv() { return _fanTV || (_fanTV = window.bkbgTypoCssVars); }
19 var IP = function () { return window.bkbgIconPicker; };
20
21 // ── data ──────────────────────────────────────────────────────
22 var categoryOptions = [
23 { label: '🆕 New Feature', value: 'new-feature' },
24 { label: '⚡ Improvement', value: 'improvement' },
25 { label: '🐛 Bug Fix', value: 'bugfix' },
26 { label: '⚠️ Deprecation', value: 'deprecation' },
27 { label: '🔒 Security', value: 'security' },
28 { label: '📦 Integration', value: 'integration' }
29 ];
30
31 var statusOptions = [
32 { label: '�
33 Available Now', value: 'available' },
34 { label: '🧪 Beta', value: 'beta' },
35 { label: '🚀 Coming Soon', value: 'coming-soon' },
36 { label: '⚠️ Deprecated', value: 'deprecated' }
37 ];
38
39 var layoutOptions = [
40 { label: 'Card', value: 'card' },
41 { label: 'Announcement', value: 'announcement' },
42 { label: 'Hero', value: 'hero' }
43 ];
44
45 var accentPositionOptions = [
46 { label: 'Top stripe', value: 'top' },
47 { label: 'Left stripe', value: 'left' },
48 { label: 'None', value: 'none' }
49 ];
50
51 function categoryLabel(cat) {
52 var map = { 'new-feature': '🆕 New Feature', 'improvement': '⚡ Improvement', 'bugfix': '🐛 Bug Fix', 'deprecation': '⚠️ Deprecation', 'security': '🔒 Security', 'integration': '📦 Integration' };
53 return map[cat] || cat;
54 }
55 function statusLabel(s) {
56 var map = { 'available': '�
57 Available Now', 'beta': '🧪 Beta', 'coming-soon': '🚀 Coming Soon', 'deprecated': '⚠️ Deprecated' };
58 return map[s] || s;
59 }
60
61 registerBlockType('blockenberg/feature-announcement', {
62 edit: function (props) {
63 var a = props.attributes;
64 var set = props.setAttributes;
65
66 var blockProps = useBlockProps({ className: 'bkbg-fan-editor-wrap', style: Object.assign({}, _tv()(a.typoName, '--bkbg-fan-nm-'), _tv()(a.typoTagline, '--bkbg-fan-tl-'), _tv()(a.typoBody, '--bkbg-fan-bd-')) });
67
68 var inner = el('div', { className: 'bkbg-fan-inner', style: { padding: '24px 28px', background: a.bgColor, position: 'relative' } },
69 // Meta badges row
70 el('div', { style: { display: 'flex', flexWrap: 'wrap', gap: 8, alignItems: 'center', marginBottom: 12 } },
71 a.showIcon && a.featureIcon && el('span', { className: 'bkbg-fan-icon', style: { fontSize: 28 } },
72 (!a.featureIconType || a.featureIconType === 'custom-char') ? a.featureIcon : IP().buildEditorIcon(a.featureIconType, a.featureIcon, a.featureIconDashicon, a.featureIconImageUrl, a.featureIconDashiconColor)
73 ),
74 el('span', { className: 'bkbg-fan-badge', style: { background: a.categoryBg, color: a.categoryColor } }, categoryLabel(a.category)),
75 a.showVersion && el('span', { className: 'bkbg-fan-badge', style: { background: a.versionBg, color: a.versionColor } }, a.version),
76 el('span', { className: 'bkbg-fan-badge', style: { background: a.statusBg, color: a.statusColor } }, statusLabel(a.status)),
77 a.showDate && a.releaseDate && el('span', { className: 'bkbg-fan-date', style: { color: '#64748b' } }, a.releaseDate)
78 ),
79 // Feature name
80 el('h2', { className: 'bkbg-fan-name', style: { margin: '0 0 8px', color: a.featureNameColor } }, a.featureName),
81 // Tagline
82 el('p', { className: 'bkbg-fan-tagline', style: { margin: '0 0 14px', color: a.taglineColor } }, a.tagline),
83 // Description
84 a.showDescription && el('p', { className: 'bkbg-fan-description', style: { margin: '0 0 16px', color: a.textColor } }, a.description),
85 // Highlights
86 a.showHighlights && a.highlights.length > 0 && el('div', { style: { marginBottom: 16 } },
87 el('div', { className: 'bkbg-fan-highlights-label', style: { color: a.accentColor, marginBottom: 8 } }, a.highlightsLabel || "What's new"),
88 el('ul', { style: { margin: 0, padding: 0, listStyle: 'none' } },
89 a.highlights.map(function (h, i) {
90 return el('li', { key: i, className: 'bkbg-fan-highlight' },
91 el('span', { className: 'bkbg-fan-highlight-icon', style: { color: a.highlightIconColor } }, ''),
92 el('span', { style: { color: a.textColor } }, h)
93 );
94 })
95 )
96 ),
97 // Plans
98 a.showPlans && a.availablePlans.length > 0 && el('div', { style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap', marginBottom: 18 } },
99 el('span', { className: 'bkbg-fan-plans-label', style: { color: '#64748b' } }, (a.plansLabel || 'Available on') + ':'),
100 a.availablePlans.map(function (plan, i) {
101 return el('span', { key: i, className: 'bkbg-fan-plan-badge', style: { background: a.planBg, color: a.planColor } }, plan);
102 })
103 ),
104 // CTAs
105 el('div', { style: { display: 'flex', gap: 10, flexWrap: 'wrap' } },
106 a.showCta && a.ctaText && el('a', { href: a.ctaUrl || '#', className: 'bkbg-fan-cta', style: { background: a.ctaBg, color: a.ctaColor, padding: '11px 22px', borderRadius: (a.borderRadius || 12) + 'px', textDecoration: 'none', display: 'inline-block' } }, a.ctaText),
107 a.showSecondaryCta && a.ctaSecondaryText && el('a', { href: a.ctaSecondaryUrl || '#', className: 'bkbg-fan-cta is-secondary', style: { borderColor: a.ctaSecondaryColor, color: a.ctaSecondaryColor, padding: '9px 22px', borderRadius: (a.borderRadius || 12) + 'px', textDecoration: 'none', display: 'inline-block' } }, a.ctaSecondaryText)
108 )
109 );
110
111 // Wrap with accent stripe
112 var wrapStyle = { border: '1px solid ' + a.borderColor, borderRadius: (a.borderRadius || 12) + 'px', overflow: 'hidden' };
113 var wrapContent;
114 if (a.accentPosition === 'top') {
115 wrapContent = el('div', { style: wrapStyle },
116 el('div', { style: { height: 5, background: a.accentStripe } }),
117 inner
118 );
119 } else if (a.accentPosition === 'left') {
120 wrapContent = el('div', { style: Object.assign({}, wrapStyle, { display: 'flex' }) },
121 el('div', { style: { width: 5, flexShrink: 0, background: a.accentStripe } }),
122 inner
123 );
124 } else {
125 wrapContent = el('div', { style: wrapStyle }, inner);
126 }
127
128 return el(Fragment, null,
129 el('div', blockProps, wrapContent),
130 el(InspectorControls, null,
131 // Feature Info
132 el(PanelBody, { title: 'Feature Info', initialOpen: true },
133 el(TextControl, { label: 'Feature Name', value: a.featureName, __nextHasNoMarginBottom: true, onChange: function (v) { set({ featureName: v }); } }),
134 el('div', { style: { marginTop: 8 } },
135 el(TextControl, { label: 'Tagline', value: a.tagline, __nextHasNoMarginBottom: true, onChange: function (v) { set({ tagline: v }); } })
136 ),
137 el('div', { style: { marginTop: 8 } },
138 el('p', { style: { fontSize: '11px', fontWeight: 600, marginTop: '8px' } }, 'Feature Icon'),
139 el(IP().IconPickerControl, IP().iconPickerProps(a, set, { charAttr: 'featureIcon', typeAttr: 'featureIconType', dashiconAttr: 'featureIconDashicon', imageUrlAttr: 'featureIconImageUrl', colorAttr: 'featureIconDashiconColor' }))
140 ),
141 el('div', { style: { marginTop: 8 } },
142 el(SelectControl, { label: 'Category', value: a.category, options: categoryOptions, __nextHasNoMarginBottom: true, onChange: function (v) { set({ category: v }); } })
143 ),
144 el('div', { style: { marginTop: 8 } },
145 el(SelectControl, { label: 'Status', value: a.status, options: statusOptions, __nextHasNoMarginBottom: true, onChange: function (v) { set({ status: v }); } })
146 ),
147 el('div', { style: { marginTop: 8 } },
148 el(TextControl, { label: 'Version (e.g. v3.2)', value: a.version, __nextHasNoMarginBottom: true, onChange: function (v) { set({ version: v }); } })
149 ),
150 el('div', { style: { marginTop: 8 } },
151 el(TextControl, { label: 'Release Date', value: a.releaseDate, __nextHasNoMarginBottom: true, onChange: function (v) { set({ releaseDate: v }); } })
152 ),
153 el('div', { style: { marginTop: 8, display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 4 } },
154 el(ToggleControl, { label: 'Show Icon', checked: a.showIcon, __nextHasNoMarginBottom: true, onChange: function (v) { set({ showIcon: v }); } }),
155 el(ToggleControl, { label: 'Show Version', checked: a.showVersion, __nextHasNoMarginBottom: true, onChange: function (v) { set({ showVersion: v }); } }),
156 el(ToggleControl, { label: 'Show Date', checked: a.showDate, __nextHasNoMarginBottom: true, onChange: function (v) { set({ showDate: v }); } })
157 )
158 ),
159 // Description
160 el(PanelBody, { title: 'Description', initialOpen: false },
161 el(ToggleControl, { label: 'Show Description', checked: a.showDescription, __nextHasNoMarginBottom: true, onChange: function (v) { set({ showDescription: v }); } }),
162 el('div', { style: { marginTop: 8 } },
163 el(TextareaControl, { value: a.description, rows: 4, __nextHasNoMarginBottom: true, onChange: function (v) { set({ description: v }); } })
164 )
165 ),
166 // Highlights
167 el(PanelBody, { title: 'Highlights', initialOpen: false },
168 el(ToggleControl, { label: 'Show Highlights', checked: a.showHighlights, __nextHasNoMarginBottom: true, onChange: function (v) { set({ showHighlights: v }); } }),
169 el('div', { style: { marginTop: 8 } },
170 el(TextControl, { label: 'Section Label', value: a.highlightsLabel, __nextHasNoMarginBottom: true, onChange: function (v) { set({ highlightsLabel: v }); } })
171 ),
172 a.highlights.map(function (h, i) {
173 return el('div', { key: i, style: { marginTop: 8, display: 'flex', gap: 4, alignItems: 'center' } },
174 el('div', { style: { flex: 1 } },
175 el(TextControl, { value: h, __nextHasNoMarginBottom: true, onChange: function (v) { set({ highlights: a.highlights.map(function (x, j) { return j === i ? v : x; }) }); } })
176 ),
177 el(Button, { isDestructive: true, variant: 'link', style: { fontSize: 11 }, onClick: function () { set({ highlights: a.highlights.filter(function (_, j) { return j !== i; }) }); } }, '')
178 );
179 }),
180 el(Button, { variant: 'secondary', style: { marginTop: 8 }, onClick: function () { set({ highlights: a.highlights.concat(['New highlight point']) }); } }, '+ Add Highlight')
181 ),
182 // Plans & CTAs
183 el(PanelBody, { title: 'Plans & CTAs', initialOpen: false },
184 el(ToggleControl, { label: 'Show Plans', checked: a.showPlans, __nextHasNoMarginBottom: true, onChange: function (v) { set({ showPlans: v }); } }),
185 el('div', { style: { marginTop: 8 } },
186 el(TextControl, { label: 'Plans Label', value: a.plansLabel, __nextHasNoMarginBottom: true, onChange: function (v) { set({ plansLabel: v }); } })
187 ),
188 el('div', { style: { marginTop: 8 } },
189 el(TextControl, { label: 'Plans (comma-separated)', value: a.availablePlans.join(', '), __nextHasNoMarginBottom: true, onChange: function (v) { set({ availablePlans: v.split(',').map(function (p) { return p.trim(); }).filter(Boolean) }); } })
190 ),
191 el('div', { style: { marginTop: 12, borderTop: '1px solid #e5e7eb', paddingTop: 12 } },
192 el(ToggleControl, { label: 'Show Primary CTA', checked: a.showCta, __nextHasNoMarginBottom: true, onChange: function (v) { set({ showCta: v }); } }),
193 el('div', { style: { marginTop: 6 } },
194 el(TextControl, { label: 'CTA Text', value: a.ctaText, __nextHasNoMarginBottom: true, onChange: function (v) { set({ ctaText: v }); } })
195 ),
196 el('div', { style: { marginTop: 6 } },
197 el(TextControl, { label: 'CTA URL', value: a.ctaUrl, __nextHasNoMarginBottom: true, onChange: function (v) { set({ ctaUrl: v }); } })
198 ),
199 el('div', { style: { marginTop: 10, borderTop: '1px solid #e5e7eb', paddingTop: 10 } },
200 el(ToggleControl, { label: 'Show Secondary CTA', checked: a.showSecondaryCta, __nextHasNoMarginBottom: true, onChange: function (v) { set({ showSecondaryCta: v }); } }),
201 el('div', { style: { marginTop: 6 } },
202 el(TextControl, { label: 'Secondary CTA Text', value: a.ctaSecondaryText, __nextHasNoMarginBottom: true, onChange: function (v) { set({ ctaSecondaryText: v }); } })
203 ),
204 el('div', { style: { marginTop: 6 } },
205 el(TextControl, { label: 'Secondary CTA URL', value: a.ctaSecondaryUrl, __nextHasNoMarginBottom: true, onChange: function (v) { set({ ctaSecondaryUrl: v }); } })
206 )
207 )
208 )
209 ),
210 // Layout
211 el(PanelBody, { title: 'Layout & Style', initialOpen: false },
212 el(SelectControl, { label: 'Accent Stripe', value: a.accentPosition, options: accentPositionOptions, __nextHasNoMarginBottom: true, onChange: function (v) { set({ accentPosition: v }); } }),
213 el('div', { style: { marginTop: 8 } },
214 el(RangeControl, { label: 'Border Radius (px)', value: a.borderRadius, min: 0, max: 24, __nextHasNoMarginBottom: true, onChange: function (v) { set({ borderRadius: v }); } })
215 )
216 ),
217 // Colors
218
219 el( PanelBody, { title: 'Typography', initialOpen: false },
220 _tc() && el(_tc(), { label: 'Feature Name', value: a.typoName, onChange: function (v) { set({ typoName: v }); } }),
221 _tc() && el(_tc(), { label: 'Tagline', value: a.typoTagline, onChange: function (v) { set({ typoTagline: v }); } }),
222 _tc() && el(_tc(), { label: 'Body', value: a.typoBody, onChange: function (v) { set({ typoBody: v }); } })
223 ),
224 el(PanelColorSettings, {
225 title: 'Block & Accent Colors',
226 initialOpen: false,
227 colorSettings: [
228 { label: 'Background', value: a.bgColor, onChange: function (v) { set({ bgColor: v || '#ffffff' }); } },
229 { label: 'Border', value: a.borderColor, onChange: function (v) { set({ borderColor: v || '#e2e8f0' }); } },
230 { label: 'Accent Color', value: a.accentColor, onChange: function (v) { set({ accentColor: v || '#7c3aed' }); } },
231 { label: 'Accent Stripe', value: a.accentStripe, onChange: function (v) { set({ accentStripe: v || '#7c3aed' }); } },
232 { label: 'Feature Name', value: a.featureNameColor, onChange: function (v) { set({ featureNameColor: v || '#0f172a' }); } },
233 { label: 'Tagline', value: a.taglineColor, onChange: function (v) { set({ taglineColor: v || '#374151' }); } },
234 { label: 'Description Text', value: a.textColor, onChange: function (v) { set({ textColor: v || '#4b5563' }); } },
235 { label: 'Highlight Icon', value: a.highlightIconColor,onChange: function (v) { set({ highlightIconColor: v || '#7c3aed' }); } }
236 ]
237 }),
238 el(PanelColorSettings, {
239 title: 'Badge & CTA Colors',
240 initialOpen: false,
241 colorSettings: [
242 { label: 'Version BG', value: a.versionBg, onChange: function (v) { set({ versionBg: v || '#ede9fe' }); } },
243 { label: 'Version Text', value: a.versionColor, onChange: function (v) { set({ versionColor: v || '#5b21b6' }); } },
244 { label: 'Category BG', value: a.categoryBg, onChange: function (v) { set({ categoryBg: v || '#f0fdf4' }); } },
245 { label: 'Category Text', value: a.categoryColor, onChange: function (v) { set({ categoryColor: v || '#14532d' }); } },
246 { label: 'Status BG', value: a.statusBg, onChange: function (v) { set({ statusBg: v || '#dcfce7' }); } },
247 { label: 'Status Text', value: a.statusColor, onChange: function (v) { set({ statusColor: v || '#14532d' }); } },
248 { label: 'Plan BG', value: a.planBg, onChange: function (v) { set({ planBg: v || '#f5f3ff' }); } },
249 { label: 'Plan Text', value: a.planColor, onChange: function (v) { set({ planColor: v || '#5b21b6' }); } },
250 { label: 'Primary CTA BG', value: a.ctaBg, onChange: function (v) { set({ ctaBg: v || '#7c3aed' }); } },
251 { label: 'Primary CTA Text', value: a.ctaColor, onChange: function (v) { set({ ctaColor: v || '#ffffff' }); } },
252 { label: 'Secondary CTA', value: a.ctaSecondaryColor, onChange: function (v) { set({ ctaSecondaryColor: v || '#7c3aed' }); } }
253 ]
254 })
255 )
256 );
257 },
258
259 save: function (props) {
260 var useBlockProps = wp.blockEditor.useBlockProps;
261 return wp.element.createElement('div', useBlockProps.save(),
262 wp.element.createElement('div', {
263 className: 'bkbg-feature-announcement-app',
264 'data-opts': JSON.stringify(props.attributes)
265 })
266 );
267 }
268 });
269 }() );
270