allow embed customization

This commit is contained in:
yequari 2026-01-03 16:06:26 -07:00
parent cddf2563ce
commit 27b9f2299e

View File

@ -1,3 +1,4 @@
class GuestbookForm extends HTMLElement {
static get observedAttributes() {
return ['guestbook'];
@ -6,6 +7,8 @@ class GuestbookForm extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
let template = document.getElementById("custom-guestbook-form");
this.templateContent = template.content;
this._guestbook = this.getAttribute('guestbook') || '';
this._postUrl = `${this._guestbook}/comments/create/remote`
this.render();
@ -63,6 +66,7 @@ class GuestbookForm extends HTMLElement {
</div>
</form>
`;
this.shadowRoot.appendChild(document.importNode(this.templateContent, true))
}
}
@ -74,9 +78,12 @@ class CommentList extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
let template = document.getElementById("custom-guestbook-comments");
this.templateContent = template.content;
this.comments = [];
this.loading = false;
this.error = null;
}
connectedCallback() {
@ -169,9 +176,11 @@ class CommentList extends HTMLElement {
}
</div>
`;
this.shadowRoot.appendChild(document.importNode(this.templateContent, true))
}
}
customElements.define('guestbook-form', GuestbookForm);
customElements.define('guestbook-comments', CommentList);