| 1 |
(function () { |
| 2 |
function logoLetter(name) { return (name || '?').charAt(0).toUpperCase(); } |
| 3 |
|
| 4 |
var typoMap = [ |
| 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(typo, prefix, el) { |
| 13 |
if (!typo || typeof typo !== 'object') return; |
| 14 |
for (var i = 0; i < typoMap.length; i++) { |
| 15 |
var v = typo[typoMap[i][0]]; |
| 16 |
if (v !== undefined && v !== '' && v !== null) el.style.setProperty(prefix + typoMap[i][1], String(v)); |
| 17 |
} |
| 18 |
} |
| 19 |
|
| 20 |
function init() { |
| 21 |
document.querySelectorAll('.bkbg-igw-app').forEach(function (el) { |
| 22 |
if (el.dataset.rendered) return; |
| 23 |
el.dataset.rendered = '1'; |
| 24 |
|
| 25 |
var opts; |
| 26 |
try { opts = JSON.parse(el.dataset.opts || '{}'); } catch (e) { opts = {}; } |
| 27 |
|
| 28 |
var o = Object.assign({ |
| 29 |
eyebrow: 'Ecosystem', heading: 'Works With Your Favourite Tools', |
| 30 |
subtext: 'Connect to 200+ apps and automate your workflow.', |
| 31 |
integrations: [], showFilter: true, cardStyle: 'card', columns: 4, |
| 32 |
showDesc: true, showCta: true, ctaLabel: 'Browse All Integrations →', ctaUrl: '#', |
| 33 |
maxWidth: 1200, paddingTop: 80, paddingBottom: 80, |
| 34 |
bgColor: '#ffffff', headingColor: '#111827', subColor: '#6b7280', eyebrowColor: '#6366f1', |
| 35 |
cardBg: '#f8fafc', cardBorder: '#e2e8f0', nameColor: '#111827', descColor: '#6b7280', |
| 36 |
logoBg: '#e0e7ff', logoColor: '#4338ca', |
| 37 |
filterBg: '#f1f5f9', filterColor: '#64748b', filterActiveBg: '#6366f1', filterActiveColor: '#ffffff', |
| 38 |
accentColor: '#6366f1' |
| 39 |
}, opts); |
| 40 |
|
| 41 |
el.parentElement && (el.parentElement.style.background = o.bgColor); |
| 42 |
|
| 43 |
var inner = document.createElement('div'); |
| 44 |
inner.className = 'bkbg-igw-inner'; |
| 45 |
inner.style.cssText = 'max-width:' + o.maxWidth + 'px;margin:0 auto;padding:' + o.paddingTop + 'px 24px ' + o.paddingBottom + 'px;'; |
| 46 |
typoCssVarsForEl(o.headingTypo, '--bkbg-igw-h-', inner); |
| 47 |
typoCssVarsForEl(o.subtextTypo, '--bkbg-igw-st-', inner); |
| 48 |
typoCssVarsForEl(o.nameTypo, '--bkbg-igw-nm-', inner); |
| 49 |
|
| 50 |
/* Header */ |
| 51 |
var header = document.createElement('div'); |
| 52 |
header.className = 'bkbg-igw-header'; |
| 53 |
header.style.cssText = 'text-align:center;margin-bottom:40px;'; |
| 54 |
|
| 55 |
var ey = document.createElement('p'); ey.className = 'bkbg-igw-eyebrow'; ey.style.color = o.eyebrowColor; ey.innerHTML = o.eyebrow; |
| 56 |
var h2 = document.createElement('h2'); h2.className = 'bkbg-igw-heading'; h2.style.color = o.headingColor; h2.innerHTML = o.heading; |
| 57 |
var sub = document.createElement('p'); sub.className = 'bkbg-igw-sub'; sub.style.color = o.subColor; sub.innerHTML = o.subtext; |
| 58 |
header.appendChild(ey); header.appendChild(h2); header.appendChild(sub); |
| 59 |
inner.appendChild(header); |
| 60 |
|
| 61 |
/* Categories */ |
| 62 |
var cats = ['All']; |
| 63 |
(o.integrations || []).forEach(function (it) { if (it.category && cats.indexOf(it.category) === -1) cats.push(it.category); }); |
| 64 |
|
| 65 |
var activeFilter = 'All'; |
| 66 |
var cardEls = []; |
| 67 |
|
| 68 |
/* Filter */ |
| 69 |
if (o.showFilter) { |
| 70 |
var filterRow = document.createElement('div'); |
| 71 |
filterRow.className = 'bkbg-igw-filter'; |
| 72 |
|
| 73 |
cats.forEach(function (cat) { |
| 74 |
var pill = document.createElement('button'); |
| 75 |
pill.className = 'bkbg-igw-pill'; |
| 76 |
pill.textContent = cat; |
| 77 |
pill.style.cssText = cat === 'All' ? 'background:' + o.filterActiveBg + ';color:' + o.filterActiveColor : 'background:' + o.filterBg + ';color:' + o.filterColor; |
| 78 |
pill.addEventListener('click', function () { |
| 79 |
activeFilter = cat; |
| 80 |
filterRow.querySelectorAll('.bkbg-igw-pill').forEach(function (p) { |
| 81 |
p.style.cssText = p.textContent === activeFilter ? 'background:' + o.filterActiveBg + ';color:' + o.filterActiveColor : 'background:' + o.filterBg + ';color:' + o.filterColor; |
| 82 |
}); |
| 83 |
cardEls.forEach(function (info) { |
| 84 |
info.card.classList.toggle('hidden', activeFilter !== 'All' && info.category !== activeFilter); |
| 85 |
}); |
| 86 |
}); |
| 87 |
filterRow.appendChild(pill); |
| 88 |
}); |
| 89 |
inner.appendChild(filterRow); |
| 90 |
} |
| 91 |
|
| 92 |
/* Grid */ |
| 93 |
var grid = document.createElement('div'); |
| 94 |
grid.className = 'bkbg-igw-grid card-style-' + o.cardStyle; |
| 95 |
grid.style.gridTemplateColumns = 'repeat(' + o.columns + ',1fr)'; |
| 96 |
|
| 97 |
(o.integrations || []).forEach(function (integ) { |
| 98 |
var card = document.createElement(integ.url && integ.url !== '#' ? 'a' : 'div'); |
| 99 |
card.className = 'bkbg-igw-card'; |
| 100 |
card.style.cssText = 'background:' + o.cardBg + ';border-color:' + o.cardBorder; |
| 101 |
if (integ.url) { card.href = integ.url; card.target = '_blank'; card.rel = 'noopener'; } |
| 102 |
|
| 103 |
if (integ.logoUrl) { |
| 104 |
var img = document.createElement('img'); |
| 105 |
img.className = 'bkbg-igw-logo-img'; img.src = integ.logoUrl; img.alt = integ.name; |
| 106 |
card.appendChild(img); |
| 107 |
} else { |
| 108 |
var fallback = document.createElement('div'); |
| 109 |
fallback.className = 'bkbg-igw-logo-fallback'; |
| 110 |
fallback.style.cssText = 'background:' + o.logoBg + ';color:' + o.logoColor; |
| 111 |
fallback.textContent = logoLetter(integ.name); |
| 112 |
card.appendChild(fallback); |
| 113 |
} |
| 114 |
|
| 115 |
var body = document.createElement('div'); |
| 116 |
body.className = 'bkbg-igw-card-body'; |
| 117 |
|
| 118 |
var name = document.createElement('div'); |
| 119 |
name.className = 'bkbg-igw-integ-name'; name.style.color = o.nameColor; name.textContent = integ.name; |
| 120 |
body.appendChild(name); |
| 121 |
|
| 122 |
if (o.showDesc && integ.description) { |
| 123 |
var desc = document.createElement('div'); |
| 124 |
desc.className = 'bkbg-igw-integ-desc'; desc.style.color = o.descColor; desc.textContent = integ.description; |
| 125 |
body.appendChild(desc); |
| 126 |
} |
| 127 |
card.appendChild(body); |
| 128 |
grid.appendChild(card); |
| 129 |
cardEls.push({ card: card, category: integ.category }); |
| 130 |
}); |
| 131 |
|
| 132 |
inner.appendChild(grid); |
| 133 |
|
| 134 |
if (o.showCta) { |
| 135 |
var ctaRow = document.createElement('div'); |
| 136 |
ctaRow.className = 'bkbg-igw-cta-row'; |
| 137 |
var cta = document.createElement('a'); |
| 138 |
cta.className = 'bkbg-igw-cta'; cta.href = o.ctaUrl; cta.style.color = o.accentColor; cta.textContent = o.ctaLabel; |
| 139 |
ctaRow.appendChild(cta); |
| 140 |
inner.appendChild(ctaRow); |
| 141 |
} |
| 142 |
|
| 143 |
el.appendChild(inner); |
| 144 |
}); |
| 145 |
} |
| 146 |
|
| 147 |
if (document.readyState !== 'loading') { init(); } |
| 148 |
else { document.addEventListener('DOMContentLoaded', init); } |
| 149 |
})(); |
| 150 |
|