| 1 |
(function () { |
| 2 |
var CONTACT_ICONS = { email: '✉', phone: '📞', location: '📍', website: '🌐' }; |
| 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 initials(name) { |
| 26 |
return (name || 'A').split(' ').map(function (w) { return w[0]; }).slice(0, 2).join('').toUpperCase(); |
| 27 |
} |
| 28 |
|
| 29 |
function sectionHeader(title, accentColor, textColor) { |
| 30 |
var wrap = document.createElement('div'); |
| 31 |
wrap.className = 'bkbg-rv-section-header'; |
| 32 |
|
| 33 |
var bar = document.createElement('span'); |
| 34 |
bar.className = 'bkbg-rv-section-bar'; |
| 35 |
bar.style.background = accentColor; |
| 36 |
|
| 37 |
var label = document.createElement('span'); |
| 38 |
label.className = 'bkbg-rv-section-label'; |
| 39 |
label.textContent = title; |
| 40 |
label.style.color = textColor; |
| 41 |
|
| 42 |
wrap.appendChild(bar); |
| 43 |
wrap.appendChild(label); |
| 44 |
return wrap; |
| 45 |
} |
| 46 |
|
| 47 |
function buildDivider(color) { |
| 48 |
var d = document.createElement('div'); |
| 49 |
d.style.cssText = 'height:1px;background:' + color + ';margin:0 0 16px'; |
| 50 |
return d; |
| 51 |
} |
| 52 |
|
| 53 |
function buildExperience(exp, o, isLast) { |
| 54 |
var item = document.createElement('div'); |
| 55 |
item.className = 'bkbg-rv-exp-item'; |
| 56 |
item.style.cssText = 'padding-bottom:' + (isLast ? 0 : 20) + 'px;margin-bottom:' + (isLast ? 0 : 4) + 'px'; |
| 57 |
|
| 58 |
// Timeline column |
| 59 |
var tCol = document.createElement('div'); |
| 60 |
tCol.className = 'bkbg-rv-timeline-col'; |
| 61 |
|
| 62 |
var dot = document.createElement('div'); |
| 63 |
dot.className = 'bkbg-rv-timeline-dot'; |
| 64 |
dot.style.background = o.timelineDotColor; |
| 65 |
tCol.appendChild(dot); |
| 66 |
|
| 67 |
if (!isLast) { |
| 68 |
var line = document.createElement('div'); |
| 69 |
line.className = 'bkbg-rv-timeline-line'; |
| 70 |
line.style.background = o.dividerColor; |
| 71 |
tCol.appendChild(line); |
| 72 |
} |
| 73 |
|
| 74 |
// Content |
| 75 |
var content = document.createElement('div'); |
| 76 |
content.className = 'bkbg-rv-exp-content'; |
| 77 |
|
| 78 |
var meta = document.createElement('div'); |
| 79 |
meta.className = 'bkbg-rv-exp-meta'; |
| 80 |
|
| 81 |
var leftDiv = document.createElement('div'); |
| 82 |
|
| 83 |
var role = document.createElement('div'); |
| 84 |
role.className = 'bkbg-rv-exp-role'; |
| 85 |
role.textContent = exp.role; |
| 86 |
role.style.color = o.sectionHeadingColor; |
| 87 |
|
| 88 |
var company = document.createElement('div'); |
| 89 |
company.className = 'bkbg-rv-exp-company'; |
| 90 |
company.textContent = exp.company + (exp.location ? ' · ' + exp.location : ''); |
| 91 |
company.style.color = o.accentColor; |
| 92 |
|
| 93 |
leftDiv.appendChild(role); |
| 94 |
leftDiv.appendChild(company); |
| 95 |
|
| 96 |
var dates = document.createElement('div'); |
| 97 |
dates.className = 'bkbg-rv-exp-dates'; |
| 98 |
dates.textContent = exp.startDate + ' – ' + (exp.isCurrent ? 'Present' : exp.endDate); |
| 99 |
dates.style.color = o.subtextColor; |
| 100 |
|
| 101 |
meta.appendChild(leftDiv); |
| 102 |
meta.appendChild(dates); |
| 103 |
content.appendChild(meta); |
| 104 |
|
| 105 |
if (exp.description) { |
| 106 |
var desc = document.createElement('p'); |
| 107 |
desc.className = 'bkbg-rv-exp-desc'; |
| 108 |
desc.textContent = exp.description; |
| 109 |
desc.style.color = o.textColor; |
| 110 |
content.appendChild(desc); |
| 111 |
} |
| 112 |
|
| 113 |
item.appendChild(tCol); |
| 114 |
item.appendChild(content); |
| 115 |
return item; |
| 116 |
} |
| 117 |
|
| 118 |
function buildEducation(edu, o, isLast) { |
| 119 |
var item = document.createElement('div'); |
| 120 |
item.className = 'bkbg-rv-edu-item'; |
| 121 |
if (!isLast) { |
| 122 |
item.style.cssText = 'padding-bottom:16px;border-bottom:1px solid ' + o.dividerColor + ';margin-bottom:16px'; |
| 123 |
} |
| 124 |
|
| 125 |
var meta = document.createElement('div'); |
| 126 |
meta.className = 'bkbg-rv-edu-meta'; |
| 127 |
|
| 128 |
var leftDiv = document.createElement('div'); |
| 129 |
|
| 130 |
var degree = document.createElement('div'); |
| 131 |
degree.className = 'bkbg-rv-edu-degree'; |
| 132 |
degree.textContent = edu.degree; |
| 133 |
degree.style.color = o.sectionHeadingColor; |
| 134 |
|
| 135 |
var institution = document.createElement('div'); |
| 136 |
institution.className = 'bkbg-rv-edu-institution'; |
| 137 |
institution.textContent = edu.institution; |
| 138 |
institution.style.color = o.accentColor; |
| 139 |
|
| 140 |
leftDiv.appendChild(degree); |
| 141 |
leftDiv.appendChild(institution); |
| 142 |
|
| 143 |
var years = document.createElement('div'); |
| 144 |
years.className = 'bkbg-rv-edu-years'; |
| 145 |
years.textContent = edu.startYear + (edu.endYear && edu.endYear !== edu.startYear ? ' – ' + edu.endYear : ''); |
| 146 |
years.style.color = o.subtextColor; |
| 147 |
|
| 148 |
meta.appendChild(leftDiv); |
| 149 |
meta.appendChild(years); |
| 150 |
item.appendChild(meta); |
| 151 |
|
| 152 |
if (edu.description) { |
| 153 |
var desc = document.createElement('p'); |
| 154 |
desc.className = 'bkbg-rv-edu-desc'; |
| 155 |
desc.textContent = edu.description; |
| 156 |
desc.style.color = o.textColor; |
| 157 |
item.appendChild(desc); |
| 158 |
} |
| 159 |
|
| 160 |
return item; |
| 161 |
} |
| 162 |
|
| 163 |
function buildSkillGroup(skill, o) { |
| 164 |
var group = document.createElement('div'); |
| 165 |
group.className = 'bkbg-rv-skill-group'; |
| 166 |
group.style.marginBottom = '14px'; |
| 167 |
|
| 168 |
var cat = document.createElement('div'); |
| 169 |
cat.className = 'bkbg-rv-skill-cat'; |
| 170 |
cat.textContent = skill.category; |
| 171 |
cat.style.color = o.sectionHeadingColor; |
| 172 |
group.appendChild(cat); |
| 173 |
|
| 174 |
var tags = document.createElement('div'); |
| 175 |
tags.className = 'bkbg-rv-tags'; |
| 176 |
|
| 177 |
(skill.items || '').split(',').forEach(function (item) { |
| 178 |
var t = item.trim(); |
| 179 |
if (!t) return; |
| 180 |
var tag = document.createElement('span'); |
| 181 |
tag.className = 'bkbg-rv-tag'; |
| 182 |
tag.textContent = t; |
| 183 |
tag.style.background = o.tagBg; |
| 184 |
tag.style.color = o.tagColor; |
| 185 |
tags.appendChild(tag); |
| 186 |
}); |
| 187 |
|
| 188 |
group.appendChild(tags); |
| 189 |
return group; |
| 190 |
} |
| 191 |
|
| 192 |
function init() { |
| 193 |
document.querySelectorAll('.bkbg-rv-app').forEach(function (appEl) { |
| 194 |
if (appEl.dataset.rendered) return; |
| 195 |
appEl.dataset.rendered = '1'; |
| 196 |
|
| 197 |
var opts; |
| 198 |
try { opts = JSON.parse(appEl.dataset.opts || '{}'); } catch (e) { opts = {}; } |
| 199 |
var o = Object.assign({ |
| 200 |
name: 'Alex Morgan', jobTitle: 'Senior Product Designer', |
| 201 |
summary: '', email: '', phone: '', location: '', website: '', |
| 202 |
photoUrl: '', showPhoto: true, showSummary: true, showExperience: true, |
| 203 |
showEducation: true, showSkills: true, showContact: true, |
| 204 |
experienceTitle: 'Work Experience', educationTitle: 'Education', |
| 205 |
skillsTitle: 'Skills', summaryTitle: 'About', |
| 206 |
experience: [], education: [], skills: [], |
| 207 |
layout: 'classic', maxWidth: 820, containerPadding: 40, |
| 208 |
borderRadius: 12, sectionGap: 36, avatarSize: 88, |
| 209 |
accentColor: '#6366f1', bgColor: '#ffffff', headerBg: '#f8fafc', |
| 210 |
sectionHeadingColor: '#111827', textColor: '#374151', |
| 211 |
subtextColor: '#6b7280', tagBg: '#f1f5f9', tagColor: '#475569', |
| 212 |
dividerColor: '#e5e7eb', timelineDotColor: '#6366f1', |
| 213 |
}, opts); |
| 214 |
|
| 215 |
var outer = document.createElement('div'); |
| 216 |
outer.className = 'bkbg-rv-outer layout-' + o.layout; |
| 217 |
|
| 218 |
typoCssVarsForEl(outer, o.nameTypo, '--bkrv-nm-'); |
| 219 |
typoCssVarsForEl(outer, o.bodyTypo, '--bkrv-bt-'); |
| 220 |
|
| 221 |
var card = document.createElement('div'); |
| 222 |
card.className = 'bkbg-rv-card'; |
| 223 |
card.style.cssText = [ |
| 224 |
'max-width:' + o.maxWidth + 'px', |
| 225 |
'margin:0 auto', |
| 226 |
'border-radius:' + o.borderRadius + 'px', |
| 227 |
'background:' + o.bgColor, |
| 228 |
'border:1px solid ' + o.dividerColor, |
| 229 |
'overflow:hidden', |
| 230 |
].join(';'); |
| 231 |
|
| 232 |
// ── Header ── |
| 233 |
var header = document.createElement('div'); |
| 234 |
header.className = 'bkbg-rv-header'; |
| 235 |
header.style.cssText = [ |
| 236 |
'background:' + o.headerBg, |
| 237 |
'padding:' + o.containerPadding + 'px', |
| 238 |
'border-bottom:1px solid ' + o.dividerColor, |
| 239 |
].join(';'); |
| 240 |
|
| 241 |
if (o.showPhoto) { |
| 242 |
if (o.photoUrl) { |
| 243 |
var img = document.createElement('img'); |
| 244 |
img.className = 'bkbg-rv-avatar'; |
| 245 |
img.src = o.photoUrl; |
| 246 |
img.alt = o.name; |
| 247 |
img.style.cssText = 'width:' + o.avatarSize + 'px;height:' + o.avatarSize + 'px'; |
| 248 |
header.appendChild(img); |
| 249 |
} else { |
| 250 |
var fallback = document.createElement('div'); |
| 251 |
fallback.className = 'bkbg-rv-avatar-fallback'; |
| 252 |
fallback.textContent = initials(o.name); |
| 253 |
fallback.style.cssText = [ |
| 254 |
'width:' + o.avatarSize + 'px', |
| 255 |
'height:' + o.avatarSize + 'px', |
| 256 |
'font-size:' + Math.round(o.avatarSize * 0.38) + 'px', |
| 257 |
'background:' + o.accentColor, |
| 258 |
].join(';'); |
| 259 |
header.appendChild(fallback); |
| 260 |
} |
| 261 |
} |
| 262 |
|
| 263 |
var headerInfo = document.createElement('div'); |
| 264 |
headerInfo.style.flexGrow = '1'; |
| 265 |
|
| 266 |
var nameEl = document.createElement('h2'); |
| 267 |
nameEl.className = 'bkbg-rv-name'; |
| 268 |
nameEl.textContent = o.name; |
| 269 |
nameEl.style.color = o.sectionHeadingColor; |
| 270 |
headerInfo.appendChild(nameEl); |
| 271 |
|
| 272 |
var titleEl = document.createElement('p'); |
| 273 |
titleEl.className = 'bkbg-rv-title'; |
| 274 |
titleEl.textContent = o.jobTitle; |
| 275 |
titleEl.style.cssText = 'font-size:16px;color:' + o.accentColor; |
| 276 |
headerInfo.appendChild(titleEl); |
| 277 |
|
| 278 |
if (o.showContact) { |
| 279 |
var contacts = document.createElement('div'); |
| 280 |
contacts.className = 'bkbg-rv-contacts'; |
| 281 |
contacts.style.color = o.subtextColor; |
| 282 |
|
| 283 |
var fields = [ |
| 284 |
{ key: 'email', value: o.email, href: 'mailto:' + o.email }, |
| 285 |
{ key: 'phone', value: o.phone, href: 'tel:' + o.phone }, |
| 286 |
{ key: 'location', value: o.location, href: null }, |
| 287 |
{ key: 'website', value: o.website, href: (o.website && !/^https?:\/\//.test(o.website) ? 'https://' : '') + o.website }, |
| 288 |
]; |
| 289 |
|
| 290 |
fields.forEach(function (f) { |
| 291 |
if (!f.value) return; |
| 292 |
var el; |
| 293 |
if (f.href) { |
| 294 |
el = document.createElement('a'); |
| 295 |
el.href = f.href; |
| 296 |
el.rel = 'noopener'; |
| 297 |
} else { |
| 298 |
el = document.createElement('span'); |
| 299 |
} |
| 300 |
el.className = 'bkbg-rv-contact-item'; |
| 301 |
el.style.color = o.subtextColor; |
| 302 |
el.textContent = (CONTACT_ICONS[f.key] || '') + ' ' + f.value; |
| 303 |
contacts.appendChild(el); |
| 304 |
}); |
| 305 |
|
| 306 |
headerInfo.appendChild(contacts); |
| 307 |
} |
| 308 |
|
| 309 |
header.appendChild(headerInfo); |
| 310 |
card.appendChild(header); |
| 311 |
|
| 312 |
// ── Body ── |
| 313 |
var body = document.createElement('div'); |
| 314 |
body.className = 'bkbg-rv-body'; |
| 315 |
body.style.padding = o.containerPadding + 'px'; |
| 316 |
|
| 317 |
var cp = o.containerPadding; |
| 318 |
var sg = o.sectionGap; |
| 319 |
|
| 320 |
// Summary |
| 321 |
if (o.showSummary && o.summary) { |
| 322 |
var sumSection = document.createElement('div'); |
| 323 |
sumSection.className = 'bkbg-rv-section'; |
| 324 |
sumSection.style.marginBottom = sg + 'px'; |
| 325 |
sumSection.appendChild(sectionHeader(o.summaryTitle, o.accentColor, o.sectionHeadingColor)); |
| 326 |
var sumText = document.createElement('p'); |
| 327 |
sumText.className = 'bkbg-rv-summary'; |
| 328 |
sumText.style.cssText = 'margin:0;color:' + o.textColor; |
| 329 |
sumText.textContent = o.summary; |
| 330 |
sumSection.appendChild(sumText); |
| 331 |
body.appendChild(sumSection); |
| 332 |
} |
| 333 |
|
| 334 |
// Experience |
| 335 |
if (o.showExperience && o.experience && o.experience.length) { |
| 336 |
var expSection = document.createElement('div'); |
| 337 |
expSection.className = 'bkbg-rv-section'; |
| 338 |
expSection.style.marginBottom = sg + 'px'; |
| 339 |
expSection.appendChild(sectionHeader(o.experienceTitle, o.accentColor, o.sectionHeadingColor)); |
| 340 |
var expList = document.createElement('div'); |
| 341 |
expList.style.marginTop = '12px'; |
| 342 |
o.experience.forEach(function (exp, i) { |
| 343 |
expList.appendChild(buildExperience(exp, o, i === o.experience.length - 1)); |
| 344 |
}); |
| 345 |
expSection.appendChild(expList); |
| 346 |
body.appendChild(expSection); |
| 347 |
} |
| 348 |
|
| 349 |
// Education |
| 350 |
if (o.showEducation && o.education && o.education.length) { |
| 351 |
var eduSection = document.createElement('div'); |
| 352 |
eduSection.className = 'bkbg-rv-section'; |
| 353 |
eduSection.style.marginBottom = sg + 'px'; |
| 354 |
eduSection.appendChild(sectionHeader(o.educationTitle, o.accentColor, o.sectionHeadingColor)); |
| 355 |
var eduList = document.createElement('div'); |
| 356 |
eduList.style.marginTop = '12px'; |
| 357 |
o.education.forEach(function (edu, i) { |
| 358 |
eduList.appendChild(buildEducation(edu, o, i === o.education.length - 1)); |
| 359 |
}); |
| 360 |
eduSection.appendChild(eduList); |
| 361 |
body.appendChild(eduSection); |
| 362 |
} |
| 363 |
|
| 364 |
// Skills |
| 365 |
if (o.showSkills && o.skills && o.skills.length) { |
| 366 |
var skillSection = document.createElement('div'); |
| 367 |
skillSection.className = 'bkbg-rv-section'; |
| 368 |
skillSection.appendChild(sectionHeader(o.skillsTitle, o.accentColor, o.sectionHeadingColor)); |
| 369 |
var skillList = document.createElement('div'); |
| 370 |
skillList.style.marginTop = '12px'; |
| 371 |
o.skills.forEach(function (skill) { |
| 372 |
skillList.appendChild(buildSkillGroup(skill, o)); |
| 373 |
}); |
| 374 |
skillSection.appendChild(skillList); |
| 375 |
body.appendChild(skillSection); |
| 376 |
} |
| 377 |
|
| 378 |
card.appendChild(body); |
| 379 |
outer.appendChild(card); |
| 380 |
|
| 381 |
appEl.parentNode.insertBefore(outer, appEl); |
| 382 |
appEl.style.display = 'none'; |
| 383 |
}); |
| 384 |
} |
| 385 |
|
| 386 |
if (document.readyState !== 'loading') { init(); } |
| 387 |
else { document.addEventListener('DOMContentLoaded', init); } |
| 388 |
})(); |
| 389 |
|