import {html} from 'lit'; import {customElement, property} from 'lit/decorators.js'; import {styles} from './article.styles'; import {LinkPreviewDataDirective} from './directives/link-preview-data-directive'; import {TEST_IDS} from './lib/util/test-helper'; import './components/skeleton-shape'; import './components/limit-info'; import './components/powered-by-previewbox'; import './components/favicon'; import './components/image'; import {ApiError} from './lib/services/api-fetcher'; /** * Previewbox Link | * * @csspart link - The a-element that contains the link * @csspart container - The container element that contains the anchor element * @csspart thumbnail - The thumbnail element that contains the image */ @customElement('previewbox-article') export class PreviewBoxArticleElement extends LinkPreviewDataDirective { static override styles = styles; /** * If attribute is present, the read more button will not be shown. */ @property() hideReadMoreBtn: string | undefined; /** * The text for the read more button. * * Default: 'Read more' */ @property() readMoreBtnText: string = 'Read more'; override render() { return html`
${this._apiError === ApiError.API_LIMIT_REACHED ? html`` : ''}
${this._isLoading ? html` ` : this.linkData.title}
${this._isLoading ? html` ` : this.linkData.description}
${typeof this.hideReadMoreBtn === 'undefined' ? html` ` : html``}
${typeof this.hidePoweredBy !== 'undefined' ? '' : html``}
`; } } declare global { interface HTMLElementTagNameMap { 'previewbox-article': PreviewBoxArticleElement; } }