| 1 |
(function () { |
| 2 |
'use strict'; |
| 3 |
|
| 4 |
var _typoKeys = { |
| 5 |
family:'font-family', weight:'font-weight', style:'font-style', |
| 6 |
decoration:'text-decoration', transform:'text-transform', |
| 7 |
sizeDesktop:'font-size-d', sizeTablet:'font-size-t', sizeMobile:'font-size-m', |
| 8 |
lineHeightDesktop:'line-height-d', lineHeightTablet:'line-height-t', lineHeightMobile:'line-height-m', |
| 9 |
letterSpacingDesktop:'letter-spacing-d', letterSpacingTablet:'letter-spacing-t', letterSpacingMobile:'letter-spacing-m', |
| 10 |
wordSpacingDesktop:'word-spacing-d', wordSpacingTablet:'word-spacing-t', wordSpacingMobile:'word-spacing-m' |
| 11 |
}; |
| 12 |
function typoCssVarsForEl(el, obj, prefix) { |
| 13 |
if (!obj || typeof obj !== 'object') return; |
| 14 |
Object.keys(_typoKeys).forEach(function (k) { |
| 15 |
var v = obj[k]; |
| 16 |
if (v === undefined || v === '' || v === null) return; |
| 17 |
if (k === 'sizeDesktop' || k === 'sizeTablet' || k === 'sizeMobile') v = v + (obj.sizeUnit || 'px'); |
| 18 |
else if (k === 'lineHeightDesktop' || k === 'lineHeightTablet' || k === 'lineHeightMobile') v = v + (obj.lineHeightUnit || ''); |
| 19 |
else if (k === 'letterSpacingDesktop' || k === 'letterSpacingTablet' || k === 'letterSpacingMobile') v = v + (obj.letterSpacingUnit || 'px'); |
| 20 |
else if (k === 'wordSpacingDesktop' || k === 'wordSpacingTablet' || k === 'wordSpacingMobile') v = v + (obj.wordSpacingUnit || 'px'); |
| 21 |
el.style.setProperty(prefix + _typoKeys[k], String(v)); |
| 22 |
}); |
| 23 |
} |
| 24 |
|
| 25 |
function applyCSS(el, styles) { |
| 26 |
Object.keys(styles).forEach(function (k) { el.style[k] = styles[k]; }); |
| 27 |
} |
| 28 |
|
| 29 |
function makeEl(tag, className, styles) { |
| 30 |
var el = document.createElement(tag); |
| 31 |
if (className) el.className = className; |
| 32 |
if (styles) applyCSS(el, styles); |
| 33 |
return el; |
| 34 |
} |
| 35 |
|
| 36 |
function makeText(tag, className, text, styles) { |
| 37 |
var el = makeEl(tag, className, styles); |
| 38 |
el.textContent = text; |
| 39 |
return el; |
| 40 |
} |
| 41 |
|
| 42 |
function init() { |
| 43 |
document.querySelectorAll('.bkbg-stry-app').forEach(function (appEl) { |
| 44 |
if (appEl.dataset.rendered) return; |
| 45 |
appEl.dataset.rendered = '1'; |
| 46 |
|
| 47 |
var opts; |
| 48 |
try { opts = JSON.parse(appEl.dataset.opts || '{}'); } catch (e) { opts = {}; } |
| 49 |
var o = Object.assign({ |
| 50 |
layout: 'photo-left', |
| 51 |
headline: 'Our Story', |
| 52 |
subheadline: 'How it all started — and where we\'re headed.', |
| 53 |
bodyText: 'We started with a simple idea: make the web more beautiful and accessible for everyone.', |
| 54 |
founderName: 'Alex Johnson', |
| 55 |
founderTitle: 'Founder & CEO', |
| 56 |
founderPhotoUrl: '', |
| 57 |
showPhoto: true, |
| 58 |
photoCaption: true, |
| 59 |
pullQuote: '"We didn\'t just build a product — we built something we\'re proud of."', |
| 60 |
showPullQuote: true, |
| 61 |
showMilestones: true, |
| 62 |
milestones: [ |
| 63 |
{ year: '2018', title: 'Founded', description: 'Started as a one-person project in a home office.' }, |
| 64 |
{ year: '2020', title: 'First 1,000 Users', description: 'Reached our first major milestone through word of mouth.' }, |
| 65 |
{ year: '2022', title: 'Series A', description: 'Raised funding to grow the team and expand the product.' }, |
| 66 |
{ year: '2024', title: 'Global Launch', description: 'Expanded to 40+ countries and 100,000+ active users.' } |
| 67 |
], |
| 68 |
showCta: true, |
| 69 |
ctaLabel: 'Join Our Journey', |
| 70 |
ctaUrl: '#', |
| 71 |
ctaNewTab: false, |
| 72 |
bgColor: '#ffffff', |
| 73 |
accentColor: '#6366f1', |
| 74 |
headlineColor: '#0f172a', |
| 75 |
subColor: '#475569', |
| 76 |
bodyColor: '#334155', |
| 77 |
quoteColor: '#1e293b', |
| 78 |
yearColor: '#6366f1', |
| 79 |
milestoneTitleColor: '#0f172a', |
| 80 |
milestoneTextColor: '#475569', |
| 81 |
ctaBg: '#6366f1', |
| 82 |
ctaColor: '#ffffff', |
| 83 |
headlineSize: 40, |
| 84 |
subSize: 18, |
| 85 |
quoteSize: 22, |
| 86 |
bodySize: 16, |
| 87 |
borderRadius: 12, |
| 88 |
photoBorderRadius: 12 |
| 89 |
}, opts); |
| 90 |
|
| 91 |
// ── outer block ────────────────────────────────────────────────────── |
| 92 |
var block = makeEl('div', 'bkbg-stry-block', { background: o.bgColor }); |
| 93 |
|
| 94 |
// Typography vars on block wrapper |
| 95 |
typoCssVarsForEl(block, o.headlineTypo, '--bkstry-hl-'); |
| 96 |
typoCssVarsForEl(block, o.subheadlineTypo, '--bkstry-sh-'); |
| 97 |
typoCssVarsForEl(block, o.bodyTypo, '--bkstry-bd-'); |
| 98 |
typoCssVarsForEl(block, o.quoteTypo, '--bkstry-qt-'); |
| 99 |
|
| 100 |
// ── main row ──────────────────────────────────────────────────────── |
| 101 |
var mainClass = 'bkbg-stry-main bkbg-stry-layout-' + o.layout; |
| 102 |
var main = makeEl('div', mainClass); |
| 103 |
|
| 104 |
// ── photo column ───────────────────────────────────────────────────── |
| 105 |
function buildPhotoCol() { |
| 106 |
var photoCol = makeEl('div', 'bkbg-stry-photo-col'); |
| 107 |
var photoWrap = makeEl('div', 'bkbg-stry-photo-wrap', { |
| 108 |
borderRadius: o.photoBorderRadius + 'px' |
| 109 |
}); |
| 110 |
|
| 111 |
if (o.founderPhotoUrl) { |
| 112 |
var img = document.createElement('img'); |
| 113 |
img.src = o.founderPhotoUrl; |
| 114 |
img.alt = o.founderName; |
| 115 |
img.className = 'bkbg-stry-photo'; |
| 116 |
img.style.borderRadius = o.photoBorderRadius + 'px'; |
| 117 |
photoWrap.appendChild(img); |
| 118 |
|
| 119 |
if (o.photoCaption) { |
| 120 |
var caption = makeEl('div', 'bkbg-stry-founder-caption', { color: o.subColor }); |
| 121 |
var nameStrong = document.createElement('strong'); |
| 122 |
nameStrong.textContent = o.founderName; |
| 123 |
nameStrong.style.color = o.headlineColor; |
| 124 |
caption.appendChild(nameStrong); |
| 125 |
if (o.founderTitle) { |
| 126 |
caption.appendChild(document.createTextNode(', ' + o.founderTitle)); |
| 127 |
} |
| 128 |
photoWrap.appendChild(caption); |
| 129 |
} |
| 130 |
} |
| 131 |
|
| 132 |
photoCol.appendChild(photoWrap); |
| 133 |
return photoCol; |
| 134 |
} |
| 135 |
|
| 136 |
// ── content column ─────────────────────────────────────────────────── |
| 137 |
function buildContentCol() { |
| 138 |
var col = makeEl('div', 'bkbg-stry-content-col'); |
| 139 |
|
| 140 |
col.appendChild(makeText('h2', 'bkbg-stry-headline', o.headline, { |
| 141 |
color: o.headlineColor |
| 142 |
})); |
| 143 |
|
| 144 |
col.appendChild(makeText('p', 'bkbg-stry-subheadline', o.subheadline, { |
| 145 |
color: o.subColor |
| 146 |
})); |
| 147 |
|
| 148 |
col.appendChild(makeText('p', 'bkbg-stry-body', o.bodyText, { |
| 149 |
color: o.bodyColor |
| 150 |
})); |
| 151 |
|
| 152 |
if (o.showPullQuote && o.pullQuote) { |
| 153 |
var quote = makeText('blockquote', 'bkbg-stry-quote', o.pullQuote, { |
| 154 |
color: o.quoteColor, |
| 155 |
borderLeftColor: o.accentColor |
| 156 |
}); |
| 157 |
// centered layout: switch to border-top |
| 158 |
if (o.layout === 'centered') { |
| 159 |
quote.style.borderLeft = 'none'; |
| 160 |
quote.style.borderTop = '4px solid ' + o.accentColor; |
| 161 |
} |
| 162 |
col.appendChild(quote); |
| 163 |
} |
| 164 |
|
| 165 |
if (o.showCta && o.ctaLabel) { |
| 166 |
var ctaRow = makeEl('div', 'bkbg-stry-cta-row'); |
| 167 |
var ctaLink = document.createElement('a'); |
| 168 |
ctaLink.href = o.ctaUrl || '#'; |
| 169 |
if (o.ctaNewTab) { ctaLink.target = '_blank'; ctaLink.rel = 'noopener noreferrer'; } |
| 170 |
ctaLink.className = 'bkbg-stry-cta-btn'; |
| 171 |
ctaLink.textContent = o.ctaLabel; |
| 172 |
applyCSS(ctaLink, { |
| 173 |
background: o.ctaBg, |
| 174 |
color: o.ctaColor, |
| 175 |
borderRadius: o.borderRadius + 'px' |
| 176 |
}); |
| 177 |
ctaRow.appendChild(ctaLink); |
| 178 |
col.appendChild(ctaRow); |
| 179 |
} |
| 180 |
|
| 181 |
return col; |
| 182 |
} |
| 183 |
|
| 184 |
// Build columns in correct order per layout |
| 185 |
if (o.layout === 'centered') { |
| 186 |
if (o.showPhoto && o.founderPhotoUrl) main.appendChild(buildPhotoCol()); |
| 187 |
main.appendChild(buildContentCol()); |
| 188 |
} else if (o.layout === 'photo-right') { |
| 189 |
main.appendChild(buildContentCol()); |
| 190 |
if (o.showPhoto) main.appendChild(buildPhotoCol()); |
| 191 |
} else { |
| 192 |
// photo-left (default) |
| 193 |
if (o.showPhoto) main.appendChild(buildPhotoCol()); |
| 194 |
main.appendChild(buildContentCol()); |
| 195 |
} |
| 196 |
|
| 197 |
block.appendChild(main); |
| 198 |
|
| 199 |
// ── milestones ─────────────────────────────────────────────────────── |
| 200 |
if (o.showMilestones && o.milestones && o.milestones.length) { |
| 201 |
var msSection = makeEl('div', 'bkbg-stry-milestones'); |
| 202 |
|
| 203 |
var msLine = makeEl('div', 'bkbg-stry-milestone-line', { |
| 204 |
background: o.accentColor |
| 205 |
}); |
| 206 |
msSection.appendChild(msLine); |
| 207 |
|
| 208 |
var msList = makeEl('div', 'bkbg-stry-milestone-list'); |
| 209 |
|
| 210 |
o.milestones.forEach(function (m) { |
| 211 |
var ms = makeEl('div', 'bkbg-stry-milestone'); |
| 212 |
|
| 213 |
var dot = makeEl('div', 'bkbg-stry-milestone-dot', { |
| 214 |
background: o.accentColor |
| 215 |
}); |
| 216 |
ms.appendChild(dot); |
| 217 |
|
| 218 |
var mInner = makeEl('div', 'bkbg-stry-milestone-inner'); |
| 219 |
mInner.appendChild(makeText('div', 'bkbg-stry-milestone-year', m.year, { color: o.yearColor })); |
| 220 |
mInner.appendChild(makeText('div', 'bkbg-stry-milestone-title', m.title, { color: o.milestoneTitleColor })); |
| 221 |
mInner.appendChild(makeText('div', 'bkbg-stry-milestone-desc', m.description, { color: o.milestoneTextColor })); |
| 222 |
|
| 223 |
ms.appendChild(mInner); |
| 224 |
msList.appendChild(ms); |
| 225 |
}); |
| 226 |
|
| 227 |
msSection.appendChild(msList); |
| 228 |
block.appendChild(msSection); |
| 229 |
} |
| 230 |
|
| 231 |
appEl.parentNode.insertBefore(block, appEl); |
| 232 |
appEl.style.display = 'none'; |
| 233 |
}); |
| 234 |
} |
| 235 |
|
| 236 |
if (document.readyState !== 'loading') { init(); } |
| 237 |
else { document.addEventListener('DOMContentLoaded', init); } |
| 238 |
})(); |
| 239 |
|