@rocktimsaikia/github-card 3.0.0 → 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 +17 -21
- package/package.json +2 -1
- /package/{readme.md → README.md} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
let widgetStyle=`
|
|
2
2
|
h1, div, p {
|
|
3
3
|
margin: 0px;
|
|
4
4
|
padding: 0px;
|
|
@@ -32,7 +32,8 @@ a{
|
|
|
32
32
|
border-radius: 5px;
|
|
33
33
|
box-shadow: 0 12px 13px rgba(0,0,0,0.16), 0 12px 13px rgba(0,0,0,0.16);
|
|
34
34
|
text-align: center;
|
|
35
|
-
padding: 20px
|
|
35
|
+
padding: 20px 50px;
|
|
36
|
+
margin: 5px;
|
|
36
37
|
padding-top: 5px;
|
|
37
38
|
transition: all 0.5s;
|
|
38
39
|
}
|
|
@@ -90,8 +91,8 @@ a{
|
|
|
90
91
|
}
|
|
91
92
|
.card .card-img-wrapper {
|
|
92
93
|
position: relative;
|
|
93
|
-
height:
|
|
94
|
-
width:
|
|
94
|
+
height: 160px;
|
|
95
|
+
width: 160px;
|
|
95
96
|
margin: 10px auto;
|
|
96
97
|
margin-bottom: 20px;
|
|
97
98
|
}
|
|
@@ -108,7 +109,6 @@ a{
|
|
|
108
109
|
border-top: 2px solid #ff9b9b;
|
|
109
110
|
box-shadow: 0 3px 6px -1px rgb(0 0 0 / 26%), 0 2px 4px -1px rgb(0 0 0 / 6%);
|
|
110
111
|
border-radius: 5px;
|
|
111
|
-
width: 300px;
|
|
112
112
|
margin: 0 auto;
|
|
113
113
|
padding: 10px;
|
|
114
114
|
display: flex;
|
|
@@ -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,40 +129,36 @@ a{
|
|
|
129
129
|
color: #00000085;
|
|
130
130
|
letter-spacing: 0.5px;
|
|
131
131
|
}
|
|
132
|
-
|
|
133
|
-
@media(max-width:400px){
|
|
134
|
-
.card .card-footer .footer-box{
|
|
135
|
-
width: 100%;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
`;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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}let template=document.createElement("template");template.innerHTML=`
|
|
139
133
|
<style>
|
|
140
134
|
${widgetStyle}
|
|
141
135
|
</style>
|
|
142
136
|
<div class="card"></div>
|
|
143
|
-
`;class myCard extends HTMLElement{constructor(){super(),this._shadowRoot=this.attachShadow({mode:"open"}),this._shadowRoot.append(template.content.cloneNode(!0))}get
|
|
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`
|
|
144
138
|
<div class="cover"></div>
|
|
145
139
|
<div class="card-wrapper">
|
|
146
|
-
<a href="https://github.com/${
|
|
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>
|
|
147
141
|
<div class="card-header">
|
|
148
|
-
<div class="card-img-wrapper"><img src="https://avatars.githubusercontent.com/${
|
|
149
|
-
<h1><a class="card-title" href="${
|
|
150
|
-
<div class="card-responsename"><a href="${
|
|
151
|
-
<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>
|
|
152
146
|
<div class="card-footer">
|
|
153
147
|
<div class="footer-box">
|
|
154
148
|
<div class="box-wrapper">
|
|
155
149
|
<div class="count">${nFormatter(t.followers)}</div>
|
|
156
150
|
<div class="box-text">Followers</div>
|
|
157
|
-
</div>
|
|
151
|
+
</div>
|
|
158
152
|
<div class="box-wrapper">
|
|
159
153
|
<div class="count">${nFormatter(t.following)}</div>
|
|
160
154
|
<div class="box-text">Following</div>
|
|
161
|
-
</div>
|
|
155
|
+
</div>
|
|
162
156
|
<div class="box-wrapper">
|
|
163
157
|
<div class="count">${nFormatter(t.public_repos)}</div>
|
|
164
158
|
<div class="box-text">Repositories</div>
|
|
165
159
|
</div>
|
|
166
160
|
</div>
|
|
167
161
|
</div>
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
168
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.
|
|
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",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"lint": "eslint .",
|
|
13
13
|
"build": "rollup -c",
|
|
14
|
+
"build-watch": "npm run build --watch",
|
|
14
15
|
"prebuild": "del-cli dist && npm run lint",
|
|
15
16
|
"prepublishOnly": "npm run lint && npm run build",
|
|
16
17
|
"postversion": "git push && git push --tags"
|
/package/{readme.md → README.md}
RENAMED
|
File without changes
|