| 1 |
( function () { |
| 2 |
var el = wp.element.createElement; |
| 3 |
var Fragment = wp.element.Fragment; |
| 4 |
var useState = wp.element.useState; |
| 5 |
var __ = wp.i18n.__; |
| 6 |
var registerBlockType = wp.blocks.registerBlockType; |
| 7 |
var InspectorControls = wp.blockEditor.InspectorControls; |
| 8 |
var RichText = wp.blockEditor.RichText; |
| 9 |
var useBlockProps = wp.blockEditor.useBlockProps; |
| 10 |
var PanelBody = wp.components.PanelBody; |
| 11 |
var Button = wp.components.Button; |
| 12 |
var ToggleControl = wp.components.ToggleControl; |
| 13 |
var RangeControl = wp.components.RangeControl; |
| 14 |
var SelectControl = wp.components.SelectControl; |
| 15 |
var TextControl = wp.components.TextControl; |
| 16 |
var ColorPicker = wp.components.ColorPicker; |
| 17 |
var Popover = wp.components.Popover; |
| 18 |
|
| 19 |
function getTypographyControl() { return (window.bkbgTypographyControl || function () { return null; }); } |
| 20 |
function getTypoCssVars() { return (window.bkbgTypoCssVars || function () { return {}; }); } |
| 21 |
function _tv(typo, prefix) { var fn = getTypoCssVars(); return fn(typo || {}, prefix); } |
| 22 |
|
| 23 |
function makeId() { return 'cpc' + Math.random().toString(36).substr(2, 5); } |
| 24 |
|
| 25 |
function buildWrapStyle(a) { |
| 26 |
return Object.assign({ |
| 27 |
'--bkbg-cpc-accent': a.accentColor, |
| 28 |
'--bkbg-cpc-hl-bg': a.highlightBg, |
| 29 |
'--bkbg-cpc-hl-color': a.highlightColor, |
| 30 |
'--bkbg-cpc-hl-border': a.highlightBorder, |
| 31 |
'--bkbg-cpc-card-bg': a.cardBg, |
| 32 |
'--bkbg-cpc-card-border': a.cardBorder, |
| 33 |
'--bkbg-cpc-check': a.checkColor, |
| 34 |
'--bkbg-cpc-cross': a.crossColor, |
| 35 |
'--bkbg-cpc-dash': a.dashColor, |
| 36 |
'--bkbg-cpc-badge-bg': a.badgeBg, |
| 37 |
'--bkbg-cpc-badge-color': a.badgeColor, |
| 38 |
'--bkbg-cpc-title-color': a.titleColor, |
| 39 |
'--bkbg-cpc-sect-title': a.sectionTitleColor, |
| 40 |
'--bkbg-cpc-sub-color': a.subtitleColor, |
| 41 |
'--bkbg-cpc-price-color': a.priceColor, |
| 42 |
'--bkbg-cpc-period-color': a.periodColor, |
| 43 |
'--bkbg-cpc-feat-color': a.featureColor, |
| 44 |
'--bkbg-cpc-cta-bg': a.ctaBg, |
| 45 |
'--bkbg-cpc-cta-color': a.ctaColor, |
| 46 |
'--bkbg-cpc-cta-hl-bg': a.ctaHighlightBg, |
| 47 |
'--bkbg-cpc-cta-hl-color': a.ctaHighlightColor, |
| 48 |
'--bkbg-cpc-card-r': a.cardRadius + 'px', |
| 49 |
'--bkbg-cpc-cta-r': a.ctaRadius + 'px', |
| 50 |
'--bkbg-cpc-badge-r': a.badgeRadius + 'px', |
| 51 |
'--bkbg-cpc-gap': a.gap + 'px', |
| 52 |
'--bkbg-cpc-price-sz': a.priceSize + 'px', |
| 53 |
'--bkbg-cpc-feat-sz': a.featureSize + 'px', |
| 54 |
'--bkbg-cpc-title-fw': a.titleFontWeight, |
| 55 |
'--bkbg-cpc-title-lh': a.titleLineHeight, |
| 56 |
'--bkbg-cpc-feat-fw': a.featureFontWeight, |
| 57 |
'--bkbg-cpc-feat-lh': a.featureLineHeight, |
| 58 |
paddingTop: a.paddingTop + 'px', |
| 59 |
paddingBottom: a.paddingBottom + 'px', |
| 60 |
backgroundColor: a.bgColor || undefined, |
| 61 |
}, _tv(a.typoTitle, '--bkcpc-title-'), _tv(a.typoFeature, '--bkcpc-feat-')); |
| 62 |
} |
| 63 |
|
| 64 |
function renderColorControl(key, label, value, onChange, openKey, setOpenKey) { |
| 65 |
var isOpen = openKey === key; |
| 66 |
return el('div', { key: key, style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '4px 0', gap: '8px' } }, |
| 67 |
el('span', { style: { fontSize: '12px', color: '#1e1e1e', flex: 1, lineHeight: 1.4 } }, label), |
| 68 |
el('div', { style: { position: 'relative', flexShrink: 0 } }, |
| 69 |
el('button', { type: 'button', onClick: function () { setOpenKey(isOpen ? null : key); }, style: { width: '28px', height: '28px', borderRadius: '4px', border: isOpen ? '2px solid #007cba' : '2px solid #ddd', cursor: 'pointer', padding: 0, background: value || '#ccc' } }), |
| 70 |
isOpen && el(Popover, { position: 'bottom left', onClose: function () { setOpenKey(null); } }, |
| 71 |
el('div', { style: { padding: '8px' } }, |
| 72 |
el(ColorPicker, { color: value, enableAlpha: true, onChange: onChange }) |
| 73 |
) |
| 74 |
) |
| 75 |
) |
| 76 |
); |
| 77 |
} |
| 78 |
|
| 79 |
/* Feature icon + color by type */ |
| 80 |
function featureIcon(type, a) { |
| 81 |
if (type === 'check') return el('span', { style: { color: a.checkColor, fontWeight: 700, fontSize: '15px', flexShrink: 0 } }, '✓'); |
| 82 |
if (type === 'cross') return el('span', { style: { color: a.crossColor, fontWeight: 700, fontSize: '15px', flexShrink: 0 } }, '✗'); |
| 83 |
return el('span', { style: { color: a.dashColor, fontWeight: 700, fontSize: '15px', flexShrink: 0 } }, '—'); |
| 84 |
} |
| 85 |
|
| 86 |
/* ── Individual comparison card ───────────────────────────────── */ |
| 87 |
function CompCard(props) { |
| 88 |
var item = props.item; |
| 89 |
var a = props.a; |
| 90 |
var hl = item.highlighted; |
| 91 |
|
| 92 |
var cardStyle = { |
| 93 |
flex: '1 1 0', |
| 94 |
minWidth: '220px', |
| 95 |
background: hl ? a.highlightBg : a.cardBg, |
| 96 |
border: '2px solid ' + (hl ? a.highlightBorder : a.cardBorder), |
| 97 |
borderRadius: a.cardRadius + 'px', |
| 98 |
display: 'flex', |
| 99 |
flexDirection: 'column', |
| 100 |
overflow: 'hidden', |
| 101 |
position: 'relative', |
| 102 |
boxShadow: hl ? '0 8px 32px rgba(108,63,181,0.18)' : '0 2px 10px rgba(0,0,0,0.06)', |
| 103 |
transform: hl ? 'translateY(-8px)' : 'none', |
| 104 |
transition: 'box-shadow 0.2s, transform 0.2s', |
| 105 |
}; |
| 106 |
|
| 107 |
return el('div', { style: cardStyle }, |
| 108 |
/* Badge */ |
| 109 |
item.badge && el('div', { style: { background: a.badgeBg, color: a.badgeColor, fontSize: '11px', fontWeight: 700, textAlign: 'center', padding: '4px 10px', borderRadius: a.badgeRadius + 'px 0 ' + a.badgeRadius + 'px 0', position: 'absolute', top: 0, right: 0, letterSpacing: '0.05em', textTransform: 'uppercase' } }, item.badge), |
| 110 |
|
| 111 |
/* Header */ |
| 112 |
el('div', { style: { padding: '28px 24px 20px', flex: '0 0 auto' } }, |
| 113 |
el('p', { style: { margin: 0, fontSize: a.cardTitleSize + 'px', fontWeight: 800, color: hl ? a.highlightColor : a.sectionTitleColor } }, item.title), |
| 114 |
item.subtitle && el('p', { style: { margin: '4px 0 0', fontSize: '13px', color: hl ? a.highlightColor : a.subtitleColor, opacity: 0.85 } }, item.subtitle) |
| 115 |
), |
| 116 |
|
| 117 |
/* Price */ |
| 118 |
el('div', { style: { padding: '0 24px 20px', flex: '0 0 auto', borderBottom: '1px solid ' + (hl ? a.highlightBorder : a.cardBorder) } }, |
| 119 |
el('div', { style: { display: 'flex', alignItems: 'flex-end', gap: '4px' } }, |
| 120 |
el('span', { style: { fontSize: a.priceSize + 'px', fontWeight: 900, color: hl ? a.highlightColor : a.priceColor, lineHeight: 1 } }, |
| 121 |
a.currency + item.price |
| 122 |
), |
| 123 |
item.period && el('span', { style: { fontSize: '13px', color: hl ? a.highlightColor : a.periodColor, marginBottom: '6px', opacity: 0.8 } }, '/' + item.period) |
| 124 |
) |
| 125 |
), |
| 126 |
|
| 127 |
/* Features */ |
| 128 |
el('div', { style: { padding: '20px 24px', flex: '1 1 auto' } }, |
| 129 |
item.features.map(function (f, fi) { |
| 130 |
return el('div', { key: fi, style: { display: 'flex', alignItems: 'center', gap: '10px', marginBottom: '12px' } }, |
| 131 |
featureIcon(f.type, a), |
| 132 |
el('span', { style: { fontSize: a.featureSize + 'px', color: hl ? a.highlightColor : a.featureColor, lineHeight: a.featureLineHeight, fontWeight: a.featureFontWeight } }, f.text) |
| 133 |
); |
| 134 |
}) |
| 135 |
), |
| 136 |
|
| 137 |
/* CTA */ |
| 138 |
item.ctaLabel && el('div', { style: { padding: '0 24px 28px', flex: '0 0 auto' } }, |
| 139 |
el('a', { href: item.ctaUrl || '#', target: item.ctaNewTab ? '_blank' : '_self', rel: 'noopener noreferrer', |
| 140 |
style: { display: 'block', textAlign: 'center', padding: '13px 20px', borderRadius: a.ctaRadius + 'px', fontWeight: 700, fontSize: '15px', textDecoration: 'none', letterSpacing: '0.02em', |
| 141 |
background: hl ? a.ctaHighlightBg : a.ctaBg, |
| 142 |
color: hl ? a.ctaHighlightColor : a.ctaColor, |
| 143 |
border: hl ? 'none' : '2px solid ' + a.cardBorder, |
| 144 |
} |
| 145 |
}, item.ctaLabel) |
| 146 |
) |
| 147 |
); |
| 148 |
} |
| 149 |
|
| 150 |
registerBlockType('blockenberg/comparison-cards', { |
| 151 |
title: __('Comparison Cards', 'blockenberg'), |
| 152 |
icon: 'columns', |
| 153 |
category: 'bkbg-marketing', |
| 154 |
|
| 155 |
edit: function (props) { |
| 156 |
var a = props.attributes; |
| 157 |
var setAttributes = props.setAttributes; |
| 158 |
|
| 159 |
var openColorKeyState = useState(null); |
| 160 |
var openColorKey = openColorKeyState[0]; |
| 161 |
var setOpenColorKey = openColorKeyState[1]; |
| 162 |
|
| 163 |
var editItemState = useState(null); |
| 164 |
var editItemId = editItemState[0]; |
| 165 |
var setEditItemId = editItemState[1]; |
| 166 |
|
| 167 |
var blockProps = useBlockProps({ style: buildWrapStyle(a) }); |
| 168 |
|
| 169 |
function cc(key, label, attrKey) { |
| 170 |
return renderColorControl(key, label, a[attrKey], function (val) { |
| 171 |
var upd = {}; upd[attrKey] = val; setAttributes(upd); |
| 172 |
}, openColorKey, setOpenColorKey); |
| 173 |
} |
| 174 |
|
| 175 |
function updateItem(id, key, val) { |
| 176 |
setAttributes({ items: a.items.map(function (it) { |
| 177 |
if (it.id !== id) return it; |
| 178 |
var u = Object.assign({}, it); u[key] = val; return u; |
| 179 |
}) }); |
| 180 |
} |
| 181 |
|
| 182 |
function removeItem(id) { |
| 183 |
setAttributes({ items: a.items.filter(function (it) { return it.id !== id; }) }); |
| 184 |
} |
| 185 |
|
| 186 |
function addItem() { |
| 187 |
var newId = makeId(); |
| 188 |
setAttributes({ items: a.items.concat([{ |
| 189 |
id: newId, title: 'New Plan', subtitle: '', price: '49', period: 'mo', |
| 190 |
badge: '', highlighted: false, ctaLabel: 'Get Started', ctaUrl: '', ctaNewTab: false, |
| 191 |
features: [{ text: 'Feature one', type: 'check' }, { text: 'Feature two', type: 'cross' }] |
| 192 |
}]) }); |
| 193 |
setEditItemId(newId); |
| 194 |
} |
| 195 |
|
| 196 |
function addFeature(id) { |
| 197 |
updateItem(id, 'features', (a.items.find(function (it) { return it.id === id; }).features || []).concat([{ text: 'New feature', type: 'check' }])); |
| 198 |
} |
| 199 |
|
| 200 |
function updateFeature(itemId, fi, key, val) { |
| 201 |
setAttributes({ items: a.items.map(function (it) { |
| 202 |
if (it.id !== itemId) return it; |
| 203 |
var feats = it.features.map(function (f, idx) { |
| 204 |
if (idx !== fi) return f; |
| 205 |
var u = Object.assign({}, f); u[key] = val; return u; |
| 206 |
}); |
| 207 |
return Object.assign({}, it, { features: feats }); |
| 208 |
}) }); |
| 209 |
} |
| 210 |
|
| 211 |
function removeFeature(itemId, fi) { |
| 212 |
setAttributes({ items: a.items.map(function (it) { |
| 213 |
if (it.id !== itemId) return it; |
| 214 |
return Object.assign({}, it, { features: it.features.filter(function (_, idx) { return idx !== fi; }) }); |
| 215 |
}) }); |
| 216 |
} |
| 217 |
|
| 218 |
return el(Fragment, null, |
| 219 |
el(InspectorControls, null, |
| 220 |
el(PanelBody, { title: __('Cards', 'blockenberg'), initialOpen: true }, |
| 221 |
a.items.map(function (item) { |
| 222 |
var isEdit = editItemId === item.id; |
| 223 |
return el('div', { key: item.id, style: { border: '1px solid #e0e0e0', borderRadius: '8px', marginBottom: '8px', overflow: 'hidden' } }, |
| 224 |
el('div', { onClick: function () { setEditItemId(isEdit ? null : item.id); }, |
| 225 |
style: { display: 'flex', alignItems: 'center', gap: '8px', padding: '8px 10px', cursor: 'pointer', background: isEdit ? '#f0e9ff' : '#fafafa' } }, |
| 226 |
item.highlighted && el('span', { style: { background: '#6c3fb5', color: '#fff', fontSize: '9px', fontWeight: 800, padding: '2px 6px', borderRadius: '99px', textTransform: 'uppercase' } }, 'HL'), |
| 227 |
el('span', { style: { flex: 1, fontSize: '12px', fontWeight: 700 } }, item.title), |
| 228 |
el('span', { style: { fontSize: '12px', color: '#888' } }, a.currency + item.price) |
| 229 |
), |
| 230 |
isEdit && el('div', { style: { padding: '10px', borderTop: '1px solid #e0e0e0' } }, |
| 231 |
el(TextControl, { label: __('Plan title', 'blockenberg'), value: item.title, onChange: function (v) { updateItem(item.id, 'title', v); } }), |
| 232 |
el(TextControl, { label: __('Subtitle', 'blockenberg'), value: item.subtitle, onChange: function (v) { updateItem(item.id, 'subtitle', v); } }), |
| 233 |
el(TextControl, { label: __('Price', 'blockenberg'), value: item.price, onChange: function (v) { updateItem(item.id, 'price', v); } }), |
| 234 |
el(TextControl, { label: __('Period (e.g. mo / yr)', 'blockenberg'), value: item.period, onChange: function (v) { updateItem(item.id, 'period', v); } }), |
| 235 |
el(TextControl, { label: __('Badge text', 'blockenberg'), value: item.badge, onChange: function (v) { updateItem(item.id, 'badge', v); }, placeholder: 'Most Popular' }), |
| 236 |
el(TextControl, { label: __('CTA label', 'blockenberg'), value: item.ctaLabel, onChange: function (v) { updateItem(item.id, 'ctaLabel', v); } }), |
| 237 |
el(TextControl, { label: __('CTA URL', 'blockenberg'), value: item.ctaUrl, onChange: function (v) { updateItem(item.id, 'ctaUrl', v); } }), |
| 238 |
el(ToggleControl, { label: __('Highlighted (featured card)', 'blockenberg'), checked: item.highlighted, onChange: function (v) { updateItem(item.id, 'highlighted', v); }, __nextHasNoMarginBottom: true }), |
| 239 |
el(ToggleControl, { label: __('CTA opens in new tab', 'blockenberg'), checked: item.ctaNewTab, onChange: function (v) { updateItem(item.id, 'ctaNewTab', v); }, __nextHasNoMarginBottom: true }), |
| 240 |
|
| 241 |
/* Features sub-list */ |
| 242 |
el('p', { style: { fontWeight: 700, fontSize: '12px', margin: '12px 0 6px', textTransform: 'uppercase', color: '#444', letterSpacing: '0.05em' } }, __('Features', 'blockenberg')), |
| 243 |
item.features.map(function (feat, fi) { |
| 244 |
return el('div', { key: fi, style: { border: '1px solid #eee', borderRadius: '6px', padding: '6px 8px', marginBottom: '6px' } }, |
| 245 |
el(TextControl, { label: __('Text', 'blockenberg'), value: feat.text, onChange: function (v) { updateFeature(item.id, fi, 'text', v); } }), |
| 246 |
el(SelectControl, { label: __('Type', 'blockenberg'), value: feat.type, options: [{ label: '✓ Check', value: 'check' }, { label: '✗ Cross', value: 'cross' }, { label: '— Dash', value: 'dash' }], onChange: function (v) { updateFeature(item.id, fi, 'type', v); } }), |
| 247 |
el(Button, { isDestructive: true, variant: 'tertiary', size: 'compact', onClick: function () { removeFeature(item.id, fi); } }, __('Remove', 'blockenberg')) |
| 248 |
); |
| 249 |
}), |
| 250 |
el(Button, { variant: 'secondary', size: 'compact', onClick: function () { addFeature(item.id); }, style: { marginBottom: '10px' } }, '+ ' + __('Add Feature', 'blockenberg')), |
| 251 |
el(Button, { isDestructive: true, variant: 'tertiary', size: 'compact', onClick: function () { removeItem(item.id); } }, __('Remove card', 'blockenberg')) |
| 252 |
) |
| 253 |
); |
| 254 |
}), |
| 255 |
el(Button, { variant: 'secondary', onClick: addItem, style: { width: '100%', justifyContent: 'center' } }, '+ ' + __('Add Card', 'blockenberg')) |
| 256 |
), |
| 257 |
el(PanelBody, { title: __('Header', 'blockenberg'), initialOpen: false }, |
| 258 |
el(ToggleControl, { label: __('Show section title', 'blockenberg'), checked: a.showTitle, onChange: function (v) { setAttributes({ showTitle: v }); }, __nextHasNoMarginBottom: true }), |
| 259 |
el(ToggleControl, { label: __('Show subtitle', 'blockenberg'), checked: a.showSubtitle, onChange: function (v) { setAttributes({ showSubtitle: v }); }, __nextHasNoMarginBottom: true }), |
| 260 |
el(ToggleControl, { label: __('Show "vs" badges', 'blockenberg'), checked: a.showVsBadge, onChange: function (v) { setAttributes({ showVsBadge: v }); }, __nextHasNoMarginBottom: true }), |
| 261 |
el(TextControl, { label: __('Currency symbol', 'blockenberg'), value: a.currency, onChange: function (v) { setAttributes({ currency: v }); } }) |
| 262 |
), |
| 263 |
el(PanelBody, { title: __('Appearance', 'blockenberg'), initialOpen: false }, |
| 264 |
el(RangeControl, { label: __('Card radius (px)', 'blockenberg'), value: a.cardRadius, min: 0, max: 32, onChange: function (v) { setAttributes({ cardRadius: v }); } }), |
| 265 |
el(RangeControl, { label: __('CTA radius (px)', 'blockenberg'), value: a.ctaRadius, min: 0, max: 32, onChange: function (v) { setAttributes({ ctaRadius: v }); } }), |
| 266 |
el(RangeControl, { label: __('Gap (px)', 'blockenberg'), value: a.gap, min: 0, max: 60, onChange: function (v) { setAttributes({ gap: v }); } }) |
| 267 |
), |
| 268 |
|
| 269 |
el( PanelBody, { title: __( 'Typography', 'blockenberg' ), initialOpen: false }, |
| 270 |
el(getTypographyControl(), { label: __('Title Typography', 'blockenberg'), value: a.typoTitle, onChange: function (v) { setAttributes({ typoTitle: v }); } }), |
| 271 |
el(getTypographyControl(), { label: __('Feature Typography', 'blockenberg'), value: a.typoFeature, onChange: function (v) { setAttributes({ typoFeature: v }); } }), |
| 272 |
el(RangeControl, { label: __('Card title size (px)','blockenberg'), value: a.cardTitleSize, min: 14, max: 36, onChange: function (v) { setAttributes({ cardTitleSize: v }); } }), |
| 273 |
el(RangeControl, { label: __('Price size (px)', 'blockenberg'), value: a.priceSize, min: 24, max: 72, onChange: function (v) { setAttributes({ priceSize: v }); } }) |
| 274 |
), |
| 275 |
el(PanelBody, { title: __('Colors', 'blockenberg'), initialOpen: false }, |
| 276 |
cc('accentColor', __('Accent', 'blockenberg'), 'accentColor'), |
| 277 |
cc('highlightBg', __('Highlighted card bg', 'blockenberg'), 'highlightBg'), |
| 278 |
cc('highlightColor', __('Highlighted text', 'blockenberg'), 'highlightColor'), |
| 279 |
cc('highlightBorder', __('Highlighted border', 'blockenberg'), 'highlightBorder'), |
| 280 |
cc('cardBg', __('Card background', 'blockenberg'), 'cardBg'), |
| 281 |
cc('cardBorder', __('Card border', 'blockenberg'), 'cardBorder'), |
| 282 |
cc('checkColor', __('Check icon', 'blockenberg'), 'checkColor'), |
| 283 |
cc('crossColor', __('Cross icon', 'blockenberg'), 'crossColor'), |
| 284 |
cc('dashColor', __('Dash icon', 'blockenberg'), 'dashColor'), |
| 285 |
cc('badgeBg', __('Badge background', 'blockenberg'), 'badgeBg'), |
| 286 |
cc('badgeColor', __('Badge text', 'blockenberg'), 'badgeColor'), |
| 287 |
cc('titleColor', __('Section title', 'blockenberg'), 'titleColor'), |
| 288 |
cc('sectionTitleColor',__('Card title', 'blockenberg'), 'sectionTitleColor'), |
| 289 |
cc('subtitleColor', __('Subtitle', 'blockenberg'), 'subtitleColor'), |
| 290 |
cc('priceColor', __('Price', 'blockenberg'), 'priceColor'), |
| 291 |
cc('periodColor', __('Period', 'blockenberg'), 'periodColor'), |
| 292 |
cc('featureColor', __('Feature text', 'blockenberg'), 'featureColor'), |
| 293 |
cc('ctaBg', __('CTA background', 'blockenberg'), 'ctaBg'), |
| 294 |
cc('ctaColor', __('CTA text', 'blockenberg'), 'ctaColor'), |
| 295 |
cc('ctaHighlightBg', __('CTA highlighted bg', 'blockenberg'), 'ctaHighlightBg'), |
| 296 |
cc('ctaHighlightColor',__('CTA highlighted text', 'blockenberg'), 'ctaHighlightColor'), |
| 297 |
cc('bgColor', __('Section background', 'blockenberg'), 'bgColor') |
| 298 |
), |
| 299 |
el(PanelBody, { title: __('Spacing', 'blockenberg'), initialOpen: false }, |
| 300 |
el(RangeControl, { label: __('Padding top', 'blockenberg'), value: a.paddingTop, min: 0, max: 200, onChange: function (v) { setAttributes({ paddingTop: v }); } }), |
| 301 |
el(RangeControl, { label: __('Padding bottom', 'blockenberg'), value: a.paddingBottom, min: 0, max: 200, onChange: function (v) { setAttributes({ paddingBottom: v }); } }) |
| 302 |
) |
| 303 |
), |
| 304 |
|
| 305 |
el('div', blockProps, |
| 306 |
/* Section header */ |
| 307 |
el('div', { style: { textAlign: 'center', marginBottom: '40px' } }, |
| 308 |
a.showTitle && el(RichText, { tagName: 'h2', value: a.title, onChange: function (v) { setAttributes({ title: v }); }, placeholder: __('Compare Plans', 'blockenberg'), className: 'bkcpc-title', style: { color: a.titleColor, margin: '0 0 10px' } }), |
| 309 |
a.showSubtitle && el(RichText, { tagName: 'p', value: a.subtitle, onChange: function (v) { setAttributes({ subtitle: v }); }, placeholder: __('Choose the plan that works for you', 'blockenberg'), style: { fontSize: '17px', color: a.subtitleColor, margin: 0, maxWidth: '520px', marginLeft: 'auto', marginRight: 'auto' } }) |
| 310 |
), |
| 311 |
|
| 312 |
/* Cards row */ |
| 313 |
el('div', { style: { display: 'flex', gap: a.gap + 'px', alignItems: 'flex-end', flexWrap: 'wrap', position: 'relative' } }, |
| 314 |
a.items.map(function (item, idx) { |
| 315 |
return el(Fragment, { key: item.id }, |
| 316 |
el(CompCard, { item: item, a: a }), |
| 317 |
/* vs badge between cards */ |
| 318 |
a.showVsBadge && idx < a.items.length - 1 && el('div', { style: { flexShrink: 0, width: '28px', height: '28px', borderRadius: '50%', background: a.accentColor, color: '#fff', display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: '11px', fontWeight: 900, alignSelf: 'center', boxShadow: '0 2px 8px rgba(0,0,0,0.15)', zIndex: 2 } }, 'vs') |
| 319 |
); |
| 320 |
}) |
| 321 |
) |
| 322 |
) |
| 323 |
); |
| 324 |
}, |
| 325 |
|
| 326 |
save: function (props) { |
| 327 |
var a = props.attributes; |
| 328 |
return el('div', wp.blockEditor.useBlockProps.save({ className: 'bkbg-cpc-wrapper', style: buildWrapStyle(a) }), |
| 329 |
el('div', { style: { textAlign: 'center', marginBottom: '40px' } }, |
| 330 |
a.showTitle && el(RichText.Content, { tagName: 'h2', className: 'bkbg-cpc-title bkcpc-title', value: a.title }), |
| 331 |
a.showSubtitle && el(RichText.Content, { tagName: 'p', className: 'bkbg-cpc-subtitle', value: a.subtitle }) |
| 332 |
), |
| 333 |
el('div', { className: 'bkbg-cpc-grid', 'data-items': JSON.stringify(a.items), 'data-currency': a.currency, 'data-show-vs': a.showVsBadge ? '1' : '0' }) |
| 334 |
); |
| 335 |
} |
| 336 |
}); |
| 337 |
}() ); |
| 338 |
|