-
Notifications
You must be signed in to change notification settings - Fork 1
/
github-ribbon-wc.min.js
1 lines (1 loc) · 4.72 KB
/
github-ribbon-wc.min.js
1
class github_ribbon extends HTMLElement{constructor(){super(),this.link=this.getAttribute("link"),this.side=this.getAttribute("side"),this.fixed=this.getAttribute("fixed"),this.message=this.getAttribute("message"),this.color=this.getAttribute("color"),this.text_color=this.getAttribute("text-color")}async connectedCallback(){this.initShadowDom()}initShadowDom(){this.attachShadow({mode:"open"}).innerHTML=this.template}get style(){return"\n \n \n "}get template(){var t=this.link,n=this.message;null!=t&&""!=t||(n="Error: No Link Found"),null!=n&&""!=n||(n="Fork Me On GitHub");var e=this.side;null!=e&&""!=e||(e=" right");var o=this.color;null!=o&&""!=o||(o="red");var r=this.text_color;null==r&&(r="#fff");var i=`<style>\n .github-fork-ribbon {\n width: 12.1em;\n height: 12.1em;\n position: absolute;\n overflow: hidden;\n top: 0;\n right: 0;\n z-index: 9999;\n pointer-events: none;\n font-size: 13px;\n text-decoration: none;\n text-indent: -999999px;\n}\n\n.github-fork-ribbon.fixed {\n position: fixed;\n}\n\n.github-fork-ribbon:hover, .github-fork-ribbon:active {\n background-color: rgba(0, 0, 0, 0.0);\n}\n\n.github-fork-ribbon:before, .github-fork-ribbon:after {\n /* The right and left classes determine the side we attach our banner to */\n position: absolute;\n display: block;\n width: 15.38em;\n height: 1.54em;\n\n top: 3.23em;\n right: -3.23em;\n\n -webkit-box-sizing: content-box;\n -moz-box-sizing: content-box;\n box-sizing: content-box;\n\n -webkit-transform: rotate(45deg);\n -moz-transform: rotate(45deg);\n -ms-transform: rotate(45deg);\n -o-transform: rotate(45deg);\n transform: rotate(45deg);\n}\n\n.github-fork-ribbon:before {\n content: "";\n\n /* Add a bit of padding to give some substance outside the "stitching" */\n padding: .38em 0;\n\n /* Set the base colour */\n background-color:${o};\n\n /* Set a gradient: transparent black at the top to almost-transparent black at the bottom */\n background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0, 0, 0, 0)), to(rgba(0, 0, 0, 0.15)));\n background-image: -webkit-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15));\n background-image: -moz-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15));\n background-image: -ms-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15));\n background-image: -o-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15));\n background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15));\n\n /* Add a drop shadow */\n -webkit-box-shadow: 0 .15em .23em 0 rgba(0, 0, 0, 0.5);\n -moz-box-shadow: 0 .15em .23em 0 rgba(0, 0, 0, 0.5);\n box-shadow: 0 .15em .23em 0 rgba(0, 0, 0, 0.5);\n\n pointer-events: auto;\n}\n\n.github-fork-ribbon:after {\n /* Set the text from the data-ribbon attribute */\n content: attr(data-ribbon);\n\n /* Set the text properties */\n color: ${r};\n font: 700 1em "Helvetica Neue", Helvetica, Arial, sans-serif;\n line-height: 1.54em;\n text-decoration: none;\n text-shadow: 0 -.08em rgba(0, 0, 0, 0.5);\n text-align: center;\n text-indent: 0;\n\n /* Set the layout properties */\n padding: .15em 0;\n margin: .15em 0;\n\n /* Add "stitching" effect */\n border-width: .08em 0;\n border-style: dotted;\n border-color: #fff;\n border-color: rgba(255, 255, 255, 0.7);\n}\n\n.github-fork-ribbon.left-top, .github-fork-ribbon.left-bottom {\n right: auto;\n left: 0;\n}\n\n.github-fork-ribbon.left-bottom, .github-fork-ribbon.right-bottom {\n top: auto;\n bottom: 0;\n}\n\n.github-fork-ribbon.left-top:before, .github-fork-ribbon.left-top:after, .github-fork-ribbon.left-bottom:before, .github-fork-ribbon.left-bottom:after {\n right: auto;\n left: -3.23em;\n}\n\n.github-fork-ribbon.left-bottom:before, .github-fork-ribbon.left-bottom:after, .github-fork-ribbon.right-bottom:before, .github-fork-ribbon.right-bottom:after {\n top: auto;\n bottom: 3.23em;\n}\n\n.github-fork-ribbon.left-top:before, .github-fork-ribbon.left-top:after, .github-fork-ribbon.right-bottom:before, .github-fork-ribbon.right-bottom:after {\n -webkit-transform: rotate(-45deg);\n -moz-transform: rotate(-45deg);\n -ms-transform: rotate(-45deg);\n -o-transform: rotate(-45deg);\n transform: rotate(-45deg);\n}\n}</style>`;null!=e&&""!=e||(e=" right"),"top-right"==e&&(e=" right-top"),"top-left"==e&&(e=" left-top"),"bottom-right"==e&&(e=" right-bottom"),"bottom-left"==e&&(e=" left-bottom");var b=this.fixed;if(null!=b&&""!=b||(b=" fixed"),"False"==b&&(b=""),"True"==this.getAttribute("new-window"))var a='target="_blank"';else a="";return`\n ${i} \n \n ${` \n \n <a class="github-fork-ribbon ${e} ${b}" href="${t}" ${a} data-ribbon="${n}" title="${n}">${n}</a>\n `}\n \n `}}window.customElements.define("github-ribbon",github_ribbon);