├── .gitignore
├── LICENSE
├── README.md
├── dist
├── github-card-playground.min.js
└── github-card.min.js
├── examples
└── test.html
├── github-card.svg
├── package-lock.json
├── package.json
├── public
└── index.html
├── rollup.config.js
└── src
├── App.svelte
├── GithubCard.svelte
└── main.js
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules/
2 | /public/build/
3 |
4 | .DS_Store
5 | .idea
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 reddec
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Custom element tag for github repository
2 |
3 | [](https://reddec.net/demo/github-card/)
4 | [](https://github.com/reddec/github-card)
5 | [](http://reddec.net/about/#donate)
6 |
7 | 
8 |
9 |
10 | [Check online DEMO](https://reddec.net/demo/github-card/)
11 |
12 | 
13 |
14 | Minimal sample for embedding for the `sveltejs/svelte` repo
15 |
16 | ```html
17 |
18 |
19 |
20 | ```
21 |
22 | Additional flags:
23 |
24 | * `flat="yes"` - disables card shadow
25 | * `plain="yes"` - disables logo for the repository
26 |
27 | ## Features
28 |
29 | * ultra light - 12KB without gzip (4.5KB - gzipped)
30 | * easy to use
31 | * caches information
32 | * provides fallback if no JS available (or for old browsers)
33 | * powered by Svelte
34 |
35 | ## Reason
36 |
37 | I wanted to add nice Github card to my blog, but I didn't want to learn PHP (wordpress).
38 |
39 |
40 | [](https://www.buymeacoffee.com/reddec)
41 |
--------------------------------------------------------------------------------
/dist/github-card-playground.min.js:
--------------------------------------------------------------------------------
1 | !function(){"use strict";function e(){}function t(e){return e()}function n(){return Object.create(null)}function l(e){e.forEach(t)}function o(e){return"function"==typeof e}function c(e,t){return e!=e?t==t:e!==t||e&&"object"==typeof e||"function"==typeof e}function s(e,t){e.appendChild(t)}function i(e,t,n){e.insertBefore(t,n||null)}function r(e){e.parentNode.removeChild(e)}function a(e){return document.createElement(e)}function d(e){return document.createTextNode(e)}function u(){return d(" ")}function h(){return d("")}function g(e,t,n,l){return e.addEventListener(t,n,l),()=>e.removeEventListener(t,n,l)}function f(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function p(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function v(e,t){e.value=null==t?"":t}function b(e,t,n,l){e.style.setProperty(t,n,l?"important":"")}function m(e,t,n){e.classList[n?"add":"remove"](t)}let y;function j(e){y=e}function x(){if(!y)throw new Error("Function called outside component initialization");return y}const k=[],w=[],$=[],_=[],C=Promise.resolve();let E=!1;function S(e){$.push(e)}let z=!1;const N=new Set;function B(){if(!z){z=!0;do{for(let e=0;e{O.delete(e),l&&(n&&e.d(1),l())}),e.o(t)}}function A(e,t){const n=t.token={};function l(e,l,o,c){if(t.token!==n)return;t.resolved=c;let s=t.ctx;void 0!==o&&(s=s.slice(),s[o]=c);const i=e&&(t.current=e)(s);let r=!1;t.block&&(t.blocks?t.blocks.forEach((e,n)=>{n!==l&&e&&(L(),T(e,1,1,()=>{t.blocks[n]===e&&(t.blocks[n]=null)}),F())}):t.block.d(1),i.c(),P(i,1),i.m(t.mount(),t.anchor),r=!0),t.block=i,t.blocks&&(t.blocks[l]=i),r&&B()}if((o=e)&&"object"==typeof o&&"function"==typeof o.then){const n=x();if(e.then(e=>{j(n),l(t.then,1,t.value,e),j(null)},e=>{if(j(n),l(t.catch,2,t.error,e),j(null),!t.hasCatch)throw e}),t.current!==t.pending)return l(t.pending,0),!0}else{if(t.current!==t.then)return l(t.then,1,t.value,e),!0;t.resolved=e}var o}function H(e,n,c,s){const{fragment:i,on_mount:r,on_destroy:a,after_update:d}=e.$$;i&&i.m(n,c),s||S(()=>{const n=r.map(t).filter(o);a?a.push(...n):l(n),e.$$.on_mount=[]}),d.forEach(S)}function U(e,t){const n=e.$$;null!==n.fragment&&(l(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function R(e,t){-1===e.$$.dirty[0]&&(k.push(e),E||(E=!0,C.then(B)),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const o=l.length?l[0]:n;return h.ctx&&i(h.ctx[e],h.ctx[e]=o)&&(!h.skip_bound&&h.bound[e]&&h.bound[e](o),g&&R(t,e)),n}):[],h.update(),g=!0,l(h.before_update),h.fragment=!!s&&s(h.ctx),o.target){if(o.hydrate){const e=function(e){return Array.from(e.childNodes)}(o.target);h.fragment&&h.fragment.l(e),e.forEach(r)}else h.fragment&&h.fragment.c();o.intro&&P(t.$$.fragment),H(t,o.target,o.anchor,o.customElement),B()}j(u)}class J{$destroy(){U(this,1),this.$destroy=e}$on(e,t){const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}$set(e){var t;this.$$set&&(t=e,0!==Object.keys(t).length)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}function q(e){let t,n,l,o,c,h,g,v,b,m,y,j=e[7]+"";return{c(){t=a("p"),n=a("a"),l=d("https://github.com/"),o=d(e[0]),h=u(),g=a("br"),v=u(),b=a("small"),m=d("oops... load failed "),y=d(j),f(n,"href",c="https://github.com/"+e[0])},m(e,c){i(e,t,c),s(t,n),s(n,l),s(n,o),s(t,h),s(t,g),s(t,v),s(t,b),s(b,m),s(b,y)},p(e,t){1&t&&p(o,e[0]),1&t&&c!==(c="https://github.com/"+e[0])&&f(n,"href",c),1&t&&j!==(j=e[7]+"")&&p(y,j)},d(e){e&&r(t)}}}function G(e){let t,n,l,o,c,h,g,v,b,y,j,x,k,w,$,_,C,E,S,z,N,B,M,O,I,L,F,P,T,A,H,U,R,D,J,q,G,K,Q,V,X,Y,Z,ee,te=e[6].name+"",ne=e[6].language+"",le=e[6].license.spdx_id+"",oe=e[6].stargazers_count+"",ce=e[6].subscribers_count+"",se=e[6].description+"",ie=e[6].owner.login+"",re=!e[2]&&W(e);return{c(){t=a("div"),n=a("div"),re&&re.c(),l=u(),o=a("div"),c=a("div"),h=a("div"),g=a("a"),v=d(te),y=u(),j=a("div"),x=a("div"),k=d(ne),w=u(),$=a("div"),_=d(le),C=u(),E=a("div"),S=a("a"),z=a("div"),N=a("div"),N.innerHTML=' \n Star',B=u(),M=a("div"),O=d(oe),L=u(),F=a("a"),P=a("div"),T=a("div"),T.innerHTML=' \n Follow',A=u(),H=a("div"),U=d(ce),D=u(),J=a("p"),q=d(se),G=u(),K=a("div"),Q=a("a"),V=d("by "),X=d(ie),Z=u(),ee=a("a"),ee.textContent="widget by reddec",f(g,"target","_blank"),f(g,"href",b=e[6].html_url),f(g,"class","svelte-oc8ljn"),f(h,"class","github-title svelte-oc8ljn"),f(x,"class","github-language svelte-oc8ljn"),f($,"class","github-license svelte-oc8ljn"),f(j,"class","github-tags svelte-oc8ljn"),f(c,"class","github-head svelte-oc8ljn"),f(N,"class","github-badge-title svelte-oc8ljn"),f(M,"class","github-badge-content svelte-oc8ljn"),f(z,"class","github-badge svelte-oc8ljn"),f(S,"href",I=e[6].html_url),f(S,"target","_blank"),f(S,"class","svelte-oc8ljn"),f(T,"class","github-badge-title svelte-oc8ljn"),f(H,"class","github-badge-content svelte-oc8ljn"),f(P,"class","github-badge svelte-oc8ljn"),f(F,"href",R=e[6].html_url),f(F,"target","_blank"),f(F,"class","svelte-oc8ljn"),f(E,"class","github-meta svelte-oc8ljn"),f(J,"class","github-description svelte-oc8ljn"),f(o,"class","github-content svelte-oc8ljn"),f(n,"class","github-card svelte-oc8ljn"),f(Q,"class","github-author svelte-oc8ljn"),f(Q,"href",Y=e[6].owner.html_url),f(Q,"target","_blank"),f(ee,"class","github-made svelte-oc8ljn"),f(ee,"href","https://github.com/reddec/github-card"),f(K,"class","github-footer svelte-oc8ljn"),f(t,"class","github svelte-oc8ljn"),m(t,"shadow",!e[3]),m(t,"block",e[1]),m(t,"inline-block",!e[1])},m(e,r){i(e,t,r),s(t,n),re&&re.m(n,null),s(n,l),s(n,o),s(o,c),s(c,h),s(h,g),s(g,v),s(c,y),s(c,j),s(j,x),s(x,k),s(j,w),s(j,$),s($,_),s(o,C),s(o,E),s(E,S),s(S,z),s(z,N),s(z,B),s(z,M),s(M,O),s(E,L),s(E,F),s(F,P),s(P,T),s(P,A),s(P,H),s(H,U),s(o,D),s(o,J),s(J,q),s(t,G),s(t,K),s(K,Q),s(Q,V),s(Q,X),s(K,Z),s(K,ee)},p(e,o){e[2]?re&&(re.d(1),re=null):re?re.p(e,o):(re=W(e),re.c(),re.m(n,l)),1&o&&te!==(te=e[6].name+"")&&p(v,te),1&o&&b!==(b=e[6].html_url)&&f(g,"href",b),1&o&&ne!==(ne=e[6].language+"")&&p(k,ne),1&o&&le!==(le=e[6].license.spdx_id+"")&&p(_,le),1&o&&oe!==(oe=e[6].stargazers_count+"")&&p(O,oe),1&o&&I!==(I=e[6].html_url)&&f(S,"href",I),1&o&&ce!==(ce=e[6].subscribers_count+"")&&p(U,ce),1&o&&R!==(R=e[6].html_url)&&f(F,"href",R),1&o&&se!==(se=e[6].description+"")&&p(q,se),1&o&&ie!==(ie=e[6].owner.login+"")&&p(X,ie),1&o&&Y!==(Y=e[6].owner.html_url)&&f(Q,"href",Y),8&o&&m(t,"shadow",!e[3]),2&o&&m(t,"block",e[1]),2&o&&m(t,"inline-block",!e[1])},d(e){e&&r(t),re&&re.d()}}}function W(e){let t,n,l,o,c,d;return{c(){t=a("div"),n=a("a"),l=a("img"),f(l,"alt",o=e[6].owner.login+" logo"),l.src!==(c=e[6].owner.avatar_url)&&f(l,"src",c),f(l,"class","svelte-oc8ljn"),f(n,"target","_blank"),f(n,"href",d=e[6].html_url),f(t,"class","github-logo svelte-oc8ljn")},m(e,o){i(e,t,o),s(t,n),s(n,l)},p(e,t){1&t&&o!==(o=e[6].owner.login+" logo")&&f(l,"alt",o),1&t&&l.src!==(c=e[6].owner.avatar_url)&&f(l,"src",c),1&t&&d!==(d=e[6].html_url)&&f(n,"href",d)},d(e){e&&r(t)}}}function K(e){let t,n,l,o,c,h,g,v,b;return{c(){t=a("p"),n=a("a"),l=d("https://github.com/"),o=d(e[0]),h=u(),g=a("br"),v=u(),b=a("small"),b.textContent="loading...",f(n,"href",c="https://github.com/"+e[0])},m(e,c){i(e,t,c),s(t,n),s(n,l),s(n,o),s(t,h),s(t,g),s(t,v),s(t,b)},p(e,t){1&t&&p(o,e[0]),1&t&&c!==(c="https://github.com/"+e[0])&&f(n,"href",c)},d(e){e&&r(t)}}}function Q(t){let n,l,o={ctx:t,current:null,token:null,hasCatch:!0,pending:K,then:G,catch:q,value:6,error:7};return A(l=t[4](t[0]),o),{c(){n=h(),o.block.c()},m(e,t){i(e,n,t),o.block.m(e,o.anchor=t),o.mount=()=>n.parentNode,o.anchor=n},p(e,[n]){if(t=e,o.ctx=t,1&n&&l!==(l=t[4](t[0]))&&A(l,o));else{const e=t.slice();e[6]=e[7]=o.resolved,o.block.p(e,n)}},i:e,o:e,d(e){e&&r(n),o.block.d(e),o.token=null,o=null}}}function V(e,t,n){let{repo:l}=t,{wide:o=!1}=t,{plain:c=!1}=t,{flat:s=!1}=t,{keepalive:i=36e5}=t;return e.$$set=e=>{"repo"in e&&n(0,l=e.repo),"wide"in e&&n(1,o=e.wide),"plain"in e&&n(2,c=e.plain),"flat"in e&&n(3,s=e.flat),"keepalive"in e&&n(5,i=e.keepalive)},[l,o,c,s,async function(e){if(!e)throw new Error("no repo defined");let t=localStorage.getItem(e);if(t)try{let{at:e,info:n}=JSON.parse(t);if(Date.now()-e\n"),z&&z.c(),$=d('\n
7 |
8 |
9 |
10 |
11 |
12 |
13 |
20 |
21 |