| 1 |
(function () { |
| 2 |
|
| 3 |
/* ── Typography CSS-var helper ─────────────────────────────────────── */ |
| 4 |
function typoCssVarsForEl(typo, prefix, el) { |
| 5 |
if (!typo || typeof typo !== 'object') return; |
| 6 |
var map = { |
| 7 |
family:'font-family', weight:'font-weight', style:'font-style', |
| 8 |
transform:'text-transform', decoration:'text-decoration', |
| 9 |
sizeDesktop:'font-size-d', sizeTablet:'font-size-t', sizeMobile:'font-size-m', sizeUnit:'font-size-unit', |
| 10 |
lineHeightDesktop:'line-height-d', lineHeightTablet:'line-height-t', lineHeightMobile:'line-height-m', lineHeightUnit:'line-height-unit', |
| 11 |
letterSpacingDesktop:'letter-spacing-d', letterSpacingTablet:'letter-spacing-t', letterSpacingMobile:'letter-spacing-m', letterSpacingUnit:'letter-spacing-unit', |
| 12 |
wordSpacingDesktop:'word-spacing-d', wordSpacingTablet:'word-spacing-t', wordSpacingMobile:'word-spacing-m', wordSpacingUnit:'word-spacing-unit' |
| 13 |
}; |
| 14 |
Object.keys(map).forEach(function(k) { |
| 15 |
if (typo[k] !== undefined && typo[k] !== '') { |
| 16 |
var v = typo[k]; |
| 17 |
var css = map[k]; |
| 18 |
if (css.indexOf('size-d') !== -1 || css.indexOf('size-t') !== -1 || css.indexOf('size-m') !== -1 || |
| 19 |
css.indexOf('height-d') !== -1 || css.indexOf('height-t') !== -1 || css.indexOf('height-m') !== -1 || |
| 20 |
css.indexOf('spacing-d') !== -1 || css.indexOf('spacing-t') !== -1 || css.indexOf('spacing-m') !== -1) { |
| 21 |
var unitKey = css.replace(/-[dtm]$/, '-unit'); |
| 22 |
var unit = ''; |
| 23 |
Object.keys(map).forEach(function(k2) { if (map[k2] === unitKey && typo[k2]) unit = typo[k2]; }); |
| 24 |
if (!unit) unit = css.indexOf('size') !== -1 ? 'px' : ''; |
| 25 |
v = v + unit; |
| 26 |
} |
| 27 |
el.style.setProperty(prefix + css, v); |
| 28 |
} |
| 29 |
}); |
| 30 |
} |
| 31 |
|
| 32 |
function init() { |
| 33 |
document.querySelectorAll('.bkbg-crs-app').forEach(function (el) { |
| 34 |
if (el.dataset.rendered) return; |
| 35 |
el.dataset.rendered = '1'; |
| 36 |
|
| 37 |
var opts; |
| 38 |
try { opts = JSON.parse(el.dataset.opts || '{}'); } catch (e) { opts = {}; } |
| 39 |
|
| 40 |
var o = Object.assign({ |
| 41 |
eyebrow: 'Customer Success', heading: 'Real Teams, Real Results', |
| 42 |
subtext: 'See how companies like yours are achieving measurable growth.', |
| 43 |
results: [], layout: 'grid', columns: 3, |
| 44 |
showMetrics: true, showTags: true, showAuthor: true, showLogo: true, |
| 45 |
maxWidth: 1200, paddingTop: 80, paddingBottom: 80, |
| 46 |
bgColor: '#f8fafc', headingColor: '#111827', subColor: '#6b7280', eyebrowColor: '#6366f1', |
| 47 |
cardBg: '#ffffff', cardBorder: '#e2e8f0', quoteColor: '#374151', |
| 48 |
authorColor: '#111827', titleColor: '#6b7280', |
| 49 |
metricNumColor: '#6366f1', metricLabelColor: '#6b7280', |
| 50 |
tagBg: '#ede9fe', tagColor: '#6d28d9', logoBg: '#f1f5f9', accentColor: '#6366f1' |
| 51 |
}, opts); |
| 52 |
|
| 53 |
el.parentElement && (el.parentElement.style.background = o.bgColor); |
| 54 |
|
| 55 |
var inner = document.createElement('div'); |
| 56 |
inner.className = 'bkbg-crs-inner'; |
| 57 |
inner.style.cssText = 'max-width:' + o.maxWidth + 'px;margin:0 auto;padding:' + o.paddingTop + 'px 24px ' + o.paddingBottom + 'px;'; |
| 58 |
|
| 59 |
/* Apply typography CSS vars on inner */ |
| 60 |
inner.style.setProperty('--bkbg-crs-eye-fs', (o.eyebrowFontSize || 14) + 'px'); |
| 61 |
inner.style.setProperty('--bkbg-crs-hdg-fs', (o.headingFontSize || 28) + 'px'); |
| 62 |
inner.style.setProperty('--bkbg-crs-sub-fs', (o.subtextFontSize || 16) + 'px'); |
| 63 |
typoCssVarsForEl(o.typoEyebrow, '--bkbg-crs-eye-', inner); |
| 64 |
typoCssVarsForEl(o.typoHeading, '--bkbg-crs-hdg-', inner); |
| 65 |
typoCssVarsForEl(o.typoSubtext, '--bkbg-crs-sub-', inner); |
| 66 |
|
| 67 |
/* Header */ |
| 68 |
var header = document.createElement('div'); |
| 69 |
header.style.cssText = 'text-align:center;margin-bottom:48px;'; |
| 70 |
var ey = document.createElement('p'); ey.className = 'bkbg-crs-eyebrow'; ey.style.color = o.eyebrowColor; ey.innerHTML = o.eyebrow; |
| 71 |
var h2 = document.createElement('h2'); h2.className = 'bkbg-crs-heading'; h2.style.color = o.headingColor; h2.innerHTML = o.heading; |
| 72 |
var sub = document.createElement('p'); sub.className = 'bkbg-crs-sub'; sub.style.color = o.subColor; sub.innerHTML = o.subtext; |
| 73 |
header.appendChild(ey); header.appendChild(h2); header.appendChild(sub); |
| 74 |
inner.appendChild(header); |
| 75 |
|
| 76 |
/* Grid */ |
| 77 |
var grid = document.createElement('div'); |
| 78 |
grid.className = 'bkbg-crs-grid layout-' + o.layout; |
| 79 |
if (o.layout === 'grid') grid.style.gridTemplateColumns = 'repeat(' + o.columns + ',1fr)'; |
| 80 |
|
| 81 |
(o.results || []).forEach(function (result) { |
| 82 |
var card = document.createElement('div'); |
| 83 |
card.className = 'bkbg-crs-card'; |
| 84 |
card.style.cssText = 'background:' + o.cardBg + ';border-color:' + o.cardBorder; |
| 85 |
|
| 86 |
/* Company */ |
| 87 |
if (o.showLogo) { |
| 88 |
var compRow = document.createElement('div'); |
| 89 |
compRow.className = 'bkbg-crs-company-row'; |
| 90 |
compRow.style.background = o.logoBg; |
| 91 |
if (result.companyLogo) { |
| 92 |
var logo = document.createElement('img'); |
| 93 |
logo.className = 'bkbg-crs-company-logo'; logo.src = result.companyLogo; logo.alt = result.companyName; |
| 94 |
compRow.appendChild(logo); |
| 95 |
} else { |
| 96 |
var nameEl = document.createElement('div'); |
| 97 |
nameEl.className = 'bkbg-crs-company-name-fallback'; nameEl.style.color = o.accentColor; nameEl.textContent = result.companyName; |
| 98 |
compRow.appendChild(nameEl); |
| 99 |
} |
| 100 |
card.appendChild(compRow); |
| 101 |
} |
| 102 |
|
| 103 |
/* Quote */ |
| 104 |
var quote = document.createElement('blockquote'); |
| 105 |
quote.className = 'bkbg-crs-quote'; quote.style.color = o.quoteColor; |
| 106 |
quote.textContent = '\u201C' + result.quote + '\u201D'; |
| 107 |
card.appendChild(quote); |
| 108 |
|
| 109 |
/* Author */ |
| 110 |
if (o.showAuthor) { |
| 111 |
var authorRow = document.createElement('div'); |
| 112 |
authorRow.className = 'bkbg-crs-author-row'; |
| 113 |
var aName = document.createElement('div'); aName.className = 'bkbg-crs-author-name'; aName.style.color = o.authorColor; aName.textContent = result.authorName; |
| 114 |
var aTitle = document.createElement('div'); aTitle.className = 'bkbg-crs-author-title'; aTitle.style.color = o.titleColor; aTitle.textContent = result.authorTitle; |
| 115 |
authorRow.appendChild(aName); authorRow.appendChild(aTitle); |
| 116 |
card.appendChild(authorRow); |
| 117 |
} |
| 118 |
|
| 119 |
/* Metrics */ |
| 120 |
if (o.showMetrics && result.metrics && result.metrics.length) { |
| 121 |
var metrics = document.createElement('div'); |
| 122 |
metrics.className = 'bkbg-crs-metrics'; |
| 123 |
result.metrics.forEach(function (m) { |
| 124 |
var mEl = document.createElement('div'); mEl.className = 'bkbg-crs-metric'; |
| 125 |
var mVal = document.createElement('div'); mVal.className = 'bkbg-crs-metric-val'; mVal.style.color = o.metricNumColor; mVal.textContent = m.value; |
| 126 |
var mLab = document.createElement('div'); mLab.className = 'bkbg-crs-metric-label'; mLab.style.color = o.metricLabelColor; mLab.textContent = m.label; |
| 127 |
mEl.appendChild(mVal); mEl.appendChild(mLab); |
| 128 |
metrics.appendChild(mEl); |
| 129 |
}); |
| 130 |
card.appendChild(metrics); |
| 131 |
} |
| 132 |
|
| 133 |
/* Tags */ |
| 134 |
if (o.showTags && result.tags && result.tags.length) { |
| 135 |
var tags = document.createElement('div'); |
| 136 |
tags.className = 'bkbg-crs-tags'; |
| 137 |
result.tags.forEach(function (tag) { |
| 138 |
var t = document.createElement('span'); |
| 139 |
t.className = 'bkbg-crs-tag'; t.style.cssText = 'background:' + o.tagBg + ';color:' + o.tagColor; t.textContent = tag; |
| 140 |
tags.appendChild(t); |
| 141 |
}); |
| 142 |
card.appendChild(tags); |
| 143 |
} |
| 144 |
|
| 145 |
grid.appendChild(card); |
| 146 |
}); |
| 147 |
|
| 148 |
inner.appendChild(grid); |
| 149 |
el.appendChild(inner); |
| 150 |
}); |
| 151 |
} |
| 152 |
|
| 153 |
if (document.readyState !== 'loading') { init(); } |
| 154 |
else { document.addEventListener('DOMContentLoaded', init); } |
| 155 |
})(); |
| 156 |
|