/* * Copyright (C) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { BaseElement, element } from '../BaseElement'; @element('lit-headline') export class LitHeadLine extends BaseElement { private titleContent: string = ''; private _isShow: Boolean = false; private headline: HTMLDivElement | null | undefined; private closeBtn: HTMLDivElement | null | undefined; private _titleContext: HTMLLabelElement | null | undefined; private _width: number = 0; public closeCallback = function (): void {}; static get observedAttributes(): string[] { return ['_isShow', 'width', 'titleTxt']; } set isShow(value: Boolean) { this._isShow = value; if (value) { this.headline!.style.display = 'block'; } else { this.headline!.style.display = 'none'; } } get isShow(): Boolean { return this._isShow; } set titleTxt(value: string) { this.titleContent = value; this._titleContext!.innerHTML = value; } get titleTxt(): string { return this.titleContent || ''; } connectedCallback(): void {} initElements(): void { this.closeBtn = this.shadowRoot?.querySelector('.icon-box'); this.headline = this.shadowRoot?.querySelector('#headline'); this._titleContext = this.shadowRoot?.querySelector('#titleContext'); this.closeBtn!.addEventListener('click', () => { this.headline!.style.display = 'none'; this.closeCallback(); }); } clear(): void { this.titleTxt = ''; this.isShow = false; } initHtml(): string { return `