-
-
Notifications
You must be signed in to change notification settings - Fork 266
/
Copy pathcredit-entry.html
51 lines (44 loc) · 1.23 KB
/
credit-entry.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!-- Displays credit for a third-party dependency -->
<template id="credit-entry-template">
<style>
@import "css/style.css";
.project {
margin-bottom: 0.2rem;
}
.title {
font-weight: bold;
}
.license-wrapper {
margin-left: 0.2em;
font-size: 0.85em;
}
</style>
<li class="project">
<a class="homepage" target="_blank" rel="noopener noreferrer">
<span class="title"></span>
</a>
<span class="license-wrapper">
(<a class="license" target="_blank" rel="noopener noreferrer">License</a>)
</span>
</li>
</template>
<script type="module">
(function () {
const template = document.querySelector("#credit-entry-template");
customElements.define(
"credit-entry",
class extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: "open" }).appendChild(
template.content.cloneNode(true)
);
}
populate(title, licenseUrl, homepageUrl) {
this.shadowRoot.querySelector(".title").innerText = title;
this.shadowRoot.querySelector(".license").href = licenseUrl;
this.shadowRoot.querySelector(".homepage").href = homepageUrl;
}
}
);
})();
</script>