forked from docker-ko/docker-ko.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutton-component.ts
More file actions
33 lines (27 loc) · 772 Bytes
/
Copy pathbutton-component.ts
File metadata and controls
33 lines (27 loc) · 772 Bytes
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
export default class ButtonComponent extends HTMLElement {
static get observedAttributes() {
return ['href', 'title'];
}
constructor() {
super();
}
attributeChangedCallback() {
this.render();
}
connectedCallback() {
this.render();
}
render() {
const href = this.getAttribute('href') || '#';
const title = this.getAttribute('title') || '';
this.innerHTML = `
<button type="button" class="not-prose my-4">
<a href="${href}" class="cursor-pointer py-2 px-4 rounded bg-docker-primary hover:bg-docker-hover text-white!">
${title}
</a>
</button>
`;
}
}
// 웹 컴포넌트 등록
customElements.define('button-component', ButtonComponent);