| 1 |
(function () { |
| 2 |
var _typoKeys = { |
| 3 |
family: '-ff', sizeDesktop: '-fs', sizeTablet: '-fs-tab', sizeMobile: '-fs-mob', |
| 4 |
weight: '-fw', style: '-fst', decoration: '-td', transform: '-tt', |
| 5 |
letterSpacing: '-ls', lineHeight: '-lh' |
| 6 |
}; |
| 7 |
function typoCssVarsForEl(el, obj, prefix) { |
| 8 |
if (!obj) return; |
| 9 |
Object.keys(_typoKeys).forEach(function (k) { |
| 10 |
var v = obj[k]; if (v === undefined || v === '') return; |
| 11 |
var u = (k === 'sizeDesktop' || k === 'sizeTablet' || k === 'sizeMobile') |
| 12 |
? (String(v).match(/[a-z%]/i) ? v : v + 'px') |
| 13 |
: (k === 'lineHeight' ? String(v) : v); |
| 14 |
el.style.setProperty(prefix + _typoKeys[k], u); |
| 15 |
}); |
| 16 |
} |
| 17 |
|
| 18 |
function init() { |
| 19 |
document.querySelectorAll('.bkbg-per-app').forEach(function (el) { |
| 20 |
if (el.dataset.rendered) return; |
| 21 |
el.dataset.rendered = '1'; |
| 22 |
|
| 23 |
var opts; |
| 24 |
try { opts = JSON.parse(el.dataset.opts || '{}'); } catch (e) { opts = {}; } |
| 25 |
|
| 26 |
var o = Object.assign({ |
| 27 |
eyebrow: 'Who Is This For?', heading: 'Built for Teams Who Move Fast', |
| 28 |
subtext: 'Whether you\'re a solo founder or a growing team, Blockenberg fits your workflow.', |
| 29 |
personas: [], layout: 'grid', columns: 3, |
| 30 |
showPainPoints: true, showBenefits: true, |
| 31 |
maxWidth: 1200, paddingTop: 100, paddingBottom: 100, |
| 32 |
painLabel: 'Pain points:', benefitLabel: 'With Blockenberg:', |
| 33 |
bgColor: '#ffffff', eyebrowColor: '#6366f1', headingColor: '#111827', subColor: '#6b7280', |
| 34 |
cardBg: '#f8fafc', cardBorder: '#e2e8f0', iconBg: '#ede9fe', |
| 35 |
roleColor: '#111827', descColor: '#6b7280', accentColor: '#6366f1', |
| 36 |
painColor: '#374151', painIconColor: '#ef4444', |
| 37 |
benefitColor: '#374151', benefitIconColor: '#22c55e' |
| 38 |
}, opts); |
| 39 |
|
| 40 |
el.parentElement && (el.parentElement.style.background = o.bgColor); |
| 41 |
|
| 42 |
var inner = document.createElement('div'); |
| 43 |
inner.className = 'bkbg-per-inner'; |
| 44 |
inner.style.cssText = 'max-width:' + o.maxWidth + 'px;margin:0 auto;padding:' + o.paddingTop + 'px 24px ' + o.paddingBottom + 'px;'; |
| 45 |
|
| 46 |
/* Header */ |
| 47 |
var header = document.createElement('div'); |
| 48 |
header.className = 'bkbg-per-header'; |
| 49 |
|
| 50 |
var ey = document.createElement('span'); ey.className = 'bkbg-per-eyebrow'; ey.style.color = o.eyebrowColor; ey.textContent = o.eyebrow; |
| 51 |
typoCssVarsForEl(ey, o.eyebrowTypo, '--bkbg-per-eyebrow'); |
| 52 |
var h2 = document.createElement('h2'); h2.className = 'bkbg-per-heading'; h2.style.color = o.headingColor; h2.innerHTML = o.heading; |
| 53 |
typoCssVarsForEl(h2, o.headingTypo, '--bkbg-per-heading'); |
| 54 |
var sub = document.createElement('p'); sub.className = 'bkbg-per-sub'; sub.style.color = o.subColor; sub.innerHTML = o.subtext; |
| 55 |
typoCssVarsForEl(sub, o.subtextTypo, '--bkbg-per-subtext'); |
| 56 |
header.appendChild(ey); header.appendChild(h2); header.appendChild(sub); |
| 57 |
inner.appendChild(header); |
| 58 |
|
| 59 |
/* Grid */ |
| 60 |
var grid = document.createElement('div'); |
| 61 |
grid.className = 'bkbg-per-grid'; |
| 62 |
grid.style.gridTemplateColumns = 'repeat(' + o.columns + ',1fr)'; |
| 63 |
|
| 64 |
(o.personas || []).forEach(function (p) { |
| 65 |
var card = document.createElement('div'); |
| 66 |
card.className = 'bkbg-per-card'; |
| 67 |
card.style.cssText = 'background:' + o.cardBg + ';border-color:' + o.cardBorder + ';border-radius:' + (o.borderRadius || 12) + 'px;'; |
| 68 |
|
| 69 |
/* Icon */ |
| 70 |
var icon = document.createElement('div'); icon.className = 'bkbg-per-icon'; |
| 71 |
icon.style.background = o.iconBg; |
| 72 |
var _IP = window.bkbgIconPicker; |
| 73 |
var _iType = p.iconType || 'custom-char'; |
| 74 |
if (_IP && _iType !== 'custom-char') { |
| 75 |
var _in = _IP.buildFrontendIcon(_iType, p.icon, p.iconDashicon, p.iconImageUrl, p.iconDashiconColor); |
| 76 |
if (_in) icon.appendChild(_in); else icon.textContent = p.icon || '⭐'; |
| 77 |
} else { icon.textContent = p.icon || '⭐'; } |
| 78 |
card.appendChild(icon); |
| 79 |
|
| 80 |
/* Role */ |
| 81 |
var role = document.createElement('h3'); role.className = 'bkbg-per-role'; role.style.color = o.roleColor; role.textContent = p.role; |
| 82 |
typoCssVarsForEl(role, o.roleTypo, '--bkbg-per-role'); |
| 83 |
card.appendChild(role); |
| 84 |
|
| 85 |
/* Desc */ |
| 86 |
var desc = document.createElement('p'); desc.className = 'bkbg-per-desc'; desc.style.color = o.descColor; desc.textContent = p.description; |
| 87 |
typoCssVarsForEl(desc, o.descTypo, '--bkbg-per-desc'); |
| 88 |
card.appendChild(desc); |
| 89 |
|
| 90 |
/* Pain points */ |
| 91 |
if (o.showPainPoints && p.painPoints && p.painPoints.length) { |
| 92 |
var painLabel = document.createElement('span'); painLabel.className = 'bkbg-per-list-label'; painLabel.style.color = o.accentColor; painLabel.textContent = o.painLabel; |
| 93 |
card.appendChild(painLabel); |
| 94 |
var painUl = document.createElement('ul'); painUl.className = 'bkbg-per-list'; |
| 95 |
p.painPoints.forEach(function (pt) { |
| 96 |
var li = document.createElement('li'); li.style.color = o.painColor; |
| 97 |
typoCssVarsForEl(li, o.itemTypo, '--bkbg-per-item'); |
| 98 |
var icon2 = document.createElement('i'); icon2.className = 'bkbg-per-list-icon'; icon2.style.color = o.painIconColor; icon2.textContent = '✕'; |
| 99 |
li.appendChild(icon2); li.appendChild(document.createTextNode(pt)); |
| 100 |
painUl.appendChild(li); |
| 101 |
}); |
| 102 |
card.appendChild(painUl); |
| 103 |
} |
| 104 |
|
| 105 |
/* Benefits */ |
| 106 |
if (o.showBenefits && p.benefits && p.benefits.length) { |
| 107 |
var benLabel = document.createElement('span'); benLabel.className = 'bkbg-per-list-label'; benLabel.style.color = o.accentColor; benLabel.textContent = o.benefitLabel; |
| 108 |
card.appendChild(benLabel); |
| 109 |
var benUl = document.createElement('ul'); benUl.className = 'bkbg-per-list'; |
| 110 |
p.benefits.forEach(function (b) { |
| 111 |
var li = document.createElement('li'); li.style.color = o.benefitColor; |
| 112 |
typoCssVarsForEl(li, o.itemTypo, '--bkbg-per-item'); |
| 113 |
var icon3 = document.createElement('i'); icon3.className = 'bkbg-per-list-icon'; icon3.style.color = o.benefitIconColor; icon3.textContent = '✓'; |
| 114 |
li.appendChild(icon3); li.appendChild(document.createTextNode(b)); |
| 115 |
benUl.appendChild(li); |
| 116 |
}); |
| 117 |
card.appendChild(benUl); |
| 118 |
} |
| 119 |
|
| 120 |
grid.appendChild(card); |
| 121 |
}); |
| 122 |
|
| 123 |
inner.appendChild(grid); |
| 124 |
el.appendChild(inner); |
| 125 |
}); |
| 126 |
} |
| 127 |
|
| 128 |
if (document.readyState !== 'loading') { init(); } |
| 129 |
else { document.addEventListener('DOMContentLoaded', init); } |
| 130 |
})(); |
| 131 |
|