@codersrank/work-experience
Advanced tools
Comparing version 0.9.3 to 0.9.4
@@ -38,4 +38,3 @@ "use strict"; | ||
var STYLES = ":host{--preloader-color:#72a0a8;--logo-size:48px;--logo-margin:16px;--nested-circle-size:12px;--nested-circle-border-width:2px;--nested-circle-opacity:0.25;--nested-line-opacity:0.25;--nested-line-width:2px;--company-font-size:1.15em;--company-font-weight:bold;--company-text-color:inherit;--company-opacity:1;--title-font-size:inherit;--title-font-weight:bold;--title-text-color:inherit;--title-opacity:1;--location-text-color:inherit;--location-opacity:0.55;--location-font-size:inherit;--location-font-weight:inherit;--date-text-color:inherit;--date-opacity:0.55;--date-font-size:inherit;--date-font-weight:inherit;--description-font-size:inherit;--description-font-weight:inherit;--description-text-color:inherit;--description-opacity:1;--tag-border:none;--tag-star-color:#ff9900;--tag-bg-color:rgba(0, 0, 100, 0.075);--tag-font-size:0.85em;--tag-font-weight:bold;--tag-padding:0.35em 0.57em;--tag-margin:0.28em;--tag-border-radius:4px;--tag-text-color:inherit;width:100%;display:block;position:relative}.codersrank-work-experience{position:relative}.codersrank-work-experience-loading{height:100px}.codersrank-work-experience-preloader{position:absolute;left:50%;top:50%;width:32px;height:32px;margin:-16px 0 0 -16px;border:3px solid var(--preloader-color);border-left-color:transparent;border-bottom-color:transparent;border-radius:50%;box-sizing:border-box;-webkit-animation:preloader 1s infinite linear;animation:preloader 1s infinite linear}.codersrank-work-experience li,.codersrank-work-experience ul{list-style:none;margin:0;padding:0}.codersrank-work-experience-item-wrap{display:flex;align-items:flex-start;justify-content:space-between}.codersrank-work-experience-content-wrap{min-width:0;width:100%;flex-shrink:10}.codersrank-work-experience-logo{width:var(--logo-size);height:var(--logo-size);margin-right:var(--logo-margin);display:flex;justify-content:center;align-items:center}.codersrank-work-experience-logo img,.codersrank-work-experience-logo svg{width:auto;height:auto;max-width:100%;max-height:100%}.codersrank-work-experience-logo svg{width:100%}.codersrank-work-experience-company{font-size:var(--company-font-size);font-weight:var(--company-font-weight);color:var(--company-text-color);opacity:var(--company-opacity)}.codersrank-work-experience-date{font-size:var(--date-font-size);font-weight:var(--date-font-weight);color:var(--date-text-color);opacity:var(--date-opacity)}.codersrank-work-experience-location{font-size:var(--location-font-size);font-weight:var(--location-font-weight);color:var(--location-text-color);opacity:var(--location-opacity)}.codersrank-work-experience-title{font-size:var(--title-font-size);font-weight:var(--title-font-weight);color:var(--title-text-color);opacity:var(--title-opacity)}.codersrank-work-experience-description{font-size:var(--description-font-size);font-weight:var(--description-font-weight);color:var(--description-text-color);opacity:var(--description-opacity)}.codersrank-work-experience-item{margin-top:1em}.codersrank-work-experience-item-nested{position:relative;--center:calc(var(--logo-size) / 2 - var(--logo-size) - var(--logo-margin))}.codersrank-work-experience-item-nested:before{content:'';position:absolute;left:var(--center);top:.71em;width:var(--nested-circle-size);height:var(--nested-circle-size);border-radius:50%;border:var(--nested-circle-border-width) solid currentColor;box-sizing:border-box;margin-left:calc(-1 * var(--nested-circle-size)/ 2);margin-top:calc(-1 * var(--nested-circle-size)/ 2);opacity:var(--nested-circle-opacity)}.codersrank-work-experience-item-nested:after{position:absolute;left:var(--center);top:calc(.71em + var(--nested-circle-size)/ 2 + 10px);content:'';width:var(--nested-line-width);margin-left:calc(-1 * var(--nested-line-width)/ 2);height:calc(100% - var(--nested-circle-size) - 10px);box-sizing:border-box;background-color:currentColor;opacity:var(--nested-line-opacity)}.codersrank-work-experience-item-nested:last-child:after{display:none}.codersrank-work-experience li+li{margin-top:2em}.codersrank-work-experience-tags{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-start;margin-top:.5em}.codersrank-work-experience-tag{display:inline-flex;padding:var(--tag-padding);font-size:var(--tag-font-size);background:var(--tag-bg-color);border-radius:var(--tag-border-radius);font-weight:var(--tag-font-weight);line-height:1;margin-right:var(--tag-margin);margin-bottom:var(--tag-margin);border:var(--tag-border);color:var(--tag-text-color)}.codersrank-work-experience-tag-star{color:var(--tag-star-color);margin-right:4px}.codersrank-work-experience-no-logos{--logo-size:var(--nested-circle-size)}.codersrank-work-experience-no-logos .codersrank-work-experience-item-nested{margin-left:calc(var(--nested-circle-size) + 16px)}@-webkit-keyframes preloader{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}@keyframes preloader{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}"; | ||
var tempDiv = document.createElement('div'); // eslint-disable-next-line | ||
var STYLES = ":host{--preloader-color:#72a0a8;--logo-size:48px;--logo-margin:16px;--nested-circle-size:12px;--nested-circle-border-width:2px;--nested-circle-opacity:0.25;--nested-line-opacity:0.25;--nested-line-width:2px;--company-font-size:1.15em;--company-font-weight:bold;--company-text-color:inherit;--company-opacity:1;--title-font-size:inherit;--title-font-weight:bold;--title-text-color:inherit;--title-opacity:1;--location-text-color:inherit;--location-opacity:0.55;--location-font-size:inherit;--location-font-weight:inherit;--date-text-color:inherit;--date-opacity:0.55;--date-font-size:inherit;--date-font-weight:inherit;--description-font-size:inherit;--description-font-weight:inherit;--description-text-color:inherit;--description-opacity:1;--tag-border:none;--tag-star-color:#ff9900;--tag-bg-color:rgba(0, 0, 100, 0.075);--tag-font-size:0.85em;--tag-font-weight:bold;--tag-padding:0.35em 0.57em;--tag-margin:0.28em;--tag-border-radius:4px;--tag-text-color:inherit;--item-spacing:2em;--item-border-radius:0px;--item-border:none;--item-padding:0px;--item-bg-color:0px;--grid-columns:1;width:100%;display:block;position:relative}.codersrank-work-experience{position:relative}.codersrank-work-experience-loading{height:100px}.codersrank-work-experience-preloader{position:absolute;left:50%;top:50%;width:32px;height:32px;margin:-16px 0 0 -16px;border:3px solid var(--preloader-color);border-left-color:transparent;border-bottom-color:transparent;border-radius:50%;box-sizing:border-box;-webkit-animation:preloader 1s infinite linear;animation:preloader 1s infinite linear}.codersrank-work-experience ul,.codersrank-work-experience-item{list-style:none;margin:0;padding:0}.codersrank-work-experience li+li{margin-top:var(--item-spacing)}.codersrank-work-experience-grid ul{display:grid;grid-template-columns:repeat(var(--grid-columns),1fr);-moz-column-gap:var(--item-spacing);column-gap:var(--item-spacing);row-gap:var(--item-spacing)}.codersrank-work-experience-grid li+li{margin:0}.codersrank-work-experience-item{display:flex;align-items:flex-start;justify-content:space-between;border-radius:var(--item-border-radius);border:var(--item-border);padding:var(--item-padding);background-color:var(--item-bg-color)}.codersrank-work-experience-content-wrap{min-width:0;width:100%;flex-shrink:10}.codersrank-work-experience-logo{width:var(--logo-size);height:var(--logo-size);margin-right:var(--logo-margin);display:flex;justify-content:center;align-items:center}.codersrank-work-experience-logo img,.codersrank-work-experience-logo svg{width:auto;height:auto;max-width:100%;max-height:100%}.codersrank-work-experience-logo svg{width:100%}.codersrank-work-experience-company{font-size:var(--company-font-size);font-weight:var(--company-font-weight);color:var(--company-text-color);opacity:var(--company-opacity)}.codersrank-work-experience-date{font-size:var(--date-font-size);font-weight:var(--date-font-weight);color:var(--date-text-color);opacity:var(--date-opacity)}.codersrank-work-experience-location{font-size:var(--location-font-size);font-weight:var(--location-font-weight);color:var(--location-text-color);opacity:var(--location-opacity)}.codersrank-work-experience-title{font-size:var(--title-font-size);font-weight:var(--title-font-weight);color:var(--title-text-color);opacity:var(--title-opacity)}.codersrank-work-experience-description{font-size:var(--description-font-size);font-weight:var(--description-font-weight);color:var(--description-text-color);opacity:var(--description-opacity)}.codersrank-work-experience-position{margin-top:1em}.codersrank-work-experience-position-nested{position:relative;--center:calc(var(--logo-size) / 2 - var(--logo-size) - var(--logo-margin))}.codersrank-work-experience-position-nested:before{content:'';position:absolute;left:var(--center);top:.71em;width:var(--nested-circle-size);height:var(--nested-circle-size);border-radius:50%;border:var(--nested-circle-border-width) solid currentColor;box-sizing:border-box;margin-left:calc(-1 * var(--nested-circle-size)/ 2);margin-top:calc(-1 * var(--nested-circle-size)/ 2);opacity:var(--nested-circle-opacity)}.codersrank-work-experience-position-nested:after{position:absolute;left:var(--center);top:calc(.71em + var(--nested-circle-size)/ 2 + 10px);content:'';width:var(--nested-line-width);margin-left:calc(-1 * var(--nested-line-width)/ 2);height:calc(100% - var(--nested-circle-size) - 10px);box-sizing:border-box;background-color:currentColor;opacity:var(--nested-line-opacity)}.codersrank-work-experience-position-nested:last-child:after{display:none}.codersrank-work-experience-tags{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-start;margin-top:.5em}.codersrank-work-experience-tag{display:inline-flex;padding:var(--tag-padding);font-size:var(--tag-font-size);background:var(--tag-bg-color);border-radius:var(--tag-border-radius);font-weight:var(--tag-font-weight);line-height:1;margin-right:var(--tag-margin);margin-bottom:var(--tag-margin);border:var(--tag-border);color:var(--tag-text-color)}.codersrank-work-experience-tag-star{color:var(--tag-star-color);margin-right:4px}.codersrank-work-experience-no-logos{--logo-size:var(--nested-circle-size)}.codersrank-work-experience-no-logos .codersrank-work-experience-position-nested{margin-left:calc(var(--nested-circle-size) + 16px)}@-webkit-keyframes preloader{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}@keyframes preloader{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}"; // eslint-disable-next-line | ||
@@ -52,2 +51,3 @@ var CodersrankWorkExperience = /*#__PURE__*/function (_HTMLElement) { | ||
}); | ||
_this.tempDiv = document.createElement('div'); | ||
_this.stylesEl = document.createElement('style'); | ||
@@ -72,6 +72,8 @@ _this.stylesEl.textContent = STYLES; | ||
data = this.data, | ||
logos = this.logos; | ||
logos = this.logos, | ||
grid = this.grid; | ||
var ctx = { | ||
data: data, | ||
logos: logos | ||
logos: logos, | ||
grid: grid | ||
}; | ||
@@ -81,7 +83,7 @@ if (!username || !mounted) return; | ||
if (state === STATE_SUCCESS) { | ||
tempDiv.innerHTML = (0, _render2.render)(ctx); | ||
this.tempDiv.innerHTML = (0, _render2.render)(ctx); | ||
} else if (state === STATE_ERROR) { | ||
tempDiv.innerHTML = (0, _renderError.renderError)(ctx); | ||
this.tempDiv.innerHTML = (0, _renderError.renderError)(ctx); | ||
} else if (state === STATE_IDLE || state === STATE_LOADING) { | ||
tempDiv.innerHTML = (0, _renderLoading.renderLoading)(ctx); | ||
this.tempDiv.innerHTML = (0, _renderLoading.renderLoading)(ctx); | ||
} | ||
@@ -95,3 +97,3 @@ | ||
widgetEl = tempDiv.querySelector('.codersrank-work-experience'); | ||
widgetEl = this.tempDiv.querySelector('.codersrank-work-experience'); | ||
if (!widgetEl) return; | ||
@@ -109,3 +111,3 @@ this.widgetEl = widgetEl; | ||
(0, _fetchData.fetchData)(username).then(function (profile) { | ||
_this2.data = (0, _formatData.formatData)(profile); | ||
_this2.data = (0, _formatData.formatData)(profile, _this2.maxItems); | ||
_this2.state = STATE_SUCCESS; | ||
@@ -140,2 +142,5 @@ | ||
return this.getAttribute('username'); | ||
}, | ||
set: function set(value) { | ||
this.setAttribute('username', value); | ||
} | ||
@@ -148,7 +153,34 @@ }, { | ||
return false; | ||
}, | ||
set: function set(value) { | ||
this.setAttribute('logos', value); | ||
} | ||
}, { | ||
key: "grid", | ||
get: function get() { | ||
var grid = this.getAttribute('grid'); | ||
if (grid === 'true' || grid === '') return true; | ||
return false; | ||
}, | ||
set: function set(value) { | ||
this.setAttribute('grid', value); | ||
} | ||
}, { | ||
key: "maxItems", | ||
get: function get() { | ||
var maxItems = parseInt(this.getAttribute('max-items') || 0, 10) || 0; | ||
return maxItems; | ||
}, | ||
set: function set(value) { | ||
this.setAttribute('max-items', value); | ||
} | ||
}, { | ||
key: 'max-items', | ||
set: function set(value) { | ||
this.setAttribute('max-items', value); | ||
} | ||
}], [{ | ||
key: "observedAttributes", | ||
get: function get() { | ||
return ['username', 'logos']; | ||
return ['username', 'logos', 'grid', 'max-items']; | ||
} | ||
@@ -155,0 +187,0 @@ }]); |
@@ -10,3 +10,3 @@ "use strict"; | ||
var formatData = function formatData(profile) { | ||
var formatData = function formatData(profile, maxItems) { | ||
if (profile === void 0) { | ||
@@ -17,2 +17,7 @@ profile = {}; | ||
var workExperience = profile.workExperience || []; | ||
if (maxItems) { | ||
workExperience = workExperience.slice(0, maxItems); | ||
} | ||
var items = []; | ||
@@ -19,0 +24,0 @@ var companyMapping = {}; |
@@ -14,2 +14,3 @@ "use strict"; | ||
logos = _ref.logos, | ||
grid = _ref.grid, | ||
preloader = _ref.preloader; | ||
@@ -75,3 +76,3 @@ | ||
/* html */ | ||
"\n <div class=\"codersrank-work-experience " + (!logos ? 'codersrank-work-experience-no-logos' : '') + " " + (preloader ? 'codersrank-work-experience-loading' : '') + "\">\n " + (preloader ? | ||
"\n <div class=\"codersrank-work-experience " + (grid ? 'codersrank-work-experience-grid' : '') + " " + (!logos ? 'codersrank-work-experience-no-logos' : '') + " " + (preloader ? 'codersrank-work-experience-loading' : '') + "\">\n " + (preloader ? | ||
/* html */ | ||
@@ -81,3 +82,3 @@ "\n <div class=\"codersrank-work-experience-preloader\"></div>\n " : '') + "\n <ul>\n " + workExperience.map(function (we) { | ||
/* html */ | ||
"\n <li class=\"codersrank-work-experience-item-wrap\">\n " + (logos ? | ||
"\n <li class=\"codersrank-work-experience-item\">\n " + (logos ? | ||
/* html */ | ||
@@ -89,3 +90,3 @@ "\n <div class=\"codersrank-work-experience-logo\">\n " + (0, _companyLogo.companyLogo)(we.companyName, we.companyLogoUrl) + "\n </div>\n " : '') + "\n <div class=\"codersrank-work-experience-content-wrap\">\n <div class=\"codersrank-work-experience-company\">\n " + we.companyName + "\n </div>\n <div class=\"codersrank-work-experience-date\">\n " + (we.titles.length > 1 ? formatInterval(we.totalMonths) : dates(we.titles[0])) + "\n </div>\n\n " + (workExperienceLocation(we) ? | ||
/* html */ | ||
"\n <div\n class=\"codersrank-work-experience-item " + (we.titles.length > 1 ? 'codersrank-work-experience-item-nested' : '') + "\"\n >\n <div class=\"codersrank-work-experience-title\">\n " + title.title + "\n </div>\n\n " + (we.titles.length > 1 ? | ||
"\n <div\n class=\"codersrank-work-experience-position " + (we.titles.length > 1 ? 'codersrank-work-experience-position-nested' : '') + "\"\n >\n <div class=\"codersrank-work-experience-title\">\n " + title.title + "\n </div>\n\n " + (we.titles.length > 1 ? | ||
/* html */ | ||
@@ -92,0 +93,0 @@ "\n <div class=\"codersrank-work-experience-date\">\n <div>" + dates(title) + "</div>\n </div>\n " : '') + "\n\n " + (title.description ? |
/** | ||
* Codersrank Work Experience Widget 0.9.3 | ||
* Codersrank Work Experience Widget 0.9.4 | ||
* undefined | ||
@@ -10,3 +10,3 @@ * https://github.com/codersrank-org/work-experience-widget#readme | ||
* | ||
* Released on: October 26, 2020 | ||
* Released on: November 4, 2020 | ||
*/ | ||
@@ -211,2 +211,3 @@ | ||
logos = _ref.logos, | ||
grid = _ref.grid, | ||
preloader = _ref.preloader; | ||
@@ -272,3 +273,3 @@ | ||
/* html */ | ||
"\n <div class=\"codersrank-work-experience " + (!logos ? 'codersrank-work-experience-no-logos' : '') + " " + (preloader ? 'codersrank-work-experience-loading' : '') + "\">\n " + (preloader ? | ||
"\n <div class=\"codersrank-work-experience " + (grid ? 'codersrank-work-experience-grid' : '') + " " + (!logos ? 'codersrank-work-experience-no-logos' : '') + " " + (preloader ? 'codersrank-work-experience-loading' : '') + "\">\n " + (preloader ? | ||
/* html */ | ||
@@ -278,3 +279,3 @@ "\n <div class=\"codersrank-work-experience-preloader\"></div>\n " : '') + "\n <ul>\n " + workExperience.map(function (we) { | ||
/* html */ | ||
"\n <li class=\"codersrank-work-experience-item-wrap\">\n " + (logos ? | ||
"\n <li class=\"codersrank-work-experience-item\">\n " + (logos ? | ||
/* html */ | ||
@@ -286,3 +287,3 @@ "\n <div class=\"codersrank-work-experience-logo\">\n " + companyLogo(we.companyName, we.companyLogoUrl) + "\n </div>\n " : '') + "\n <div class=\"codersrank-work-experience-content-wrap\">\n <div class=\"codersrank-work-experience-company\">\n " + we.companyName + "\n </div>\n <div class=\"codersrank-work-experience-date\">\n " + (we.titles.length > 1 ? formatInterval(we.totalMonths) : dates(we.titles[0])) + "\n </div>\n\n " + (workExperienceLocation(we) ? | ||
/* html */ | ||
"\n <div\n class=\"codersrank-work-experience-item " + (we.titles.length > 1 ? 'codersrank-work-experience-item-nested' : '') + "\"\n >\n <div class=\"codersrank-work-experience-title\">\n " + title.title + "\n </div>\n\n " + (we.titles.length > 1 ? | ||
"\n <div\n class=\"codersrank-work-experience-position " + (we.titles.length > 1 ? 'codersrank-work-experience-position-nested' : '') + "\"\n >\n <div class=\"codersrank-work-experience-title\">\n " + title.title + "\n </div>\n\n " + (we.titles.length > 1 ? | ||
/* html */ | ||
@@ -322,3 +323,3 @@ "\n <div class=\"codersrank-work-experience-date\">\n <div>" + dates(title) + "</div>\n </div>\n " : '') + "\n\n " + (title.description ? | ||
var formatData = function formatData(profile) { | ||
var formatData = function formatData(profile, maxItems) { | ||
if (profile === void 0) { | ||
@@ -329,2 +330,7 @@ profile = {}; | ||
var workExperience = profile.workExperience || []; | ||
if (maxItems) { | ||
workExperience = workExperience.slice(0, maxItems); | ||
} | ||
var items = []; | ||
@@ -393,4 +399,3 @@ var companyMapping = {}; | ||
var STYLES = ":host{--preloader-color:#72a0a8;--logo-size:48px;--logo-margin:16px;--nested-circle-size:12px;--nested-circle-border-width:2px;--nested-circle-opacity:0.25;--nested-line-opacity:0.25;--nested-line-width:2px;--company-font-size:1.15em;--company-font-weight:bold;--company-text-color:inherit;--company-opacity:1;--title-font-size:inherit;--title-font-weight:bold;--title-text-color:inherit;--title-opacity:1;--location-text-color:inherit;--location-opacity:0.55;--location-font-size:inherit;--location-font-weight:inherit;--date-text-color:inherit;--date-opacity:0.55;--date-font-size:inherit;--date-font-weight:inherit;--description-font-size:inherit;--description-font-weight:inherit;--description-text-color:inherit;--description-opacity:1;--tag-border:none;--tag-star-color:#ff9900;--tag-bg-color:rgba(0, 0, 100, 0.075);--tag-font-size:0.85em;--tag-font-weight:bold;--tag-padding:0.35em 0.57em;--tag-margin:0.28em;--tag-border-radius:4px;--tag-text-color:inherit;width:100%;display:block;position:relative}.codersrank-work-experience{position:relative}.codersrank-work-experience-loading{height:100px}.codersrank-work-experience-preloader{position:absolute;left:50%;top:50%;width:32px;height:32px;margin:-16px 0 0 -16px;border:3px solid var(--preloader-color);border-left-color:transparent;border-bottom-color:transparent;border-radius:50%;box-sizing:border-box;-webkit-animation:preloader 1s infinite linear;animation:preloader 1s infinite linear}.codersrank-work-experience li,.codersrank-work-experience ul{list-style:none;margin:0;padding:0}.codersrank-work-experience-item-wrap{display:flex;align-items:flex-start;justify-content:space-between}.codersrank-work-experience-content-wrap{min-width:0;width:100%;flex-shrink:10}.codersrank-work-experience-logo{width:var(--logo-size);height:var(--logo-size);margin-right:var(--logo-margin);display:flex;justify-content:center;align-items:center}.codersrank-work-experience-logo img,.codersrank-work-experience-logo svg{width:auto;height:auto;max-width:100%;max-height:100%}.codersrank-work-experience-logo svg{width:100%}.codersrank-work-experience-company{font-size:var(--company-font-size);font-weight:var(--company-font-weight);color:var(--company-text-color);opacity:var(--company-opacity)}.codersrank-work-experience-date{font-size:var(--date-font-size);font-weight:var(--date-font-weight);color:var(--date-text-color);opacity:var(--date-opacity)}.codersrank-work-experience-location{font-size:var(--location-font-size);font-weight:var(--location-font-weight);color:var(--location-text-color);opacity:var(--location-opacity)}.codersrank-work-experience-title{font-size:var(--title-font-size);font-weight:var(--title-font-weight);color:var(--title-text-color);opacity:var(--title-opacity)}.codersrank-work-experience-description{font-size:var(--description-font-size);font-weight:var(--description-font-weight);color:var(--description-text-color);opacity:var(--description-opacity)}.codersrank-work-experience-item{margin-top:1em}.codersrank-work-experience-item-nested{position:relative;--center:calc(var(--logo-size) / 2 - var(--logo-size) - var(--logo-margin))}.codersrank-work-experience-item-nested:before{content:'';position:absolute;left:var(--center);top:.71em;width:var(--nested-circle-size);height:var(--nested-circle-size);border-radius:50%;border:var(--nested-circle-border-width) solid currentColor;box-sizing:border-box;margin-left:calc(-1 * var(--nested-circle-size)/ 2);margin-top:calc(-1 * var(--nested-circle-size)/ 2);opacity:var(--nested-circle-opacity)}.codersrank-work-experience-item-nested:after{position:absolute;left:var(--center);top:calc(.71em + var(--nested-circle-size)/ 2 + 10px);content:'';width:var(--nested-line-width);margin-left:calc(-1 * var(--nested-line-width)/ 2);height:calc(100% - var(--nested-circle-size) - 10px);box-sizing:border-box;background-color:currentColor;opacity:var(--nested-line-opacity)}.codersrank-work-experience-item-nested:last-child:after{display:none}.codersrank-work-experience li+li{margin-top:2em}.codersrank-work-experience-tags{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-start;margin-top:.5em}.codersrank-work-experience-tag{display:inline-flex;padding:var(--tag-padding);font-size:var(--tag-font-size);background:var(--tag-bg-color);border-radius:var(--tag-border-radius);font-weight:var(--tag-font-weight);line-height:1;margin-right:var(--tag-margin);margin-bottom:var(--tag-margin);border:var(--tag-border);color:var(--tag-text-color)}.codersrank-work-experience-tag-star{color:var(--tag-star-color);margin-right:4px}.codersrank-work-experience-no-logos{--logo-size:var(--nested-circle-size)}.codersrank-work-experience-no-logos .codersrank-work-experience-item-nested{margin-left:calc(var(--nested-circle-size) + 16px)}@-webkit-keyframes preloader{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}@keyframes preloader{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}"; | ||
var tempDiv = document.createElement('div'); // eslint-disable-next-line | ||
var STYLES = ":host{--preloader-color:#72a0a8;--logo-size:48px;--logo-margin:16px;--nested-circle-size:12px;--nested-circle-border-width:2px;--nested-circle-opacity:0.25;--nested-line-opacity:0.25;--nested-line-width:2px;--company-font-size:1.15em;--company-font-weight:bold;--company-text-color:inherit;--company-opacity:1;--title-font-size:inherit;--title-font-weight:bold;--title-text-color:inherit;--title-opacity:1;--location-text-color:inherit;--location-opacity:0.55;--location-font-size:inherit;--location-font-weight:inherit;--date-text-color:inherit;--date-opacity:0.55;--date-font-size:inherit;--date-font-weight:inherit;--description-font-size:inherit;--description-font-weight:inherit;--description-text-color:inherit;--description-opacity:1;--tag-border:none;--tag-star-color:#ff9900;--tag-bg-color:rgba(0, 0, 100, 0.075);--tag-font-size:0.85em;--tag-font-weight:bold;--tag-padding:0.35em 0.57em;--tag-margin:0.28em;--tag-border-radius:4px;--tag-text-color:inherit;--item-spacing:2em;--item-border-radius:0px;--item-border:none;--item-padding:0px;--item-bg-color:0px;--grid-columns:1;width:100%;display:block;position:relative}.codersrank-work-experience{position:relative}.codersrank-work-experience-loading{height:100px}.codersrank-work-experience-preloader{position:absolute;left:50%;top:50%;width:32px;height:32px;margin:-16px 0 0 -16px;border:3px solid var(--preloader-color);border-left-color:transparent;border-bottom-color:transparent;border-radius:50%;box-sizing:border-box;-webkit-animation:preloader 1s infinite linear;animation:preloader 1s infinite linear}.codersrank-work-experience ul,.codersrank-work-experience-item{list-style:none;margin:0;padding:0}.codersrank-work-experience li+li{margin-top:var(--item-spacing)}.codersrank-work-experience-grid ul{display:grid;grid-template-columns:repeat(var(--grid-columns),1fr);-moz-column-gap:var(--item-spacing);column-gap:var(--item-spacing);row-gap:var(--item-spacing)}.codersrank-work-experience-grid li+li{margin:0}.codersrank-work-experience-item{display:flex;align-items:flex-start;justify-content:space-between;border-radius:var(--item-border-radius);border:var(--item-border);padding:var(--item-padding);background-color:var(--item-bg-color)}.codersrank-work-experience-content-wrap{min-width:0;width:100%;flex-shrink:10}.codersrank-work-experience-logo{width:var(--logo-size);height:var(--logo-size);margin-right:var(--logo-margin);display:flex;justify-content:center;align-items:center}.codersrank-work-experience-logo img,.codersrank-work-experience-logo svg{width:auto;height:auto;max-width:100%;max-height:100%}.codersrank-work-experience-logo svg{width:100%}.codersrank-work-experience-company{font-size:var(--company-font-size);font-weight:var(--company-font-weight);color:var(--company-text-color);opacity:var(--company-opacity)}.codersrank-work-experience-date{font-size:var(--date-font-size);font-weight:var(--date-font-weight);color:var(--date-text-color);opacity:var(--date-opacity)}.codersrank-work-experience-location{font-size:var(--location-font-size);font-weight:var(--location-font-weight);color:var(--location-text-color);opacity:var(--location-opacity)}.codersrank-work-experience-title{font-size:var(--title-font-size);font-weight:var(--title-font-weight);color:var(--title-text-color);opacity:var(--title-opacity)}.codersrank-work-experience-description{font-size:var(--description-font-size);font-weight:var(--description-font-weight);color:var(--description-text-color);opacity:var(--description-opacity)}.codersrank-work-experience-position{margin-top:1em}.codersrank-work-experience-position-nested{position:relative;--center:calc(var(--logo-size) / 2 - var(--logo-size) - var(--logo-margin))}.codersrank-work-experience-position-nested:before{content:'';position:absolute;left:var(--center);top:.71em;width:var(--nested-circle-size);height:var(--nested-circle-size);border-radius:50%;border:var(--nested-circle-border-width) solid currentColor;box-sizing:border-box;margin-left:calc(-1 * var(--nested-circle-size)/ 2);margin-top:calc(-1 * var(--nested-circle-size)/ 2);opacity:var(--nested-circle-opacity)}.codersrank-work-experience-position-nested:after{position:absolute;left:var(--center);top:calc(.71em + var(--nested-circle-size)/ 2 + 10px);content:'';width:var(--nested-line-width);margin-left:calc(-1 * var(--nested-line-width)/ 2);height:calc(100% - var(--nested-circle-size) - 10px);box-sizing:border-box;background-color:currentColor;opacity:var(--nested-line-opacity)}.codersrank-work-experience-position-nested:last-child:after{display:none}.codersrank-work-experience-tags{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-start;margin-top:.5em}.codersrank-work-experience-tag{display:inline-flex;padding:var(--tag-padding);font-size:var(--tag-font-size);background:var(--tag-bg-color);border-radius:var(--tag-border-radius);font-weight:var(--tag-font-weight);line-height:1;margin-right:var(--tag-margin);margin-bottom:var(--tag-margin);border:var(--tag-border);color:var(--tag-text-color)}.codersrank-work-experience-tag-star{color:var(--tag-star-color);margin-right:4px}.codersrank-work-experience-no-logos{--logo-size:var(--nested-circle-size)}.codersrank-work-experience-no-logos .codersrank-work-experience-position-nested{margin-left:calc(var(--nested-circle-size) + 16px)}@-webkit-keyframes preloader{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}@keyframes preloader{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}"; // eslint-disable-next-line | ||
@@ -407,2 +412,3 @@ var CodersrankWorkExperience = /*#__PURE__*/function (_HTMLElement) { | ||
}); | ||
_this.tempDiv = document.createElement('div'); | ||
_this.stylesEl = document.createElement('style'); | ||
@@ -427,6 +433,8 @@ _this.stylesEl.textContent = STYLES; | ||
data = this.data, | ||
logos = this.logos; | ||
logos = this.logos, | ||
grid = this.grid; | ||
var ctx = { | ||
data: data, | ||
logos: logos | ||
logos: logos, | ||
grid: grid | ||
}; | ||
@@ -436,7 +444,7 @@ if (!username || !mounted) return; | ||
if (state === STATE_SUCCESS) { | ||
tempDiv.innerHTML = render(ctx); | ||
this.tempDiv.innerHTML = render(ctx); | ||
} else if (state === STATE_ERROR) { | ||
tempDiv.innerHTML = renderError(); | ||
this.tempDiv.innerHTML = renderError(); | ||
} else if (state === STATE_IDLE || state === STATE_LOADING) { | ||
tempDiv.innerHTML = renderLoading(ctx); | ||
this.tempDiv.innerHTML = renderLoading(ctx); | ||
} | ||
@@ -450,3 +458,3 @@ | ||
widgetEl = tempDiv.querySelector('.codersrank-work-experience'); | ||
widgetEl = this.tempDiv.querySelector('.codersrank-work-experience'); | ||
if (!widgetEl) return; | ||
@@ -464,3 +472,3 @@ this.widgetEl = widgetEl; | ||
fetchData(username).then(function (profile) { | ||
_this2.data = formatData(profile); | ||
_this2.data = formatData(profile, _this2.maxItems); | ||
_this2.state = STATE_SUCCESS; | ||
@@ -495,2 +503,5 @@ | ||
return this.getAttribute('username'); | ||
}, | ||
set: function set(value) { | ||
this.setAttribute('username', value); | ||
} | ||
@@ -503,7 +514,34 @@ }, { | ||
return false; | ||
}, | ||
set: function set(value) { | ||
this.setAttribute('logos', value); | ||
} | ||
}, { | ||
key: "grid", | ||
get: function get() { | ||
var grid = this.getAttribute('grid'); | ||
if (grid === 'true' || grid === '') return true; | ||
return false; | ||
}, | ||
set: function set(value) { | ||
this.setAttribute('grid', value); | ||
} | ||
}, { | ||
key: "maxItems", | ||
get: function get() { | ||
var maxItems = parseInt(this.getAttribute('max-items') || 0, 10) || 0; | ||
return maxItems; | ||
}, | ||
set: function set(value) { | ||
this.setAttribute('max-items', value); | ||
} | ||
}, { | ||
key: 'max-items', | ||
set: function set(value) { | ||
this.setAttribute('max-items', value); | ||
} | ||
}], [{ | ||
key: "observedAttributes", | ||
get: function get() { | ||
return ['username', 'logos']; | ||
return ['username', 'logos', 'grid', 'max-items']; | ||
} | ||
@@ -510,0 +548,0 @@ }]); |
/** | ||
* Codersrank Work Experience Widget 0.9.3 | ||
* Codersrank Work Experience Widget 0.9.4 | ||
* undefined | ||
@@ -10,6 +10,6 @@ * https://github.com/codersrank-org/work-experience-widget#readme | ||
* | ||
* Released on: October 26, 2020 | ||
* Released on: November 4, 2020 | ||
*/ | ||
!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function n(e){return(n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function i(e,t,n){return(i=o()?Reflect.construct:function(e,t,n){var o=[null];o.push.apply(o,t);var i=new(Function.bind.apply(e,o));return n&&r(i,n.prototype),i}).apply(null,arguments)}function a(e){var t="function"==typeof Map?new Map:void 0;return(a=function(e){if(null===e||(o=e,-1===Function.toString.call(o).indexOf("[native code]")))return e;var o;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,a)}function a(){return i(e,arguments,n(this).constructor)}return a.prototype=Object.create(e.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),r(a,e)})(e)}var c={};var s=function(e,t){var n;return n=12*(t.getFullYear()-e.getFullYear()),n-=e.getMonth(),n+=t.getMonth(),Math.abs(n<=0?0:n)},l=function(e){var t=void 0===e?{}:e,n=t.data,r=t.logos,o=t.preloader,i=function(e){var t=e.titles[0].location;return"Remote, Earth"===t?"Remote":t||""},a=function(e){var t="";return 0===e?"Less than a month":(e>=12&&(t+=Math.floor(e/12),t+=" year",1!==Math.floor(e/12)&&(t+="s")),e%12!=0&&(e>=12&&(t+=" "),t+=e%12,t+=" month",e%12!=1&&(t+="s")),t)},c=function(e){return e?Intl.DateTimeFormat("en",{month:"short",year:"numeric"}).format(new Date(e)):""},l=function(e,t){void 0===t&&(t=!0);var n=c(e.startDate||e.dateFrom),r=e.currentlyWorkingHere?"Present":c(e.endDate||e.dateTo);return t?n+" - "+r+" ("+a(function(e,t,n){var r=n?new Date:new Date(t);return s(new Date(e),r)}(e.startDate||e.dateFrom,e.endDate||e.dateTo,e.currentlyWorkingHere))+")":n+" - "+r};return'\n <div class="codersrank-work-experience '+(r?"":"codersrank-work-experience-no-logos")+" "+(o?"codersrank-work-experience-loading":"")+'">\n '+(o?'\n <div class="codersrank-work-experience-preloader"></div>\n ':"")+"\n <ul>\n "+n.map((function(e){return'\n <li class="codersrank-work-experience-item-wrap">\n '+(r?'\n <div class="codersrank-work-experience-logo">\n '+(t=e.companyName,n=e.companyLogoUrl,s=("#"+(o=function(e){for(var t=0,n=0;n<e.length;n+=1)t=e.charCodeAt(n)+((t<<5)-t);return t}(t||""),c=(16777215&o).toString(16).toUpperCase(),"00000".substring(0,6-c.length)+c)).toLowerCase(),(n?'\n <img src="'+n+'" alt="'+t+'" title="'+t+'" />\n ':'\n <svg title="'+t+'" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">\n <rect width="32" height="32" fill="'+s+'" rx="3" />\n '+(t?'\n <text\n x="50%"\n y="50%"\n font-weight="bold"\n font-size="20"\n fill="#fff"\n dy="0"\n text-anchor="middle"\n dominant-baseline="middle"\n >\n '+t[0].toUpperCase()+"\n </text>\n ":"")+"\n\n </svg>\n ")+"\n </div>\n "):"")+'\n <div class="codersrank-work-experience-content-wrap">\n <div class="codersrank-work-experience-company">\n '+e.companyName+'\n </div>\n <div class="codersrank-work-experience-date">\n '+(e.titles.length>1?a(e.totalMonths):l(e.titles[0]))+"\n </div>\n\n "+(i(e)?'\n <div class="codersrank-work-experience-location">\n '+i(e)+"\n </div>\n ":"")+'\n\n <div class="codersrank-work-experience-items">\n '+e.titles.map((function(t){return'\n <div\n class="codersrank-work-experience-item '+(e.titles.length>1?"codersrank-work-experience-item-nested":"")+'"\n >\n <div class="codersrank-work-experience-title">\n '+t.title+"\n </div>\n\n "+(e.titles.length>1?'\n <div class="codersrank-work-experience-date">\n <div>'+l(t)+"</div>\n </div>\n ":"")+"\n\n "+(t.description?'\n <div class="codersrank-work-experience-description">'+t.description+"</div>\n ":"")+"\n\n "+(t.highlightedTechnologies||t.otherTechnologies?'\n <div class="codersrank-work-experience-tags">\n '+t.highlightedTechnologies.map((function(e){return'\n <span class="codersrank-work-experience-tag"><span class="codersrank-work-experience-tag-star">★</span>'+e+"</span>\n "})).join("")+"\n\n "+t.otherTechnologies.map((function(e){return'\n <span class="codersrank-work-experience-tag">'+e+"</span>\n "})).join("")+"\n </div>\n ":"")+"\n\n </div>\n "})).join("")+"\n </div>\n </div>\n </li>\n ";var t,n,o,c,s})).join("")+"\n </ul>\n </div>\n "},d="codersrank-work-experience",p=document.createElement("div"),g=function(n){var r,o;function i(){var e;return(e=n.call(this)||this).shadowEl=e.attachShadow({mode:"closed"}),e.stylesEl=document.createElement("style"),e.stylesEl.textContent=":host{--preloader-color:#72a0a8;--logo-size:48px;--logo-margin:16px;--nested-circle-size:12px;--nested-circle-border-width:2px;--nested-circle-opacity:0.25;--nested-line-opacity:0.25;--nested-line-width:2px;--company-font-size:1.15em;--company-font-weight:bold;--company-text-color:inherit;--company-opacity:1;--title-font-size:inherit;--title-font-weight:bold;--title-text-color:inherit;--title-opacity:1;--location-text-color:inherit;--location-opacity:0.55;--location-font-size:inherit;--location-font-weight:inherit;--date-text-color:inherit;--date-opacity:0.55;--date-font-size:inherit;--date-font-weight:inherit;--description-font-size:inherit;--description-font-weight:inherit;--description-text-color:inherit;--description-opacity:1;--tag-border:none;--tag-star-color:#ff9900;--tag-bg-color:rgba(0, 0, 100, 0.075);--tag-font-size:0.85em;--tag-font-weight:bold;--tag-padding:0.35em 0.57em;--tag-margin:0.28em;--tag-border-radius:4px;--tag-text-color:inherit;width:100%;display:block;position:relative}.codersrank-work-experience{position:relative}.codersrank-work-experience-loading{height:100px}.codersrank-work-experience-preloader{position:absolute;left:50%;top:50%;width:32px;height:32px;margin:-16px 0 0 -16px;border:3px solid var(--preloader-color);border-left-color:transparent;border-bottom-color:transparent;border-radius:50%;box-sizing:border-box;-webkit-animation:preloader 1s infinite linear;animation:preloader 1s infinite linear}.codersrank-work-experience li,.codersrank-work-experience ul{list-style:none;margin:0;padding:0}.codersrank-work-experience-item-wrap{display:flex;align-items:flex-start;justify-content:space-between}.codersrank-work-experience-content-wrap{min-width:0;width:100%;flex-shrink:10}.codersrank-work-experience-logo{width:var(--logo-size);height:var(--logo-size);margin-right:var(--logo-margin);display:flex;justify-content:center;align-items:center}.codersrank-work-experience-logo img,.codersrank-work-experience-logo svg{width:auto;height:auto;max-width:100%;max-height:100%}.codersrank-work-experience-logo svg{width:100%}.codersrank-work-experience-company{font-size:var(--company-font-size);font-weight:var(--company-font-weight);color:var(--company-text-color);opacity:var(--company-opacity)}.codersrank-work-experience-date{font-size:var(--date-font-size);font-weight:var(--date-font-weight);color:var(--date-text-color);opacity:var(--date-opacity)}.codersrank-work-experience-location{font-size:var(--location-font-size);font-weight:var(--location-font-weight);color:var(--location-text-color);opacity:var(--location-opacity)}.codersrank-work-experience-title{font-size:var(--title-font-size);font-weight:var(--title-font-weight);color:var(--title-text-color);opacity:var(--title-opacity)}.codersrank-work-experience-description{font-size:var(--description-font-size);font-weight:var(--description-font-weight);color:var(--description-text-color);opacity:var(--description-opacity)}.codersrank-work-experience-item{margin-top:1em}.codersrank-work-experience-item-nested{position:relative;--center:calc(var(--logo-size) / 2 - var(--logo-size) - var(--logo-margin))}.codersrank-work-experience-item-nested:before{content:'';position:absolute;left:var(--center);top:.71em;width:var(--nested-circle-size);height:var(--nested-circle-size);border-radius:50%;border:var(--nested-circle-border-width) solid currentColor;box-sizing:border-box;margin-left:calc(-1 * var(--nested-circle-size)/ 2);margin-top:calc(-1 * var(--nested-circle-size)/ 2);opacity:var(--nested-circle-opacity)}.codersrank-work-experience-item-nested:after{position:absolute;left:var(--center);top:calc(.71em + var(--nested-circle-size)/ 2 + 10px);content:'';width:var(--nested-line-width);margin-left:calc(-1 * var(--nested-line-width)/ 2);height:calc(100% - var(--nested-circle-size) - 10px);box-sizing:border-box;background-color:currentColor;opacity:var(--nested-line-opacity)}.codersrank-work-experience-item-nested:last-child:after{display:none}.codersrank-work-experience li+li{margin-top:2em}.codersrank-work-experience-tags{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-start;margin-top:.5em}.codersrank-work-experience-tag{display:inline-flex;padding:var(--tag-padding);font-size:var(--tag-font-size);background:var(--tag-bg-color);border-radius:var(--tag-border-radius);font-weight:var(--tag-font-weight);line-height:1;margin-right:var(--tag-margin);margin-bottom:var(--tag-margin);border:var(--tag-border);color:var(--tag-text-color)}.codersrank-work-experience-tag-star{color:var(--tag-star-color);margin-right:4px}.codersrank-work-experience-no-logos{--logo-size:var(--nested-circle-size)}.codersrank-work-experience-no-logos .codersrank-work-experience-item-nested{margin-left:calc(var(--nested-circle-size) + 16px)}@-webkit-keyframes preloader{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}@keyframes preloader{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}",e.shadowEl.appendChild(e.stylesEl),e.mounted=!1,e.state=0,e.data=null,e}o=n,(r=i).prototype=Object.create(o.prototype),r.prototype.constructor=r,r.__proto__=o;var a,d,g,h=i.prototype;return h.render=function(){var e=this.username,n=this.mounted,r=this.state,o=this.shadowEl,i={data:this.data,logos:this.logos};if(e&&n){3===r?p.innerHTML=l(i):2===r?p.innerHTML="":0!==r&&1!==r||(p.innerHTML=function(e){return l(t({},e,{preloader:!0,data:[]}))}(i));var a=o.querySelector(".codersrank-work-experience");a&&a.parentNode.removeChild(a),(a=p.querySelector(".codersrank-work-experience"))&&(this.widgetEl=a,o.appendChild(a))}},h.loadAndRender=function(){var e=this,n=this.username;this.state=1,this.render(),function(e){return c[e]?Promise.resolve(c[e]):fetch("https://api.codersrank.io/app/candidate/GetScore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e})}).then((function(e){return e.json()})).then((function(t){return c[e]=t,t})).catch((function(e){return console.error(e),Promise.reject(e)}))}(n).then((function(n){e.data=function(e){void 0===e&&(e={});var n=e.workExperience||[],r=[],o={},i=0;return n.forEach((function(e){e.companyName in o?r[o[e.companyName]]=t({},r[o[e.companyName]],{titles:[].concat(r[o[e.companyName]].titles,[{originalIndex:i+=1,title:e.title,description:e.description,startDate:e.startDate,endDate:e.endDate,location:e.location,currentlyWorkingHere:e.currentlyWorkingHere,highlightedTechnologies:e.highlightedTechnologies,otherTechnologies:e.otherTechnologies}])}):(r=[].concat(r,[{companyName:e.companyName,companyLogoUrl:e.companyLogoUrl||e.companyLogoURL,titles:[{originalIndex:i+=1,title:e.title,description:e.description,startDate:e.startDate,endDate:e.endDate,location:e.location,currentlyWorkingHere:e.currentlyWorkingHere,highlightedTechnologies:e.highlightedTechnologies,otherTechnologies:e.otherTechnologies}]}]),o[e.companyName]=r.length-1)})),r.map((function(e){return t({},e,{titles:e.titles.slice().sort((function(e,t){return new Date(t.startDate).getTime()-new Date(e.startDate).getTime()}))})})).sort((function(e,t){return new Date(t.titles[0].startDate).getTime()-new Date(e.titles[0].startDate).getTime()})).map((function(e){var n=0;return e.titles.forEach((function(e){var t=e.currentlyWorkingHere?new Date:new Date(e.endDate);n+=s(new Date(e.startDate),t)})),t({},e,{totalMonths:n})}))}(n),e.state=3,e.render()})).catch((function(){e.state=2,e.render()}))},h.attributeChangedCallback=function(){this.mounted&&this.loadAndRender()},h.connectedCallback=function(){this.width=this.offsetWidth,this.mounted=!0,this.loadAndRender()},h.disconnectedCallback=function(){this.mounted=!1},a=i,g=[{key:"observedAttributes",get:function(){return["username","logos"]}}],(d=[{key:"username",get:function(){return this.getAttribute("username")}},{key:"logos",get:function(){var e=this.getAttribute("logos");return"true"===e||""===e}}])&&e(a.prototype,d),g&&e(a,g),i}(a(HTMLElement));window.customElements&&!window.customElements.get(d)&&window.customElements.define(d,g)})); | ||
!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function n(e,t){return(n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function i(e,t,r){return(i=o()?Reflect.construct:function(e,t,r){var o=[null];o.push.apply(o,t);var i=new(Function.bind.apply(e,o));return r&&n(i,r.prototype),i}).apply(null,arguments)}function a(e){var t="function"==typeof Map?new Map:void 0;return(a=function(e){if(null===e||(o=e,-1===Function.toString.call(o).indexOf("[native code]")))return e;var o;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,a)}function a(){return i(e,arguments,r(this).constructor)}return a.prototype=Object.create(e.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),n(a,e)})(e)}var c={};var s=function(e,t){var r;return r=12*(t.getFullYear()-e.getFullYear()),r-=e.getMonth(),r+=t.getMonth(),Math.abs(r<=0?0:r)},l=function(e){var t=void 0===e?{}:e,r=t.data,n=t.logos,o=t.grid,i=t.preloader,a=function(e){var t=e.titles[0].location;return"Remote, Earth"===t?"Remote":t||""},c=function(e){var t="";return 0===e?"Less than a month":(e>=12&&(t+=Math.floor(e/12),t+=" year",1!==Math.floor(e/12)&&(t+="s")),e%12!=0&&(e>=12&&(t+=" "),t+=e%12,t+=" month",e%12!=1&&(t+="s")),t)},l=function(e){return e?Intl.DateTimeFormat("en",{month:"short",year:"numeric"}).format(new Date(e)):""},d=function(e,t){void 0===t&&(t=!0);var r=l(e.startDate||e.dateFrom),n=e.currentlyWorkingHere?"Present":l(e.endDate||e.dateTo);return t?r+" - "+n+" ("+c(function(e,t,r){var n=r?new Date:new Date(t);return s(new Date(e),n)}(e.startDate||e.dateFrom,e.endDate||e.dateTo,e.currentlyWorkingHere))+")":r+" - "+n};return'\n <div class="codersrank-work-experience '+(o?"codersrank-work-experience-grid":"")+" "+(n?"":"codersrank-work-experience-no-logos")+" "+(i?"codersrank-work-experience-loading":"")+'">\n '+(i?'\n <div class="codersrank-work-experience-preloader"></div>\n ':"")+"\n <ul>\n "+r.map((function(e){return'\n <li class="codersrank-work-experience-item">\n '+(n?'\n <div class="codersrank-work-experience-logo">\n '+(t=e.companyName,r=e.companyLogoUrl,s=("#"+(o=function(e){for(var t=0,r=0;r<e.length;r+=1)t=e.charCodeAt(r)+((t<<5)-t);return t}(t||""),i=(16777215&o).toString(16).toUpperCase(),"00000".substring(0,6-i.length)+i)).toLowerCase(),(r?'\n <img src="'+r+'" alt="'+t+'" title="'+t+'" />\n ':'\n <svg title="'+t+'" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">\n <rect width="32" height="32" fill="'+s+'" rx="3" />\n '+(t?'\n <text\n x="50%"\n y="50%"\n font-weight="bold"\n font-size="20"\n fill="#fff"\n dy="0"\n text-anchor="middle"\n dominant-baseline="middle"\n >\n '+t[0].toUpperCase()+"\n </text>\n ":"")+"\n\n </svg>\n ")+"\n </div>\n "):"")+'\n <div class="codersrank-work-experience-content-wrap">\n <div class="codersrank-work-experience-company">\n '+e.companyName+'\n </div>\n <div class="codersrank-work-experience-date">\n '+(e.titles.length>1?c(e.totalMonths):d(e.titles[0]))+"\n </div>\n\n "+(a(e)?'\n <div class="codersrank-work-experience-location">\n '+a(e)+"\n </div>\n ":"")+'\n\n <div class="codersrank-work-experience-items">\n '+e.titles.map((function(t){return'\n <div\n class="codersrank-work-experience-position '+(e.titles.length>1?"codersrank-work-experience-position-nested":"")+'"\n >\n <div class="codersrank-work-experience-title">\n '+t.title+"\n </div>\n\n "+(e.titles.length>1?'\n <div class="codersrank-work-experience-date">\n <div>'+d(t)+"</div>\n </div>\n ":"")+"\n\n "+(t.description?'\n <div class="codersrank-work-experience-description">'+t.description+"</div>\n ":"")+"\n\n "+(t.highlightedTechnologies||t.otherTechnologies?'\n <div class="codersrank-work-experience-tags">\n '+t.highlightedTechnologies.map((function(e){return'\n <span class="codersrank-work-experience-tag"><span class="codersrank-work-experience-tag-star">★</span>'+e+"</span>\n "})).join("")+"\n\n "+t.otherTechnologies.map((function(e){return'\n <span class="codersrank-work-experience-tag">'+e+"</span>\n "})).join("")+"\n </div>\n ":"")+"\n\n </div>\n "})).join("")+"\n </div>\n </div>\n </li>\n ";var t,r,o,i,s})).join("")+"\n </ul>\n </div>\n "},d="codersrank-work-experience",p=function(r){var n,o;function i(){var e;return(e=r.call(this)||this).shadowEl=e.attachShadow({mode:"closed"}),e.tempDiv=document.createElement("div"),e.stylesEl=document.createElement("style"),e.stylesEl.textContent=":host{--preloader-color:#72a0a8;--logo-size:48px;--logo-margin:16px;--nested-circle-size:12px;--nested-circle-border-width:2px;--nested-circle-opacity:0.25;--nested-line-opacity:0.25;--nested-line-width:2px;--company-font-size:1.15em;--company-font-weight:bold;--company-text-color:inherit;--company-opacity:1;--title-font-size:inherit;--title-font-weight:bold;--title-text-color:inherit;--title-opacity:1;--location-text-color:inherit;--location-opacity:0.55;--location-font-size:inherit;--location-font-weight:inherit;--date-text-color:inherit;--date-opacity:0.55;--date-font-size:inherit;--date-font-weight:inherit;--description-font-size:inherit;--description-font-weight:inherit;--description-text-color:inherit;--description-opacity:1;--tag-border:none;--tag-star-color:#ff9900;--tag-bg-color:rgba(0, 0, 100, 0.075);--tag-font-size:0.85em;--tag-font-weight:bold;--tag-padding:0.35em 0.57em;--tag-margin:0.28em;--tag-border-radius:4px;--tag-text-color:inherit;--item-spacing:2em;--item-border-radius:0px;--item-border:none;--item-padding:0px;--item-bg-color:0px;--grid-columns:1;width:100%;display:block;position:relative}.codersrank-work-experience{position:relative}.codersrank-work-experience-loading{height:100px}.codersrank-work-experience-preloader{position:absolute;left:50%;top:50%;width:32px;height:32px;margin:-16px 0 0 -16px;border:3px solid var(--preloader-color);border-left-color:transparent;border-bottom-color:transparent;border-radius:50%;box-sizing:border-box;-webkit-animation:preloader 1s infinite linear;animation:preloader 1s infinite linear}.codersrank-work-experience ul,.codersrank-work-experience-item{list-style:none;margin:0;padding:0}.codersrank-work-experience li+li{margin-top:var(--item-spacing)}.codersrank-work-experience-grid ul{display:grid;grid-template-columns:repeat(var(--grid-columns),1fr);-moz-column-gap:var(--item-spacing);column-gap:var(--item-spacing);row-gap:var(--item-spacing)}.codersrank-work-experience-grid li+li{margin:0}.codersrank-work-experience-item{display:flex;align-items:flex-start;justify-content:space-between;border-radius:var(--item-border-radius);border:var(--item-border);padding:var(--item-padding);background-color:var(--item-bg-color)}.codersrank-work-experience-content-wrap{min-width:0;width:100%;flex-shrink:10}.codersrank-work-experience-logo{width:var(--logo-size);height:var(--logo-size);margin-right:var(--logo-margin);display:flex;justify-content:center;align-items:center}.codersrank-work-experience-logo img,.codersrank-work-experience-logo svg{width:auto;height:auto;max-width:100%;max-height:100%}.codersrank-work-experience-logo svg{width:100%}.codersrank-work-experience-company{font-size:var(--company-font-size);font-weight:var(--company-font-weight);color:var(--company-text-color);opacity:var(--company-opacity)}.codersrank-work-experience-date{font-size:var(--date-font-size);font-weight:var(--date-font-weight);color:var(--date-text-color);opacity:var(--date-opacity)}.codersrank-work-experience-location{font-size:var(--location-font-size);font-weight:var(--location-font-weight);color:var(--location-text-color);opacity:var(--location-opacity)}.codersrank-work-experience-title{font-size:var(--title-font-size);font-weight:var(--title-font-weight);color:var(--title-text-color);opacity:var(--title-opacity)}.codersrank-work-experience-description{font-size:var(--description-font-size);font-weight:var(--description-font-weight);color:var(--description-text-color);opacity:var(--description-opacity)}.codersrank-work-experience-position{margin-top:1em}.codersrank-work-experience-position-nested{position:relative;--center:calc(var(--logo-size) / 2 - var(--logo-size) - var(--logo-margin))}.codersrank-work-experience-position-nested:before{content:'';position:absolute;left:var(--center);top:.71em;width:var(--nested-circle-size);height:var(--nested-circle-size);border-radius:50%;border:var(--nested-circle-border-width) solid currentColor;box-sizing:border-box;margin-left:calc(-1 * var(--nested-circle-size)/ 2);margin-top:calc(-1 * var(--nested-circle-size)/ 2);opacity:var(--nested-circle-opacity)}.codersrank-work-experience-position-nested:after{position:absolute;left:var(--center);top:calc(.71em + var(--nested-circle-size)/ 2 + 10px);content:'';width:var(--nested-line-width);margin-left:calc(-1 * var(--nested-line-width)/ 2);height:calc(100% - var(--nested-circle-size) - 10px);box-sizing:border-box;background-color:currentColor;opacity:var(--nested-line-opacity)}.codersrank-work-experience-position-nested:last-child:after{display:none}.codersrank-work-experience-tags{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-start;margin-top:.5em}.codersrank-work-experience-tag{display:inline-flex;padding:var(--tag-padding);font-size:var(--tag-font-size);background:var(--tag-bg-color);border-radius:var(--tag-border-radius);font-weight:var(--tag-font-weight);line-height:1;margin-right:var(--tag-margin);margin-bottom:var(--tag-margin);border:var(--tag-border);color:var(--tag-text-color)}.codersrank-work-experience-tag-star{color:var(--tag-star-color);margin-right:4px}.codersrank-work-experience-no-logos{--logo-size:var(--nested-circle-size)}.codersrank-work-experience-no-logos .codersrank-work-experience-position-nested{margin-left:calc(var(--nested-circle-size) + 16px)}@-webkit-keyframes preloader{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}@keyframes preloader{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}",e.shadowEl.appendChild(e.stylesEl),e.mounted=!1,e.state=0,e.data=null,e}o=r,(n=i).prototype=Object.create(o.prototype),n.prototype.constructor=n,n.__proto__=o;var a,d,p,g=i.prototype;return g.render=function(){var e=this.username,r=this.mounted,n=this.state,o=this.shadowEl,i={data:this.data,logos:this.logos,grid:this.grid};if(e&&r){3===n?this.tempDiv.innerHTML=l(i):2===n?this.tempDiv.innerHTML="":0!==n&&1!==n||(this.tempDiv.innerHTML=function(e){return l(t({},e,{preloader:!0,data:[]}))}(i));var a=o.querySelector(".codersrank-work-experience");a&&a.parentNode.removeChild(a),(a=this.tempDiv.querySelector(".codersrank-work-experience"))&&(this.widgetEl=a,o.appendChild(a))}},g.loadAndRender=function(){var e=this,r=this.username;this.state=1,this.render(),function(e){return c[e]?Promise.resolve(c[e]):fetch("https://api.codersrank.io/app/candidate/GetScore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e})}).then((function(e){return e.json()})).then((function(t){return c[e]=t,t})).catch((function(e){return console.error(e),Promise.reject(e)}))}(r).then((function(r){e.data=function(e,r){void 0===e&&(e={});var n=e.workExperience||[];r&&(n=n.slice(0,r));var o=[],i={},a=0;return n.forEach((function(e){e.companyName in i?o[i[e.companyName]]=t({},o[i[e.companyName]],{titles:[].concat(o[i[e.companyName]].titles,[{originalIndex:a+=1,title:e.title,description:e.description,startDate:e.startDate,endDate:e.endDate,location:e.location,currentlyWorkingHere:e.currentlyWorkingHere,highlightedTechnologies:e.highlightedTechnologies,otherTechnologies:e.otherTechnologies}])}):(o=[].concat(o,[{companyName:e.companyName,companyLogoUrl:e.companyLogoUrl||e.companyLogoURL,titles:[{originalIndex:a+=1,title:e.title,description:e.description,startDate:e.startDate,endDate:e.endDate,location:e.location,currentlyWorkingHere:e.currentlyWorkingHere,highlightedTechnologies:e.highlightedTechnologies,otherTechnologies:e.otherTechnologies}]}]),i[e.companyName]=o.length-1)})),o.map((function(e){return t({},e,{titles:e.titles.slice().sort((function(e,t){return new Date(t.startDate).getTime()-new Date(e.startDate).getTime()}))})})).sort((function(e,t){return new Date(t.titles[0].startDate).getTime()-new Date(e.titles[0].startDate).getTime()})).map((function(e){var r=0;return e.titles.forEach((function(e){var t=e.currentlyWorkingHere?new Date:new Date(e.endDate);r+=s(new Date(e.startDate),t)})),t({},e,{totalMonths:r})}))}(r,e.maxItems),e.state=3,e.render()})).catch((function(){e.state=2,e.render()}))},g.attributeChangedCallback=function(){this.mounted&&this.loadAndRender()},g.connectedCallback=function(){this.width=this.offsetWidth,this.mounted=!0,this.loadAndRender()},g.disconnectedCallback=function(){this.mounted=!1},a=i,p=[{key:"observedAttributes",get:function(){return["username","logos","grid","max-items"]}}],(d=[{key:"username",get:function(){return this.getAttribute("username")},set:function(e){this.setAttribute("username",e)}},{key:"logos",get:function(){var e=this.getAttribute("logos");return"true"===e||""===e},set:function(e){this.setAttribute("logos",e)}},{key:"grid",get:function(){var e=this.getAttribute("grid");return"true"===e||""===e},set:function(e){this.setAttribute("grid",e)}},{key:"maxItems",get:function(){return parseInt(this.getAttribute("max-items")||0,10)||0},set:function(e){this.setAttribute("max-items",e)}},{key:"max-items",set:function(e){this.setAttribute("max-items",e)}}])&&e(a.prototype,d),p&&e(a,p),i}(a(HTMLElement));window.customElements&&!window.customElements.get(d)&&window.customElements.define(d,p)})); | ||
//# sourceMappingURL=codersrank-work-experience.min.js.map |
@@ -31,4 +31,3 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
var STYLES = ":host{--preloader-color:#72a0a8;--logo-size:48px;--logo-margin:16px;--nested-circle-size:12px;--nested-circle-border-width:2px;--nested-circle-opacity:0.25;--nested-line-opacity:0.25;--nested-line-width:2px;--company-font-size:1.15em;--company-font-weight:bold;--company-text-color:inherit;--company-opacity:1;--title-font-size:inherit;--title-font-weight:bold;--title-text-color:inherit;--title-opacity:1;--location-text-color:inherit;--location-opacity:0.55;--location-font-size:inherit;--location-font-weight:inherit;--date-text-color:inherit;--date-opacity:0.55;--date-font-size:inherit;--date-font-weight:inherit;--description-font-size:inherit;--description-font-weight:inherit;--description-text-color:inherit;--description-opacity:1;--tag-border:none;--tag-star-color:#ff9900;--tag-bg-color:rgba(0, 0, 100, 0.075);--tag-font-size:0.85em;--tag-font-weight:bold;--tag-padding:0.35em 0.57em;--tag-margin:0.28em;--tag-border-radius:4px;--tag-text-color:inherit;width:100%;display:block;position:relative}.codersrank-work-experience{position:relative}.codersrank-work-experience-loading{height:100px}.codersrank-work-experience-preloader{position:absolute;left:50%;top:50%;width:32px;height:32px;margin:-16px 0 0 -16px;border:3px solid var(--preloader-color);border-left-color:transparent;border-bottom-color:transparent;border-radius:50%;box-sizing:border-box;-webkit-animation:preloader 1s infinite linear;animation:preloader 1s infinite linear}.codersrank-work-experience li,.codersrank-work-experience ul{list-style:none;margin:0;padding:0}.codersrank-work-experience-item-wrap{display:flex;align-items:flex-start;justify-content:space-between}.codersrank-work-experience-content-wrap{min-width:0;width:100%;flex-shrink:10}.codersrank-work-experience-logo{width:var(--logo-size);height:var(--logo-size);margin-right:var(--logo-margin);display:flex;justify-content:center;align-items:center}.codersrank-work-experience-logo img,.codersrank-work-experience-logo svg{width:auto;height:auto;max-width:100%;max-height:100%}.codersrank-work-experience-logo svg{width:100%}.codersrank-work-experience-company{font-size:var(--company-font-size);font-weight:var(--company-font-weight);color:var(--company-text-color);opacity:var(--company-opacity)}.codersrank-work-experience-date{font-size:var(--date-font-size);font-weight:var(--date-font-weight);color:var(--date-text-color);opacity:var(--date-opacity)}.codersrank-work-experience-location{font-size:var(--location-font-size);font-weight:var(--location-font-weight);color:var(--location-text-color);opacity:var(--location-opacity)}.codersrank-work-experience-title{font-size:var(--title-font-size);font-weight:var(--title-font-weight);color:var(--title-text-color);opacity:var(--title-opacity)}.codersrank-work-experience-description{font-size:var(--description-font-size);font-weight:var(--description-font-weight);color:var(--description-text-color);opacity:var(--description-opacity)}.codersrank-work-experience-item{margin-top:1em}.codersrank-work-experience-item-nested{position:relative;--center:calc(var(--logo-size) / 2 - var(--logo-size) - var(--logo-margin))}.codersrank-work-experience-item-nested:before{content:'';position:absolute;left:var(--center);top:.71em;width:var(--nested-circle-size);height:var(--nested-circle-size);border-radius:50%;border:var(--nested-circle-border-width) solid currentColor;box-sizing:border-box;margin-left:calc(-1 * var(--nested-circle-size)/ 2);margin-top:calc(-1 * var(--nested-circle-size)/ 2);opacity:var(--nested-circle-opacity)}.codersrank-work-experience-item-nested:after{position:absolute;left:var(--center);top:calc(.71em + var(--nested-circle-size)/ 2 + 10px);content:'';width:var(--nested-line-width);margin-left:calc(-1 * var(--nested-line-width)/ 2);height:calc(100% - var(--nested-circle-size) - 10px);box-sizing:border-box;background-color:currentColor;opacity:var(--nested-line-opacity)}.codersrank-work-experience-item-nested:last-child:after{display:none}.codersrank-work-experience li+li{margin-top:2em}.codersrank-work-experience-tags{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-start;margin-top:.5em}.codersrank-work-experience-tag{display:inline-flex;padding:var(--tag-padding);font-size:var(--tag-font-size);background:var(--tag-bg-color);border-radius:var(--tag-border-radius);font-weight:var(--tag-font-weight);line-height:1;margin-right:var(--tag-margin);margin-bottom:var(--tag-margin);border:var(--tag-border);color:var(--tag-text-color)}.codersrank-work-experience-tag-star{color:var(--tag-star-color);margin-right:4px}.codersrank-work-experience-no-logos{--logo-size:var(--nested-circle-size)}.codersrank-work-experience-no-logos .codersrank-work-experience-item-nested{margin-left:calc(var(--nested-circle-size) + 16px)}@-webkit-keyframes preloader{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}@keyframes preloader{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}"; | ||
var tempDiv = document.createElement('div'); // eslint-disable-next-line | ||
var STYLES = ":host{--preloader-color:#72a0a8;--logo-size:48px;--logo-margin:16px;--nested-circle-size:12px;--nested-circle-border-width:2px;--nested-circle-opacity:0.25;--nested-line-opacity:0.25;--nested-line-width:2px;--company-font-size:1.15em;--company-font-weight:bold;--company-text-color:inherit;--company-opacity:1;--title-font-size:inherit;--title-font-weight:bold;--title-text-color:inherit;--title-opacity:1;--location-text-color:inherit;--location-opacity:0.55;--location-font-size:inherit;--location-font-weight:inherit;--date-text-color:inherit;--date-opacity:0.55;--date-font-size:inherit;--date-font-weight:inherit;--description-font-size:inherit;--description-font-weight:inherit;--description-text-color:inherit;--description-opacity:1;--tag-border:none;--tag-star-color:#ff9900;--tag-bg-color:rgba(0, 0, 100, 0.075);--tag-font-size:0.85em;--tag-font-weight:bold;--tag-padding:0.35em 0.57em;--tag-margin:0.28em;--tag-border-radius:4px;--tag-text-color:inherit;--item-spacing:2em;--item-border-radius:0px;--item-border:none;--item-padding:0px;--item-bg-color:0px;--grid-columns:1;width:100%;display:block;position:relative}.codersrank-work-experience{position:relative}.codersrank-work-experience-loading{height:100px}.codersrank-work-experience-preloader{position:absolute;left:50%;top:50%;width:32px;height:32px;margin:-16px 0 0 -16px;border:3px solid var(--preloader-color);border-left-color:transparent;border-bottom-color:transparent;border-radius:50%;box-sizing:border-box;-webkit-animation:preloader 1s infinite linear;animation:preloader 1s infinite linear}.codersrank-work-experience ul,.codersrank-work-experience-item{list-style:none;margin:0;padding:0}.codersrank-work-experience li+li{margin-top:var(--item-spacing)}.codersrank-work-experience-grid ul{display:grid;grid-template-columns:repeat(var(--grid-columns),1fr);-moz-column-gap:var(--item-spacing);column-gap:var(--item-spacing);row-gap:var(--item-spacing)}.codersrank-work-experience-grid li+li{margin:0}.codersrank-work-experience-item{display:flex;align-items:flex-start;justify-content:space-between;border-radius:var(--item-border-radius);border:var(--item-border);padding:var(--item-padding);background-color:var(--item-bg-color)}.codersrank-work-experience-content-wrap{min-width:0;width:100%;flex-shrink:10}.codersrank-work-experience-logo{width:var(--logo-size);height:var(--logo-size);margin-right:var(--logo-margin);display:flex;justify-content:center;align-items:center}.codersrank-work-experience-logo img,.codersrank-work-experience-logo svg{width:auto;height:auto;max-width:100%;max-height:100%}.codersrank-work-experience-logo svg{width:100%}.codersrank-work-experience-company{font-size:var(--company-font-size);font-weight:var(--company-font-weight);color:var(--company-text-color);opacity:var(--company-opacity)}.codersrank-work-experience-date{font-size:var(--date-font-size);font-weight:var(--date-font-weight);color:var(--date-text-color);opacity:var(--date-opacity)}.codersrank-work-experience-location{font-size:var(--location-font-size);font-weight:var(--location-font-weight);color:var(--location-text-color);opacity:var(--location-opacity)}.codersrank-work-experience-title{font-size:var(--title-font-size);font-weight:var(--title-font-weight);color:var(--title-text-color);opacity:var(--title-opacity)}.codersrank-work-experience-description{font-size:var(--description-font-size);font-weight:var(--description-font-weight);color:var(--description-text-color);opacity:var(--description-opacity)}.codersrank-work-experience-position{margin-top:1em}.codersrank-work-experience-position-nested{position:relative;--center:calc(var(--logo-size) / 2 - var(--logo-size) - var(--logo-margin))}.codersrank-work-experience-position-nested:before{content:'';position:absolute;left:var(--center);top:.71em;width:var(--nested-circle-size);height:var(--nested-circle-size);border-radius:50%;border:var(--nested-circle-border-width) solid currentColor;box-sizing:border-box;margin-left:calc(-1 * var(--nested-circle-size)/ 2);margin-top:calc(-1 * var(--nested-circle-size)/ 2);opacity:var(--nested-circle-opacity)}.codersrank-work-experience-position-nested:after{position:absolute;left:var(--center);top:calc(.71em + var(--nested-circle-size)/ 2 + 10px);content:'';width:var(--nested-line-width);margin-left:calc(-1 * var(--nested-line-width)/ 2);height:calc(100% - var(--nested-circle-size) - 10px);box-sizing:border-box;background-color:currentColor;opacity:var(--nested-line-opacity)}.codersrank-work-experience-position-nested:last-child:after{display:none}.codersrank-work-experience-tags{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-start;margin-top:.5em}.codersrank-work-experience-tag{display:inline-flex;padding:var(--tag-padding);font-size:var(--tag-font-size);background:var(--tag-bg-color);border-radius:var(--tag-border-radius);font-weight:var(--tag-font-weight);line-height:1;margin-right:var(--tag-margin);margin-bottom:var(--tag-margin);border:var(--tag-border);color:var(--tag-text-color)}.codersrank-work-experience-tag-star{color:var(--tag-star-color);margin-right:4px}.codersrank-work-experience-no-logos{--logo-size:var(--nested-circle-size)}.codersrank-work-experience-no-logos .codersrank-work-experience-position-nested{margin-left:calc(var(--nested-circle-size) + 16px)}@-webkit-keyframes preloader{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}@keyframes preloader{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}"; // eslint-disable-next-line | ||
@@ -45,2 +44,3 @@ var CodersrankWorkExperience = /*#__PURE__*/function (_HTMLElement) { | ||
}); | ||
_this.tempDiv = document.createElement('div'); | ||
_this.stylesEl = document.createElement('style'); | ||
@@ -65,6 +65,8 @@ _this.stylesEl.textContent = STYLES; | ||
data = this.data, | ||
logos = this.logos; | ||
logos = this.logos, | ||
grid = this.grid; | ||
var ctx = { | ||
data: data, | ||
logos: logos | ||
logos: logos, | ||
grid: grid | ||
}; | ||
@@ -74,7 +76,7 @@ if (!username || !mounted) return; | ||
if (state === STATE_SUCCESS) { | ||
tempDiv.innerHTML = _render(ctx); | ||
this.tempDiv.innerHTML = _render(ctx); | ||
} else if (state === STATE_ERROR) { | ||
tempDiv.innerHTML = renderError(ctx); | ||
this.tempDiv.innerHTML = renderError(ctx); | ||
} else if (state === STATE_IDLE || state === STATE_LOADING) { | ||
tempDiv.innerHTML = renderLoading(ctx); | ||
this.tempDiv.innerHTML = renderLoading(ctx); | ||
} | ||
@@ -88,3 +90,3 @@ | ||
widgetEl = tempDiv.querySelector('.codersrank-work-experience'); | ||
widgetEl = this.tempDiv.querySelector('.codersrank-work-experience'); | ||
if (!widgetEl) return; | ||
@@ -102,3 +104,3 @@ this.widgetEl = widgetEl; | ||
fetchData(username).then(function (profile) { | ||
_this2.data = formatData(profile); | ||
_this2.data = formatData(profile, _this2.maxItems); | ||
_this2.state = STATE_SUCCESS; | ||
@@ -133,2 +135,5 @@ | ||
return this.getAttribute('username'); | ||
}, | ||
set: function set(value) { | ||
this.setAttribute('username', value); | ||
} | ||
@@ -141,7 +146,34 @@ }, { | ||
return false; | ||
}, | ||
set: function set(value) { | ||
this.setAttribute('logos', value); | ||
} | ||
}, { | ||
key: "grid", | ||
get: function get() { | ||
var grid = this.getAttribute('grid'); | ||
if (grid === 'true' || grid === '') return true; | ||
return false; | ||
}, | ||
set: function set(value) { | ||
this.setAttribute('grid', value); | ||
} | ||
}, { | ||
key: "maxItems", | ||
get: function get() { | ||
var maxItems = parseInt(this.getAttribute('max-items') || 0, 10) || 0; | ||
return maxItems; | ||
}, | ||
set: function set(value) { | ||
this.setAttribute('max-items', value); | ||
} | ||
}, { | ||
key: 'max-items', | ||
set: function set(value) { | ||
this.setAttribute('max-items', value); | ||
} | ||
}], [{ | ||
key: "observedAttributes", | ||
get: function get() { | ||
return ['username', 'logos']; | ||
return ['username', 'logos', 'grid', 'max-items']; | ||
} | ||
@@ -148,0 +180,0 @@ }]); |
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
import { differenceInMonths } from './difference-in-months'; | ||
export var formatData = function formatData(profile) { | ||
export var formatData = function formatData(profile, maxItems) { | ||
if (profile === void 0) { | ||
@@ -10,2 +10,7 @@ profile = {}; | ||
var workExperience = profile.workExperience || []; | ||
if (maxItems) { | ||
workExperience = workExperience.slice(0, maxItems); | ||
} | ||
var items = []; | ||
@@ -12,0 +17,0 @@ var companyMapping = {}; |
@@ -7,2 +7,3 @@ import { companyLogo } from './company-logo'; | ||
logos = _ref.logos, | ||
grid = _ref.grid, | ||
preloader = _ref.preloader; | ||
@@ -68,3 +69,3 @@ | ||
/* html */ | ||
"\n <div class=\"codersrank-work-experience " + (!logos ? 'codersrank-work-experience-no-logos' : '') + " " + (preloader ? 'codersrank-work-experience-loading' : '') + "\">\n " + (preloader ? | ||
"\n <div class=\"codersrank-work-experience " + (grid ? 'codersrank-work-experience-grid' : '') + " " + (!logos ? 'codersrank-work-experience-no-logos' : '') + " " + (preloader ? 'codersrank-work-experience-loading' : '') + "\">\n " + (preloader ? | ||
/* html */ | ||
@@ -74,3 +75,3 @@ "\n <div class=\"codersrank-work-experience-preloader\"></div>\n " : '') + "\n <ul>\n " + workExperience.map(function (we) { | ||
/* html */ | ||
"\n <li class=\"codersrank-work-experience-item-wrap\">\n " + (logos ? | ||
"\n <li class=\"codersrank-work-experience-item\">\n " + (logos ? | ||
/* html */ | ||
@@ -82,3 +83,3 @@ "\n <div class=\"codersrank-work-experience-logo\">\n " + companyLogo(we.companyName, we.companyLogoUrl) + "\n </div>\n " : '') + "\n <div class=\"codersrank-work-experience-content-wrap\">\n <div class=\"codersrank-work-experience-company\">\n " + we.companyName + "\n </div>\n <div class=\"codersrank-work-experience-date\">\n " + (we.titles.length > 1 ? formatInterval(we.totalMonths) : dates(we.titles[0])) + "\n </div>\n\n " + (workExperienceLocation(we) ? | ||
/* html */ | ||
"\n <div\n class=\"codersrank-work-experience-item " + (we.titles.length > 1 ? 'codersrank-work-experience-item-nested' : '') + "\"\n >\n <div class=\"codersrank-work-experience-title\">\n " + title.title + "\n </div>\n\n " + (we.titles.length > 1 ? | ||
"\n <div\n class=\"codersrank-work-experience-position " + (we.titles.length > 1 ? 'codersrank-work-experience-position-nested' : '') + "\"\n >\n <div class=\"codersrank-work-experience-title\">\n " + title.title + "\n </div>\n\n " + (we.titles.length > 1 ? | ||
/* html */ | ||
@@ -85,0 +86,0 @@ "\n <div class=\"codersrank-work-experience-date\">\n <div>" + dates(title) + "</div>\n </div>\n " : '') + "\n\n " + (title.description ? |
{ | ||
"name": "@codersrank/work-experience", | ||
"version": "0.9.3", | ||
"version": "0.9.4", | ||
"description": "Codersrank Work Experience Widget", | ||
@@ -5,0 +5,0 @@ "main": "cjs/codersrank-work-experience.js", |
103
README.md
@@ -47,6 +47,8 @@ # Codersrank Work Experience Widget | ||
| Name | Type | Default | Description | | ||
| ---------- | --------- | ------- | ------------------------------------------------- | | ||
| `username` | `string` | | Your [CodersRank](https://codersrank.io) username | | ||
| `logos` | `boolean` | `false` | Enables company logos | | ||
| Name | Type | Default | Description | | ||
| ----------- | --------- | ------- | ----------------------------------------------------------------------------------------- | | ||
| `username` | `string` | | Your [CodersRank](https://codersrank.io) username | | ||
| `logos` | `boolean` | `false` | Enables company logos | | ||
| `max-items` | `number` | | Limit number of work experiences to display | | ||
| `grid` | `boolean` | `false` | Enables grid layout. Number of columns is configurable with `--grid-columns` CSS variable | | ||
@@ -65,42 +67,57 @@ For example: | ||
| Property | Value | | ||
| ---------------------------- | ---------------------- | | ||
| --preloader-color | #72a0a8 | | ||
| --logo-size | 48px | | ||
| --logo-margin | 16px | | ||
| --nested-circle-size | 12px | | ||
| --nested-circle-border-width | 2px | | ||
| --nested-circle-opacity | 0.25 | | ||
| --nested-line-opacity | 0.25 | | ||
| --nested-line-width | 2px | | ||
| --company-font-size | 1.15em | | ||
| --company-font-weight | bold | | ||
| --company-text-color | inherit | | ||
| --company-opacity | 1 | | ||
| --title-font-size | inherit | | ||
| --title-font-weight | bold | | ||
| --title-text-color | inherit | | ||
| --title-opacity | 1 | | ||
| --location-text-color | inherit | | ||
| --location-opacity | 0.55 | | ||
| --location-font-size | inherit | | ||
| --location-font-weight | inherit | | ||
| --date-text-color | inherit | | ||
| --date-opacity | 0.55 | | ||
| --date-font-size | inherit | | ||
| --date-font-weight | inherit | | ||
| --description-font-size | inherit | | ||
| --description-font-weight | inherit | | ||
| --description-text-color | inherit | | ||
| --description-opacity | 1 | | ||
| --tag-border | none | | ||
| --tag-star-color | #ff9900 | | ||
| --tag-bg-color | rgba(0, 0, 100, 0.075) | | ||
| --tag-font-size | 0.85em | | ||
| --tag-font-weight | bold | | ||
| --tag-padding | 0.35em 0.57em | | ||
| --tag-margin | 0.28em | | ||
| --tag-border-radius | 4px | | ||
| --tag-text-color | inherit | | ||
| Property | Value | | ||
| ------------------------------ | ------------------------ | | ||
| `--preloader-color` | `#72a0a8` | | ||
| `--item-spacing` | `2em` | | ||
| `--item-border-radius` | `0px` | | ||
| `--item-border` | `none` | | ||
| `--item-padding` | `0px` | | ||
| `--item-bg-color` | `0px` | | ||
| `--grid-columns` | `1` | | ||
| `--logo-size` | `48px` | | ||
| `--logo-margin` | `16px` | | ||
| `--nested-circle-size` | `12px` | | ||
| `--nested-circle-border-width` | `2px` | | ||
| `--nested-circle-opacity` | `0.25` | | ||
| `--nested-line-opacity` | `0.25` | | ||
| `--nested-line-width` | `2px` | | ||
| `--company-font-size` | `1.15em` | | ||
| `--company-font-weight` | `bold` | | ||
| `--company-text-color` | `inherit` | | ||
| `--company-opacity` | `1` | | ||
| `--title-font-size` | `inherit` | | ||
| `--title-font-weight` | `bold` | | ||
| `--title-text-color` | `inherit` | | ||
| `--title-opacity` | `1` | | ||
| `--location-text-color` | `inherit` | | ||
| `--location-opacity` | `0.55` | | ||
| `--location-font-size` | `inherit` | | ||
| `--location-font-weight` | `inherit` | | ||
| `--date-text-color` | `inherit` | | ||
| `--date-opacity` | `0.55` | | ||
| `--date-font-size` | `inherit` | | ||
| `--date-font-weight` | `inherit` | | ||
| `--description-font-size` | `inherit` | | ||
| `--description-font-weight` | `inherit` | | ||
| `--description-text-color` | `inherit` | | ||
| `--description-opacity` | `1` | | ||
| `--tag-border` | `none` | | ||
| `--tag-star-color` | `#ff9900` | | ||
| `--tag-bg-color` | `rgba(0, 0, 100, 0.075)` | | ||
| `--tag-font-size` | `0.85em` | | ||
| `--tag-font-weight` | `bold` | | ||
| `--tag-padding` | `0.35em 0.57em` | | ||
| `--tag-margin` | `0.28em` | | ||
| `--tag-border-radius` | `4px` | | ||
| `--tag-text-color` | `inherit` | | ||
For example, to change work experience title color to `purple` and font-size to `20px`, add this to CSS stylesheet: | ||
```css | ||
codersrank-work-experience { | ||
--title-text-color: purple; | ||
--title-font-size: 20px; | ||
} | ||
``` | ||
## Contribution | ||
@@ -107,0 +124,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
131085
1364
128