@rocktimsaikia/github-card 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const widgetStyle=`
1
+ let widgetStyle=`
2
2
  h1, div, p {
3
3
  margin: 0px;
4
4
  padding: 0px;
@@ -118,7 +118,7 @@ a{
118
118
  position: relative;
119
119
  }
120
120
  .card .card-footer .footer-box .box-wrapper .count {
121
- font-family: 'consolas'
121
+ font-family: 'consolas';
122
122
  color: #434343;
123
123
  font-size: 20px;
124
124
  font-weight: 600;
@@ -129,34 +129,36 @@ a{
129
129
  color: #00000085;
130
130
  letter-spacing: 0.5px;
131
131
  }
132
- `;function nFormatter(t){if(!(1e3<=t))return t;let o=t;let r=0;for(;1e3<=o;)o/=1e3,r+=1;return o=o.toPrecision(3),o+=["","K","M","B","T"][r],o}const template=document.createElement("template");template.innerHTML=`
132
+ `;function nFormatter(t){if(!(1e3<=t))return t;let e=t;let o=0;for(;1e3<=e;)e/=1e3,o+=1;return e=e.toPrecision(3),e+=["","K","M","B","T"][o]}function escapeHtml(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}let template=document.createElement("template");template.innerHTML=`
133
133
  <style>
134
134
  ${widgetStyle}
135
135
  </style>
136
136
  <div class="card"></div>
137
- `;class myCard extends HTMLElement{constructor(){super(),this._shadowRoot=this.attachShadow({mode:"open"}),this._shadowRoot.append(template.content.cloneNode(!0))}get observedAttribute(){return["data-theme"]}attributeChangedCallback(t,o,r){"data-theme"===t&&o!==r&&""!==r&&(this[t]=r)}connectedCallback(){var t;this.fetchData(this.getAttribute("data-user")).then(t=>{t=this.createCard(t);this._shadowRoot.querySelector(".card").innerHTML=t}),this.getAttribute("data-theme")&&(t=this.getAttribute("data-theme"),this.setTheme(t))}setTheme(t){"dark"===t?this._shadowRoot.querySelector(".card").classList.add("dark"):this._shadowRoot.querySelector(".card").classList.remove("dark")}async fetchData(t){const o=await fetch(`https://api.github.com/users/${t}`,{method:"GET"});return await o.json()}createCard(t){return`
137
+ `;class myCard extends HTMLElement{constructor(){super(),this._shadowRoot=this.attachShadow({mode:"open"}),this._shadowRoot.append(template.content.cloneNode(!0))}static get observedAttributes(){return["data-theme"]}attributeChangedCallback(t,e,o){"data-theme"===t&&e!==o&&this.setTheme(o)}connectedCallback(){this.fetchData(this.getAttribute("data-user")).then(t=>{t=this.createCard(t);this._shadowRoot.querySelector(".card").innerHTML=t})}setTheme(t){"dark"===t?this._shadowRoot.querySelector(".card").classList.add("dark"):this._shadowRoot.querySelector(".card").classList.remove("dark")}async fetchData(t){return await(await fetch("https://api.github.com/users/"+t,{method:"GET"})).json()}createCard(t){var e=escapeHtml(t.login),o=escapeHtml(t.html_url),r=escapeHtml(t.name);return`
138
138
  <div class="cover"></div>
139
139
  <div class="card-wrapper">
140
- <a href="https://github.com/${t.login}" target="_blank" rel="noopener"><img id="github-logo" src="https://i.ibb.co/frv5pB3/github-logo.png" alt="github-logo" border="0"></a>
140
+ <a href="https://github.com/${e}" target="_blank" rel="noopener"><img id="github-logo" src="https://i.ibb.co/frv5pB3/github-logo.png" alt="github-logo" border="0"></a>
141
141
  <div class="card-header">
142
- <div class="card-img-wrapper"><img src="https://avatars.githubusercontent.com/${t.login}"/></div>
143
- <h1><a class="card-title" href="${t.html_url}" target="_blank" rel="noopener">${t.name}</a></h1>
144
- <div class="card-responsename"><a href="${t.html_url}" target="_blank" rel="noopener">@${t.login}</a></div>
145
- <p class="card-desc">${t.bio??""}</p>
142
+ <div class="card-img-wrapper"><img src="https://avatars.githubusercontent.com/${e}" alt="${r}"/></div>
143
+ <h1><a class="card-title" href="${o}" target="_blank" rel="noopener">${r}</a></h1>
144
+ <div class="card-responsename"><a href="${o}" target="_blank" rel="noopener">@${e}</a></div>
145
+ <p class="card-desc">${escapeHtml(t.bio??"")}</p>
146
146
  <div class="card-footer">
147
147
  <div class="footer-box">
148
148
  <div class="box-wrapper">
149
149
  <div class="count">${nFormatter(t.followers)}</div>
150
150
  <div class="box-text">Followers</div>
151
- </div>
151
+ </div>
152
152
  <div class="box-wrapper">
153
153
  <div class="count">${nFormatter(t.following)}</div>
154
154
  <div class="box-text">Following</div>
155
- </div>
155
+ </div>
156
156
  <div class="box-wrapper">
157
157
  <div class="count">${nFormatter(t.public_repos)}</div>
158
158
  <div class="box-text">Repositories</div>
159
159
  </div>
160
160
  </div>
161
161
  </div>
162
+ </div>
163
+ </div>
162
164
  `}}customElements.define("github-card",myCard);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rocktimsaikia/github-card",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "A minimal github card widget for your portfolio.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
File without changes