| 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 MediaUpload = wp.blockEditor.MediaUpload; |
| 10 |
var MediaUploadCheck = wp.blockEditor.MediaUploadCheck; |
| 11 |
var useBlockProps = wp.blockEditor.useBlockProps; |
| 12 |
var PanelBody = wp.components.PanelBody; |
| 13 |
var Button = wp.components.Button; |
| 14 |
var ToggleControl = wp.components.ToggleControl; |
| 15 |
var RangeControl = wp.components.RangeControl; |
| 16 |
var SelectControl = wp.components.SelectControl; |
| 17 |
var TextControl = wp.components.TextControl; |
| 18 |
var ColorPicker = wp.components.ColorPicker; |
| 19 |
var Popover = wp.components.Popover; |
| 20 |
|
| 21 |
var SIDE_OPTIONS = [ |
| 22 |
{ label: __('Content left', 'blockenberg'), value: 'left' }, |
| 23 |
{ label: __('Content right', 'blockenberg'), value: 'right' }, |
| 24 |
]; |
| 25 |
var RATIO_OPTIONS = [ |
| 26 |
{ label: '40 / 60', value: '40' }, |
| 27 |
{ label: '50 / 50', value: '50' }, |
| 28 |
{ label: '60 / 40', value: '60' }, |
| 29 |
]; |
| 30 |
var BADGE_OPTIONS = [ |
| 31 |
{ label: __('Pill', 'blockenberg'), value: 'pill' }, |
| 32 |
{ label: __('Badge', 'blockenberg'), value: 'badge' }, |
| 33 |
{ label: __('Label', 'blockenberg'), value: 'label' }, |
| 34 |
]; |
| 35 |
var MEDIA_OPTIONS = [ |
| 36 |
{ label: __('Image', 'blockenberg'), value: 'image' }, |
| 37 |
{ label: __('Video', 'blockenberg'), value: 'video' }, |
| 38 |
]; |
| 39 |
var TAG_OPTIONS = [ |
| 40 |
{ label: 'h1', value: 'h1' }, |
| 41 |
{ label: 'h2', value: 'h2' }, |
| 42 |
{ label: 'h3', value: 'h3' }, |
| 43 |
{ label: 'p', value: 'p' }, |
| 44 |
]; |
| 45 |
|
| 46 |
/* Lazy typography helpers */ |
| 47 |
var _tc, _tv; |
| 48 |
function getTypoControl() { return _tc || (_tc = window.bkbgTypographyControl); } |
| 49 |
function getTypoCssVars() { return _tv || (_tv = window.bkbgTypoCssVars); } |
| 50 |
|
| 51 |
function buildWrapStyle(a) { |
| 52 |
var tv = getTypoCssVars(); |
| 53 |
var s = { |
| 54 |
'--bkbg-sh-min-height': a.minHeight + 'px', |
| 55 |
'--bkbg-sh-accent': a.accentColor, |
| 56 |
'--bkbg-sh-h-color': a.headlineColor, |
| 57 |
'--bkbg-sh-sub-color': a.subtextColor, |
| 58 |
'--bkbg-sh-badge-color': a.badgeColor, |
| 59 |
'--bkbg-sh-badge-bg': a.badgeBg, |
| 60 |
'--bkbg-sh-cta1-bg': a.ctaPrimaryBg, |
| 61 |
'--bkbg-sh-cta1-color': a.ctaPrimaryColor, |
| 62 |
'--bkbg-sh-cta2-color': a.ctaSecondaryColor, |
| 63 |
'--bkbg-sh-star-color': a.starColor, |
| 64 |
'--bkbg-sh-proof-color': a.socialProofColor, |
| 65 |
'--bkbg-sh-content-bg': a.contentBg, |
| 66 |
'--bkbg-sh-media-bg': a.mediaBg, |
| 67 |
'--bkbg-sh-cta-radius': a.ctaRadius + 'px', |
| 68 |
'--bkbg-sh-h-size': a.headlineSize + 'px', |
| 69 |
'--bkbg-sh-h-w': String(a.headlineFontWeight || 800), |
| 70 |
'--bkbg-sh-sub-size': a.subtextSize + 'px', |
| 71 |
'--bkbg-sh-badge-size': a.badgeSize + 'px', |
| 72 |
'--bkbg-sh-rating-size': a.ratingSize + 'px', |
| 73 |
'--bkbg-sh-cta1-size': a.ctaPrimarySize + 'px', |
| 74 |
'--bkbg-sh-cta2-size': a.ctaSecondarySize + 'px', |
| 75 |
backgroundColor: a.bgColor || undefined, |
| 76 |
}; |
| 77 |
if (tv) { |
| 78 |
Object.assign(s, tv(a.headlineTypo, '--bksh-hl-')); |
| 79 |
Object.assign(s, tv(a.subtextTypo, '--bksh-st-')); |
| 80 |
Object.assign(s, tv(a.badgeTypo, '--bksh-bd-')); |
| 81 |
Object.assign(s, tv(a.ratingTypo, '--bksh-rt-')); |
| 82 |
Object.assign(s, tv(a.proofTypo, '--bksh-sp-')); |
| 83 |
Object.assign(s, tv(a.cta1Typo, '--bksh-c1-')); |
| 84 |
Object.assign(s, tv(a.cta2Typo, '--bksh-c2-')); |
| 85 |
} |
| 86 |
return s; |
| 87 |
} |
| 88 |
|
| 89 |
function SvgStar(props) { |
| 90 |
return el('svg', { width: 16, height: 16, viewBox: '0 0 24 24', fill: props.filled ? props.color : '#e5e7eb' }, |
| 91 |
el('polygon', { points: '12,2 15.09,8.26 22,9.27 17,14.14 18.18,21.02 12,17.77 5.82,21.02 7,14.14 2,9.27 8.91,8.26' }) |
| 92 |
); |
| 93 |
} |
| 94 |
|
| 95 |
function renderColorControl(key, label, value, onChange, openKey, setOpenKey) { |
| 96 |
var isOpen = openKey === key; |
| 97 |
return el('div', { key: key, style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '4px 0', gap: '8px' } }, |
| 98 |
el('span', { style: { fontSize: '12px', color: '#1e1e1e', flex: 1, lineHeight: 1.4 } }, label), |
| 99 |
el('div', { style: { position: 'relative', flexShrink: 0 } }, |
| 100 |
el('button', { type: 'button', title: value || 'default', 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 || '#cccccc' } }), |
| 101 |
isOpen && el(Popover, { position: 'bottom left', onClose: function () { setOpenKey(null); } }, |
| 102 |
el('div', { style: { padding: '8px' } }, |
| 103 |
el(ColorPicker, { color: value, enableAlpha: true, onChange: onChange }) |
| 104 |
) |
| 105 |
) |
| 106 |
) |
| 107 |
); |
| 108 |
} |
| 109 |
|
| 110 |
registerBlockType('blockenberg/split-hero', { |
| 111 |
title: __('Split Hero', 'blockenberg'), |
| 112 |
icon: 'align-pull-left', |
| 113 |
category: 'bkbg-layout', |
| 114 |
description: __('Purpose-built hero with headline, CTAs, social proof, and a full-height media panel.', 'blockenberg'), |
| 115 |
|
| 116 |
edit: function (props) { |
| 117 |
var a = props.attributes; |
| 118 |
var setAttributes = props.setAttributes; |
| 119 |
|
| 120 |
var openColorKeyState = useState(null); |
| 121 |
var openColorKey = openColorKeyState[0]; |
| 122 |
var setOpenColorKey = openColorKeyState[1]; |
| 123 |
|
| 124 |
var blockProps = useBlockProps({ style: buildWrapStyle(a) }); |
| 125 |
|
| 126 |
function cc(key, label, attrKey) { |
| 127 |
return renderColorControl(key, label, a[attrKey], function (val) { |
| 128 |
var upd = {}; upd[attrKey] = val; setAttributes(upd); |
| 129 |
}, openColorKey, setOpenColorKey); |
| 130 |
} |
| 131 |
|
| 132 |
var contentRatio = parseInt(a.splitRatio, 10); |
| 133 |
var mediaRatio = 100 - contentRatio; |
| 134 |
var isLeft = a.contentSide === 'left'; |
| 135 |
|
| 136 |
var badgeDecor = a.showBadge ? el('span', { |
| 137 |
className: 'bkbg-sh-badge bkbg-sh-badge--' + a.badgeStyle, |
| 138 |
style: { |
| 139 |
display: 'inline-block', |
| 140 |
color: 'var(--bkbg-sh-badge-color)', |
| 141 |
background: 'var(--bkbg-sh-badge-bg)', |
| 142 |
borderRadius: a.badgeStyle === 'pill' ? '99px' : a.badgeStyle === 'badge' ? '6px' : '0', |
| 143 |
padding: a.badgeStyle === 'label' ? '2px 0' : '4px 14px', |
| 144 |
marginBottom: '18px', |
| 145 |
} |
| 146 |
}, a.badge) : null; |
| 147 |
|
| 148 |
var headlineEl = el(RichText, { |
| 149 |
tagName: a.headlineTag || 'h1', |
| 150 |
className: 'bkbg-sh-headline', |
| 151 |
value: a.headline, |
| 152 |
onChange: function (v) { setAttributes({ headline: v }); }, |
| 153 |
placeholder: __('Your powerful headline…', 'blockenberg'), |
| 154 |
style: { color: 'var(--bkbg-sh-h-color)', margin: '0 0 18px' } |
| 155 |
}); |
| 156 |
|
| 157 |
var subtextEl = el(RichText, { |
| 158 |
tagName: 'p', |
| 159 |
className: 'bkbg-sh-subtext', |
| 160 |
value: a.subtext, |
| 161 |
onChange: function (v) { setAttributes({ subtext: v }); }, |
| 162 |
placeholder: __('Supporting subtext…', 'blockenberg'), |
| 163 |
style: { color: 'var(--bkbg-sh-sub-color)', margin: '0 0 28px' } |
| 164 |
}); |
| 165 |
|
| 166 |
var ctaRow = el('div', { className: 'bkbg-sh-cta-row', style: { display: 'flex', flexWrap: 'wrap', gap: '12px', marginBottom: '28px', alignItems: 'center' } }, |
| 167 |
el('a', { href: a.ctaPrimaryUrl || '#', className: 'bkbg-sh-cta1', style: { display: 'inline-flex', alignItems: 'center', background: 'var(--bkbg-sh-cta1-bg)', color: 'var(--bkbg-sh-cta1-color)', padding: '12px 28px', borderRadius: 'var(--bkbg-sh-cta-radius)' } }, a.ctaPrimaryLabel || 'Get Started'), |
| 168 |
a.showSecondaryCta && el('a', { href: a.ctaSecondaryUrl || '#', className: 'bkbg-sh-cta2', style: { display: 'inline-flex', alignItems: 'center', color: 'var(--bkbg-sh-cta2-color)', padding: '11px 20px', borderRadius: 'var(--bkbg-sh-cta-radius)', border: '1.5px solid currentColor' } }, a.ctaSecondaryLabel || 'Learn more') |
| 169 |
); |
| 170 |
|
| 171 |
var ratingRow = a.showRating ? el('div', { className: 'bkbg-sh-rating', style: { display: 'flex', alignItems: 'center', gap: '6px', marginBottom: '10px' } }, |
| 172 |
el('div', { style: { display: 'flex', gap: '2px' } }, |
| 173 |
[1,2,3,4,5].map(function (n) { return el(SvgStar, { key: n, filled: n <= a.ratingStars, color: a.starColor || '#f59e0b' }); }) |
| 174 |
), |
| 175 |
el('span', { className: 'bkbg-sh-score', style: { color: 'var(--bkbg-sh-sub-color)' } }, a.ratingScore + '/5'), |
| 176 |
a.ratingText && el('span', { className: 'bkbg-sh-rating-text', style: { color: 'var(--bkbg-sh-proof-color)' } }, a.ratingText) |
| 177 |
) : null; |
| 178 |
|
| 179 |
var proofRow = a.showSocialProof && a.socialProofText ? el('p', { className: 'bkbg-sh-proof', style: { color: 'var(--bkbg-sh-proof-color)', margin: '8px 0 0' } }, a.socialProofText) : null; |
| 180 |
|
| 181 |
var contentCol = el('div', { className: 'bkbg-sh-content', style: { width: contentRatio + '%', background: 'var(--bkbg-sh-content-bg)', padding: a.contentPaddingV + 'px ' + a.contentPaddingH + 'px', display: 'flex', flexDirection: 'column', justifyContent: 'center', minHeight: 'var(--bkbg-sh-min-height)' } }, |
| 182 |
badgeDecor, |
| 183 |
headlineEl, |
| 184 |
subtextEl, |
| 185 |
ctaRow, |
| 186 |
ratingRow, |
| 187 |
proofRow |
| 188 |
); |
| 189 |
|
| 190 |
var mediaEl; |
| 191 |
if (a.mediaType === 'video' && a.videoUrl) { |
| 192 |
mediaEl = el('iframe', { src: a.videoUrl, style: { position: 'absolute', inset: 0, width: '100%', height: '100%', border: 'none' }, allow: 'autoplay; fullscreen' }); |
| 193 |
} else if (a.imageUrl) { |
| 194 |
mediaEl = el('img', { src: a.imageUrl, alt: '', style: { position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover', borderRadius: a.imageRadius + 'px', boxShadow: a.imageShadow ? '0 20px 60px rgba(0,0,0,0.15)' : 'none' } }); |
| 195 |
} else { |
| 196 |
mediaEl = el('div', { style: { position: 'absolute', inset: 0, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#9ca3af', fontSize: '14px' } }, __('Media panel', 'blockenberg')); |
| 197 |
} |
| 198 |
|
| 199 |
var mediaCol = el('div', { className: 'bkbg-sh-media', style: { width: mediaRatio + '%', background: 'var(--bkbg-sh-media-bg)', position: 'relative', minHeight: 'var(--bkbg-sh-min-height)', overflow: 'hidden' } }, |
| 200 |
mediaEl |
| 201 |
); |
| 202 |
|
| 203 |
return el(Fragment, null, |
| 204 |
el(InspectorControls, null, |
| 205 |
el(PanelBody, { title: __('Hero Layout', 'blockenberg'), initialOpen: true }, |
| 206 |
el(SelectControl, { label: __('Content side', 'blockenberg'), value: a.contentSide, options: SIDE_OPTIONS, onChange: function (v) { setAttributes({ contentSide: v }); } }), |
| 207 |
el(SelectControl, { label: __('Split ratio (content %)', 'blockenberg'), value: a.splitRatio, options: RATIO_OPTIONS, onChange: function (v) { setAttributes({ splitRatio: v }); } }), |
| 208 |
el(RangeControl, { label: __('Min height (px)', 'blockenberg'), value: a.minHeight, min: 400, max: 900, onChange: function (v) { setAttributes({ minHeight: v }); } }) |
| 209 |
), |
| 210 |
el(PanelBody, { title: __('Badge', 'blockenberg'), initialOpen: false }, |
| 211 |
el(ToggleControl, { label: __('Show badge', 'blockenberg'), checked: a.showBadge, onChange: function (v) { setAttributes({ showBadge: v }); }, __nextHasNoMarginBottom: true }), |
| 212 |
a.showBadge && el(TextControl, { label: __('Badge text', 'blockenberg'), value: a.badge, onChange: function (v) { setAttributes({ badge: v }); } }), |
| 213 |
a.showBadge && el(SelectControl, { label: __('Badge style', 'blockenberg'), value: a.badgeStyle, options: BADGE_OPTIONS, onChange: function (v) { setAttributes({ badgeStyle: v }); } }) |
| 214 |
), |
| 215 |
el(PanelBody, { title: __('Content', 'blockenberg'), initialOpen: false }, |
| 216 |
el(SelectControl, { label: __('Headline tag', 'blockenberg'), value: a.headlineTag, options: TAG_OPTIONS, onChange: function (v) { setAttributes({ headlineTag: v }); } }), |
| 217 |
el(RangeControl, { label: __('Horizontal padding (px)', 'blockenberg'), value: a.contentPaddingH, min: 20, max: 120, onChange: function (v) { setAttributes({ contentPaddingH: v }); } }), |
| 218 |
el(RangeControl, { label: __('Vertical padding (px)', 'blockenberg'), value: a.contentPaddingV, min: 20, max: 120, onChange: function (v) { setAttributes({ contentPaddingV: v }); } }), |
| 219 |
el(RangeControl, { label: __('CTA border radius (px)', 'blockenberg'), value: a.ctaRadius, min: 0, max: 99, onChange: function (v) { setAttributes({ ctaRadius: v }); } }) |
| 220 |
), |
| 221 |
el(PanelBody, { title: __('Primary CTA', 'blockenberg'), initialOpen: false }, |
| 222 |
el(TextControl, { label: __('Label', 'blockenberg'), value: a.ctaPrimaryLabel, onChange: function (v) { setAttributes({ ctaPrimaryLabel: v }); } }), |
| 223 |
el(TextControl, { label: __('URL', 'blockenberg'), value: a.ctaPrimaryUrl, onChange: function (v) { setAttributes({ ctaPrimaryUrl: v }); } }), |
| 224 |
el(ToggleControl, { label: __('Open in new tab', 'blockenberg'), checked: a.ctaPrimaryTarget, onChange: function (v) { setAttributes({ ctaPrimaryTarget: v }); }, __nextHasNoMarginBottom: true }) |
| 225 |
), |
| 226 |
el(PanelBody, { title: __('Secondary CTA', 'blockenberg'), initialOpen: false }, |
| 227 |
el(ToggleControl, { label: __('Show secondary CTA', 'blockenberg'), checked: a.showSecondaryCta, onChange: function (v) { setAttributes({ showSecondaryCta: v }); }, __nextHasNoMarginBottom: true }), |
| 228 |
a.showSecondaryCta && el(TextControl, { label: __('Label', 'blockenberg'), value: a.ctaSecondaryLabel, onChange: function (v) { setAttributes({ ctaSecondaryLabel: v }); } }), |
| 229 |
a.showSecondaryCta && el(TextControl, { label: __('URL', 'blockenberg'), value: a.ctaSecondaryUrl, onChange: function (v) { setAttributes({ ctaSecondaryUrl: v }); } }), |
| 230 |
a.showSecondaryCta && el(ToggleControl, { label: __('Open in new tab', 'blockenberg'), checked: a.ctaSecondaryTarget, onChange: function (v) { setAttributes({ ctaSecondaryTarget: v }); }, __nextHasNoMarginBottom: true }) |
| 231 |
), |
| 232 |
el(PanelBody, { title: __('Social Proof', 'blockenberg'), initialOpen: false }, |
| 233 |
el(ToggleControl, { label: __('Show rating', 'blockenberg'), checked: a.showRating, onChange: function (v) { setAttributes({ showRating: v }); }, __nextHasNoMarginBottom: true }), |
| 234 |
a.showRating && el(RangeControl, { label: __('Rating score', 'blockenberg'), value: a.ratingScore, min: 1, max: 5, step: 0.1, onChange: function (v) { setAttributes({ ratingScore: v }); } }), |
| 235 |
a.showRating && el(RangeControl, { label: __('Stars filled', 'blockenberg'), value: a.ratingStars, min: 1, max: 5, onChange: function (v) { setAttributes({ ratingStars: v }); } }), |
| 236 |
a.showRating && el(TextControl, { label: __('Rating label', 'blockenberg'), value: a.ratingText, onChange: function (v) { setAttributes({ ratingText: v }); } }), |
| 237 |
el(ToggleControl, { label: __('Show social proof text', 'blockenberg'), checked: a.showSocialProof, onChange: function (v) { setAttributes({ showSocialProof: v }); }, __nextHasNoMarginBottom: true }), |
| 238 |
a.showSocialProof && el(TextControl, { label: __('Social proof text', 'blockenberg'), value: a.socialProofText, onChange: function (v) { setAttributes({ socialProofText: v }); } }) |
| 239 |
), |
| 240 |
el(PanelBody, { title: __('Media', 'blockenberg'), initialOpen: false }, |
| 241 |
el(SelectControl, { label: __('Media type', 'blockenberg'), value: a.mediaType, options: MEDIA_OPTIONS, onChange: function (v) { setAttributes({ mediaType: v }); } }), |
| 242 |
a.mediaType === 'image' && el(MediaUploadCheck, null, |
| 243 |
el(MediaUpload, { |
| 244 |
onSelect: function (media) { setAttributes({ imageUrl: media.url, imageId: media.id }); }, |
| 245 |
allowedTypes: ['image'], value: a.imageId, |
| 246 |
render: function (p) { return el(Button, { onClick: p.open, variant: a.imageUrl ? 'secondary' : 'primary', style: { marginBottom: '8px' } }, a.imageUrl ? __('Replace image', 'blockenberg') : __('Upload hero image', 'blockenberg')); } |
| 247 |
}) |
| 248 |
), |
| 249 |
a.mediaType === 'image' && el(RangeControl, { label: __('Image radius (px)', 'blockenberg'), value: a.imageRadius, min: 0, max: 40, onChange: function (v) { setAttributes({ imageRadius: v }); } }), |
| 250 |
a.mediaType === 'image' && el(ToggleControl, { label: __('Drop shadow', 'blockenberg'), checked: a.imageShadow, onChange: function (v) { setAttributes({ imageShadow: v }); }, __nextHasNoMarginBottom: true }), |
| 251 |
a.mediaType === 'video' && el(TextControl, { label: __('Embed video URL', 'blockenberg'), value: a.videoUrl, placeholder: 'https://…/embed/…', onChange: function (v) { setAttributes({ videoUrl: v }); } }) |
| 252 |
), |
| 253 |
el(PanelBody, { title: __('Typography', 'blockenberg'), initialOpen: false }, |
| 254 |
getTypoControl() && getTypoControl()({ label: __('Headline', 'blockenberg'), value: a.headlineTypo, onChange: function (v) { setAttributes({ headlineTypo: v }); } }), |
| 255 |
getTypoControl() && getTypoControl()({ label: __('Subtext', 'blockenberg'), value: a.subtextTypo, onChange: function (v) { setAttributes({ subtextTypo: v }); } }), |
| 256 |
getTypoControl() && getTypoControl()({ label: __('Badge', 'blockenberg'), value: a.badgeTypo, onChange: function (v) { setAttributes({ badgeTypo: v }); } }), |
| 257 |
getTypoControl() && getTypoControl()({ label: __('Rating', 'blockenberg'), value: a.ratingTypo, onChange: function (v) { setAttributes({ ratingTypo: v }); } }), |
| 258 |
getTypoControl() && getTypoControl()({ label: __('Social proof', 'blockenberg'), value: a.proofTypo, onChange: function (v) { setAttributes({ proofTypo: v }); } }), |
| 259 |
getTypoControl() && getTypoControl()({ label: __('Primary CTA', 'blockenberg'), value: a.cta1Typo, onChange: function (v) { setAttributes({ cta1Typo: v }); } }), |
| 260 |
getTypoControl() && getTypoControl()({ label: __('Secondary CTA', 'blockenberg'), value: a.cta2Typo, onChange: function (v) { setAttributes({ cta2Typo: v }); } }) |
| 261 |
), |
| 262 |
el(PanelBody, { title: __('Colors', 'blockenberg'), initialOpen: false }, |
| 263 |
cc('accentColor', __('Accent', 'blockenberg'), 'accentColor'), |
| 264 |
cc('headlineColor', __('Headline', 'blockenberg'), 'headlineColor'), |
| 265 |
cc('subtextColor', __('Subtext', 'blockenberg'), 'subtextColor'), |
| 266 |
cc('badgeColor', __('Badge text', 'blockenberg'), 'badgeColor'), |
| 267 |
cc('badgeBg', __('Badge background', 'blockenberg'), 'badgeBg'), |
| 268 |
cc('cta1Bg', __('Primary CTA bg', 'blockenberg'), 'ctaPrimaryBg'), |
| 269 |
cc('cta1Color', __('Primary CTA text', 'blockenberg'), 'ctaPrimaryColor'), |
| 270 |
cc('cta2Color', __('Secondary CTA', 'blockenberg'), 'ctaSecondaryColor'), |
| 271 |
cc('starColor', __('Stars', 'blockenberg'), 'starColor'), |
| 272 |
cc('proofColor', __('Social proof text', 'blockenberg'), 'socialProofColor'), |
| 273 |
cc('contentBg', __('Content panel bg', 'blockenberg'), 'contentBg'), |
| 274 |
cc('mediaBg', __('Media panel bg', 'blockenberg'), 'mediaBg'), |
| 275 |
cc('bgColor', __('Outer background', 'blockenberg'), 'bgColor') |
| 276 |
) |
| 277 |
), |
| 278 |
|
| 279 |
el('div', blockProps, |
| 280 |
el('div', { className: 'bkbg-sh-inner', style: { display: 'flex', flexDirection: isLeft ? 'row' : 'row-reverse', minHeight: 'var(--bkbg-sh-min-height)' } }, |
| 281 |
contentCol, |
| 282 |
mediaCol |
| 283 |
) |
| 284 |
) |
| 285 |
); |
| 286 |
}, |
| 287 |
|
| 288 |
save: function (props) { |
| 289 |
var a = props.attributes; |
| 290 |
var contentRatio = parseInt(a.splitRatio, 10); |
| 291 |
var mediaRatio = 100 - contentRatio; |
| 292 |
var isLeft = a.contentSide === 'left'; |
| 293 |
|
| 294 |
var badgeEl = a.showBadge ? el('span', { className: 'bkbg-sh-badge bkbg-sh-badge--' + a.badgeStyle, style: { display: 'inline-block', color: 'var(--bkbg-sh-badge-color)', background: 'var(--bkbg-sh-badge-bg)', borderRadius: a.badgeStyle === 'pill' ? '99px' : a.badgeStyle === 'badge' ? '6px' : '0', padding: a.badgeStyle === 'label' ? '2px 0' : '4px 14px' } }, a.badge) : null; |
| 295 |
|
| 296 |
var headline = a.headline ? el(RichText.Content, { tagName: a.headlineTag || 'h1', value: a.headline, className: 'bkbg-sh-headline', style: { color: 'var(--bkbg-sh-h-color)' } }) : null; |
| 297 |
var subtext = a.subtext ? el(RichText.Content, { tagName: 'p', value: a.subtext, className: 'bkbg-sh-subtext', style: { color: 'var(--bkbg-sh-sub-color)' } }) : null; |
| 298 |
|
| 299 |
var ctaRow = el('div', { className: 'bkbg-sh-cta-row' }, |
| 300 |
el('a', { href: a.ctaPrimaryUrl || '#', target: a.ctaPrimaryTarget ? '_blank' : undefined, rel: a.ctaPrimaryTarget ? 'noopener noreferrer' : undefined, className: 'bkbg-sh-cta1', style: { background: 'var(--bkbg-sh-cta1-bg)', color: 'var(--bkbg-sh-cta1-color)', borderRadius: 'var(--bkbg-sh-cta-radius)' } }, a.ctaPrimaryLabel || 'Get Started'), |
| 301 |
a.showSecondaryCta && el('a', { href: a.ctaSecondaryUrl || '#', target: a.ctaSecondaryTarget ? '_blank' : undefined, rel: a.ctaSecondaryTarget ? 'noopener noreferrer' : undefined, className: 'bkbg-sh-cta2', style: { color: 'var(--bkbg-sh-cta2-color)', borderRadius: 'var(--bkbg-sh-cta-radius)' } }, a.ctaSecondaryLabel || 'Learn more') |
| 302 |
); |
| 303 |
|
| 304 |
var ratingEl = a.showRating ? el('div', { className: 'bkbg-sh-rating' }, |
| 305 |
el('div', { className: 'bkbg-sh-stars' }, |
| 306 |
[1,2,3,4,5].map(function (n) { |
| 307 |
return el('svg', { key: n, width: 16, height: 16, viewBox: '0 0 24 24', fill: n <= a.ratingStars ? a.starColor : '#e5e7eb' }, |
| 308 |
el('polygon', { points: '12,2 15.09,8.26 22,9.27 17,14.14 18.18,21.02 12,17.77 5.82,21.02 7,14.14 2,9.27 8.91,8.26' }) |
| 309 |
); |
| 310 |
}) |
| 311 |
), |
| 312 |
el('span', { className: 'bkbg-sh-score', style: { color: 'var(--bkbg-sh-sub-color)' } }, a.ratingScore + '/5'), |
| 313 |
a.ratingText && el('span', { className: 'bkbg-sh-rating-text', style: { color: 'var(--bkbg-sh-proof-color)' } }, a.ratingText) |
| 314 |
) : null; |
| 315 |
|
| 316 |
var proofEl = a.showSocialProof && a.socialProofText ? el('p', { className: 'bkbg-sh-proof', style: { color: 'var(--bkbg-sh-proof-color)' } }, a.socialProofText) : null; |
| 317 |
|
| 318 |
var contentCol = el('div', { className: 'bkbg-sh-content', style: { width: contentRatio + '%', background: 'var(--bkbg-sh-content-bg)', padding: a.contentPaddingV + 'px ' + a.contentPaddingH + 'px' } }, |
| 319 |
badgeEl, headline, subtext, ctaRow, ratingEl, proofEl |
| 320 |
); |
| 321 |
|
| 322 |
var mediaInner; |
| 323 |
if (a.mediaType === 'video' && a.videoUrl) { |
| 324 |
mediaInner = el('iframe', { src: a.videoUrl, style: { position: 'absolute', inset: 0, width: '100%', height: '100%', border: 'none' }, allow: 'autoplay; fullscreen', loading: 'lazy' }); |
| 325 |
} else if (a.imageUrl) { |
| 326 |
mediaInner = el('img', { src: a.imageUrl, alt: '', loading: 'lazy', className: 'bkbg-sh-img', style: { position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover', borderRadius: a.imageRadius + 'px', boxShadow: a.imageShadow ? '0 20px 60px rgba(0,0,0,0.15)' : 'none' } }); |
| 327 |
} else { |
| 328 |
mediaInner = null; |
| 329 |
} |
| 330 |
var mediaCol = el('div', { className: 'bkbg-sh-media', style: { width: mediaRatio + '%', background: 'var(--bkbg-sh-media-bg)', position: 'relative', overflow: 'hidden' } }, mediaInner); |
| 331 |
|
| 332 |
return el('div', wp.blockEditor.useBlockProps.save({ className: 'bkbg-sh-wrapper', style: buildWrapStyle(a) }), |
| 333 |
el('div', { className: 'bkbg-sh-inner bkbg-sh-side--' + a.contentSide, style: { display: 'flex', flexDirection: isLeft ? 'row' : 'row-reverse', minHeight: 'var(--bkbg-sh-min-height)' } }, |
| 334 |
contentCol, |
| 335 |
mediaCol |
| 336 |
) |
| 337 |
); |
| 338 |
} |
| 339 |
}); |
| 340 |
}() ); |
| 341 |
|