| 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 |
var COLUMNS_OPTIONS = [ |
| 20 |
{ label: '1', value: 1 }, { label: '2', value: 2 }, { label: '3', value: 3 }, { label: '4', value: 4 }, |
| 21 |
]; |
| 22 |
var CARD_STYLE_OPTIONS = [ |
| 23 |
{ label: __('Card (shadow)', 'blockenberg'), value: 'card' }, |
| 24 |
{ label: __('Bordered', 'blockenberg'), value: 'bordered' }, |
| 25 |
{ label: __('Flat / Ghost', 'blockenberg'), value: 'flat' }, |
| 26 |
]; |
| 27 |
var HOVER_OPTIONS = [ |
| 28 |
{ label: __('Lift (shadow)', 'blockenberg'), value: 'lift' }, |
| 29 |
{ label: __('Glow', 'blockenberg'), value: 'glow' }, |
| 30 |
{ label: __('None', 'blockenberg'), value: 'none' }, |
| 31 |
]; |
| 32 |
var ACCENT_BAR_POS_OPTIONS = [ |
| 33 |
{ label: __('Top', 'blockenberg'), value: 'top' }, |
| 34 |
{ label: __('Bottom', 'blockenberg'), value: 'bottom' }, |
| 35 |
{ label: __('Left', 'blockenberg'), value: 'left' }, |
| 36 |
{ label: __('None', 'blockenberg'), value: 'none' }, |
| 37 |
]; |
| 38 |
var ICON_SHAPE_OPTIONS = [ |
| 39 |
{ label: __('Rounded', 'blockenberg'), value: 'rounded' }, |
| 40 |
{ label: __('Circle', 'blockenberg'), value: 'circle' }, |
| 41 |
{ label: __('Square', 'blockenberg'), value: 'square' }, |
| 42 |
]; |
| 43 |
var CTA_STYLE_OPTIONS = [ |
| 44 |
{ label: __('Link arrow', 'blockenberg'), value: 'link' }, |
| 45 |
{ label: __('Button', 'blockenberg'), value: 'button' }, |
| 46 |
]; |
| 47 |
|
| 48 |
function makeId() { return 'sk' + Math.random().toString(36).substr(2, 5); } |
| 49 |
|
| 50 |
var _tc, _tv; |
| 51 |
function getTC() { return _tc || (_tc = window.bkbgTypographyControl); } |
| 52 |
function getTV() { return _tv || (_tv = window.bkbgTypoCssVars); } |
| 53 |
var IP = function () { return window.bkbgIconPicker; }; |
| 54 |
|
| 55 |
function buildWrapStyle(a) { |
| 56 |
return { |
| 57 |
'--bkbg-sk-accent': a.globalAccent, |
| 58 |
'--bkbg-sk-card-bg': a.cardBg, |
| 59 |
'--bkbg-sk-card-border': a.cardBorderColor, |
| 60 |
'--bkbg-sk-title-color': a.titleColor, |
| 61 |
'--bkbg-sk-text-color': a.textColor, |
| 62 |
'--bkbg-sk-hl-color': a.highlightColor, |
| 63 |
'--bkbg-sk-hl-icon-color': a.highlightIconColor, |
| 64 |
'--bkbg-sk-title-sz': a.titleSize + 'px', |
| 65 |
'--bkbg-sk-text-sz': a.textSize + 'px', |
| 66 |
'--bkbg-sk-hl-sz': a.highlightSize + 'px', |
| 67 |
'--bkbg-sk-cta-sz': a.ctaSize + 'px', |
| 68 |
'--bkbg-sk-icon-sz': a.iconSize + 'px', |
| 69 |
'--bkbg-sk-icon-bg-sz': a.iconBgSize + 'px', |
| 70 |
'--bkbg-sk-cols': a.columns, |
| 71 |
'--bkbg-sk-gap': a.gap + 'px', |
| 72 |
'--bkbg-sk-card-pad': a.cardPadding + 'px', |
| 73 |
'--bkbg-sk-card-r': a.cardRadius + 'px', |
| 74 |
'--bkbg-sk-bar-h': a.accentBarHeight + 'px', |
| 75 |
'--bkbg-sk-cta-r': a.ctaRadius + 'px', |
| 76 |
paddingTop: a.paddingTop + 'px', |
| 77 |
paddingBottom: a.paddingBottom + 'px', |
| 78 |
backgroundColor: a.bgColor || undefined, |
| 79 |
}; |
| 80 |
} |
| 81 |
|
| 82 |
function renderColorControl(key, label, value, onChange, openKey, setOpenKey) { |
| 83 |
var isOpen = openKey === key; |
| 84 |
return el('div', { key: key, style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '4px 0', gap: '8px' } }, |
| 85 |
el('span', { style: { fontSize: '12px', color: '#1e1e1e', flex: 1, lineHeight: 1.4 } }, label), |
| 86 |
el('div', { style: { position: 'relative', flexShrink: 0 } }, |
| 87 |
el('button', { type: 'button', title: value || 'default', onClick: function () { setOpenKey(isOpen ? null : key); }, |
| 88 |
style: { width: '28px', height: '28px', borderRadius: '4px', border: isOpen ? '2px solid #007cba' : '2px solid #ddd', cursor: 'pointer', padding: 0, background: value || '#cccccc' } |
| 89 |
}), |
| 90 |
isOpen && el(Popover, { position: 'bottom left', onClose: function () { setOpenKey(null); } }, |
| 91 |
el('div', { style: { padding: '8px' } }, |
| 92 |
el(ColorPicker, { color: value, enableAlpha: true, onChange: onChange }) |
| 93 |
) |
| 94 |
) |
| 95 |
) |
| 96 |
); |
| 97 |
} |
| 98 |
|
| 99 |
/* ── Card preview ───────────────────────────────────────────────── */ |
| 100 |
function ServiceCard(props) { |
| 101 |
var item = props.item; |
| 102 |
var a = props.a; |
| 103 |
var isEditor = props.isEditor; |
| 104 |
var onUpdate = props.onUpdate; /* fn(key, val) — editor only */ |
| 105 |
var accent = (a.useItemAccent && item.accentColor) ? item.accentColor : a.globalAccent; |
| 106 |
|
| 107 |
var borderVar = a.cardStyle === 'card' ? 'none' : '1.5px solid ' + (a.cardBorderColor || '#e5e7eb'); |
| 108 |
var shadowVar = a.cardStyle === 'card' ? '0 4px 20px rgba(0,0,0,0.08)' : 'none'; |
| 109 |
var bgVar = a.cardBg || '#fff'; |
| 110 |
|
| 111 |
var accentBarTop = a.accentBarPosition === 'top' ? { height: a.accentBarHeight + 'px', backgroundColor: accent, margin: '-' + a.cardPadding + 'px -' + a.cardPadding + 'px ' + (a.cardPadding / 2) + 'px', borderRadius: a.cardRadius + 'px ' + a.cardRadius + 'px 0 0' } : null; |
| 112 |
var accentBarBottom = a.accentBarPosition === 'bottom' ? { height: a.accentBarHeight + 'px', backgroundColor: accent, margin: (a.cardPadding / 2) + 'px -' + a.cardPadding + 'px -' + a.cardPadding + 'px', borderRadius: '0 0 ' + a.cardRadius + 'px ' + a.cardRadius + 'px' } : null; |
| 113 |
var accentBarLeft = a.accentBarPosition === 'left' ? { position: 'absolute', top: 0, left: 0, width: a.accentBarHeight + 'px', height: '100%', backgroundColor: accent, borderRadius: a.cardRadius + 'px 0 0 ' + a.cardRadius + 'px' } : null; |
| 114 |
|
| 115 |
var iconBgRadius = a.iconShape === 'circle' ? '50%' : (a.iconShape === 'rounded' ? '12px' : '4px'); |
| 116 |
|
| 117 |
var cardStyle = { position: 'relative', background: bgVar, border: borderVar, boxShadow: shadowVar, borderRadius: a.cardRadius + 'px', padding: a.cardPadding + 'px', overflow: 'hidden', display: 'flex', flexDirection: 'column', gap: '16px' }; |
| 118 |
|
| 119 |
var ctaStyle = a.ctaStyle === 'button' |
| 120 |
? { display: 'inline-block', padding: '10px 22px', borderRadius: a.ctaRadius + 'px', background: accent, color: '#fff', fontWeight: 700, fontSize: a.ctaSize + 'px', textDecoration: 'none', cursor: 'pointer' } |
| 121 |
: { display: 'inline-flex', alignItems: 'center', gap: '6px', fontSize: a.ctaSize + 'px', fontWeight: 700, color: accent, textDecoration: 'none', cursor: 'pointer' }; |
| 122 |
|
| 123 |
return el('div', { className: 'bkbg-sk-card bkbg-sk-card--' + a.cardStyle + ' bkbg-sk-bar--' + a.accentBarPosition + ' bkbg-sk-hover--' + a.hoverEffect, style: cardStyle }, |
| 124 |
accentBarLeft && el('div', { className: 'bkbg-sk-accent-bar bkbg-sk-accent-bar--left', style: accentBarLeft }), |
| 125 |
accentBarTop && el('div', { className: 'bkbg-sk-accent-bar bkbg-sk-accent-bar--top', style: accentBarTop }), |
| 126 |
|
| 127 |
/* Icon */ |
| 128 |
el('div', { className: 'bkbg-sk-icon-wrap', style: { width: a.iconBgSize + 'px', height: a.iconBgSize + 'px', borderRadius: iconBgRadius, backgroundColor: accent + '1a', display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: a.iconSize + 'px', flexShrink: 0 } }, |
| 129 |
isEditor |
| 130 |
? el('span', { title: __('Edit in sidebar', 'blockenberg'), style: { cursor: 'default' } }, IP().buildEditorIcon(item.iconType || 'custom-char', item.icon, item.iconDashicon, item.iconImageUrl, item.iconDashiconColor)) |
| 131 |
: el('span', null, IP().buildSaveIcon(item.iconType || 'custom-char', item.icon, item.iconDashicon, item.iconImageUrl, item.iconDashiconColor)) |
| 132 |
), |
| 133 |
|
| 134 |
/* Title */ |
| 135 |
isEditor |
| 136 |
? el(RichText, { tagName: 'h3', className: 'bkbg-sk-title', value: item.title, onChange: function (v) { onUpdate('title', v); }, placeholder: __('Service title', 'blockenberg'), style: { color: a.titleColor, margin: 0 } }) |
| 137 |
: el(RichText.Content, { tagName: 'h3', className: 'bkbg-sk-title', value: item.title }), |
| 138 |
|
| 139 |
/* Description */ |
| 140 |
isEditor |
| 141 |
? el(RichText, { tagName: 'p', className: 'bkbg-sk-text', value: item.text, onChange: function (v) { onUpdate('text', v); }, placeholder: __('Describe the service…', 'blockenberg'), style: { color: a.textColor, margin: 0 } }) |
| 142 |
: el(RichText.Content, { tagName: 'p', className: 'bkbg-sk-text', value: item.text }), |
| 143 |
|
| 144 |
/* Highlights */ |
| 145 |
a.showHighlights && item.highlights && item.highlights.length > 0 && el('ul', { className: 'bkbg-sk-highlights', style: { listStyle: 'none', margin: 0, padding: 0, display: 'flex', flexDirection: 'column', gap: '6px' } }, |
| 146 |
item.highlights.map(function (hl, hi) { |
| 147 |
return el('li', { key: hi, style: { display: 'flex', alignItems: 'center', gap: '8px', fontSize: a.highlightSize + 'px', color: a.highlightColor } }, |
| 148 |
el('span', { style: { color: accent, fontSize: (a.highlightSize + 2) + 'px', flexShrink: 0 } }, '✓'), |
| 149 |
el('span', null, hl) |
| 150 |
); |
| 151 |
}) |
| 152 |
), |
| 153 |
|
| 154 |
/* CTA */ |
| 155 |
a.showCta && item.ctaLabel && el('div', { className: 'bkbg-sk-cta-wrap', style: { marginTop: 'auto', paddingTop: '8px' } }, |
| 156 |
isEditor |
| 157 |
? el('span', { className: 'bkbg-sk-cta', style: ctaStyle }, item.ctaLabel, a.ctaStyle === 'link' && el('span', null, '→')) |
| 158 |
: el('a', { href: item.ctaUrl || '#', className: 'bkbg-sk-cta', style: ctaStyle }, item.ctaLabel, a.ctaStyle === 'link' && el('span', null, '→')) |
| 159 |
), |
| 160 |
|
| 161 |
accentBarBottom && el('div', { className: 'bkbg-sk-accent-bar bkbg-sk-accent-bar--bottom', style: accentBarBottom }) |
| 162 |
); |
| 163 |
} |
| 164 |
|
| 165 |
registerBlockType('blockenberg/service-cards', { |
| 166 |
title: __('Service Cards', 'blockenberg'), |
| 167 |
icon: 'admin-multisite', |
| 168 |
category: 'bkbg-business', |
| 169 |
|
| 170 |
edit: function (props) { |
| 171 |
var a = props.attributes; |
| 172 |
var setAttributes = props.setAttributes; |
| 173 |
|
| 174 |
var openColorKeyState = useState(null); |
| 175 |
var openColorKey = openColorKeyState[0]; |
| 176 |
var setOpenColorKey = openColorKeyState[1]; |
| 177 |
|
| 178 |
var blockProps = useBlockProps((function () { |
| 179 |
var _tv = getTV(); |
| 180 |
var s = buildWrapStyle(a); |
| 181 |
Object.assign(s, _tv(a.titleTypo, '--bksk-tt-')); |
| 182 |
Object.assign(s, _tv(a.textTypo, '--bksk-bt-')); |
| 183 |
return { style: s }; |
| 184 |
})()); |
| 185 |
|
| 186 |
function cc(key, label, attrKey) { |
| 187 |
return renderColorControl(key, label, a[attrKey], function (val) { |
| 188 |
var upd = {}; upd[attrKey] = val; setAttributes(upd); |
| 189 |
}, openColorKey, setOpenColorKey); |
| 190 |
} |
| 191 |
|
| 192 |
function updateItem(id, key, val) { |
| 193 |
setAttributes({ items: a.items.map(function (item) { if (item.id !== id) return item; var u = Object.assign({}, item); u[key] = val; return u; }) }); |
| 194 |
} |
| 195 |
|
| 196 |
var gridStyle = { display: 'grid', gridTemplateColumns: 'repeat(' + a.columns + ', 1fr)', gap: a.gap + 'px' }; |
| 197 |
|
| 198 |
return el(Fragment, null, |
| 199 |
el(InspectorControls, null, |
| 200 |
el(PanelBody, { title: __('Layout', 'blockenberg'), initialOpen: true }, |
| 201 |
el(SelectControl, { label: __('Columns (desktop)', 'blockenberg'), value: a.columns, options: COLUMNS_OPTIONS, onChange: function (v) { setAttributes({ columns: parseInt(v,10) }); } }), |
| 202 |
el(SelectControl, { label: __('Columns (tablet)', 'blockenberg'), value: a.columnsTablet, options: COLUMNS_OPTIONS, onChange: function (v) { setAttributes({ columnsTablet: parseInt(v,10) }); } }), |
| 203 |
el(SelectControl, { label: __('Columns (mobile)', 'blockenberg'), value: a.columnsMobile, options: COLUMNS_OPTIONS.slice(0,2), onChange: function (v) { setAttributes({ columnsMobile: parseInt(v,10) }); } }), |
| 204 |
el(RangeControl, { label: __('Gap (px)', 'blockenberg'), value: a.gap, min: 8, max: 64, onChange: function (v) { setAttributes({ gap: v }); } }) |
| 205 |
), |
| 206 |
el(PanelBody, { title: __('Card Style', 'blockenberg'), initialOpen: false }, |
| 207 |
el(SelectControl, { label: __('Card style', 'blockenberg'), value: a.cardStyle, options: CARD_STYLE_OPTIONS, onChange: function (v) { setAttributes({ cardStyle: v }); } }), |
| 208 |
el(SelectControl, { label: __('Hover effect', 'blockenberg'), value: a.hoverEffect, options: HOVER_OPTIONS, onChange: function (v) { setAttributes({ hoverEffect: v }); } }), |
| 209 |
el(RangeControl, { label: __('Padding (px)', 'blockenberg'), value: a.cardPadding, min: 12, max: 64, onChange: function (v) { setAttributes({ cardPadding: v }); } }), |
| 210 |
el(RangeControl, { label: __('Radius (px)', 'blockenberg'), value: a.cardRadius, min: 0, max: 32, onChange: function (v) { setAttributes({ cardRadius: v }); } }) |
| 211 |
), |
| 212 |
el(PanelBody, { title: __('Accent Bar', 'blockenberg'), initialOpen: false }, |
| 213 |
el(SelectControl, { label: __('Bar position', 'blockenberg'), value: a.accentBarPosition, options: ACCENT_BAR_POS_OPTIONS, onChange: function (v) { setAttributes({ accentBarPosition: v }); } }), |
| 214 |
a.accentBarPosition !== 'none' && el(RangeControl, { label: __('Bar thickness (px)', 'blockenberg'), value: a.accentBarHeight, min: 2, max: 12, onChange: function (v) { setAttributes({ accentBarHeight: v }); } }), |
| 215 |
el(ToggleControl, { label: __('Use per-card accent color', 'blockenberg'), checked: a.useItemAccent, onChange: function (v) { setAttributes({ useItemAccent: v }); }, __nextHasNoMarginBottom: true }), |
| 216 |
!a.useItemAccent && renderColorControl('globalAccent', __('Global accent color', 'blockenberg'), a.globalAccent, function (v) { setAttributes({ globalAccent: v }); }, openColorKey, setOpenColorKey) |
| 217 |
), |
| 218 |
el(PanelBody, { title: __('Display', 'blockenberg'), initialOpen: false }, |
| 219 |
el(ToggleControl, { label: __('Show highlights', 'blockenberg'), checked: a.showHighlights, onChange: function (v) { setAttributes({ showHighlights: v }); }, __nextHasNoMarginBottom: true }), |
| 220 |
el(ToggleControl, { label: __('Show CTA', 'blockenberg'), checked: a.showCta, onChange: function (v) { setAttributes({ showCta: v }); }, __nextHasNoMarginBottom: true }), |
| 221 |
a.showCta && el(SelectControl, { label: __('CTA style', 'blockenberg'), value: a.ctaStyle, options: CTA_STYLE_OPTIONS, onChange: function (v) { setAttributes({ ctaStyle: v }); } }), |
| 222 |
a.showCta && el(RangeControl, { label: __('CTA button radius (px)', 'blockenberg'), value: a.ctaRadius, min: 0, max: 99, onChange: function (v) { setAttributes({ ctaRadius: v }); } }), |
| 223 |
el(SelectControl, { label: __('Icon shape', 'blockenberg'), value: a.iconShape, options: ICON_SHAPE_OPTIONS, onChange: function (v) { setAttributes({ iconShape: v }); } }), |
| 224 |
el(RangeControl, { label: __('Icon emoji (px)', 'blockenberg'), value: a.iconSize, min: 20, max: 56, onChange: function (v) { setAttributes({ iconSize: v }); } }), |
| 225 |
el(RangeControl, { label: __('Icon bg size (px)', 'blockenberg'), value: a.iconBgSize, min: 36, max: 100, onChange: function (v) { setAttributes({ iconBgSize: v }); } }) |
| 226 |
), |
| 227 |
el(PanelBody, { title: __('Typography', 'blockenberg'), initialOpen: false }, |
| 228 |
el(getTC(), { label: __('Title', 'blockenberg'), value: a.titleTypo, onChange: function (v) { setAttributes({ titleTypo: v }); } }), |
| 229 |
el(getTC(), { label: __('Description', 'blockenberg'), value: a.textTypo, onChange: function (v) { setAttributes({ textTypo: v }); } }), |
| 230 |
el(RangeControl, { label: __('Highlights (px)', 'blockenberg'), value: a.highlightSize, min: 11, max: 18, onChange: function (v) { setAttributes({ highlightSize: v }); } }), |
| 231 |
el(RangeControl, { label: __('CTA text (px)', 'blockenberg'), value: a.ctaSize, min: 12, max: 20, onChange: function (v) { setAttributes({ ctaSize: v }); } }) |
| 232 |
), |
| 233 |
el(PanelBody, { title: __('Colors', 'blockenberg'), initialOpen: false }, |
| 234 |
cc('cardBg', __('Card background', 'blockenberg'), 'cardBg'), |
| 235 |
cc('cardBorderColor', __('Card border', 'blockenberg'), 'cardBorderColor'), |
| 236 |
cc('titleColor', __('Title text', 'blockenberg'), 'titleColor'), |
| 237 |
cc('textColor', __('Description text', 'blockenberg'), 'textColor'), |
| 238 |
cc('highlightColor', __('Highlight text', 'blockenberg'), 'highlightColor'), |
| 239 |
cc('highlightIconColor',__('Highlight icon', 'blockenberg'), 'highlightIconColor'), |
| 240 |
cc('bgColor', __('Section background','blockenberg'), 'bgColor') |
| 241 |
), |
| 242 |
el(PanelBody, { title: __('Spacing', 'blockenberg'), initialOpen: false }, |
| 243 |
el(RangeControl, { label: __('Padding top (px)', 'blockenberg'), value: a.paddingTop, min: 0, max: 200, onChange: function (v) { setAttributes({ paddingTop: v }); } }), |
| 244 |
el(RangeControl, { label: __('Padding bottom (px)', 'blockenberg'), value: a.paddingBottom, min: 0, max: 200, onChange: function (v) { setAttributes({ paddingBottom: v }); } }) |
| 245 |
), |
| 246 |
el(PanelBody, { title: __('Cards', 'blockenberg'), initialOpen: false }, |
| 247 |
a.items.map(function (item, ii) { |
| 248 |
var accent = (a.useItemAccent && item.accentColor) ? item.accentColor : a.globalAccent; |
| 249 |
return el(PanelBody, { key: item.id, title: (item.icon || '🔧') + ' ' + (item.title ? item.title.replace(/<[^>]+>/g,'').substring(0,20) : 'Card ' + (ii + 1)), initialOpen: false }, |
| 250 |
el(IP().IconPickerControl, IP().iconPickerProps(item, function (key, val) { updateItem(item.id, key, val); }, { label: __('Icon', 'blockenberg'), typeAttr: 'iconType', dashiconAttr: 'iconDashicon', imageUrlAttr: 'iconImageUrl' })), |
| 251 |
a.useItemAccent && renderColorControl(item.id + '_accent', __('Card accent color', 'blockenberg'), item.accentColor, function (v) { updateItem(item.id, 'accentColor', v); }, openColorKey, setOpenColorKey), |
| 252 |
el(TextControl, { label: __('CTA label', 'blockenberg'), value: item.ctaLabel, onChange: function (v) { updateItem(item.id, 'ctaLabel', v); } }), |
| 253 |
el(TextControl, { label: __('CTA URL', 'blockenberg'), value: item.ctaUrl, onChange: function (v) { updateItem(item.id, 'ctaUrl', v); } }), |
| 254 |
/* Highlights editor */ |
| 255 |
el('div', { style: { marginTop: '8px' } }, |
| 256 |
el('p', { style: { fontSize: '12px', fontWeight: 600, margin: '0 0 6px' } }, __('Highlights', 'blockenberg')), |
| 257 |
(item.highlights || []).map(function (hl, hi) { |
| 258 |
return el('div', { key: hi, style: { display: 'flex', gap: '6px', alignItems: 'center', marginBottom: '4px' } }, |
| 259 |
el(TextControl, { value: hl, onChange: function (v) { var newHls = item.highlights.slice(); newHls[hi] = v; updateItem(item.id, 'highlights', newHls); }, style: { flex: 1, margin: 0 }, hideLabelFromVision: true, label: '' }), |
| 260 |
el(Button, { onClick: function () { updateItem(item.id, 'highlights', item.highlights.filter(function (_, i) { return i !== hi; })); }, isDestructive: true, variant: 'tertiary', size: 'compact' }, '✕') |
| 261 |
); |
| 262 |
}), |
| 263 |
el(Button, { variant: 'secondary', size: 'compact', onClick: function () { updateItem(item.id, 'highlights', (item.highlights || []).concat(['New highlight'])); } }, __('+ Add highlight', 'blockenberg')) |
| 264 |
), |
| 265 |
el(Button, { onClick: function () { setAttributes({ items: a.items.filter(function (it) { return it.id !== item.id; }) }); }, isDestructive: true, variant: 'tertiary', size: 'compact', style: { marginTop: '8px' } }, __('Remove card', 'blockenberg')) |
| 266 |
); |
| 267 |
}), |
| 268 |
el(Button, { variant: 'primary', onClick: function () { setAttributes({ items: a.items.concat([{ id: makeId(), icon: '⭐', iconType: 'custom-char', iconDashicon: '', iconImageUrl: '', accentColor: '#6c3fb5', title: __('New Service', 'blockenberg'), text: '', highlights: [], ctaLabel: __('Learn more', 'blockenberg'), ctaUrl: '' }]) }); }, style: { marginTop: '8px' } }, __('+ Add Card', 'blockenberg')) |
| 269 |
) |
| 270 |
), |
| 271 |
|
| 272 |
el('div', blockProps, |
| 273 |
el('div', { className: 'bkbg-sk-grid', style: gridStyle }, |
| 274 |
a.items.map(function (item) { |
| 275 |
return el(ServiceCard, { key: item.id, item: item, a: a, isEditor: true, onUpdate: function (key, val) { updateItem(item.id, key, val); } }); |
| 276 |
}) |
| 277 |
) |
| 278 |
) |
| 279 |
); |
| 280 |
}, |
| 281 |
|
| 282 |
save: function (props) { |
| 283 |
var a = props.attributes; |
| 284 |
var _tv = window.bkbgTypoCssVars || function () { return {}; }; |
| 285 |
var s = buildWrapStyle(a); |
| 286 |
Object.assign(s, _tv(a.titleTypo, '--bksk-tt-')); |
| 287 |
Object.assign(s, _tv(a.textTypo, '--bksk-bt-')); |
| 288 |
return el('div', wp.blockEditor.useBlockProps.save({ className: 'bkbg-sk-wrapper', style: s, 'data-cols-tablet': a.columnsTablet, 'data-cols-mobile': a.columnsMobile }), |
| 289 |
el('div', { className: 'bkbg-sk-grid', style: { display: 'grid', gridTemplateColumns: 'repeat(' + a.columns + ', 1fr)', gap: a.gap + 'px' } }, |
| 290 |
a.items.map(function (item) { |
| 291 |
return el(ServiceCard, { key: item.id, item: item, a: a, isEditor: false }); |
| 292 |
}) |
| 293 |
) |
| 294 |
); |
| 295 |
}, |
| 296 |
|
| 297 |
deprecated: [{ |
| 298 |
attributes: Object.assign({}, wp.blocks.getBlockType('blockenberg/service-cards') ? wp.blocks.getBlockType('blockenberg/service-cards').attributes : {}, |
| 299 |
{ |
| 300 |
titleFontWeight: { type: 'number', default: 700 }, |
| 301 |
textFontWeight: { type: 'number', default: 400 }, |
| 302 |
titleSize: { type: 'number', default: 20 }, |
| 303 |
textSize: { type: 'number', default: 15 }, |
| 304 |
highlightSize: { type: 'number', default: 13 }, |
| 305 |
ctaSize: { type: 'number', default: 14 } |
| 306 |
} |
| 307 |
), |
| 308 |
save: function (props) { |
| 309 |
var a = props.attributes; |
| 310 |
return el('div', wp.blockEditor.useBlockProps.save({ className: 'bkbg-sk-wrapper', style: buildWrapStyle(a), 'data-cols-tablet': a.columnsTablet, 'data-cols-mobile': a.columnsMobile }), |
| 311 |
el('div', { className: 'bkbg-sk-grid', style: { display: 'grid', gridTemplateColumns: 'repeat(' + a.columns + ', 1fr)', gap: a.gap + 'px' } }, |
| 312 |
a.items.map(function (item) { |
| 313 |
return el(ServiceCard, { key: item.id, item: item, a: a, isEditor: false }); |
| 314 |
}) |
| 315 |
) |
| 316 |
); |
| 317 |
} |
| 318 |
}] |
| 319 |
}); |
| 320 |
}() ); |
| 321 |
|