| 1 |
(function () { |
| 2 |
'use strict'; |
| 3 |
|
| 4 |
var _typoKeys = { family:'font-family', weight:'font-weight', style:'font-style', |
| 5 |
decoration:'text-decoration', transform:'text-transform', |
| 6 |
sizeDesktop:'font-size-d', sizeTablet:'font-size-t', sizeMobile:'font-size-m', |
| 7 |
lineHeightDesktop:'line-height-d', lineHeightTablet:'line-height-t', lineHeightMobile:'line-height-m', |
| 8 |
letterSpacingDesktop:'letter-spacing-d', letterSpacingTablet:'letter-spacing-t', letterSpacingMobile:'letter-spacing-m', |
| 9 |
wordSpacingDesktop:'word-spacing-d', wordSpacingTablet:'word-spacing-t', wordSpacingMobile:'word-spacing-m' }; |
| 10 |
function typoCssVarsForEl(el, typo, prefix) { |
| 11 |
if (!typo || typeof typo !== 'object') return; |
| 12 |
Object.keys(_typoKeys).forEach(function (k) { |
| 13 |
if (typo[k] !== undefined && typo[k] !== '') el.style.setProperty(prefix + _typoKeys[k], String(typo[k])); |
| 14 |
}); |
| 15 |
} |
| 16 |
|
| 17 |
function ce(tag, attrs, children) { |
| 18 |
var el = document.createElement(tag); |
| 19 |
if (attrs) { |
| 20 |
Object.keys(attrs).forEach(function (k) { |
| 21 |
if (k === 'className') { el.className = attrs[k]; } |
| 22 |
else if (k === 'style') { Object.assign(el.style, attrs[k]); } |
| 23 |
else if (k === 'textContent') { el.textContent = attrs[k]; } |
| 24 |
else if (k === 'innerHTML') { el.innerHTML = attrs[k]; } |
| 25 |
else { el.setAttribute(k, attrs[k]); } |
| 26 |
}); |
| 27 |
} |
| 28 |
if (children) { |
| 29 |
(Array.isArray(children) ? children : [children]).forEach(function (child) { |
| 30 |
if (!child) return; |
| 31 |
if (typeof child === 'string') el.appendChild(document.createTextNode(child)); |
| 32 |
else el.appendChild(child); |
| 33 |
}); |
| 34 |
} |
| 35 |
return el; |
| 36 |
} |
| 37 |
|
| 38 |
function section(o, titleText, content) { |
| 39 |
var sec = ce('div', { |
| 40 |
className: 'bkbg-mkit-section', |
| 41 |
style: { |
| 42 |
background: o.sectionBg || '#fff', |
| 43 |
borderColor: o.borderColor || '#e5e7eb', |
| 44 |
borderRadius: (o.sectionBorderRadius || 12) + 'px' |
| 45 |
} |
| 46 |
}); |
| 47 |
var title = ce('div', { |
| 48 |
className: 'bkbg-mkit-section-title', |
| 49 |
style: { color: o.accentColor || '#6366f1' }, |
| 50 |
textContent: titleText |
| 51 |
}); |
| 52 |
sec.appendChild(title); |
| 53 |
if (Array.isArray(content)) content.forEach(function (c) { if (c) sec.appendChild(c); }); |
| 54 |
else if (content) sec.appendChild(content); |
| 55 |
return sec; |
| 56 |
} |
| 57 |
|
| 58 |
function buildMediaKit(appEl, o) { |
| 59 |
|
| 60 |
/* ── Google Fonts ── */ |
| 61 |
(o.fonts || []).forEach(function (font) { |
| 62 |
if (font.googleFontUrl) { |
| 63 |
var link = document.createElement('link'); |
| 64 |
link.rel = 'stylesheet'; |
| 65 |
link.href = font.googleFontUrl; |
| 66 |
document.head.appendChild(link); |
| 67 |
} |
| 68 |
}); |
| 69 |
|
| 70 |
var wrap = ce('div', { |
| 71 |
className: 'bkbg-mkit-wrap', |
| 72 |
style: { |
| 73 |
background: o.bgColor || '#f8fafc', |
| 74 |
paddingTop: (o.paddingTop || 40) + 'px', |
| 75 |
paddingBottom: (o.paddingBottom || 40) + 'px' |
| 76 |
} |
| 77 |
}); |
| 78 |
|
| 79 |
typoCssVarsForEl(wrap, o.brandNameTypo, '--bkbg-mkit-bn-'); |
| 80 |
typoCssVarsForEl(wrap, o.taglineTypo, '--bkbg-mkit-tl-'); |
| 81 |
typoCssVarsForEl(wrap, o.sectionTitleTypo, '--bkbg-mkit-st-'); |
| 82 |
typoCssVarsForEl(wrap, o.bodyTypo, '--bkbg-mkit-bd-'); |
| 83 |
typoCssVarsForEl(wrap, o.labelTypo, '--bkbg-mkit-lb-'); |
| 84 |
typoCssVarsForEl(wrap, o.metaTypo, '--bkbg-mkit-mt-'); |
| 85 |
|
| 86 |
var inner = ce('div', { |
| 87 |
className: 'bkbg-mkit-inner', |
| 88 |
style: { maxWidth: (o.maxWidth || 900) + 'px' } |
| 89 |
}); |
| 90 |
|
| 91 |
/* ── header ── */ |
| 92 |
var header = ce('div', { |
| 93 |
className: 'bkbg-mkit-section bkbg-mkit-header', |
| 94 |
style: { |
| 95 |
background: o.sectionBg || '#fff', |
| 96 |
borderColor: o.borderColor || '#e5e7eb', |
| 97 |
borderRadius: (o.sectionBorderRadius || 12) + 'px' |
| 98 |
} |
| 99 |
}, [ |
| 100 |
ce('div', { className: 'bkbg-mkit-brand-name', style: { color: o.headingColor || '#111827' }, textContent: o.brandName || '' }), |
| 101 |
o.brandTagline ? ce('div', { className: 'bkbg-mkit-brand-tagline', style: { color: o.textColor || '#374151' }, textContent: o.brandTagline }) : null |
| 102 |
]); |
| 103 |
inner.appendChild(header); |
| 104 |
|
| 105 |
/* ── logos ── */ |
| 106 |
if (o.showLogos && (o.logoVariants || []).length) { |
| 107 |
var logosGrid = ce('div', { className: 'bkbg-mkit-logos-grid' }); |
| 108 |
(o.logoVariants || []).forEach(function (lv) { |
| 109 |
var card = ce('div', { |
| 110 |
className: 'bkbg-mkit-logo-card', |
| 111 |
style: { |
| 112 |
background: o.cardBg || '#f9fafb', |
| 113 |
borderColor: o.borderColor || '#e5e7eb' |
| 114 |
} |
| 115 |
}); |
| 116 |
|
| 117 |
var preview = ce('div', { |
| 118 |
className: 'bkbg-mkit-logo-preview', |
| 119 |
style: { background: lv.format === 'Dark' ? '#1f2937' : '#fff' } |
| 120 |
}); |
| 121 |
if (lv.url) { |
| 122 |
var img = document.createElement('img'); |
| 123 |
img.src = lv.url; |
| 124 |
img.alt = lv.label || ''; |
| 125 |
img.style.maxWidth = '100%'; |
| 126 |
img.style.maxHeight = '72px'; |
| 127 |
img.style.objectFit = 'contain'; |
| 128 |
preview.appendChild(img); |
| 129 |
} else { |
| 130 |
preview.appendChild(ce('div', { className: 'bkbg-mkit-logo-placeholder', textContent: '[ ' + (lv.format || 'Logo') + ' ]' })); |
| 131 |
} |
| 132 |
card.appendChild(preview); |
| 133 |
card.appendChild(ce('div', { className: 'bkbg-mkit-logo-label', style: { color: o.headingColor || '#111827' }, textContent: lv.label || '' })); |
| 134 |
card.appendChild(ce('div', { className: 'bkbg-mkit-logo-format', style: { color: o.labelColor || '#6b7280' }, textContent: lv.format || '' })); |
| 135 |
|
| 136 |
if (lv.downloadUrl) { |
| 137 |
var dl = document.createElement('a'); |
| 138 |
dl.className = 'bkbg-mkit-logo-dl'; |
| 139 |
dl.href = lv.downloadUrl; |
| 140 |
dl.download = ''; |
| 141 |
dl.textContent = '↓ Download'; |
| 142 |
dl.style.color = o.accentColor || '#6366f1'; |
| 143 |
card.appendChild(dl); |
| 144 |
} |
| 145 |
logosGrid.appendChild(card); |
| 146 |
}); |
| 147 |
inner.appendChild(section(o, 'Logo Variants', logosGrid)); |
| 148 |
} |
| 149 |
|
| 150 |
/* ── colors ── */ |
| 151 |
if (o.showColors && (o.brandColors || []).length) { |
| 152 |
var colsPerRow = o.colorsPerRow || 5; |
| 153 |
var colorsGrid = ce('div', { |
| 154 |
className: 'bkbg-mkit-colors-grid', |
| 155 |
style: { gridTemplateColumns: 'repeat(' + colsPerRow + ', 1fr)' } |
| 156 |
}); |
| 157 |
(o.brandColors || []).forEach(function (color) { |
| 158 |
var swatchWrap = ce('div', { className: 'bkbg-mkit-color-swatch-wrap' }); |
| 159 |
var swatch = ce('div', { |
| 160 |
className: 'bkbg-mkit-color-swatch', |
| 161 |
style: { background: color.hex || '#ccc' } |
| 162 |
}); |
| 163 |
|
| 164 |
/* tooltip */ |
| 165 |
var tooltip = ce('div', { className: 'bkbg-mkit-color-tooltip', textContent: 'Copied!' }); |
| 166 |
swatch.appendChild(tooltip); |
| 167 |
|
| 168 |
/* click to copy */ |
| 169 |
swatch.setAttribute('title', color.hex || ''); |
| 170 |
swatch.style.cursor = 'pointer'; |
| 171 |
swatch.addEventListener('click', function () { |
| 172 |
if (navigator.clipboard) { |
| 173 |
navigator.clipboard.writeText(color.hex || '').then(function () { |
| 174 |
tooltip.style.opacity = '1'; |
| 175 |
setTimeout(function () { tooltip.style.opacity = '0'; }, 1500); |
| 176 |
}); |
| 177 |
} |
| 178 |
}); |
| 179 |
|
| 180 |
swatchWrap.appendChild(swatch); |
| 181 |
swatchWrap.appendChild(ce('div', { className: 'bkbg-mkit-color-info' }, [ |
| 182 |
ce('div', { className: 'bkbg-mkit-color-name', style: { color: o.headingColor || '#111827' }, textContent: color.name || '' }), |
| 183 |
ce('div', { className: 'bkbg-mkit-color-hex', style: { color: o.labelColor || '#6b7280' }, textContent: color.hex || '' }) |
| 184 |
])); |
| 185 |
colorsGrid.appendChild(swatchWrap); |
| 186 |
}); |
| 187 |
inner.appendChild(section(o, 'Brand Colors', colorsGrid)); |
| 188 |
} |
| 189 |
|
| 190 |
/* ── fonts ── */ |
| 191 |
if (o.showFonts && (o.fonts || []).length) { |
| 192 |
var fontsList = ce('div', { className: 'bkbg-mkit-fonts-list' }); |
| 193 |
(o.fonts || []).forEach(function (font) { |
| 194 |
var card = ce('div', { |
| 195 |
className: 'bkbg-mkit-font-card', |
| 196 |
style: { |
| 197 |
background: o.cardBg || '#f9fafb', |
| 198 |
borderColor: o.borderColor || '#e5e7eb' |
| 199 |
} |
| 200 |
}); |
| 201 |
var header2 = ce('div', { className: 'bkbg-mkit-font-header' }, [ |
| 202 |
ce('div', { className: 'bkbg-mkit-font-name', style: { color: o.headingColor || '#111827', fontFamily: font.name || 'inherit' }, textContent: font.name || '' }), |
| 203 |
ce('div', { className: 'bkbg-mkit-font-role', style: { color: o.accentColor || '#6366f1' }, textContent: font.role || '' }) |
| 204 |
]); |
| 205 |
var preview = ce('div', { |
| 206 |
className: 'bkbg-mkit-font-preview', |
| 207 |
style: { |
| 208 |
fontFamily: font.name || 'inherit', |
| 209 |
color: o.textColor || '#374151' |
| 210 |
}, |
| 211 |
textContent: font.previewText || 'The quick brown fox jumps over the lazy dog' |
| 212 |
}); |
| 213 |
card.appendChild(header2); |
| 214 |
card.appendChild(preview); |
| 215 |
fontsList.appendChild(card); |
| 216 |
}); |
| 217 |
inner.appendChild(section(o, 'Typography', fontsList)); |
| 218 |
} |
| 219 |
|
| 220 |
/* ── downloads ── */ |
| 221 |
if (o.showDownloads && (o.downloadAllUrl || o.guidelinesDownloadUrl)) { |
| 222 |
var dlContainer = ce('div', { className: 'bkbg-mkit-downloads' }); |
| 223 |
|
| 224 |
if (o.downloadAllUrl) { |
| 225 |
var dlAll = document.createElement('a'); |
| 226 |
dlAll.className = 'bkbg-mkit-dl-btn'; |
| 227 |
dlAll.href = o.downloadAllUrl; |
| 228 |
dlAll.download = ''; |
| 229 |
dlAll.textContent = '⬇ ' + (o.downloadAllLabel || 'Download All Assets (ZIP)'); |
| 230 |
dlAll.style.background = o.downloadBg || '#6366f1'; |
| 231 |
dlAll.style.color = o.downloadColor || '#fff'; |
| 232 |
dlContainer.appendChild(dlAll); |
| 233 |
} |
| 234 |
|
| 235 |
if (o.guidelinesDownloadUrl) { |
| 236 |
var dlGuide = document.createElement('a'); |
| 237 |
dlGuide.className = 'bkbg-mkit-dl-btn is-outline'; |
| 238 |
dlGuide.href = o.guidelinesDownloadUrl; |
| 239 |
dlGuide.download = ''; |
| 240 |
dlGuide.textContent = '📄 ' + (o.guidelinesLabel || 'Download Brand Guidelines'); |
| 241 |
dlGuide.style.color = o.accentColor || '#6366f1'; |
| 242 |
dlGuide.style.borderColor = o.accentColor || '#6366f1'; |
| 243 |
dlContainer.appendChild(dlGuide); |
| 244 |
} |
| 245 |
|
| 246 |
inner.appendChild(section(o, 'Asset Downloads', dlContainer)); |
| 247 |
} |
| 248 |
|
| 249 |
/* ── contact ── */ |
| 250 |
if (o.showContact && (o.pressEmail || o.websiteUrl)) { |
| 251 |
var contactRow = ce('div', { className: 'bkbg-mkit-contact' }); |
| 252 |
|
| 253 |
if (o.pressEmail) { |
| 254 |
var grp1 = ce('div', { className: 'bkbg-mkit-contact-group' }, [ |
| 255 |
ce('div', { className: 'bkbg-mkit-contact-label', style: { color: o.labelColor || '#6b7280' }, textContent: 'Press Inquiries' }), |
| 256 |
(function () { |
| 257 |
var a = document.createElement('a'); |
| 258 |
a.className = 'bkbg-mkit-contact-link'; |
| 259 |
a.href = 'mailto:' + o.pressEmail; |
| 260 |
a.textContent = o.pressEmail; |
| 261 |
a.style.color = o.accentColor || '#6366f1'; |
| 262 |
return a; |
| 263 |
})() |
| 264 |
]); |
| 265 |
contactRow.appendChild(grp1); |
| 266 |
} |
| 267 |
|
| 268 |
if (o.websiteUrl) { |
| 269 |
var grp2 = ce('div', { className: 'bkbg-mkit-contact-group' }, [ |
| 270 |
ce('div', { className: 'bkbg-mkit-contact-label', style: { color: o.labelColor || '#6b7280' }, textContent: 'Website' }), |
| 271 |
(function () { |
| 272 |
var a = document.createElement('a'); |
| 273 |
a.className = 'bkbg-mkit-contact-link'; |
| 274 |
a.href = o.websiteUrl; |
| 275 |
a.target = '_blank'; |
| 276 |
a.rel = 'noopener'; |
| 277 |
a.textContent = o.websiteUrl; |
| 278 |
a.style.color = o.accentColor || '#6366f1'; |
| 279 |
return a; |
| 280 |
})() |
| 281 |
]); |
| 282 |
contactRow.appendChild(grp2); |
| 283 |
} |
| 284 |
|
| 285 |
var contactSec = section(o, 'Media Contact', contactRow); |
| 286 |
contactSec.style.background = o.cardBg || '#f9fafb'; |
| 287 |
inner.appendChild(contactSec); |
| 288 |
} |
| 289 |
|
| 290 |
wrap.appendChild(inner); |
| 291 |
appEl.parentNode.insertBefore(wrap, appEl); |
| 292 |
appEl.style.display = 'none'; |
| 293 |
} |
| 294 |
|
| 295 |
function init() { |
| 296 |
document.querySelectorAll('.bkbg-mkit-app').forEach(function (appEl) { |
| 297 |
if (appEl.dataset.rendered) return; |
| 298 |
appEl.dataset.rendered = '1'; |
| 299 |
|
| 300 |
var opts; |
| 301 |
try { opts = JSON.parse(appEl.dataset.opts || '{}'); } catch (e) { opts = {}; } |
| 302 |
|
| 303 |
var o = Object.assign({ |
| 304 |
brandName: '', |
| 305 |
brandTagline: '', |
| 306 |
logoVariants: [], |
| 307 |
brandColors: [], |
| 308 |
fonts: [], |
| 309 |
guidelinesLabel: 'Download Brand Guidelines', |
| 310 |
guidelinesDownloadUrl: '', |
| 311 |
downloadAllLabel: 'Download All Assets (ZIP)', |
| 312 |
downloadAllUrl: '', |
| 313 |
pressEmail: '', |
| 314 |
websiteUrl: '', |
| 315 |
showLogos: true, |
| 316 |
showColors: true, |
| 317 |
showFonts: true, |
| 318 |
showDownloads: true, |
| 319 |
showContact: true, |
| 320 |
colorsPerRow: 5, |
| 321 |
maxWidth: 900, |
| 322 |
paddingTop: 40, |
| 323 |
paddingBottom: 40, |
| 324 |
bgColor: '#f8fafc', |
| 325 |
sectionBg: '#ffffff', |
| 326 |
cardBg: '#f9fafb', |
| 327 |
headingColor: '#111827', |
| 328 |
textColor: '#374151', |
| 329 |
labelColor: '#6b7280', |
| 330 |
borderColor: '#e5e7eb', |
| 331 |
accentColor: '#6366f1', |
| 332 |
downloadBg: '#6366f1', |
| 333 |
downloadColor: '#ffffff', |
| 334 |
sectionBorderRadius: 12 |
| 335 |
}, opts); |
| 336 |
|
| 337 |
buildMediaKit(appEl, o); |
| 338 |
}); |
| 339 |
} |
| 340 |
|
| 341 |
if (document.readyState !== 'loading') { init(); } |
| 342 |
else { document.addEventListener('DOMContentLoaded', init); } |
| 343 |
})(); |
| 344 |
|