| 1 |
(function () { |
| 2 |
function typoCssVarsForEl(typo, prefix, el) { |
| 3 |
if (!typo || typeof typo !== 'object') return; |
| 4 |
var map = { |
| 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 |
Object.keys(map).forEach(function(k) { |
| 13 |
if (typo[k] !== undefined && typo[k] !== '') { |
| 14 |
var v = typo[k]; |
| 15 |
if (['sizeDesktop','sizeTablet','sizeMobile'].indexOf(k) !== -1) v = v + (typo.sizeUnit || 'px'); |
| 16 |
else if (['lineHeightDesktop','lineHeightTablet','lineHeightMobile'].indexOf(k) !== -1) v = v + (typo.lineHeightUnit || ''); |
| 17 |
else if (['letterSpacingDesktop','letterSpacingTablet','letterSpacingMobile'].indexOf(k) !== -1) v = v + (typo.letterSpacingUnit || 'px'); |
| 18 |
else if (['wordSpacingDesktop','wordSpacingTablet','wordSpacingMobile'].indexOf(k) !== -1) v = v + (typo.wordSpacingUnit || 'px'); |
| 19 |
el.style.setProperty(prefix + map[k], String(v)); |
| 20 |
} |
| 21 |
}); |
| 22 |
} |
| 23 |
|
| 24 |
function init() { |
| 25 |
document.querySelectorAll('.bkbg-aps-app').forEach(function (el) { |
| 26 |
if (el.dataset.rendered) return; |
| 27 |
el.dataset.rendered = '1'; |
| 28 |
|
| 29 |
var opts; |
| 30 |
try { opts = JSON.parse(el.dataset.opts || '{}'); } catch (e) { opts = {}; } |
| 31 |
|
| 32 |
var o = Object.assign({ |
| 33 |
eyebrow: 'The Platform', |
| 34 |
heading: 'Everything You Need in One Place', |
| 35 |
subtext: 'A powerful, intuitive dashboard designed to help you move faster.', |
| 36 |
screenshotUrl: '', |
| 37 |
callouts: [], |
| 38 |
showCallouts: true, |
| 39 |
deviceFrame: 'browser', |
| 40 |
layout: 'centered', |
| 41 |
ctaLabel: 'See It in Action', |
| 42 |
ctaUrl: '#', |
| 43 |
showCta: true, |
| 44 |
bgColor: '#ffffff', |
| 45 |
headingColor: '#111827', |
| 46 |
subColor: '#6b7280', |
| 47 |
eyebrowColor: '#6366f1', |
| 48 |
frameColor: '#1e293b', |
| 49 |
calloutBg: '#6366f1', |
| 50 |
calloutColor: '#ffffff', |
| 51 |
ctaBg: '#6366f1', |
| 52 |
ctaColor: '#ffffff', |
| 53 |
maxWidth: 1200, |
| 54 |
paddingTop: 80, |
| 55 |
paddingBottom: 80 |
| 56 |
}, opts); |
| 57 |
|
| 58 |
el.parentElement && (el.parentElement.style.background = o.bgColor); |
| 59 |
|
| 60 |
// Typography CSS vars |
| 61 |
typoCssVarsForEl(o.eyebrowTypo, '--bkbg-aps-eyebrow-', el); |
| 62 |
typoCssVarsForEl(o.headingTypo, '--bkbg-aps-heading-', el); |
| 63 |
typoCssVarsForEl(o.subtextTypo, '--bkbg-aps-sub-', el); |
| 64 |
if (o.eyebrowFontSize && o.eyebrowFontSize !== 13) el.style.setProperty('--bkbg-aps-eyebrow-sz', o.eyebrowFontSize + 'px'); |
| 65 |
if (o.headingFontSize && o.headingFontSize !== 36) el.style.setProperty('--bkbg-aps-heading-sz', o.headingFontSize + 'px'); |
| 66 |
if (o.subtextFontSize && o.subtextFontSize !== 18) el.style.setProperty('--bkbg-aps-sub-sz', o.subtextFontSize + 'px'); |
| 67 |
|
| 68 |
var inner = document.createElement('div'); |
| 69 |
inner.className = 'bkbg-aps-inner'; |
| 70 |
inner.style.cssText = 'max-width:' + o.maxWidth + 'px;margin:0 auto;padding:' + o.paddingTop + 'px 24px ' + o.paddingBottom + 'px;'; |
| 71 |
|
| 72 |
var isSplit = o.layout === 'split'; |
| 73 |
var outerWrap = inner; |
| 74 |
|
| 75 |
if (isSplit) { |
| 76 |
var splitGrid = document.createElement('div'); |
| 77 |
splitGrid.className = 'bkbg-aps-split'; |
| 78 |
inner.appendChild(splitGrid); |
| 79 |
outerWrap = splitGrid; |
| 80 |
} |
| 81 |
|
| 82 |
/* Header */ |
| 83 |
var header = document.createElement('div'); |
| 84 |
header.className = 'bkbg-aps-header'; |
| 85 |
|
| 86 |
var eyebrow = document.createElement('p'); |
| 87 |
eyebrow.className = 'bkbg-aps-eyebrow'; |
| 88 |
eyebrow.style.color = o.eyebrowColor; |
| 89 |
eyebrow.innerHTML = o.eyebrow; |
| 90 |
|
| 91 |
var heading = document.createElement('h2'); |
| 92 |
heading.className = 'bkbg-aps-heading'; |
| 93 |
heading.style.color = o.headingColor; |
| 94 |
heading.innerHTML = o.heading; |
| 95 |
|
| 96 |
var sub = document.createElement('p'); |
| 97 |
sub.className = 'bkbg-aps-sub'; |
| 98 |
sub.style.color = o.subColor; |
| 99 |
sub.innerHTML = o.subtext; |
| 100 |
|
| 101 |
header.appendChild(eyebrow); |
| 102 |
header.appendChild(heading); |
| 103 |
header.appendChild(sub); |
| 104 |
|
| 105 |
if (o.showCta) { |
| 106 |
var cta = document.createElement('a'); |
| 107 |
cta.className = 'bkbg-aps-cta'; |
| 108 |
cta.href = o.ctaUrl; |
| 109 |
cta.style.cssText = 'background:' + o.ctaBg + ';color:' + o.ctaColor; |
| 110 |
cta.textContent = o.ctaLabel; |
| 111 |
header.appendChild(cta); |
| 112 |
} |
| 113 |
|
| 114 |
outerWrap.appendChild(header); |
| 115 |
|
| 116 |
/* Screenshot */ |
| 117 |
var frameWrap = document.createElement('div'); |
| 118 |
frameWrap.className = 'bkbg-aps-frame-wrap frame-' + o.deviceFrame; |
| 119 |
if (o.deviceFrame !== 'none') { |
| 120 |
frameWrap.style.cssText = 'border-color:' + o.frameColor; |
| 121 |
} |
| 122 |
|
| 123 |
if (o.deviceFrame === 'browser') { |
| 124 |
var bar = document.createElement('div'); |
| 125 |
bar.className = 'bkbg-aps-browser-bar'; |
| 126 |
bar.style.background = o.frameColor; |
| 127 |
['#ef4444', '#fbbf24', '#22c55e'].forEach(function (c) { |
| 128 |
var dot = document.createElement('span'); |
| 129 |
dot.className = 'bkbg-aps-browser-dot'; |
| 130 |
dot.style.background = c; |
| 131 |
bar.appendChild(dot); |
| 132 |
}); |
| 133 |
frameWrap.appendChild(bar); |
| 134 |
} |
| 135 |
|
| 136 |
if (o.screenshotUrl) { |
| 137 |
var img = document.createElement('img'); |
| 138 |
img.className = 'bkbg-aps-screenshot'; |
| 139 |
img.src = o.screenshotUrl; |
| 140 |
img.alt = ''; |
| 141 |
frameWrap.appendChild(img); |
| 142 |
} else { |
| 143 |
var placeholder = document.createElement('div'); |
| 144 |
placeholder.style.cssText = 'min-height:360px;background:#f1f5f9;display:flex;align-items:center;justify-content:center;color:#94a3b8;font-size:18px;'; |
| 145 |
placeholder.textContent = '🖼 App screenshot goes here'; |
| 146 |
frameWrap.appendChild(placeholder); |
| 147 |
} |
| 148 |
|
| 149 |
/* Callout points */ |
| 150 |
if (o.showCallouts && o.callouts && o.callouts.length) { |
| 151 |
var calloutsLayer = document.createElement('div'); |
| 152 |
calloutsLayer.className = 'bkbg-aps-callouts'; |
| 153 |
frameWrap.style.position = 'relative'; |
| 154 |
|
| 155 |
o.callouts.forEach(function (c) { |
| 156 |
var callout = document.createElement('div'); |
| 157 |
callout.className = 'bkbg-aps-callout'; |
| 158 |
callout.style.cssText = 'left:' + c.x + '%;top:' + c.y + '%;'; |
| 159 |
|
| 160 |
var label = document.createElement('div'); |
| 161 |
label.className = 'bkbg-aps-callout-label'; |
| 162 |
label.style.cssText = 'background:' + o.calloutBg + ';color:' + o.calloutColor; |
| 163 |
label.textContent = c.label; |
| 164 |
|
| 165 |
if (c.description) { |
| 166 |
var tooltip = document.createElement('div'); |
| 167 |
tooltip.className = 'bkbg-aps-callout-tooltip'; |
| 168 |
tooltip.textContent = c.description; |
| 169 |
label.appendChild(tooltip); |
| 170 |
} |
| 171 |
|
| 172 |
var dot = document.createElement('div'); |
| 173 |
dot.className = 'bkbg-aps-callout-dot'; |
| 174 |
dot.style.cssText = 'background:' + o.calloutBg + ';color:' + o.calloutBg; |
| 175 |
|
| 176 |
callout.appendChild(label); |
| 177 |
callout.appendChild(dot); |
| 178 |
calloutsLayer.appendChild(callout); |
| 179 |
}); |
| 180 |
|
| 181 |
frameWrap.appendChild(calloutsLayer); |
| 182 |
} |
| 183 |
|
| 184 |
outerWrap.appendChild(frameWrap); |
| 185 |
el.appendChild(inner); |
| 186 |
}); |
| 187 |
} |
| 188 |
|
| 189 |
if (document.readyState !== 'loading') { init(); } |
| 190 |
else { document.addEventListener('DOMContentLoaded', init); } |
| 191 |
})(); |
| 192 |
|