/** * Copyright Aquera Inc 2023 * * This source code is licensed under the BSD-3-Clause license found in the * LICENSE file in the root directory of this source tree. */ import { LitElement, html, CSSResultArray, TemplateResult, } from 'lit'; import { customElement, property } from 'lit/decorators.js'; import { styles } from './nile-list-item.css'; import NileElement from '../internal/nile-element'; import { HasSlotController } from '../internal/slot'; /** * Nile list-item component. * * @tag nile-list-item * */ @customElement('nile-list-item') export class NileListItem extends NileElement { /** * The styles for nile-list-item * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]` */ private readonly hasSlotController = new HasSlotController( this, 'preffix', 'heading', 'subheading' ); public static get styles(): CSSResultArray { return [styles]; } @property({ type: String, attribute: 'icon-name' }) iconName = ''; @property({ type: Number, attribute: 'icon-size' }) iconSize = 14; @property({ type: String, attribute: 'heading' }) heading = ''; @property({ type: String, attribute: 'sub-heading' }) subHeading = ''; /* #endregion */ /* #region Methods */ /** * Render method * @slot This is a slot test */ handleClick(e: any) { this.emit('nile-list-item-click', { heading: this.heading, subheading: this.subHeading, }); } public render(): TemplateResult { return html` ${this.iconName || this.hasSlotController.test('preffix') ? html` ` : ``}
${this.heading || this.hasSlotController.test('heading') ? html` ${this.heading}` : ``} ${this.subHeading || this.hasSlotController.test('subheading') ? html` ${this.subHeading}` : ` `}
`; } /* #endregion */ } export default NileListItem; declare global { interface HTMLElementTagNameMap { 'nile-list-item': NileListItem; } }