2020-07-10 15:23:56 +01:00
|
|
|
class GithubRepoElement extends HTMLElement {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
// Create a shadow root
|
|
|
|
var shadow = this.attachShadow({mode: 'open'});
|
2019-03-24 05:33:14 +00:00
|
|
|
|
2020-07-10 15:23:56 +01:00
|
|
|
// Create spans
|
|
|
|
var wrapper = document.createElement('a');
|
|
|
|
wrapper.setAttribute("class","github-repo");
|
|
|
|
const link = document.createAttribute("href");
|
|
|
|
link.value = `https://github.com/${this.innerHTML}`
|
|
|
|
wrapper.attributes.setNamedItem(link);
|
|
|
|
wrapper.innerText = this.innerHTML;
|
2019-03-25 04:50:27 +00:00
|
|
|
|
2020-07-10 15:23:56 +01:00
|
|
|
var style = document.createElement('style');
|
|
|
|
style.textContent = '.github-repo { color: #0FA0CE; }'
|
|
|
|
shadow.appendChild(style)
|
2019-03-24 05:33:14 +00:00
|
|
|
|
2020-07-10 15:23:56 +01:00
|
|
|
shadow.appendChild(wrapper);
|
|
|
|
}
|
2019-03-25 04:50:27 +00:00
|
|
|
}
|
2020-07-10 15:23:56 +01:00
|
|
|
customElements.define('github-repo', GithubRepoElement)
|