/** * @fileoverview Rant Page Component for Rantii * @author retoor * @description Single rant view page with comments * @keywords rant, page, detail, view, single */ import { BaseComponent } from '../components/base-component.js'; class RantPage extends BaseComponent { static get observedAttributes() { return ['rant-id', 'comment-id']; } init() { this.render(); } render() { const rantId = this.getAttr('rant-id'); this.addClass('page', 'rant-page'); this.setHtml(` `); if (rantId) { this.load(rantId); } } async load(rantId) { const detail = this.$('rant-detail'); if (detail) { await detail.load(rantId); const commentId = this.getAttr('comment-id'); if (commentId) { requestAnimationFrame(() => { detail.scrollToComment(commentId); }); } } } onAttributeChanged(name, oldValue, newValue) { if (name === 'rant-id' && newValue) { this.load(newValue); } if (name === 'comment-id' && newValue) { const detail = this.$('rant-detail'); if (detail) { detail.scrollToComment(newValue); } } } } customElements.define('rant-page', RantPage); export { RantPage };