import { DeesElement, property, html, customElement, type TemplateResult, css, cssManager, unsafeCSS, } from '@design.estate/dees-element'; import * as domtools from '@design.estate/dees-domtools'; import * as shared from './shared/index.js'; import * as tsclass from '@tsclass/tsclass'; declare global { interface HTMLElementTagNameMap { 'dedocument-pagecontent': DePageContent; } } @customElement('dedocument-pagecontent') export class DePageContent extends DeesElement { public static demo = () => html` `; @property({ type: Number, }) public letterData: tsclass.business.ILetter; @property({ type: Number, }) public pageNumber: number = 1; @property({ type: Number, }) public pageTotalNumber: number = 1; constructor() { super(); domtools.DomTools.setupDomTools(); } public static styles = [ domtools.elementBasic.staticStyles, css` :host { color: #333; } .content { position: absolute; left: ${unsafeCSS(shared.leftMargin + 'px')}; right: ${unsafeCSS(shared.rightMargin + 'px')}; bottom: 170px; overflow: visible; } .content .subject { font-size: 18px; font-weight: bold; margin-bottom: 20px; } .content .text { text-align: left; } .subjectRepeated { position: relative; text-align: center; background: #eeeeee; color: #999; border-radius: 50px; padding: 5px 10px; margin: auto; margin-bottom: 10px; font-size: 10px; } .continuesOnNextPage { display: inline-block; background: #eeeeee; color: #999; border-radius: 50px; padding: 5px 10px; margin-top: 8px; font-size: 10px; } .finalPage { display: inline-block; background: #29b000; color: #fff; border-radius: 50px; padding: 5px 10px; margin-top: 8px; font-size: 10px; } `, ]; public render(): TemplateResult { return html`
${this.pageNumber === 1 ? html`
${this.letterData.subject}
` : html`
${this.letterData.subject} (Page ${this.pageNumber})
`} ${this.pageTotalNumber !== this.pageNumber ? html`
Continues on page ${this.pageNumber + 1}
` : html`
This is the final page of this document.
`}
`; } public firstUpdated(_changedProperties: Map): void { super.firstUpdated(_changedProperties); this.checkOverflow(); } public async checkOverflow() { await this.elementDomReady; const contentContainer = this.shadowRoot.querySelector('.content'); if (contentContainer.scrollHeight > contentContainer.clientHeight) { console.log('overflows'); return true; } else { console.log('does not overflow!'); return false; } } }